A modular approach to topology optimization
Project description
pyMOTO | Modular Topology Optimization in Python
- Documentation https://pymoto.readthedocs.io
- Examples gallery https://pymoto.readthedocs.io/en/latest/auto_examples/index.html
- Github repository https://github.com/aatmdelissen/pyMOTO
This python library offers modular and easily reconfigurable code to perform topology optimization. Already many ingredients and variations of topology optimization are implemented! Examples are:
- Density filtering, robust formulations
- 2D and 3D topology optimization
- Static and dynamic structural mechanics
- Compliant mechanisms
- Thermal and thermo-mechanic coupling
- Stress constraints
- Multigrid preconditioning with conjugate-gradient solver
- Various optimizers suited for topology optimization, such as Optimality Criteria (OC), Method of Moving Asymptotes (MMA), and its Globally Convergent version (GCMMA)
- And more...
In pymoto a topology optimization problem is broken down into reusable sub-components (called Modules), such as density filter, finite-element assembly, linear solve, linear algebra, etc. Next to behaving like a function would (e.g. filtering the density field), a Module also implements design sensitivities (i.e. derivatives or gradients with respect to the inputs of that Module) of that operation. These are required for efficiently solving the topology optimization problem, but are usually very cumbersome to implement on the whole optimization problem. With pymoto however, the partial sensitivities are already implemented in each Module. When modules are linked together in pymoto, the chain rule is used to calculate the total sensitivities of the optimization problem (backpropagation). In essence it is a semi-automatic way of calculating design sensitivities.
Due to the modularity of the framework, existing modules can be reused and connected in different configurations without having to worry about sensitivity correctness. This allows for great flexibility in rearranging the modules, enabling a whole range of topology optimization problems even with a limited set of modules. If any functionality is not supported in a Module within the default pymoto library, a user can easily extend the framework by creating custom modules.
Quick start installation
- Make sure you have Python running in some kind of virtual environment (e.g. uv, conda, miniconda, venv)
- Install the
pymotoPython package (and its dependencies)- Option A (pip): Type
pip install pymotointo your console to install (prepend withuvwhen usinguv) - Option B (conda): If you are working with Conda, install by
conda install -c aatmdelissen pymoto
- Option A (pip): Type
- Optional: Install Intel MKL library for a fast linear solver with
pip install mkl- This can also be achieved automatically by installing
pymotoaspip install pymoto[fast]
- This can also be achieved automatically by installing
After installation, pymoto can be used.
- Examples can be found and downloaded from the pyMOTO examples gallery
- Run the example by typing
python ex_name_of_the_example.pyin the console (prepend withuv runwhen usinguv)
Citing pyMOTO
When your research uses pymoto, please consider citing our Zenodo entry in any publications:
DOI:10.5281/zenodo.8138859.
Dependencies
- numpy - Dense linear algebra and solvers
- scipy - Sparse linear algebra and solvers
- sympy - Symbolic differentiation for
MathExpressionmodule - Matplotlib - Plotting and visualisation
- (optional) opt_einsum - Optimized function for
EinSummodule
For fast linear solvers for sparse matrices:
- (optional) mkl - Use the Intel OneAPI PARDISO solver (recommended)
- (optional) scikit-umfpack - Fast LU linear solver based on UMFPACK
- (optional) scikit-sparse - Fast Cholesky solver based on CHOLMOD
- (optional) cvxopt - Another fast Cholesky solver based on CHOLMOD
Note on linear solvers for sparse matrices: Scipy implements a version of LU which is quite slow. To increase the speed of the optimization, mkl is recommended as it contains PARDISO, which is a very robust and flexible solver for any matrix (symmetric, asymmetric, real, or complex). An alternative is scikit-umfpack which provides a fast LU factorization. For symmetric matrices a Cholesky factorization can be used (not provided with Scipy), by either installing scikit-sparse or cvxopt.
Contributing
For development, a local installation of pymoto can be done by first downloading/cloning the entire git repo, and then calling pip install -e . in the pymoto folder (of course from within your virtual environment). This allows making changes to the pymoto code without having to reinstall.
You are now ready for a contribution to pymoto.
- Check the issues page to see if the subject you want to improve is listed:
- If an issue already exists, add your view to the problem as a comment and let us know you are working on this.
- Open a new issue if it is not listed, and discuss your ideas.
- Create a new branch to work the code, the branch can also be in your own fork of the repo.
- Work that code.
- Make sure all tests are passed (by running
pytest) and style is adhered - Create a pull request describing your changes
Thanks for your contribution! We will have it reviewed for it to be merged with the main code.
License
pyMOTO is available under te MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymoto-2.0.0.tar.gz.
File metadata
- Download URL: pymoto-2.0.0.tar.gz
- Upload date:
- Size: 96.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ff9ef39b40944340f17318a47243d7b0342d87a5235c15ff2d5302718e098f
|
|
| MD5 |
f3efd761f9c8690744bd8059bb32dd17
|
|
| BLAKE2b-256 |
b3682b550556e3bf212e8abd2a4f499d391d09fd82eeb96e9d811a8feeb5847b
|
Provenance
The following attestation bundles were made for pymoto-2.0.0.tar.gz:
Publisher:
publish.yaml on aatmdelissen/pyMOTO
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymoto-2.0.0.tar.gz -
Subject digest:
c3ff9ef39b40944340f17318a47243d7b0342d87a5235c15ff2d5302718e098f - Sigstore transparency entry: 725043640
- Sigstore integration time:
-
Permalink:
aatmdelissen/pyMOTO@840b2676eb8d3a4563f328539e9bb79b1c5d1936 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/aatmdelissen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@840b2676eb8d3a4563f328539e9bb79b1c5d1936 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file pymoto-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pymoto-2.0.0-py3-none-any.whl
- Upload date:
- Size: 109.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ab314f0d4425164bdad66009abaa9cfe4ac1ad7e75448a1ea660ef57617cff
|
|
| MD5 |
6d8fff1e5c3039e284f0c29d10df8a68
|
|
| BLAKE2b-256 |
7d758e55823acfd7ca8a49b21e1d552361d3a9fa0d48c89b72aaa5a07d81d832
|
Provenance
The following attestation bundles were made for pymoto-2.0.0-py3-none-any.whl:
Publisher:
publish.yaml on aatmdelissen/pyMOTO
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymoto-2.0.0-py3-none-any.whl -
Subject digest:
82ab314f0d4425164bdad66009abaa9cfe4ac1ad7e75448a1ea660ef57617cff - Sigstore transparency entry: 725043645
- Sigstore integration time:
-
Permalink:
aatmdelissen/pyMOTO@840b2676eb8d3a4563f328539e9bb79b1c5d1936 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/aatmdelissen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@840b2676eb8d3a4563f328539e9bb79b1c5d1936 -
Trigger Event:
workflow_run
-
Statement type: