Todo
Improve autoapi module
circadapt.model.benchmark
Benchmark models
Package Contents
Classes
Wrapper to communicate with c++ code. |
|
Wrapper to communicate with c++ code. |
|
Wrapper to communicate with c++ code. |
|
Wrapper to communicate with c++ code. |
|
Wrapper to communicate with c++ code. |
Objects
- class circadapt.model.benchmark.Patch(solver: str = None, path_to_circadapt: str = None, model_state: dict = None)[source]
Bases:
circadapt.model.Model
Wrapper to communicate with c++ code.
Parameters
- solver: str (optional)
Name of solver to be build. If not given, the default models solver is used.
- model: str
Name of the model to be build.
- path_to_circadapt: str (optional)
Path to CircAdapt library. If not given, the default_path_to_circadapt is used.
- model_state: (multi)
Model state to be loaded. (default) -> load model reference from package False -> do nothing str -> load filename dict -> load given model state
- build()[source]
Build pre-afterload model with Patch.
This model is designed for illustrating the Patch isolated from the circulation and for benchmarking the Patch module.
- assert_1_beat()[source]
Test status after 1 beat, used in unit tests.
This function can be tested after creating the model with the implemented reference and after 1 beat has been calculated. In case the initial model state deviates from the implemented reference, test settings might be changed accordingly.
- Test for:
l_si == l_si_init on t=t0 l_se_norm == 1 on t=tend
- plot_extended(fig=None)
Extended plot to illustrate the model state.
- get_unittest_targets()
Hardcoded results after initializing and running 1 beat.
- get_unittest_results(model)
Real-time results after initializing and running 1 beat.
- health_check()
Manually perform tests to check compatibility of model with version.
- install()
- __del__()
Destroy object.
This function is triggered when the python wrapper object is deleted or overwritten. As this wrapper only has pointers to the c++ object, the destructor of the c++ object will be triggered.
- check_build()
- get_model_reference(model_state: any = None) dict
Return reference model state as a dictionary.
If model_state is string, it is assumed to be a file location. This file will be loaded and returned. If is none, the default reference will be loaded. If no default reference available, it will be created and stored in the current active directory.
Parameters
- model_statestr or None, optional
Location of model state. The default is None.
Raises
- ValueError
DESCRIPTION.
Returns
- dict
Dictonary with model state.
- load_reference()
Load reference of current model from the package.
- load_plugin_components(path_to_library: str)
Load a plugin
Parameters
- path_to_librarystr
Path to library.
- run(n_beats: int = 1, stable: bool = False, export: bool = True) None
Run the model by solving the ODEs for n_beats.
The currently loaded model, model state, and parameterization will be used to run n_beats. Optional, more beats are performed until the model is hemodynamically stable (stable=True). By default, all data will be exported (export=True). By disabling this (export=False), the model runs faster by only solving the state variables in case a backward ODE solver is used.
Parameters
- n_beats: int, optional (default: True)
Number of beats
- stable: bool, optional (default: False)
Run beats until simulation is hemodynamically stable
- export: bool, optional (default: False)
Future
- is_stable() bool
Check if simulation is hemodynamically stable.
- get(par: str, dtype: any = None) any
Get parameter from the model.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
- Get value: type depending on dtype.
Returns the value stored in the c++ object
- set(par: str, val: any, dtype=None) bool
Set parameter from dtype with value val.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- val: any
Value to be set. The value must be the same as the parameter used.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
bool: success or not
- trigger(par) bool
Trigger a function.
Objects in the model may have a function that can be triggered. This can be done by triggering the function using the ‘par’ parameter similar to the set function, only without a parameter.
Parameters
- parstr
Function in object that will be triggered. It has a similar form to the set/get par, i.e. ‘Component.subcomponent.function_name’
Returns
is_success (bool)
- add(comp_type: str) bool
- add_component(comp_type: str, comp_name: str, base: str = '') bool
Add component to CircAdapt object.
Parameters
- comp_type: str
Type of object to create in the ComponentFactory
- comp_name: str
Name of the new object to create
- base: char, optional (default=’’)
Parent object of new component
Returns
is_success (bool)
- set_component(par, obj) bool
Set component to the parameter of a CircAdapt object.
Parameters
- par: str
Parameter of object to link object obj to
- obj: str
Object to set
- model_import(model_state, check_model_state=False) None
Load model_state into CircAdapt object.
Style and model_state version is automatically recognized.
Parameters
- model_state: dict
model_state with data to set
- obj: str
Object to set
- model_export(style: str = None) dict
Return the stored model state.
Parameters
- style: str (optional)
Style to follow. If not given, the default style from the model is used.
Returns
dict
- save(filename: str, ext: str = None) None
Save model to filename with extention.
Parameters
- filename: str
Filename to save file to. Filename must have extention .npy or .mat
- ext: str (optional)
Extention of the file. If not given, the last 3 letters of the filename is used to determine the save method.
- load(filename: str) None
Load a model dataset from a filename.
Parameters
- filename: str
Path to file that will be loaded. The extension must be .npy or .mat.
- __iter__()
Iterate over export dictionary.
Designed to create a dictionary of the object using dict(self).
Yields
- key: str
key of dictionary
- data[key]: dict
subdictionary of Pdict
- __setitem__(arg, val) bool
Make self subscriptable.
Parameters
- arg: str or slice(None, None, None)
If self[:], arg = slice(None, None, None) and set model import dictionary. If self[’…’], return self.set(arg, val)
- val: dict or any
Dictionary of the model or single value to set.
- __getitem__(arg: any) any
Make self object subscriptable.
Parameters
- arg: slice or str
If self[:], arg = slice(None, None, None) and return model export dictionary. If self[’…’], return self.get(arg)
Returns
model_export dictionary or self.get() type
- __getstate__()
Get state manually, because ctypes can not be pickled.
- __setstate__(state)
Set state manually, because ctypes can not be pickled.
- __repr__()
Object representation in string format.
- abstract copy()
Return a copy of itself.
- class circadapt.model.benchmark.Patch(solver: str = None, path_to_circadapt: str = None, model_state: dict = None)[source]
Bases:
circadapt.model.Model
Wrapper to communicate with c++ code.
Parameters
- solver: str (optional)
Name of solver to be build. If not given, the default models solver is used.
- model: str
Name of the model to be build.
- path_to_circadapt: str (optional)
Path to CircAdapt library. If not given, the default_path_to_circadapt is used.
- model_state: (multi)
Model state to be loaded. (default) -> load model reference from package False -> do nothing str -> load filename dict -> load given model state
- build()[source]
Build pre-afterload model with Patch.
This model is designed for illustrating the Patch isolated from the circulation and for benchmarking the Patch module.
- assert_1_beat()[source]
Test status after 1 beat, used in unit tests.
This function can be tested after creating the model with the implemented reference and after 1 beat has been calculated. In case the initial model state deviates from the implemented reference, test settings might be changed accordingly.
- Test for:
l_si == l_si_init on t=t0 l_se_norm == 1 on t=tend
- plot_extended(fig=None)
Extended plot to illustrate the model state.
- get_unittest_targets()
Hardcoded results after initializing and running 1 beat.
- get_unittest_results(model)
Real-time results after initializing and running 1 beat.
- health_check()
Manually perform tests to check compatibility of model with version.
- install()
- __del__()
Destroy object.
This function is triggered when the python wrapper object is deleted or overwritten. As this wrapper only has pointers to the c++ object, the destructor of the c++ object will be triggered.
- check_build()
- get_model_reference(model_state: any = None) dict
Return reference model state as a dictionary.
If model_state is string, it is assumed to be a file location. This file will be loaded and returned. If is none, the default reference will be loaded. If no default reference available, it will be created and stored in the current active directory.
Parameters
- model_statestr or None, optional
Location of model state. The default is None.
Raises
- ValueError
DESCRIPTION.
Returns
- dict
Dictonary with model state.
- load_reference()
Load reference of current model from the package.
- load_plugin_components(path_to_library: str)
Load a plugin
Parameters
- path_to_librarystr
Path to library.
- run(n_beats: int = 1, stable: bool = False, export: bool = True) None
Run the model by solving the ODEs for n_beats.
The currently loaded model, model state, and parameterization will be used to run n_beats. Optional, more beats are performed until the model is hemodynamically stable (stable=True). By default, all data will be exported (export=True). By disabling this (export=False), the model runs faster by only solving the state variables in case a backward ODE solver is used.
Parameters
- n_beats: int, optional (default: True)
Number of beats
- stable: bool, optional (default: False)
Run beats until simulation is hemodynamically stable
- export: bool, optional (default: False)
Future
- is_stable() bool
Check if simulation is hemodynamically stable.
- get(par: str, dtype: any = None) any
Get parameter from the model.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
- Get value: type depending on dtype.
Returns the value stored in the c++ object
- set(par: str, val: any, dtype=None) bool
Set parameter from dtype with value val.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- val: any
Value to be set. The value must be the same as the parameter used.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
bool: success or not
- trigger(par) bool
Trigger a function.
Objects in the model may have a function that can be triggered. This can be done by triggering the function using the ‘par’ parameter similar to the set function, only without a parameter.
Parameters
- parstr
Function in object that will be triggered. It has a similar form to the set/get par, i.e. ‘Component.subcomponent.function_name’
Returns
is_success (bool)
- add(comp_type: str) bool
- add_component(comp_type: str, comp_name: str, base: str = '') bool
Add component to CircAdapt object.
Parameters
- comp_type: str
Type of object to create in the ComponentFactory
- comp_name: str
Name of the new object to create
- base: char, optional (default=’’)
Parent object of new component
Returns
is_success (bool)
- set_component(par, obj) bool
Set component to the parameter of a CircAdapt object.
Parameters
- par: str
Parameter of object to link object obj to
- obj: str
Object to set
- model_import(model_state, check_model_state=False) None
Load model_state into CircAdapt object.
Style and model_state version is automatically recognized.
Parameters
- model_state: dict
model_state with data to set
- obj: str
Object to set
- model_export(style: str = None) dict
Return the stored model state.
Parameters
- style: str (optional)
Style to follow. If not given, the default style from the model is used.
Returns
dict
- save(filename: str, ext: str = None) None
Save model to filename with extention.
Parameters
- filename: str
Filename to save file to. Filename must have extention .npy or .mat
- ext: str (optional)
Extention of the file. If not given, the last 3 letters of the filename is used to determine the save method.
- load(filename: str) None
Load a model dataset from a filename.
Parameters
- filename: str
Path to file that will be loaded. The extension must be .npy or .mat.
- __iter__()
Iterate over export dictionary.
Designed to create a dictionary of the object using dict(self).
Yields
- key: str
key of dictionary
- data[key]: dict
subdictionary of Pdict
- __setitem__(arg, val) bool
Make self subscriptable.
Parameters
- arg: str or slice(None, None, None)
If self[:], arg = slice(None, None, None) and set model import dictionary. If self[’…’], return self.set(arg, val)
- val: dict or any
Dictionary of the model or single value to set.
- __getitem__(arg: any) any
Make self object subscriptable.
Parameters
- arg: slice or str
If self[:], arg = slice(None, None, None) and return model export dictionary. If self[’…’], return self.get(arg)
Returns
model_export dictionary or self.get() type
- __getstate__()
Get state manually, because ctypes can not be pickled.
- __setstate__(state)
Set state manually, because ctypes can not be pickled.
- __repr__()
Object representation in string format.
- abstract copy()
Return a copy of itself.
- class circadapt.model.benchmark.Chamber2022(solver: str = None, path_to_circadapt: str = None, model_state: dict = None)[source]
Bases:
circadapt.model.Model
Wrapper to communicate with c++ code.
Parameters
- solver: str (optional)
Name of solver to be build. If not given, the default models solver is used.
- model: str
Name of the model to be build.
- path_to_circadapt: str (optional)
Path to CircAdapt library. If not given, the default_path_to_circadapt is used.
- model_state: (multi)
Model state to be loaded. (default) -> load model reference from package False -> do nothing str -> load filename dict -> load given model state
- build()[source]
Build pre-afterload model with Patch2022.
This model is designed for illustrating the Patch2022 isolated from the circulation and for benchmarking the Patch2022 module.
- plot(fig=None)
Simple plot to illustrate the model state.
- plot_extended(fig=None)
Extended plot to illustrate the model state.
- assert_1_beat()
Test status after 1 beat, used in unit tests.
- get_unittest_targets()
Hardcoded results after initializing and running 1 beat.
- get_unittest_results(model)
Real-time results after initializing and running 1 beat.
- health_check()
Manually perform tests to check compatibility of model with version.
- install()
- __del__()
Destroy object.
This function is triggered when the python wrapper object is deleted or overwritten. As this wrapper only has pointers to the c++ object, the destructor of the c++ object will be triggered.
- check_build()
- get_model_reference(model_state: any = None) dict
Return reference model state as a dictionary.
If model_state is string, it is assumed to be a file location. This file will be loaded and returned. If is none, the default reference will be loaded. If no default reference available, it will be created and stored in the current active directory.
Parameters
- model_statestr or None, optional
Location of model state. The default is None.
Raises
- ValueError
DESCRIPTION.
Returns
- dict
Dictonary with model state.
- load_reference()
Load reference of current model from the package.
- load_plugin_components(path_to_library: str)
Load a plugin
Parameters
- path_to_librarystr
Path to library.
- run(n_beats: int = 1, stable: bool = False, export: bool = True) None
Run the model by solving the ODEs for n_beats.
The currently loaded model, model state, and parameterization will be used to run n_beats. Optional, more beats are performed until the model is hemodynamically stable (stable=True). By default, all data will be exported (export=True). By disabling this (export=False), the model runs faster by only solving the state variables in case a backward ODE solver is used.
Parameters
- n_beats: int, optional (default: True)
Number of beats
- stable: bool, optional (default: False)
Run beats until simulation is hemodynamically stable
- export: bool, optional (default: False)
Future
- is_stable() bool
Check if simulation is hemodynamically stable.
- get(par: str, dtype: any = None) any
Get parameter from the model.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
- Get value: type depending on dtype.
Returns the value stored in the c++ object
- set(par: str, val: any, dtype=None) bool
Set parameter from dtype with value val.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- val: any
Value to be set. The value must be the same as the parameter used.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
bool: success or not
- trigger(par) bool
Trigger a function.
Objects in the model may have a function that can be triggered. This can be done by triggering the function using the ‘par’ parameter similar to the set function, only without a parameter.
Parameters
- parstr
Function in object that will be triggered. It has a similar form to the set/get par, i.e. ‘Component.subcomponent.function_name’
Returns
is_success (bool)
- add(comp_type: str) bool
- add_component(comp_type: str, comp_name: str, base: str = '') bool
Add component to CircAdapt object.
Parameters
- comp_type: str
Type of object to create in the ComponentFactory
- comp_name: str
Name of the new object to create
- base: char, optional (default=’’)
Parent object of new component
Returns
is_success (bool)
- set_component(par, obj) bool
Set component to the parameter of a CircAdapt object.
Parameters
- par: str
Parameter of object to link object obj to
- obj: str
Object to set
- model_import(model_state, check_model_state=False) None
Load model_state into CircAdapt object.
Style and model_state version is automatically recognized.
Parameters
- model_state: dict
model_state with data to set
- obj: str
Object to set
- model_export(style: str = None) dict
Return the stored model state.
Parameters
- style: str (optional)
Style to follow. If not given, the default style from the model is used.
Returns
dict
- save(filename: str, ext: str = None) None
Save model to filename with extention.
Parameters
- filename: str
Filename to save file to. Filename must have extention .npy or .mat
- ext: str (optional)
Extention of the file. If not given, the last 3 letters of the filename is used to determine the save method.
- load(filename: str) None
Load a model dataset from a filename.
Parameters
- filename: str
Path to file that will be loaded. The extension must be .npy or .mat.
- __iter__()
Iterate over export dictionary.
Designed to create a dictionary of the object using dict(self).
Yields
- key: str
key of dictionary
- data[key]: dict
subdictionary of Pdict
- __setitem__(arg, val) bool
Make self subscriptable.
Parameters
- arg: str or slice(None, None, None)
If self[:], arg = slice(None, None, None) and set model import dictionary. If self[’…’], return self.set(arg, val)
- val: dict or any
Dictionary of the model or single value to set.
- __getitem__(arg: any) any
Make self object subscriptable.
Parameters
- arg: slice or str
If self[:], arg = slice(None, None, None) and return model export dictionary. If self[’…’], return self.get(arg)
Returns
model_export dictionary or self.get() type
- __getstate__()
Get state manually, because ctypes can not be pickled.
- __setstate__(state)
Set state manually, because ctypes can not be pickled.
- __repr__()
Object representation in string format.
- abstract copy()
Return a copy of itself.
- class circadapt.model.benchmark.Valve2022(solver: str = None, path_to_circadapt: str = None, model_state: dict = None, model_options: dict = {})[source]
Bases:
circadapt.model.Model
Wrapper to communicate with c++ code.
Parameters
- solver: str (optional)
Name of solver to be build. If not given, the default models solver is used.
- model: str
Name of the model to be build.
- path_to_circadapt: str (optional)
Path to CircAdapt library. If not given, the default_path_to_circadapt is used.
- model_state: (multi)
Model state to be loaded. (default) -> load model reference from package False -> do nothing str -> load filename dict -> load given model state
- build()[source]
Build benchmark for Valve2022.
This model has a Valve2022 module with a prescribed proximal and distal pressure using the NodePressure module.
- plot(fig=None)
Simple plot to illustrate the model state.
- plot_extended(fig=None)
Extended plot to illustrate the model state.
- assert_1_beat()
Test status after 1 beat, used in unit tests.
- get_unittest_targets()
Hardcoded results after initializing and running 1 beat.
- get_unittest_results(model)
Real-time results after initializing and running 1 beat.
- health_check()
Manually perform tests to check compatibility of model with version.
- install()
- __del__()
Destroy object.
This function is triggered when the python wrapper object is deleted or overwritten. As this wrapper only has pointers to the c++ object, the destructor of the c++ object will be triggered.
- check_build()
- get_model_reference(model_state: any = None) dict
Return reference model state as a dictionary.
If model_state is string, it is assumed to be a file location. This file will be loaded and returned. If is none, the default reference will be loaded. If no default reference available, it will be created and stored in the current active directory.
Parameters
- model_statestr or None, optional
Location of model state. The default is None.
Raises
- ValueError
DESCRIPTION.
Returns
- dict
Dictonary with model state.
- load_reference()
Load reference of current model from the package.
- load_plugin_components(path_to_library: str)
Load a plugin
Parameters
- path_to_librarystr
Path to library.
- run(n_beats: int = 1, stable: bool = False, export: bool = True) None
Run the model by solving the ODEs for n_beats.
The currently loaded model, model state, and parameterization will be used to run n_beats. Optional, more beats are performed until the model is hemodynamically stable (stable=True). By default, all data will be exported (export=True). By disabling this (export=False), the model runs faster by only solving the state variables in case a backward ODE solver is used.
Parameters
- n_beats: int, optional (default: True)
Number of beats
- stable: bool, optional (default: False)
Run beats until simulation is hemodynamically stable
- export: bool, optional (default: False)
Future
- is_stable() bool
Check if simulation is hemodynamically stable.
- get(par: str, dtype: any = None) any
Get parameter from the model.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
- Get value: type depending on dtype.
Returns the value stored in the c++ object
- set(par: str, val: any, dtype=None) bool
Set parameter from dtype with value val.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- val: any
Value to be set. The value must be the same as the parameter used.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
bool: success or not
- trigger(par) bool
Trigger a function.
Objects in the model may have a function that can be triggered. This can be done by triggering the function using the ‘par’ parameter similar to the set function, only without a parameter.
Parameters
- parstr
Function in object that will be triggered. It has a similar form to the set/get par, i.e. ‘Component.subcomponent.function_name’
Returns
is_success (bool)
- add(comp_type: str) bool
- add_component(comp_type: str, comp_name: str, base: str = '') bool
Add component to CircAdapt object.
Parameters
- comp_type: str
Type of object to create in the ComponentFactory
- comp_name: str
Name of the new object to create
- base: char, optional (default=’’)
Parent object of new component
Returns
is_success (bool)
- set_component(par, obj) bool
Set component to the parameter of a CircAdapt object.
Parameters
- par: str
Parameter of object to link object obj to
- obj: str
Object to set
- model_import(model_state, check_model_state=False) None
Load model_state into CircAdapt object.
Style and model_state version is automatically recognized.
Parameters
- model_state: dict
model_state with data to set
- obj: str
Object to set
- model_export(style: str = None) dict
Return the stored model state.
Parameters
- style: str (optional)
Style to follow. If not given, the default style from the model is used.
Returns
dict
- save(filename: str, ext: str = None) None
Save model to filename with extention.
Parameters
- filename: str
Filename to save file to. Filename must have extention .npy or .mat
- ext: str (optional)
Extention of the file. If not given, the last 3 letters of the filename is used to determine the save method.
- load(filename: str) None
Load a model dataset from a filename.
Parameters
- filename: str
Path to file that will be loaded. The extension must be .npy or .mat.
- __iter__()
Iterate over export dictionary.
Designed to create a dictionary of the object using dict(self).
Yields
- key: str
key of dictionary
- data[key]: dict
subdictionary of Pdict
- __setitem__(arg, val) bool
Make self subscriptable.
Parameters
- arg: str or slice(None, None, None)
If self[:], arg = slice(None, None, None) and set model import dictionary. If self[’…’], return self.set(arg, val)
- val: dict or any
Dictionary of the model or single value to set.
- __getitem__(arg: any) any
Make self object subscriptable.
Parameters
- arg: slice or str
If self[:], arg = slice(None, None, None) and return model export dictionary. If self[’…’], return self.get(arg)
Returns
model_export dictionary or self.get() type
- __getstate__()
Get state manually, because ctypes can not be pickled.
- __setstate__(state)
Set state manually, because ctypes can not be pickled.
- __repr__()
Object representation in string format.
- abstract copy()
Return a copy of itself.
- class circadapt.model.benchmark.Valve(solver: str = None, path_to_circadapt: str = None, model_state: dict = None, model_options: dict = {})[source]
Bases:
circadapt.model.Model
Wrapper to communicate with c++ code.
Parameters
- solver: str (optional)
Name of solver to be build. If not given, the default models solver is used.
- model: str
Name of the model to be build.
- path_to_circadapt: str (optional)
Path to CircAdapt library. If not given, the default_path_to_circadapt is used.
- model_state: (multi)
Model state to be loaded. (default) -> load model reference from package False -> do nothing str -> load filename dict -> load given model state
- build()[source]
Build benchmark for Valve.
This model has a Valve module with a prescribed proximal and distal pressure using the NodePressure module.
- plot(fig=None)
Simple plot to illustrate the model state.
- plot_extended(fig=None)
Extended plot to illustrate the model state.
- assert_1_beat()
Test status after 1 beat, used in unit tests.
- get_unittest_targets()
Hardcoded results after initializing and running 1 beat.
- get_unittest_results(model)
Real-time results after initializing and running 1 beat.
- health_check()
Manually perform tests to check compatibility of model with version.
- install()
- __del__()
Destroy object.
This function is triggered when the python wrapper object is deleted or overwritten. As this wrapper only has pointers to the c++ object, the destructor of the c++ object will be triggered.
- check_build()
- get_model_reference(model_state: any = None) dict
Return reference model state as a dictionary.
If model_state is string, it is assumed to be a file location. This file will be loaded and returned. If is none, the default reference will be loaded. If no default reference available, it will be created and stored in the current active directory.
Parameters
- model_statestr or None, optional
Location of model state. The default is None.
Raises
- ValueError
DESCRIPTION.
Returns
- dict
Dictonary with model state.
- load_reference()
Load reference of current model from the package.
- load_plugin_components(path_to_library: str)
Load a plugin
Parameters
- path_to_librarystr
Path to library.
- run(n_beats: int = 1, stable: bool = False, export: bool = True) None
Run the model by solving the ODEs for n_beats.
The currently loaded model, model state, and parameterization will be used to run n_beats. Optional, more beats are performed until the model is hemodynamically stable (stable=True). By default, all data will be exported (export=True). By disabling this (export=False), the model runs faster by only solving the state variables in case a backward ODE solver is used.
Parameters
- n_beats: int, optional (default: True)
Number of beats
- stable: bool, optional (default: False)
Run beats until simulation is hemodynamically stable
- export: bool, optional (default: False)
Future
- is_stable() bool
Check if simulation is hemodynamically stable.
- get(par: str, dtype: any = None) any
Get parameter from the model.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
- Get value: type depending on dtype.
Returns the value stored in the c++ object
- set(par: str, val: any, dtype=None) bool
Set parameter from dtype with value val.
Parameters
- par: str
Parameter name to get. This string value contains the parameter that will be obtained and the component from which it will be obtained. Components, its subcomponents, and the parameter name at the and are separated with a dot.
- val: any
Value to be set. The value must be the same as the parameter used.
- dtype: string or type, optional (default = None)
The type of parameter that will be obtained. If not specified, it will be detairmined automatically. If computational cost is important, it is better to specify the dtype.
Returns
bool: success or not
- trigger(par) bool
Trigger a function.
Objects in the model may have a function that can be triggered. This can be done by triggering the function using the ‘par’ parameter similar to the set function, only without a parameter.
Parameters
- parstr
Function in object that will be triggered. It has a similar form to the set/get par, i.e. ‘Component.subcomponent.function_name’
Returns
is_success (bool)
- add(comp_type: str) bool
- add_component(comp_type: str, comp_name: str, base: str = '') bool
Add component to CircAdapt object.
Parameters
- comp_type: str
Type of object to create in the ComponentFactory
- comp_name: str
Name of the new object to create
- base: char, optional (default=’’)
Parent object of new component
Returns
is_success (bool)
- set_component(par, obj) bool
Set component to the parameter of a CircAdapt object.
Parameters
- par: str
Parameter of object to link object obj to
- obj: str
Object to set
- model_import(model_state, check_model_state=False) None
Load model_state into CircAdapt object.
Style and model_state version is automatically recognized.
Parameters
- model_state: dict
model_state with data to set
- obj: str
Object to set
- model_export(style: str = None) dict
Return the stored model state.
Parameters
- style: str (optional)
Style to follow. If not given, the default style from the model is used.
Returns
dict
- save(filename: str, ext: str = None) None
Save model to filename with extention.
Parameters
- filename: str
Filename to save file to. Filename must have extention .npy or .mat
- ext: str (optional)
Extention of the file. If not given, the last 3 letters of the filename is used to determine the save method.
- load(filename: str) None
Load a model dataset from a filename.
Parameters
- filename: str
Path to file that will be loaded. The extension must be .npy or .mat.
- __iter__()
Iterate over export dictionary.
Designed to create a dictionary of the object using dict(self).
Yields
- key: str
key of dictionary
- data[key]: dict
subdictionary of Pdict
- __setitem__(arg, val) bool
Make self subscriptable.
Parameters
- arg: str or slice(None, None, None)
If self[:], arg = slice(None, None, None) and set model import dictionary. If self[’…’], return self.set(arg, val)
- val: dict or any
Dictionary of the model or single value to set.
- __getitem__(arg: any) any
Make self object subscriptable.
Parameters
- arg: slice or str
If self[:], arg = slice(None, None, None) and return model export dictionary. If self[’…’], return self.get(arg)
Returns
model_export dictionary or self.get() type
- __getstate__()
Get state manually, because ctypes can not be pickled.
- __setstate__(state)
Set state manually, because ctypes can not be pickled.
- __repr__()
Object representation in string format.
- abstract copy()
Return a copy of itself.