MusicBox#

Submodules#

acom_music_box.music_box module#

class acom_music_box.music_box.MusicBox(box_model_options=None, species_list=None, reaction_list=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:

boxModelOptions (BoxModelOptions): Options for the box model simulation. speciesList (SpeciesList): A list of species. reactionList (ReactionList): A list of reactions. initialConditions (Conditions): Initial conditions for the simulation. evolvingConditions (List[EvolvingConditions]): List of evolving conditions over time.

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.

create_solver(path_to_config, solver_type=<micmsolver.rosenbrock: 1>, number_of_grid_cells=1)#

Creates a micm solver object using the CAMP configuration files.

Args:

path_to_config (str): The path to CAMP configuration directory.

Returns:

None

classmethod 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:

rate_constants (dict): A dictionary of rate constants. rate_constant_ordering (dict): A dictionary that maps rate constant keys to indices for ordering.

Returns:

list: An ordered list of rate constants.

classmethod order_species_concentrations(curr_conditions, species_constant_ordering)#
readConditionsFromJson(path_to_json)#

Reads and parses a JSON file from the CAMP JSON file to set up the box model simulation.

Args:

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

Returns:

None

Raises:

ValueError: If the JSON string cannot be parsed.

solve(output_path=None, 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:

output_path (str, optional): The path to the file where the output will be written. If None, no output file is created. Defaults to None. 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.

speciesOrdering()#

Retrieves the ordering of species used in the solver.

This function calls the species_ordering function from the musica module, passing the solver instance from the current object.

Returns:

dict: The ordered dictionary of species used in the solver.

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.convert_concentration(data, key)#

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

Args:

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

Returns:

float: The concentration in molecules 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.

Module contents#

This is the music_box package.

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