Parsers & generators (internal)
Note
These classes are internal building blocks used by the public entry points. They are documented for completeness and for advanced workflows, but their interfaces may change between releases. Prefer the entry points on the Overview page where possible.
Parsers
libcuflynx.parsers.ModelParsers.CSV0DModelParser
CSV0DModelParser(inp_data_dict, parameter_id_dir=None)
Bases: object
Creates a 0D model representation from a vessel and a parameter CSV files.
libcuflynx.parsers.PrimitiveParsers.YamlFileParser
YamlFileParser()
Bases: object
Parses Yaml files
Constructor
Generators
libcuflynx.generators.CVSCellMLGenerator.CVS0DCellMLGenerator
CVS0DCellMLGenerator(model, inp_data_dict)
Bases: object
Generates CellML files for the 0D model represented in @
Constructor
create_unit_converter_component
create_unit_converter_component(
name,
input_var,
output_var,
scale_factor,
units_in,
units_out,
)
Returns a CellML component string that converts input_var (units_in) to output_var (units_out) using the given scale_factor.
add_converter_component
add_converter_component(converter_component_str)
Stores the converter component string for later writing to the CellML file.
get_variable_unit_from_component
get_variable_unit_from_component(
component_name, variable_name
)
Given a component (module) name and variable name, return the unit name as a string.
libcuflynx.generators.PythonGenerator.PythonGenerator
PythonGenerator(
cellml_path,
output_dir=None,
module_name=None,
human_readable=True,
casadi_compat=False,
aadc_compat=False,
)
Generate a Python module from a CellML file.
Usage
gen = PythonGenerator('model.cellml', output_dir='out') py_path = gen.generate()
generate
generate()
Generate Python code and return the output file path.
Protocol execution
libcuflynx.protocol_runners.protocol_executor.ProtocolExecutor
ProtocolExecutor(sim_helper)
Core multi-experiment / multi-subexperiment protocol simulation loop.
Parameters
sim_helper : SimulationHelper Any solver-wrapper instance (myokit, opencor, python, casadi). The caller retains ownership; ProtocolExecutor does not close it.
run_protocol
run_protocol(
protocol_info,
id_param_names=None,
id_param_vals=None,
result_variables=None,
extra_result_variables=None,
exp_indices=None,
continue_on_failure=False,
reset_after_experiment=True,
)
Run the multi-experiment / multi-subexperiment protocol loop.
Parameters
protocol_info : dict
Must contain:
- 'sim_times' list[list[float]] — sim duration per (exp, sub)
- 'pre_times' list[float] — pre-simulation time per exp
- 'params_to_change' dict — {param_name: [[val_exp0_sub0, ...], ...]}
May also contain pre-computed keys added by process_protocol_and_weights:
- 'num_experiments' int
- 'num_sub_per_exp' list[int]
Both are derived from sim_times when absent.
id_param_names : list, optional
Parameter names set once before each experiment (e.g. ID candidates).
id_param_vals : list, optional
Values matching id_param_names.
result_variables : list, optional
Variables to retrieve per sub-experiment via get_results().
None → collect all variables via get_all_results(flatten=True).
extra_result_variables : list, optional
A second variable set collected in the same pass (e.g. pred_names).
exp_indices : iterable, optional
Only run these experiment indices. Other slots in the output
will be absent from results_by_sub / extra_by_sub, and None in
t_by_exp.
continue_on_failure : bool, default False
If True, record None for failed sub-experiments and continue
rather than returning early. If False (default), return
immediately on the first simulation failure.
reset_after_experiment : bool, default True
If True (default), call sim_helper.reset_and_clear() after the
final sub-experiment of each experiment. Pass False for AD
(automatic differentiation) mode where the solver state must be
preserved across experiments.
Returns
success : bool
False only when a simulation failed AND continue_on_failure is False.
results_by_sub : dict
Mapping (exp_idx, sub_idx) → result of get_results() or
get_all_results(flatten=True). None for failed sub-experiments
when continue_on_failure is True.
extra_by_sub : dict
Same structure for extra_result_variables. Empty dict when
extra_result_variables is None.
t_by_exp : list[np.ndarray | None]
Concatenated, pre_time-shifted time vector per experiment index.
None for skipped or failed experiments.
Inner param-id engine
libcuflynx.param_id.paramID.OpencorParamID
module-attribute
OpencorParamID = ParamID
libcuflynx.param_id.paramID.OpencorMCMC
module-attribute
OpencorMCMC = MCMC