Skip to main content

A python package for creating and running 0D models of the cardiovascular system

Project description

ModularCirc

Actions Status PyPI version PyPI platforms

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:

  1. Heart chambers
  2. Valves
  3. Vessels

Clone the ModularCirc GitHub repo locally

Run:

git clone https://github.com/alan-turing-institute/ModularCirc
cd ModularCirc

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.

Installation

To install the pip package:

python -m pip install ModularCirc_LevanBokeria

From source:

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

  1. 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
  1. Load the ODE system solver class object:
from ModularCirc.Solver import Solver
  1. 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.

  1. 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.

  1. Create an instance of the model:
model = NaghaviModel(time_setup_dict=TEMPLATE_TIME_SETUP_DICT, parobj=parobj)
  1. Create an instace of the solver used to peform the simulation:
solver = Solver(model=model)
solver.setup()
  1. Run the simulation
solver.solve()
  1. 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:

Example PV loops!

Run tests

You can run locally the tests by running the following command:

  python -m unittest discover -s tests

there is also a autamtated test pipeline that runs the tests on every push to the repository (see here).

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

modularcirc-0.1.3.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modularcirc-0.1.3-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file modularcirc-0.1.3.tar.gz.

File metadata

  • Download URL: modularcirc-0.1.3.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for modularcirc-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1381ad5f0cd68dc89e5cd42ba959026b90fee241fc8d7af246430e505d292e36
MD5 84f611951ed121f06996f785d0c6273b
BLAKE2b-256 973311d4009be91155762c4f2b4e0e06b6941d3e4f0461e57f99659b7a170305

See more details on using hashes here.

Provenance

The following attestation bundles were made for modularcirc-0.1.3.tar.gz:

Publisher: publish.yml on alan-turing-institute/ModularCirc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file modularcirc-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: modularcirc-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for modularcirc-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a535e3f708c549cbdf98bf0d60111d32bd1043cd4843c30ffc8b83b3a04d45c
MD5 8f14ed5c94a0010a07efd21093497618
BLAKE2b-256 0ae3246685071343c87b757dbb76928bb6a17a577853d8f6c15a8550f4a191be

See more details on using hashes here.

Provenance

The following attestation bundles were made for modularcirc-0.1.3-py3-none-any.whl:

Publisher: publish.yml on alan-turing-institute/ModularCirc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page