For a while now, I’ve been interested in how machine learning could be applied to designing and optimizing CAD solutions. Here’s a promotional video of Autodesk’s generative design tool which will give you an idea of the possibilities.
ToPy is an open source topology optimization toolkit written in Python that allows a developer/designer to quickly define a problem and optimize it to fit within constraints such as minimum compliance / maximum stiffness. In this case, I’ll be looking at a maximum stiffness problem with the goal of creating structures that use the least amount of material while still maintaining maximum stiffness.
To get a general idea of how the toolkit works, I created a problem definition that optimizes a 20x20x20 cube that’s anchored at four corners with a single Z axis load that’s right on the top-middle of the cube. Below is what my .tpd (ToPY Problem Definition) file contained.
[ToPy Problem Definition File v2007] PROB_TYPE: comp PROB_NAME: super_cube ETA: exp DOF_PN: 3 VOL_FRAC: 0.15 # Retain 15% of the material FILT_RAD: 1.8 # > sqrt(3) ELEM_K: H8 NUM_ELEM_X: 20 NUM_ELEM_Y: 20 NUM_ELEM_Z: 20 FXTR_NODE_Z: 1; 21; 441; 421 # Z anchor points LOAD_NODE_Z: 9041 # Load node location LOAD_VALU_Z: -1 NUM_ITER: 50 # Number of optimization iterations # Grey-scale filter (GSF) P_FAC : 1 P_HOLD : 15 # num of iters to hold p constant from start P_INCR : 0.2 # increment by this amount P_CON : 1 # increment every 'P_CON' iters P_MAX : 3 # max value of 'P_CON' Q_FAC : 1 Q_HOLD : 15 # num of iters to hold q constant from start Q_INCR : 0.05 # increment by this amount Q_CON : 1 # increment every 'Q_CON' iters Q_MAX : 5 # max value of 'Q_CON'
Here’s the resulting optimization viewed using Paraview.
Now that the structure has been created, I’ll be investigating methods to make these optimizations 3D printable. In its current state, it will be relatively difficult to print (on my printer at home especially) with how many fine details there are in the structure.
The most up to date instructions are now located on Github.
If you’re interested in playing around with ToPy, it can be a bit tricky to set up. To make the install process a bit easier to manage, I whipped together a Dockerfile that will get everything set up automatically.
To run the file and get things set up, you will need Docker installed on your computer already. After you have Docker installed, follow these steps to get a container built up.
- Download the Dockerfile
- Open up a command prompt or terminal and change the directory to where the Dockerfile is located
docker build -t topy_env:latest .
Once the build command has finished, just run
docker run -it topy_env and you will log in (attach) to your newly created topy_env container!
Once logged in, feel free to save off the ToPy Problem Definition above to your container and validate that everything is installed correctly. A simple optimizer script that is provided in the ToPy Github has been pulled into the container for you to use. To run this, enter in the following command:
python optimise.py <your_tpd_here.tpd>
That’s it! Leave a comment below if you run into issues or have questions and I will respond as soon as I can!