Diatom – topology optimization inside Grasshopper (Mac, open source)

Hi everyone,

I’m an architecture student, and this last semester I have been working on my bachelor’s seminar paper on the topic of topology optimization in architecture. I’m a Mac user, and one thing that bothered me while writing my paper is that there aren’t really many good options to run topology optimization on macOS… That’s why I naively decided that I’m going to build my own tool for running TO inside of Grasshopper, since Rhino is my favorite 3D-modeling software. The result is Diatom; it’s free and open source (MIT), and it runs directly inside Rhino 8 Grasshopper rather than as a separate app you export to and from.

It’s built on top of PyTopo3D (Jihoon Kim and Namwoo Kang — paper here: [2504.05604] PyTopo3D: A Python Framework for 3D SIMP-based Topology Optimization), which does the actual SIMP optimization. Diatom adds the Grasshopper side with a few new features, which do not exist in the original PyTopo3D code. There are components for domain/supports/loads, a solver that runs in the background so Rhino doesn’t lock up, a live preview of the design as it converges in the viewport, and a few things I found useful along the way, like setting the minimum member size in actual model units instead of voxel counts.

Before you check Diatom out, please read this: I’m an architecture student, not a programmer, and this project was my first real coding experience with Python. All of the code was written with the help of agentic AI models (Claude Fable 5, Opus 4.8, Opus 5). Quite honestly, if these tools didn’t exist, I probably would have never even thought of making my own tool in Grasshopper. I intentionally wanted to make Diatom as simple as possible, without going through the hassle of packaging it as a compiled C# component, because I believe I shouldn’t be pushing an AI slop plugin out there. That’s why Diatom is simple. It’s basically a collection of Python scripts and packages pretending to be a plugin, which is exactly what I personally needed. I decided to make it fully open-sourced and publish it on GitHub because I want to provide people using Mac computers with the ability to run TO inside of Rhino. I know there are some people out there that are willing to try it out because I myself was one and have been looking for such options for a long time now. My secondary goal is to attract people who would be interested in potentially building an actual Grasshopper plugin, which works on macOS and has the capabilities of plugins like Millipede and tOpos. If you think you’re that person, feel free to check out Diatom, play around with it, fork it, upgrade it, or do whatever you want with it. I’d love to hear that someone got inspired and built an alternative to tOpos for Mac!

hero

An optimization run using Diatom, which took 226 seconds to complete on an M2 Pro with 16 GB of unified memory (the total iteration count was capped at 30). The final frame is the baked result coming straight out of Diatom, with no post-processing.

Diatom is roughly laid out as follows: Domain/Supports/Loads feed into a Model component, which feeds the Solver, which outputs to Result – plus a few optional components for settings, live preview and GIF export. The domain can be any closed Brep or mesh, not just a box, and you can wire in multiple load regions each pulling in its own direction.

A diagram illustrating how a Diatom definition flows.

To install it, you run the install.sh on Mac, install.ps1 on Windows. These scripts do not need admin/sudo, and finish with a self-test so you know right away if something didn’t set up correctly. You need about 1.5GB of disk space for the Python environment.

Two more things to note before anyone installs it. First, I’ve only actually run this on Apple Silicon Macs. The Windows path exists since PyTopo3D is originally built for Windows, but I haven’t been able to test it on real hardware, so if anyone’s on Windows and willing to try it, I’d like to know whether it works. Second, the physics is dimensionless, so this is meant as a form-finding tool rather than something to verify a structure with, so please run your own FEA before building anything off what comes out of it. That being said, I’ve already done some 3D-printed tests of output geometries, and they turned out quite nice and functional. :grinning_face_with_smiling_eyes:

There’s also no Heaviside projection with beta continuation, so on some models (branching ones especially) you’ll get a thin membrane where you’d expect a clean gap. Raising the penalization setting usually clears it – there’s a worked example of this in the repo. If you have no idea what any of that means, I (with the help of my dear friend Claude) tried to explain it in the README.md.

Here is the link to the GitHub repo: GitHub - vaglyarov/Diatom: 3D SIMP topology optimization for Rhino Grasshopper, on Apple Silicon · GitHub

One last thing, I do not intend to keep this project active. Coding is not really my priority, and maintaining such a project would be way too big of an undertaking. I’d be happy to answer questions and maybe fix some small bugs, but it’s very unlikely that I’ll push any major new features. If anyone’s interested in maintaining Diatom/porting the core to a compiled C# component at some point, feel free to fork the repo. Still, I’d love to hear from you! Have fun playing around with Diatom!

Nice! I found some more examples on the github page. Great job.

