A python package for creating and running 0D models of the cardiovascular system
Project description
ModularCirc
The scope of this package is to provide a framework for building 0D models and simulating cardiovascular flow and mechanics. Conceptually, the models can be split into three types of components:
- Heart chambers
- Valves
- Vessels
The current version of the published package contains two models:
- Naghavi model.
- Korakianitis Mixed model.
For other models currently under development, see the dev branch.
Setup Conda or python virtual environment
Before installation of the ModularCirc package, please setup a virtual environment using either Conda or python virtual environment.
Conda setup
Install Conda from https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html
Run:
conda create --name <yourenvname>
conda activate <yourenvname>
Proceed to installing the ModularCirc package.
Python virtual environment setup
Run python3 -m venv venv. This creates a virtual environment called venv in your base directory.
Activate the python environment: source venv/bin/activate
Proceed to installing the ModularCirc package.
Installing ModularCirc
pip install
To install the pip package:
python -m pip install ModularCirc
Installation from source:
Clone the ModularCirc GitHub repo locally.
Run:
git clone https://github.com/alan-turing-institute/ModularCirc
cd ModularCirc
After downloading the GitHub repository, from the repo directory run:
pip install ./
This will install the package based on the pyproject.toml file specifications.
Steps for running basic models
- Load the classes for the model of interest and the parameter object used to paramterise the said model:
from ModularCirc.Models.NaghaviModel import NaghaviModel, NaghaviModelParameters
- Load the ODE system solver class object:
from ModularCirc.Solver import Solver
- Define a dictionary for parameterising the temporal discretization:
TEMPLATE_TIME_SETUP_DICT = {
'name' : 'TimeTest',
'ncycles' : 40,
'tcycle' : 1.0,
'dt' : 0.001,
'export_min' : 1
}
Here, ncycles indicates the maximum number of heart cycles to run, before the simulation finishes.
If the simulation reaches steady state faster than that, the simulation will end provided the number of cycles is higher than export_min.
tcycle indicates the duration of the heart beat and dt represent the time step size used in the temporal discretization.
These measurements assume that time is measured in seconds.
If the units used are different, ensure this is done consistently in line with other parameters.
- Create an instance of the parameter object and used it to change the default values:
parobj = NaghaviModelParameters()
Note 4.1: the model and parameter object classes are usually defined in pairs and, as such using mismatched types may cause the simulation to behave unexpectedly or may result in a crash.
Note 4.2: the method used to parameterise components is typically dependent on the component type, see for example: set_chamber_comp, set_rc_comp or set_activation_function.
- Create an instance of the model:
model = NaghaviModel(time_setup_dict=TEMPLATE_TIME_SETUP_DICT, parobj=parobj)
- Create an instace of the solver used to peform the simulation:
solver = Solver(model=model)
solver.setup()
- Run the simulation
solver.solve()
- Extract the state variable values of interest.
v_lv = solver.model.components['lv'].V.values
p_lv = solver.model.components['lv'].P_i.values
Example values pv loops for all 4 chambers:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modularcirc-0.2.0.tar.gz.
File metadata
- Download URL: modularcirc-0.2.0.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211fe68759450afb12bbf8a6744cad7289807f3b1bf930d42ce16734e2dcae48
|
|
| MD5 |
a7b7c4096adcae4c6cab43fc1cdaa522
|
|
| BLAKE2b-256 |
6d1759015f714428f9336b04f90541276c076c5a7b4403a4e04e63fdfd5bc6ce
|
Provenance
The following attestation bundles were made for modularcirc-0.2.0.tar.gz:
Publisher:
publish.yml on alan-turing-institute/ModularCirc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modularcirc-0.2.0.tar.gz -
Subject digest:
211fe68759450afb12bbf8a6744cad7289807f3b1bf930d42ce16734e2dcae48 - Sigstore transparency entry: 198492588
- Sigstore integration time:
-
Permalink:
alan-turing-institute/ModularCirc@3c71c399de8e495e795d71c876fca22d21dbac12 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alan-turing-institute
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c71c399de8e495e795d71c876fca22d21dbac12 -
Trigger Event:
release
-
Statement type:
File details
Details for the file modularcirc-0.2.0-py3-none-any.whl.
File metadata
- Download URL: modularcirc-0.2.0-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c48bfccceefc74c39e85ec3fafc9f56a44f8ae10a4612a7039535465b125c4
|
|
| MD5 |
252f94e93489647c806b1c5440114fc5
|
|
| BLAKE2b-256 |
40f8fac86b6aae100bbb9a1b4e6fc269d2144a2f83ba131486d916425eafbd6c
|
Provenance
The following attestation bundles were made for modularcirc-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on alan-turing-institute/ModularCirc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modularcirc-0.2.0-py3-none-any.whl -
Subject digest:
e3c48bfccceefc74c39e85ec3fafc9f56a44f8ae10a4612a7039535465b125c4 - Sigstore transparency entry: 198492591
- Sigstore integration time:
-
Permalink:
alan-turing-institute/ModularCirc@3c71c399de8e495e795d71c876fca22d21dbac12 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alan-turing-institute
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c71c399de8e495e795d71c876fca22d21dbac12 -
Trigger Event:
release
-
Statement type: