diff --git a/src/box_model.py b/src/box_model.py new file mode 100644 index 00000000..020165f6 --- /dev/null +++ b/src/box_model.py @@ -0,0 +1,53 @@ +from music_box_evolving_conditions import EvolvingConditions +from music_box_reaction_list import ReactionList +from music_box_species_list import SpeciesList +from music_box_model_options import BoxModelOptions + +class BoxModel: + """ + 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. + """ + + def __init__(self, box_model_options, species_list, reaction_list, initial_conditions, evolving_conditions): + """ + Initializes a new instance of the BoxModel class. + + Args: + box_model_options (BoxModelOptions): Options for the box model simulation. + species_list (SpeciesList): A list of species. + reaction_list (ReactionList): A list of reactions. + initial_conditions (Conditions): Initial conditions for the simulation. + evolving_conditions (List[EvolvingConditions]): List of evolving conditions over time. + """ + self.boxModelOptions = box_model_options + self.speciesList = species_list + self.reactionList = reaction_list + self.initialConditions = initial_conditions + self.evolvingConditions = evolving_conditions + + def add_evolving_condition(self, 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. + """ + evolving_condition = EvolvingConditions(time=[time_point], conditions=[conditions]) + self.evolvingConditions.append(evolving_condition) + + def generateFiles(self): + """ + TODO: Generate configuration JSON files for the box model simulation. + """ + # TODO: Implement the logic to generate configuration files. + # This method is a placeholder, and the actual implementation is required. + pass diff --git a/src/music_box_conditions.py b/src/music_box_conditions.py new file mode 100644 index 00000000..d2beffa2 --- /dev/null +++ b/src/music_box_conditions.py @@ -0,0 +1,46 @@ +from typing import List + +class Conditions: + """ + Represents conditions for a simulation with attributes such as pressure, temperature, species concentrations, + and reaction rates. + + Attributes: + pressure (float): The pressure of the conditions in atmospheres. + temperature (float): The temperature of the conditions in Kelvin. + speciesConcentrations (List[SpeciesConcentration]): A list of species concentrations. + reactionRates (List[ReactionRate]): A list of reaction rates. + """ + + def __init__(self, pressure, temperature, species_concentrations=None, reaction_rates=None): + """ + Initializes a new instance of the Conditions class. + + Args: + pressure (float): The pressure of the conditions in atmospheres. + temperature (float): The temperature of the conditions in Kelvin. + species_concentrations (List[SpeciesConcentration]): A list of species concentrations. Default is an empty list. + reaction_rates (List[ReactionRate]): A list of reaction rates. Default is an empty list. + """ + self.pressure = pressure + self.temperature = temperature + self.speciesConcentrations = species_concentrations if species_concentrations is not None else [] + self.reactionRates = reaction_rates if reaction_rates is not None else [] + + def add_species_concentration(self, species_concentration): + """ + Add a SpeciesConcentration instance to the list of species concentrations. + + Args: + species_concentration (SpeciesConcentration): The SpeciesConcentration instance to be added. + """ + self.speciesConcentrations.append(species_concentration) + + def add_reaction_rate(self, reaction_rate): + """ + Add a ReactionRate instance to the list of reaction rates. + + Args: + reaction_rate (ReactionRate): The ReactionRate instance to be added. + """ + self.reactionRates.append(reaction_rate) diff --git a/src/music_box_evolving_conditions.py b/src/music_box_evolving_conditions.py new file mode 100644 index 00000000..b2885d70 --- /dev/null +++ b/src/music_box_evolving_conditions.py @@ -0,0 +1,43 @@ +from typing import List + +class EvolvingConditions: + """ + Represents evolving conditions with attributes such as time and associated conditions. + + Attributes: + time (List[float]): A list of time points. + conditions (List[Conditions]): A list of associated conditions. + """ + + def __init__(self, time=None, conditions=None): + """ + Initializes a new instance of the EvolvingConditions class. + + Args: + time (List[float]): A list of time points. Default is an empty list. + conditions (List[Conditions]): A list of associated conditions. Default is an empty list. + """ + self.time = time if time is not None else [] + self.conditions = conditions if conditions is not None else [] + + def add_condition(self, 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. + """ + self.time.append(time_point) + self.conditions.append(conditions) + + def read_conditions_from_file(self, file_path): + """ + TODO: Read conditions from a file and update the evolving conditions. + + Args: + file_path (str): The path to the file containing conditions data. + """ + # TODO: Implement the logic to read conditions from the specified file. + # This method is a placeholder, and the actual implementation is required. + pass diff --git a/src/music_box_model_options.py b/src/music_box_model_options.py new file mode 100644 index 00000000..537cd521 --- /dev/null +++ b/src/music_box_model_options.py @@ -0,0 +1,25 @@ +class BoxModelOptions: + """ + Represents options for a box model simulation. + + Attributes: + grid (str): The type of grid. Default is "box". + chemStepTime (float): Time step for chemical reactions in the simulation in minutes. + outputStepTime (float): Time step for output data in the simulation in hours. + simulationLength (float): Length of the simulation in hours. + """ + + def __init__(self, chem_step_time, output_step_time, simulation_length, grid="box"): + """ + Initializes a new instance of the BoxModelOptions class. + + Args: + chem_step_time (float): Time step for chemical reactions in the simulation in minutes. + output_step_time (float): Time step for output data in the simulation in hours. + simulation_length (float): Length of the simulation in hours. + grid (str): The type of grid. Default is "box". + """ + self.chemStepTime = chem_step_time + self.outputStepTime = output_step_time + self.simulationLength = simulation_length + self.grid = grid diff --git a/src/music_box_product.py b/src/music_box_product.py new file mode 100644 index 00000000..2f1d1fc2 --- /dev/null +++ b/src/music_box_product.py @@ -0,0 +1,21 @@ +class Product: + """ + Represents a product with attributes such as name and yield. + + Attributes: + name (str): The name of the product. + species (Species): An instance of the Species class representing the product. + yield_value (float): The yield of the product. + """ + + def __init__(self, species, yield_value): + """ + Initializes a new instance of the Product class. + + Args: + species (Species): An instance of the Species class representing the product. + yield_value (float): The yield of the product. + """ + self.name = species.name + self.species = species + self.yield_value = yield_value diff --git a/src/music_box_reactant.py b/src/music_box_reactant.py new file mode 100644 index 00000000..5f2b44d1 --- /dev/null +++ b/src/music_box_reactant.py @@ -0,0 +1,21 @@ +class Reactant: + """ + Represents a reactant with attributes such as name and quantity. + + Attributes: + name (str): The name of the reactant. + quantity (float): The quantity of the reactant. + """ + + def __init__(self, species, quantity): + """ + Initializes a new instance of the Reactant class. + + Args: + species (Species): An instance of the Species class representing the reactant. + quantity (float): The quantity of the reactant. + """ + self.name = species.name + self.species = species + self.quantity = quantity + diff --git a/src/music_box_reaction.py b/src/music_box_reaction.py new file mode 100644 index 00000000..e4f87d76 --- /dev/null +++ b/src/music_box_reaction.py @@ -0,0 +1,45 @@ +from typing import List + +class Reaction: + """ + Represents a chemical reaction with attributes such as name, type, reactants, and products. + + Attributes: + name (str): The name of the reaction. + reaction_type (str): The type of the reaction. + reactants (List[Reactant]): A list of Reactant instances representing the reactants. Default is an empty list. + products (List[Product]): A list of Product instances representing the products. Default is an empty list. + """ + + def __init__(self, name, reaction_type, reactants=None, products=None): + """ + Initializes a new instance of the Reaction class. + + Args: + name (str): The name of the reaction. + reaction_type (str): The type of the reaction. + reactants (List[Reactant]): A list of Reactant instances representing the reactants. Default is an empty list. + products (List[Product]): A list of Product instances representing the products. Default is an empty list. + """ + self.name = name + self.reaction_type = reaction_type + self.reactants = reactants if reactants is not None else [] + self.products = products if products is not None else [] + + def add_reactant(self, reactant): + """ + Add a Reactant instance to the list of reactants. + + Args: + reactant (Reactant): The Reactant instance to be added. + """ + self.reactants.append(reactant) + + def add_product(self, product): + """ + Add a Product instance to the list of products. + + Args: + product (Product): The Product instance to be added. + """ + self.products.append(product) diff --git a/src/music_box_reaction_list.py b/src/music_box_reaction_list.py new file mode 100644 index 00000000..245140b0 --- /dev/null +++ b/src/music_box_reaction_list.py @@ -0,0 +1,27 @@ +from typing import List + +class ReactionList: + """ + Represents a list of chemical reactions. + + Attributes: + mechanisms (List[Reaction]): A list of Reaction instances. + """ + + def __init__(self, mechanisms=None): + """ + Initializes a new instance of the ReactionList class. + + Args: + mechanisms (List[Reaction]): A list of Reaction instances. Default is an empty list. + """ + self.mechanisms = mechanisms if mechanisms is not None else [] + + def add_reaction(self, reaction): + """ + Add a Reaction instance to the ReactionList. + + Args: + reaction (Reaction): The Reaction instance to be added. + """ + self.mechanisms.append(reaction) diff --git a/src/music_box_reaction_rate.py b/src/music_box_reaction_rate.py new file mode 100644 index 00000000..45e8e1f4 --- /dev/null +++ b/src/music_box_reaction_rate.py @@ -0,0 +1,19 @@ +class ReactionRate: + """ + Represents a reaction rate with attributes such as the associated reaction and rate. + + Attributes: + reaction (Reaction): The associated reaction. + rate (float): The rate of the reaction in 1/s (inverse seconds). + """ + + def __init__(self, reaction, rate): + """ + Initializes a new instance of the ReactionRate class. + + Args: + reaction (Reaction): The associated reaction. + rate (float): The rate of the reaction in 1/s (inverse seconds). + """ + self.reaction = reaction + self.rate = rate diff --git a/src/music_box_species.py b/src/music_box_species.py new file mode 100644 index 00000000..701b8a6a --- /dev/null +++ b/src/music_box_species.py @@ -0,0 +1,28 @@ +class Species: + """ + Represents a species with various attributes such as name, absolute tolerance, phase, molecular weight, and density. + + Attributes: + name (str): The name of the species. + absolute_tolerance (float): The absolute tolerance of the species. + phase (str): The phase of the species. + molecular_weight (float): The molecular weight of the species in kg mol^-1. + density (float): The density of the species in kg m^-3. + """ + + def __init__(self, name, absolute_tolerance, phase, molecular_weight, density): + """ + Initializes a new instance of the Species class. + + Args: + name (str): The name of the species. + absolute_tolerance (float): The absolute tolerance of the species. + phase (str): The phase of the species. + molecular_weight (float): The molecular weight of the species in kg mol^-1. + density (float): The density of the species in kg m^-3. + """ + self.name = name + self.absolute_tolerance = absolute_tolerance + self.phase = phase + self.molecular_weight = molecular_weight + self.density = density diff --git a/src/music_box_species_concentration.py b/src/music_box_species_concentration.py new file mode 100644 index 00000000..3ab7d7fd --- /dev/null +++ b/src/music_box_species_concentration.py @@ -0,0 +1,19 @@ +class SpeciesConcentration: + """ + Represents a species concentration with attributes such as the associated species and concentration. + + Attributes: + species (Species): The associated species. + concentration (float): The concentration of the species. + """ + + def __init__(self, species, concentration): + """ + Initializes a new instance of the SpeciesConcentration class. + + Args: + species (Species): The associated species. + concentration (float): The concentration of the species. + """ + self.species = species + self.concentration = concentration diff --git a/src/music_box_species_list.py b/src/music_box_species_list.py new file mode 100644 index 00000000..99e1f3a9 --- /dev/null +++ b/src/music_box_species_list.py @@ -0,0 +1,30 @@ +from typing import List + +class SpeciesList: + """ + Represents a list of species with a relative tolerance. + + Attributes: + species (List[Species]): A list of Species instances. + relativeTolerance (float): The relative tolerance for the species list. + """ + + def __init__(self, species=None, relative_tolerance=0.0): + """ + Initializes a new instance of the SpeciesList class. + + Args: + species (List[Species]): A list of Species instances. Default is an empty list. + relative_tolerance (float): The relative tolerance for the species list. Default is 0.0. + """ + self.species = species if species is not None else [] + self.relativeTolerance = relative_tolerance + + def add_species(self, species): + """ + Add a Species instance to the list of species. + + Args: + species (Species): The Species instance to be added. + """ + self.species.append(species)