Enjoying the plug in so far. Indeed, the first TO for mac. Already 3d printed some results, will post later.

I did not find any relation between magnitude of vector loads and the results. So when i put two loads with different amplitudes, i do not see the difference in result. Other than that, very stable plug in.

I am using custom sdfs from chromodoris for volume smoothing, or quad remesh - to subd - to nurbs (+pack faces)

iterations

Thanks again, will be playing around with it for a while. I was thinking about offloading some computation to gpu, using Metal shaders. I wonder if you considered that to speed things up even further. There are probably some bottlenecks, but seems doable

Thanks for the reply. Glad you’re enjoying the plugin! Before you dive into this reply, here is the TL;DR: The magnitude of a single load doesn’t matter. Whether 1 or 300, it’s going to output the same thing. However, if you have two or more loads, varying their magnitudes should have an effect on the final result. More on that below. I have tried adding GPU acceleration with Metal, but ironically, it’s slower. I have gone in detail about this as well.

Firstly, the load magnitude issue: the conditions of your model change the way that the solver optimizes. There are two different scenarios, which you should consider:

  1. In Diatom, a single load’s magnitude purposefully doesn’t matter. If you’ve got a single load case and you scale that load 3x or 20x, you’ll still get the exact same shape out. This is just how compliance minimization works: the optimizer is minimizing compliance under a fixed volume fraction, and compliance scales with the square of the load while the volume constraint doesn’t care about load at all. So the optimal material layout is invariant to the overall scale – only the reported compliance number changes, not the geometry. Every SIMP-based TO tool does this, Diatom included.
  2. However, the ratio between multiple loads does matter. If that’s not the case, then it’s worth digging into the problem further. I went and tested this directly on an M2 Pro MacBook Pro running the latest v0.2.0. I used identical domain, load, and support locations for two test runs. You can see the locations of the loads and supports in the attached image below. In run 1, I set the magnitude of the upper load to 20 and the magnitude of the lower one to 1. In the second run, I just swapped the loads. This produced two significantly different results, as can be seen in the screenshot. Below this reply, I have also attached the files I used to run the tests so you can check it yourself. I hope this answers the first part of your reply. :grinning_face_with_smiling_eyes:

The two resulting geometries baked straight out of Diatom next to the support conditions. The blue dots are the two loads, and the red dots are the three supports.

A screenshot of the DiatomLoads component inputs.

diatom_multiple_loads.3dm (531.9 KB)

multiple_loads.gh (110.3 KB)

Now onto your suggestion to utilize Metal:

Before I even released Diatom publicly, I wanted to add GPU acceleration. However, early on, I found out that GPU solves are actually slower than pure CPU ones. I know it sounds strange, but back then, I ran a test, and it did perform about 20% slower. I gave it another go now, and the result was the same. I don’t really understand how these things work, but here is what Claude says about it:

  1. Metal has no float64. Not a library gap — the shading language itself has no double type. The stiffness matrix spans about 9 orders of magnitude between void and solid, and float32 can’t resolve that: the solve stalls ~5 orders short of the CPU’s accuracy, while still reporting “converged,” since the convergence check runs in float32 too.
  2. It’s not even faster before accuracy enters the picture. I tested the GPU-favoring version — no assembled matrix, just a batched element-by-element multiply, the shape a real Metal kernel would take. Per-iteration, it’s roughly tied with the CPU; it only loses because float32 needs ~25% more iterations.
  3. CPU and GPU share the same memory bus on Apple Silicon. This solve is bandwidth-bound, not compute-bound, so there’s no separate bandwidth pool to tap by moving to the GPU.

Claude also ran a full 60-iteration optimization both ways to rule out a synthetic-benchmark artifact. CPU finished in 49.7s, Metal finished in 58.8s (about 18% slower).

Something interesting I found while running these tests is that the current solver (Jacobi-preconditioned conjugate gradient) is actually not the smartest solver out there. It’s quite simple to set up and run, but it needs more iterations to converge. There are better alternatives such as Geometric multigrid (GMG), which are worth experimenting with. I might give it a go…

Anyways, I’d love to see your 3D printed results! Also, thanks for mentioning your remeshing process. I haven’t heard of chromodoris, but I should try it out. Forums are great! :grinning_face_with_smiling_eyes:

Thank you, probably i made a mistake somewhere during my tests, thus did not see vectors affecting results..

I 3d printed monitor stand.. Looks better in reality, especially when my colleague cleans his desk

It would be also nice to be able to assign weights to supports. Do you think that is possible?

Currently running such simulation, where the support on the right (yellow tube) is able to carry a lot less weight than support on the right, but solution sees them as equal, and converges on the closest one

was waiting for just that! :heart: