Skip to content

akosmrlj/FEniCS_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial on using FEniCS for solving PDEs

This is the GitHub repository for a tutorial on using the FEniCS package to solve PDEs. This tutorial was prepared for the KITP workshop Symmetry, Thermodynamics and Topology in Active Matter and the recorded video is available here.

Layout

This tutorial is organized as follows:

  • poisson - several examples of solving the Poisson's equation in 2d
  • elasticity - two examples of solving 2d linear elasticity problems
  • thermoelasticity - one examples of solving 2d thermoelasticity problem
  • CahnHilliard - solving the Cahn-Hilliard equation in 2d

Getting started

Cloning the repository

Open a terminal and clone the repository with

git clone https://github.com/akosmrlj/FEniCS_tutorial.git

This command will create a local copy of the repository on your computer. It will be stored in a directory called FEniCS_tutorial.

Creating conda environment

We recommend using Anaconda and creating a fenicsproject environment. This can be done by typing in the terminal:

conda create -n fenicsproject -c conda-forge fenics mshr matplotlib jupyterlab

This should install all packages needed to run this tutorial.

Running examples

Each example comes with three files:

  • the standalone python code
  • Jupyter notebook with explanations
  • HTML copy of the Jupyter notebook

To run examples you first need to activate the fenicsproject environment:

conda activate fenicsproject

Afterward, you can either run the python code directly from the terminal, e.g.

python poisson_basic.py

or you can start the Jupyter lab as

jupyter lab

where you can open the Jupyer notebooks containing the code and explanations.

Additional software

We recommend installing Paraview for visualization.

Note: It is also possible to install Paraview via the conda-forge channel. However, this has not been tested and one may encounter a number of package dependency issues if trying to install Paraview in the fenicsproject conda environment provided above.

Additional resources

There is a very detailed FEniCS tutorial eBook. Please note that this eBook was written in 2017 and some of the functions have slightly changed. Here are a few demos with explanations that are up to date: https://fenicsproject.org/docs/dolfin/latest/python/demos.html

Lecturer

Andrej Košmrlj, Princeton University website

About

FEniCS tutorial prepared for the KITP Active Matter workshop (https://www.kitp.ucsb.edu/activities/active20)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published