Coder Social home page Coder Social logo

fem_course's Introduction

Python package Pylint

What is this?

This is a minimal FEM implementation entirely in Python. It is only an educational project with the goal to better understand FEM in the context of electromagnetic fields. Even though it is not particularly speed optimized, vectorized assembly with numpy and petsc4py for solving is used so that the speed is pretty fast (I have used up to 200k elements, but 1M elements should also work). This is not intended to be used for real applications, there are plenty of open source FEM tools with much more features available - I think the best one is sparselizard.

Features implemented so far are:

  • phi-formulation for magnetostatics
  • A-formulation for magnetostatics
  • 1st order node and edge elements
  • homogeneous Dirichlet boundary conditions
  • mesh import from GMSH including use of physical regions
  • solution export as vtk-file for ParaView
  • tree gauge
  • eddy current example in A-V/A formulation
  • harmonics (partly implemented)

Possible features to be implemented (difficulty in in brackets):

  • higher order elements for node and edge elements (++)
  • pos-file export for GMSH (+)
  • inhomogeneous Dirichlet boundary conditions (++)
  • h-adaptation and .msh mesh export (++)
  • symbolic expressions (+++)
  • harmonics (++)
  • output animated harmonic solution (+)
  • time stepping (+++)

Install on Ubuntu 22

sudo apt update
sudo apt install -y software-properties-common lsb-release
sudo apt install -y gfortran gcc g++
sudo apt install -y libblas-dev liblapack-dev # needed for pip install petsc
sudo apt install -y libopenmpi-dev
sudo apt install -y python3.10-venv

mkdir ~/.venv
cd ~/.venv
python3 -m venv python_fem
source ./python_fem/bin/activate
pip install scipy numpy matplotlib plotly vtk pyvista meshio
pip install mpi4py    
export PETSC_CONFIGURE_OPTIONS="--with-openmp --with-mpi=0 --with-shared-libraries=1 --with-mumps-serial=1 --download-mumps --download-openblas --download-openblas-commit=origin/develop --download-metis --download-slepc --with-debugging=0 --with-scalar-type=real --with-x=0 COPTFLAGS=-O3 CXXOPTFLAGS=-O3 FOPTFLAGS=-O3"
pip install -r requirements.txt

Alternatively to install petsc manually:
git clone -b release https://gitlab.com/petsc/petsc
cd petsc
./configure --with-openmp --with-mpi=0 --with-shared-libraries=1 --with-mumps-serial=1 --download-mumps --download-openblas --download-openblas-commit=origin/develop --download-metis --download-slepc --with-debugging=0 --with-scalar-type=real --with-x=0 --with-petsc4py COPTFLAGS=-O3 CXXOPTFLAGS=-O3 FOPTFLAGS=-O3
sudo make -j$(nproc) install

Examples

examples/h_magnet.py h_magnet examples/magnet_in_room.py magnet_in_room examples/magmesh.py magnet_in_room examples/inductionheating.py inductionheating1 inductionheating2 inductionheating3

Recommended literature/papers

fem_course's People

Contributors

catkira avatar menkueclab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mfkiwl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.