MusicBox#

Submodules#

acom_music_box.music_box module#

class acom_music_box.music_box.MusicBox(box_model_options=None, initial_conditions=None, evolving_conditions=None, config_file=None)#

Bases: object

Represents a box model with attributes such as box model options, species list, reaction list, initial conditions, and evolving conditions.

Attributes:

box_model_options (BoxModelOptions): Options for the box model simulation. initial_conditions (Conditions): Initial conditions for the simulation. evolving_conditions (List[EvolvingConditions]): List of evolving conditions over time. config_file (String): File path for the configuration file to be located. Default is “camp_data/config.json”.

add_evolving_condition(time_point, conditions)#

Add an evolving condition at a specific time point.

Args:

time_point (float): The time point for the evolving condition. conditions (Conditions): The associated conditions at the given time point.

loadJson(path_to_json)#

Reads and parses a JSON file and create a solver

Args:

path_to_json (str): The JSON path to the JSON file.

Returns:

None

Raises:

ValueError: If the JSON string cannot be parsed.

static order_reaction_rates(curr_conditions, rate_constant_ordering)#

Orders the reaction rates based on the provided ordering.

This function takes the current conditions and a specified ordering for the rate constants, and reorders the reaction rates accordingly.

Args:

curr_conditions: A Condition with the current state information rate_constant_ordering: A dictionary which maps reaction names to their index in the reaction rates array

Returns:

list: An ordered list of rate constants.

static order_species_concentrations(curr_conditions, species_constant_ordering)#

Orders the species concentrations based on the provided ordering.

This function takes the current conditions and a specified ordering for the species, and reorders the species concentrations accordingly.

Args:

curr_conditions (Conditions): The current conditions. species_constant_ordering (dict): A dictionary that maps species keys to indices for ordering.

Returns:

list: An ordered list of species concentrations.

solve(callback=None)#

Solves the box model simulation and optionally writes the output to a file.

This function runs the box model simulation using the current settings and conditions. If a path is provided, it writes the output of the simulation to the specified file.

Args:

callback (function, optional): A callback function that is called after each time step. Defaults to None. The callback will take the most recent results, the current time, conditions, and the total simulation time as arguments.

Returns:

list: A 2D list where each inner list represents the results of the simulation at a specific time step.

acom_music_box.music_box_conditions module#

acom_music_box.music_box_evolving_conditions module#

acom_music_box.music_box_model_options module#

acom_music_box.music_box_product module#

acom_music_box.music_box_reactant module#

acom_music_box.music_box_reaction module#

acom_music_box.music_box_reaction_list module#

acom_music_box.music_box_reaction_rate module#

acom_music_box.music_box_species module#

acom_music_box.music_box_species_concentration module#

acom_music_box.music_box_species_list module#

acom_music_box.utils module#

acom_music_box.utils.calculate_air_density(temperature, pressure)#

Calculate the air density in moles/m^3.

Args:

temperature (float): The temperature in Kelvin. pressure (float): The pressure in Pascals.

Returns:

float: The air density in moles/m^3.

acom_music_box.utils.convert_concentration(data, key, temperature, pressure)#

Convert the concentration from the input data to moles per cubic meter.

Args:

data (dict): The input data. key (str): The key for the concentration in the input data. temperature (float): The temperature in Kelvin. pressure (float): The pressure in Pascals.

Returns:

float: The concentration in moles per cubic meter.

acom_music_box.utils.convert_pressure(data, key)#

Convert the pressure from the input data to Pascals.

Args:

data (dict): The input data. key (str): The key for the pressure in the input data.

Returns:

float: The pressure in Pascals.

acom_music_box.utils.convert_temperature(data, key)#

Convert the temperature from the input data to Kelvin.

Args:

data (dict): The input data. key (str): The key for the temperature in the input data.

Returns:

float: The temperature in Kelvin.

acom_music_box.utils.convert_time(data, key)#

Convert the time from the input data to seconds.

Args:

data (dict): The input data. key (str): The key for the time in the input data.

Returns:

float: The time in seconds.

acom_music_box.utils.extract_unit(data, key)#

Extract the value and unit from the key in data.

Module contents#

An atmospheric chemistry box model. Powered by MUSICA.

This package contains modules for handling various aspects of a music box, including species, products, reactants, reactions, and more.