This repository contains the source code to reproduce the modeling results from the paper
Paper here
Reproducible results¶
You can find a report of the results by going to the repository homepage at https://
Note that the results displayed here are re-generated every time a push is made to the repository (see https://
Also note that the results from the paper are run on a finer mesh than those displayed in the documentation.
Install dependencies¶
To run the code in this repo you need FEniCS and gmsh with OpenCascade installed. The easiest way to do this is to either use the provided docker image, i.e
docker pull ghcr.io/computationalphysiology/ciucci-2025:latestYou can create a new container using the command
docker run --name ciucci -w /home/shared -v $PWD:/home/shared -it ghcr.io/computationalphysiology/ciucci-2025:latestwhich will also share your current directory with the container. If you are interested you can also check out the Dockerfile if you want to know how the image was created.
Running scripts¶
There are three types of simulation scripts.
A contracting cylinder, with only one time point
A contraction cylinder with a full twitch
An unloaded (zero pressure) and loaded (pressure = 15 kPA) contracting left ventricle.
We refer to the documentation for more information about the models and numerical experiments.
The main script for running all the commands are located inside the code directory and you should first make sure to navigate to this directory, i.e
cd codeYou can list all the available options by typing
python3 main.py --helpHere is an example of how it looks inside the container
root@b2637926d9de:/home/shared/code# python3 main.py --help
usage: main.py [-h] [--dry-run] {preprocess-lv,preprocess-cylinder,run-lv,run-cylinder,run-cylinder-twitch,postprocess-lv,postprocess-cylinder,postprocess-cylinder-twitch} ...
positional arguments:
{preprocess-lv,preprocess-cylinder,run-lv,run-cylinder,run-cylinder-twitch,postprocess-lv,postprocess-cylinder,postprocess-cylinder-twitch}
preprocess-lv Create left ventricle mesh
preprocess-cylinder
Create cylinder mesh
run-lv Run simulations with left ventricle model
run-cylinder Run simulations with cylinder model
run-cylinder-twitch
Run simulations with cylinder model
postprocess-lv Postprocess LV results
postprocess-cylinder
Postprocess cylinder results
postprocess-cylinder-twitch
Postprocess cylinder results
options:
-h, --help show this help message and exit
--dry-run Just print the command and do not run itBelow we show the basic command. Note that you can also use the flag --help to see all the different options for each command, e.g
root@b2637926d9de:/home/shared/code# python3 main.py preprocess-cylinder --help
usage: main.py preprocess-cylinder [-h] [-o MESH_FOLDER] [-c CHAR_LENGTH] [-l LENGTH] [-r RADIUS]
options:
-h, --help show this help message and exit
-o MESH_FOLDER, --mesh-folder MESH_FOLDER
-c CHAR_LENGTH, --char_length CHAR_LENGTH
-l LENGTH, --length LENGTH
-r RADIUS, --radius RADIUSCylinder¶
Preprocessing¶
python3 main.py preprocess-cylinder -o meshes/cylinderSimulation¶
python3 main.py run-cylinder -i meshes/cylinder -o results/cylinderSimulation (twitch)¶
python3 main.py run-cylinder-twitch -i meshes/cylinder -o results/cylinder-twitchPostprocessing¶
python3 main.py postprocess-cylinder -i meshes/cylinder -r results/cylinder -o figures/cylinderPostprocessing (twitch)¶
python3 main.py postprocess-cylinder-twitch -i meshes/cylinder -r results/cylinder-twitch -o figures/cylinder-twitchLV¶
Preprocessing¶
Native¶
python3 main.py preprocess-lv -o meshes/native -c nativeTransplanted¶
python3 main.py preprocess-lv -o meshes/transplanted -c transplantedRunning simulations¶
Native¶
python3 main.py run-lv -i meshes/native -c native -o results/nativeWhen running the simulations the following files will be created in the output folder
native
├── gammas.npy
├── pressures.npy
├── results_current.h5
├── results_current.xdmf
├── results_current_smooth.h5
├── results_current_smooth.xdmf
├── results_reference.h5
├── results_reference.xdmf
├── results_reference_smooth.h5
├── results_reference_smooth.xdmf
└── volumes.npyThe xdmf files are files that can be opened in Paraview. The label reference refers to the solutions are stored on the reference mesh, while in the file with the label current the mesh has been updated to the current configuration. For the results with the label smooth we have smoothed the results using a Gaussian filter and interpolated into a first order Lagrange element function space. The files gammas.npy and pressures.npy contain the values of the gamma and pressure for each time step. The file volumes.npy contains the volume of the LV at each time step.
Transplanted¶
python3 main.py run-lv -i meshes/transplanted -c transplanted -o results/transplantedPostprocessing¶
Native¶
python3 main.py postprocess-lv -i meshes/native -r results/native -o figures/nativeTransplanted¶
python3 main.py postprocess-lv -i meshes/transplanted -r results/transplanted -o figures/transplantedGet stats using
python3 main.py postprocess-lv -i meshes/transplanted -r results/transplanted -o figures/transplanted --print-statsComparison for end-systole¶
python3 main.py postprocess-lv-ES -n results/native -t results/transplanted -o figuresCitation¶
If you use the code in this repository, please cite: TBW
Author¶
Henrik Finsberg and Sam Wall
License¶
MIT