Skip to main content

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

The current version of the published package contains two models:

  1. Naghavi model.
  2. 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

  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!

Metadata

Release files for ModularCirc 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ModularCirc 0.3.0
File Size Uploaded
modularcirc-0.3.0.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ModularCirc 0.3.0
File Interpreter ABI Platform
modularcirc-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 71.1 kB

Release files / modularcirc-0.3.0.tar.gz

Download URL modularcirc-0.3.0.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a7133739f9ccbddb70dd099b089df1bb407d653013ef18efe1bf946b00497028
BLAKE2b-256 checksum
How to use checksums
94ddb9f2897e74aa0bf57174549b0bc3797232fc93de6aa052900a65567d17b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release files / modularcirc-0.3.0-py3-none-any.whl

Download URL modularcirc-0.3.0-py3-none-any.whl
Size 37.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5867c35b4eb6c2374d444bb3f39626dae2a4c9386f9c4cc6741414dc8d191e7
BLAKE2b-256 checksum
How to use checksums
60f313973bd88863bc8d2593f6a19c5a1f64924f4b9e4de0358a9592badda8e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page