(c) 2020 Lehrstuhl für Angewandte Mechanik, Technische Universität München
This Finite Element Research code is developed, maintained and used by a part of the numerics group of AM.
Wheel built for latest release (stable): AMfe_linux_x86_64.whl
Latest developer version (beta): AMfe_linux_x86_64.whl
Important Info: The project has been moved recently. So please update your remote via:
git remote set-url origin https://gitlab.lrz.de/AM/AMfe.git
Before installing the AMfe package, check, if the latest python version and all necessary modules are installed. For managing the python packages, the Python distribution Anaconda is highly recommended. It has a very easy and effective packaging system and can thus handle all Python sources needed for this project. For installation and usage of Anaconda checkout http://docs.continuum.io/anaconda/install#anaconda-install.
The following packages should be installed for a development version via conda install command:
- Python version 3.7 or higher
numpy
,scipy
,pandas
,h5py
,matplotlib
,vtk==8.1.2
,pytables
,mkl
- for fast fortran execution a running fortran compiler (e.g. gcc and gfortran)
- for building the documentation
sphinx
,numpydoc
,sphinx_rtd_theme
- for testing
nose
,coverage
- for checking the code readability:
pylint
I recommend to create a separate environment in anaconda for your amfe installation. Then you later have the opportunity to create a new environment for other projects that can have different requirements (such as python 2.7 instead 3.7).
For getting the package type
git clone https://gitlab.lrz.de/AM/AMfe.git
in your console. Git will clone the repository into the current folder. For installing the package in development mode run
cd AMfe
conda create --name <environment-name-of-choice> python=3.7
conda activate <environment-name-of-choice>
python conda_setup.py
python setup.py develop [no_fortran]
in the main folder. The conda_setup.py file installs the dependencies via conda. It is recommended to install the dependencies with conda because setup.py can only install them via pip which can lead to an unclean conda environment.
The python setup.py develop
command builds the fortran routines and installs the python module in-place,
i.e., when you do changes to the source code they will be used the next time the module is loaded.
If you do not want to install the FORTRAN-routines, you can add the flag no_fortran
to your installation command:
python setup_develop.py develop no_fortran
If no FORTRAN-compiler is found, the installation will work only with the no_fortran
-flag.
If you do not develop AMfe you can install AMfe with conda dependencies via
cd AMfe
conda create --name <environment-name-of-choice> python=3.7
conda activate <environment-name-of-choice>
python conda_setup.py
python setup.py install [no_fortran]
If you like to use pip for your installation the easiest installation is to download the latest wheel file AMfe_linux_x86_64.whl and run
pip install AMfe_linux_x86_64.whl
The documentation of the latest master version can be found at https://am.pages.gitlab.lrz.de/AMfe/
The documentation can also be built from source by going into the folder docs/
and running
make html
The documentation will be built in the folder docs/
available as html in _build
.
If the command above does not work, try to run python setup.py build_sphinx
in the main-folder
also builds the documentation.
Preprocessing and postprocessing is not part of the code AMfe, but the open source tools gmsh and Paraview are recommended:
- gmsh The open-source meshing tool can create unstructured meshes for 2D and 3D geometries. The geometry can either be built inside the tool or outside in a CAD program with the
.stp
-file imported into gmsh. In order to define volumes for materials or points/lines/surfaces for boundaries, physical groups must be assigned in gmsh. - ParaView With ParaView the results can be analyzed. For showing the displacements, usually it is very handy to apply the Warp By Vector filter to see the displaced configuration.
AMfe provides a Mesh-Exporter for the Preprocessor GiD. This preprocessor can be downloaded as community edition or can be accessed at our chair. See the AM Wiki for more information how to access the professional edition at our chair.
Though Python is a general purpose programming language, it provides a great ecosystem for scientific computing. As resources to learn both, Python as a language and the scientific Python ecosystem, the following resources are recommended to become familiar with them. As these topics are interesting for many people on the globe, lots of resources can be found in the internet.
- A byte of Python: A good introductory tutorial to Python. My personal favorite.
- Learn Python the hard way: good introductory tutorial to the programming language.
- Youtube: Testing in Python This amazing talk explains the concept
and the philosophy of unittests, which are used in the
amfe
framework.
- Scipy Lecture Notes: Good and extensive lecture notes which are evolutionary improved online with very good reference on special topics, e.g. sparse matrices in
scipy
. - Youtube: Talk about the numpy data type This amazing talk is a must-see for using
numpy
arrays properly. It shows the concept of array manipulations, which are very effective and powerful and extensively used inamfe
. - Youtube: Talk about color maps in matplotlib This interesting talk is a little off-topic but cetainly worth to see. It is about choosing a good color-map for your diagrams.
- Youtube: Talk about the HDF5 file format and the use of Python: Maybe of interest, if the HDF5 data structure, in which the simulation data are extracted, is of interest. This video is no must-have.
- Cheat sheet with the important git commands Good cheatsheet with all the commands needed for git version control.
- Youtube: git-Workshop This workshop is extensive and time intensive but definetely worth the time spent. It is a great workshop introducing the concepts of git in a well paced manner (The slides are also available).
- Youtube: git-Talk Very fast and informative technical talk on git. Though it is a little bit dated, it is definitely worth watching.
- HowTo for generating structured meshes in gmsh This tutorial is about the generation of structured meshes in gmsh, in this case for the use in the CFD-Framework OpenFOAM. Nonetheless, everything can be used for AMfe as well.
A good IDE to start with is Spyder, which has sort of a MATLAB-Style look and feel. It is part of anaconda ans provides nice features like built-in debugging, static code analysis with pylint and a profiling tool to measure the performance of the code.
Other editors integrate very well into Python like Atom.
I personally work with PyCharm, which is an IDE for Python. However as it provides many functions one could be overwhelmed by it at first.
Hint
On Mac OS X Spyder 2
may run very slow, as there are some issues with the graphical frontent library, pyqt4. These issues are resolved on Spyder 3
by using pyqt5, which can already be installed on anaconda as beta version resolving all these issues. To install Spyder 3
, use either
conda update qt pyqt
conda install -c qttesting qt pyqt
conda install -c spyder-ide spyder==3.0.0b6
or (which worked better for me)
pip install --pre -U spyder
a good profiling tool is the cProfile module. It runs with
python -m cProfile -o stats.dat myscript.py
The stats.dat file can be analyzed using the snakeviz
-tool which is a Python tool which is available via conda
or pip
and runs with a web-based interface. To start run
snakeviz stats.dat
in your console.
The theory for finite elements is very well developed, though the knowledge is quite fragmented. When it comes to element technology for instance, good benchmarks and guidelines are often missed. A good guideline is the Documentation of the CalculiX-Software-Package which covers a lot about element technology, that is also used in AMfe. CalculiX is also an OpenSource Finite Element software written in FORTRAN an C .