diff --git a/src/acom_music_box/goMusicBox.bat b/src/acom_music_box/goMusicBox.bat index 1c159795..3af2a04f 100644 --- a/src/acom_music_box/goMusicBox.bat +++ b/src/acom_music_box/goMusicBox.bat @@ -1 +1 @@ -python music_box_main.py \ No newline at end of file +python music_box_main.py homeDir="C:\\2024\MusicBox\music-box\\tests\\configs\\analytical_config\\" diff --git a/src/acom_music_box/music_box.py b/src/acom_music_box/music_box.py index 763c9a7b..ffbc3d74 100644 --- a/src/acom_music_box/music_box.py +++ b/src/acom_music_box/music_box.py @@ -487,9 +487,7 @@ def solve(self, path_to_output = None): next_output_time = curr_time #runs the simulation at each timestep - music_box_logger.progress("solve03 path_to_output = {}".format(path_to_output)) - while(curr_time <= self.box_model_options.simulation_length): #outputs to output_array if enough time has elapsed @@ -518,9 +516,7 @@ def solve(self, path_to_output = None): else: next_conditions = None - - music_box_logger.progress("solve033 species_constant_ordering = {}".format(species_constant_ordering)) - + #updates M accordingly if 'M' in species_constant_ordering: @@ -529,7 +525,6 @@ def solve(self, path_to_output = None): GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT ordered_concentrations[species_constant_ordering['M']] = curr_conditions.pressure / (GAS_CONSTANT * curr_conditions.temperature) - music_box_logger.progress("solve035 args = {} {} {} {} {}".format(self.box_model_options.chem_step_time, curr_conditions.temperature, curr_conditions.pressure, ordered_concentrations, ordered_rate_constants)) #solves and updates concentration values in concentration array if (not ordered_concentrations): music_box_logger.progress("Warning: ordered_concentrations list is empty.") diff --git a/src/acom_music_box/music_box_logger.py b/src/acom_music_box/music_box_logger.py index 4ca3f4bf..5cd213c0 100644 --- a/src/acom_music_box/music_box_logger.py +++ b/src/acom_music_box/music_box_logger.py @@ -1,7 +1,7 @@ import sys # Class Logger is included here for completeness, -# but not used because progress() is such a lighweight function. +# but not used because progress() is such a lightweight function. class Logger: """ Logs messages to the console, which can then be captured to a log file. @@ -15,10 +15,6 @@ def __init__(self): 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. - scaling_factor (float, optional): A scaling factor for the reaction rate. Defaults to None. """ pass diff --git a/src/acom_music_box/music_box_main.py b/src/acom_music_box/music_box_main.py index 9086923f..614517c4 100644 --- a/src/acom_music_box/music_box_main.py +++ b/src/acom_music_box/music_box_main.py @@ -8,14 +8,40 @@ +# Retrieve named arguments from the command line and +# return in a dictionary of keywords. +# argPairs = list of arguments, probably from sys.argv +# named arguments are formatted like this=3.14159 +# return dictionary of keywords and values +def getArgsDictionary(argPairs): + argDict = {} + + for argPair in argPairs: + # the arguments are: arg=value + pairValue = argPair.split('=') + if (len(pairValue) < 2): + argDict[pairValue[0]] = None + continue + + argDict[pairValue[0]] = pairValue[1] + + return(argDict) + + + if __name__ == "__main__": music_box_logger.progress("{}".format(__file__)) music_box_logger.progress("Start time: {}".format(datetime.datetime.now())) music_box_logger.progress("Hello, MusicBox World!") - # set up the home configuration directory TODO: Make this a command-line argument. - musicBoxHomeDir = "C:\\2024\\MusicBox\\music-box\\tests\\configs\\analytical_config\\" + # retrieve and parse the command-line arguments + myArgs = getArgsDictionary(sys.argv) + + # set up the home configuration directory + musicBoxHomeDir = "music-box\\tests\\configs\\analytical_config\\" # default + if ("homeDir" in myArgs): + musicBoxHomeDir = myArgs.get("homeDir") # create and load a MusicBox object myBox = MusicBox()