This program is based on TopOpt by Johannes Haubner, Franziska Neumann and Michael Ulbrich.
The program is run using run.py
. This program takes in two command line arguments; a design file and a domain size. The folder designs
contains some design files, and you can easily make a custom design using those files as a template. If the design is path/to/design.json
, the output of the program is saved to output/design/data
. The produced data can be visualized with plot.py
, which automatically reads all the data files, and produces corresponding figures in output/design/figures
. plot.py
can also take a list of designs as an argument to limit which designs it will plot. For instance,
python3 plot.py design1 design2
will only create figures from output/design1/data
and output/design2/data
.
TopologyOptimizer uses fenics-dolfin, which is not available on Windows. The TopOpt project includes a docker image which makes running the program on Windows easy. As it is not my docker image, I can't guarantee that it will work forever. To use the Docker, simply run
docker pull ghcr.io/johanneshaubner/topopt:latest
cd topopt
docker run -it -v $(pwd):/topopt ghcr.io/johanneshaubner/topopt
Then, in the Docker container, you can run the program as normal:
python3 run.py designs/twin_pipe.json 40
If you are using Linux (or wsl), you can run the program using conda. I have not tested that this works, so the following text is simply copied from the TopOpt repository:
conda env create -f environment.yml --experimental-solver=libmamba
conda activate topopt
cd topopt
python3 topopt.py
conda deactivate topopt
It has to be ensured that the conda-libmamba-solver is installed.
For practical problems it is furthermore necessary to link IPOPT against HSL when compiling (see comment in http://www.dolfin-adjoint.org/en/release/documentation/stokes-topology/stokes-topology.html).
For running the MMA examples, it is required to clone the GitHub repository https://github.com/arjendeetman/GCMMA-MMA-Python into the folder mma/MMA_Python.
The design files are written in json, and the settings are:
-
objective
Allowed values: "minimize_power" or "maximize_flow"
Description: Decides the objective function to be minimized. -
width
Allowed values:float
Description: The width of the domain -
height
Allowed values:float
Description: The height of the domain -
fraction
Allowed values:float
Description: The fraction of the domain that is allowed to be empty, the volume fraction. -
flows
Allowed values: list of flows, where a flow has the following values:- side: "left", "right", "top", or "bottom"
- center:
float
- length:
float
- rate:
float
Description: Defines the boundary conditions on the velocity field. Each flow describes a parabolic flow pattern. A positive rate indicates flow into the domain, and a negative flow pattern indicates flow out of the domain.
-
max_region
Allowed values:- center:
(float, float)
- size:
(float, float)
Description: The region where you want to maximize flow. Mandatory for the "maximize_flow" objective, does nothing for the "minimize_power" objective. The desired flow direction is currently hard coded to (-1, 0).
- center:
-
no_slip (optional)
Allowed values: List containing values of "left", "right", "top", or "bottom"
Description: The sides where there is no flow (velocity is 0). Defaults to all sides with no defined flow. -
zero_pressure (optional)
Allowed values: List containing values of "left", "right", "top", or "bottom"
Description: The sides where there is no pressure. If not set, pressure is 0 at (0, 0).
To run tests, run the following command:
pytest