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
pip install git+https://github.com/MaxBalmus/ModularCirc.git
- 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.commponents['lv'].V.values
p_lv = solver.model.commponents['lv'].P_i.values