LEVEL SET-BASED 2D STRUCTURAL OPTIMIZATION USING FENICS
This educational code written for FEniCS is for compliance minimization in structural optimization, in two dimensions.
The code is based on a level set formulation and on the distributed expression of the shape derivative, and exploits the powerful features of FEniCS to solve complicated PDEs with a simple implementation.
The code is written for compliance minimization in the framework of linearized elasticity, but can be adapted for other functionals or other PDEs.
I have also added an extension of the code for compliant mechanisms.
FEniCS Project
The code consists of two files:
For instance, to run the cantilever case, the command line is
python compliance.py cantilever
I have also added an extension of the code for compliant mechanisms, see the file
python mechanism.py inverter
The code comes with a paper explaining in details the mathematical framework used for the code, and the implementation. The PDF file is included in the .tar.gz file for downloading here:
FEniCS 2017.1 code for structural optimization and PDF file
I wrote an update for FEniCS 2018.1, a few lines were modified but the structure of the code is the same. The line references in the PDF file are still valid for this update. Note that FEniCS 2018.1 requires Python 3, therefore the command line to run the codes are now:
python3 compliance.py cantilever
and
python3 mechanism.py inverter
FEniCS 2018.1 code for structural optimization and PDF file
Questions, suggestions and feedback are welcome, please send me an email at the following address: laurain at ime dot usp dot br
Updates:
The code consists of two files:
compliance.py
and init.py
. The main file is compliance.py
. The file init.py
is used to initialize one of the six following cases:
half_wheel, bridge, cantilever, cantilever_asymmetric, MBB_beam, cantilever_twoforces.
For instance, to run the cantilever case, the command line is
I have also added an extension of the code for compliant mechanisms, see the file
mechanism.py
.
To run this case, the command line is
The code comes with a paper explaining in details the mathematical framework used for the code, and the implementation. The PDF file is included in the .tar.gz file for downloading here:
I wrote an update for FEniCS 2018.1, a few lines were modified but the structure of the code is the same. The line references in the PDF file are still valid for this update. Note that FEniCS 2018.1 requires Python 3, therefore the command line to run the codes are now:
and
Questions, suggestions and feedback are welcome, please send me an email at the following address: laurain at ime dot usp dot br
Updates:
- 08/05/2017 | First upload |
- 30/05/2017 |
Update 1. Line 94, replaced print('Volume fraction : %.2f' % vol/(lx*ly))
by print('Volume fraction : %.2f' % (vol/(lx*ly)))
PDF file updated. |
- 25/08/2017 |
Update 2. Code and PDF file updated. The file compliance.py gives the same result but is shorter.
The PDF file has been significantly modified compared to the previous version. Added a file mechanism.py for compliant mechanisms.
|
- 29/01/2018 |
Update 3. The file mechanism.py was updated, corrected the sign in the Robin boundary condition.
Corrected a few errors in the PDF file. |
- 19/06/2019 |
Update 4. This is an update for FEniCS 2018.1, which now requires Python 3.
The command lines to run the codes are now python3 compliance.py cantilever
and python3 mechanism.py inverter .
set_log_level(ERROR) was removed on line 10 of compliance.py
All instances of boundaries = FacetFunction("size_t", mesh) were replaced by
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1) in the file init.py
domains = CellFunction("size_t", mesh) was replaced by
domains = MeshFunction("size_t", mesh, mesh.topology().dim()) on line 45 of compliance.py
solverav.parameters['reuse_factorization'] = True was removed on line 53 of compliance.py
th_array = th.vector().array() was replaced by
th_array = th.vector().get_local() on line 90 of compliance.py
xrange(0, dofsVvec_max,2) was changed to range(0, dofsVvec_max,2) on line 93 of compliance.py
the section 'Plot Geometry' (lines 106 to 113) was rewritten using subplot() in compliance.py
The same modifications were implemented in mechanism.py
|
Symmetric cantilever |
Asymmetric cantilever |
Half-wheel |
Bridge |
MBB beam |
Cantilever with two loads |