Skip to content

Settings

The behavior of PhysioModeler can be adapted using various settings. An overview of the different settings is shown below. The settings can be loaded by calling the load_settings function from the physiomodeler.settings module.

from physiomodeler.settings import load_settings
settings = load_settings()
settings.simulation.relative_tolerance  # Example of accessing a setting

The settings

The settings are organized into different sections, each containing related settings. The default values for each setting are shown below.

Simulation

These settings control the behavior of the simulations.

  • relative_tolerance: The relative tolerance used by the ODE solver.
  • absolute_tolerance: The absolute tolerance used by the ODE solver.
  • eq_relative_tolerance: The relative tolerance used for equilibrium calculations.
  • eq_absolute_tolerance: The absolute tolerance used for equilibrium calculations.

Templates

Templates are strings used for generating names for various entities in the model.

  • state_derivative_label: Template for state derivative labels.

Changing settings

Settings can be changed dynamically.

# Run simulation with default settings
result_1 = model.run_simulation(time=100)  

# Run a single simulation with modified settings
result_2 = model.run_simulation(time=100, relative_tolerance=1e-6)

# Change the relative tolerance for all simulations
settings.simulation.relative_tolerance = 1e-6

# Run simulation with updated settings; should equal `result_2`
result_3 = model.run_simulation(time=100)  

Settings can also be changed by modifying the configuration file in TOML format. If no configuration file is found, default settings are used.

The configuration file should be named physiomodeler.toml and be located in the current working directory. The location of the configuration file can be overwritten by setting the PHYSIOMODELER_CONFIG environment variable to the correct path. The configuration file does not need to contain all settings; any settings not specified in the configuration file will use their default values.

You can generate a default configuration file by calling the generate_default_config function from the physiomodeler.settings module. If you call this function without any arguments, the default configuration file will be created in the current working directory. You can also specify a different path where the configuration file should be created.

The default configuration file looks as follows:

[simulation]
relative_tolerance = 1e-05
absolute_tolerance = 1e-07
eq_relative_tolerance = 1e-05
eq_absolute_tolerance = 1e-07

[templates]
state_derivative_label = "d{state_label}"