MUSICA Python API#
C++ Bindings#
Core#
Mechanism Configuration#
Musica Types#
- class musica.types.Conditions(temperature: float | int | None = None, pressure: float | int | None = None, air_density: float | int | None = None)#
Bases:
_Conditions
Conditions class for the MICM solver. If air density is not provided, it will be calculated from the Ideal Gas Law using the provided temperature and pressure.
- Parameters:
temperature (float) – Temperature in Kelvin.
pressure (float) – Pressure in Pascals.
air_density (float) – Air density in mol m-3
- class musica.types.MICM(config_path: str | PathLike[str] = None, mechanism: Mechanism = None, solver_type: _SolverType = None)#
Bases:
object
The MICM class is a wrapper around the C++ MICM solver. It provides methods to create a solver, create a state, and solve the system of equations.
- Parameters:
config_path (FilePath) – Path to the configuration file.
mechanism (mechanism_configuration.Mechanism) – Mechanism object which specifies the chemical mechanism to use.
solver_type (SolverType) – Type of solver to use.
number_of_grid_cells (int) – Number of grid cells to use. The default is 1.
- create_state(number_of_grid_cells: int = 1) State #
Create a new state object.
- Returns:
A new state object.
- Return type:
- solve(state: State, time_step: float)#
Solve the system of equations for the given state and time step.
- solver_type() SolverType #
Get the type of solver used.
- Returns:
The type of solver used.
- Return type:
- class musica.types.SolverType#
Bases:
_SolverType
Enum class for the type of solver to use.
- class musica.types.State(solver: _Solver, number_of_grid_cells: int, vector_size: int = 0)#
Bases:
object
State class for the MICM solver. It contains the initial conditions and species concentrations.
- get_concentrations() Dict[str, List[float]] #
Get the concentrations of the species in the state.
- Returns:
Dictionary of species names and their concentrations.
- Return type:
Dict[str, List[float]]
- get_conditions() Dict[str, List[float]] #
Get the conditions for the state.
- Returns:
Dictionary of conditions names and their values.
- Return type:
Dict[str, List[float]]
- get_internal_states() List[_State] #
Get the internal states of the MICM solver.
- Returns:
List of internal states.
- Return type:
List[_State]
- get_user_defined_rate_parameters() Dict[str, List[float]] #
Get the user-defined rate parameters in the state.
- Returns:
Dictionary of user-defined rate parameter names and their values.
- Return type:
Dict[str, List[float]]
- set_concentrations(concentrations: Dict[str, float | int | List[float | int]])#
Set the concentrations of the species in the state. Any species not in the dictionary will be set to zero. The concentrations can be a single value when solving for a single grid cell, or a list of values when solving for multiple grid cells.
- Parameters:
concentrations (Dict[str, Union[Union[float, int], List[Union[float, int]]]]) – Dictionary of species names and their concentrations.
- set_conditions(temperatures: float | int | List[float | int], pressures: float | int | List[float | int], air_densities: float | int | List[float | int] | None = None)#
Set the conditions for the state. The individual conditions can be a single value when solving for a single grid cell, or a list of values when solving for multiple grid cells. If air density is not provided, it will be calculated from the Ideal Gas Law using the provided temperature and pressure.
- Parameters:
temperatures (Union[float, List[float]]) – Temperature in Kelvin.
pressures (Union[float, List[float]]) – Pressure in Pascals.
air_densities (Optional[Union[float, List[float]]]) – Air density in mol m-3. If not provided, it will be calculated from the Ideal Gas Law.
- set_user_defined_rate_parameters(user_defined_rate_parameters: Dict[str, float | int | List[float | int]])#
Set the user-defined rate parameters in the state. Any parameter not in the dictionary will be set to zero. The parameters can be a single value when solving for a single grid cell, or a list of values when solving for multiple grid cells.
- Parameters:
user_defined_rate_parameters (Dict[str, Union[Union[float, int], List[Union[float, int]]]]) – Dictionary of user-defined rate parameter names and their values.