Skip to content

Commit

Permalink
reads species name from config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Mar 26, 2024
1 parent 128528b commit 2819f1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/box_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def solve(self, path_to_output = None):
headers.append("time")
headers.append("ENV.temperature")
headers.append("ENV.pressure")
for spec in self.species_list:
for spec in self.species_list.species:
headers.append("CONC." + spec.name)

output_array.append(headers)
Expand Down Expand Up @@ -376,6 +376,9 @@ def readConditionsFromJson(self, path_to_json):
# Set initial conditions
self.initial_conditions = Conditions.from_config_JSON(data)

# Set species list
self.species_list = SpeciesList.from_config_JSON(data)


# for testing purposes
def __main__():
Expand Down
16 changes: 16 additions & 0 deletions src/music_box_species_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ def from_UI_JSON(cls, UI_JSON):
species_from_json.append(Species(name, absolute_tolerance, None, molecular_weight, None))

return cls(species_from_json)

@classmethod
def from_config_JSON(cls, config_JSON):

species_from_json = []

for name, properties in config_JSON['chemical species'].items():
absolute_tolerance = properties.get('absolute tolerance')
molecular_weight = properties.get('molecular weight')

# TODO: Add phase and density to species

species_from_json.append(Species(name, absolute_tolerance, None, molecular_weight, None))

return cls(species_from_json)


def add_species(self, species):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/test_config_1_out.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
time,ENV.temperature,ENV.pressure
time,ENV.temperature,ENV.pressure,CONC.A,CONC.B,CONC.C
0,272.5,101253.3,1.0,0.0,0.0
1.0,272.5,101253.3,0.99520593465931,7.2584865869196184e-09,0.004794058082203489
2.0,272.5,101253.3,0.9904348523811104,7.223688927947401e-09,0.009565140395200417
Expand Down

0 comments on commit 2819f1f

Please sign in to comment.