Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating to most recent musica version #298

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = ["License :: OSI Approved :: Apache Software License"]
dynamic = ["version", "description"]

dependencies = [
"musica==0.8.1",
"musica==0.9.0",
"xarray",
"colorlog",
"pandas",
Expand Down
2 changes: 1 addition & 1 deletion src/acom_music_box/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This package contains modules for handling various aspects of a music box,
including species, products, reactants, reactions, and more.
"""
__version__ = "2.5.5"
__version__ = "2.6.0"

from .utils import convert_time, convert_pressure, convert_temperature, convert_concentration
from .model_options import BoxModelOptions
Expand Down
5 changes: 2 additions & 3 deletions src/acom_music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ def solve(self, callback=None):
next_conditions = None

# calculate air density from the ideal gas law
air_density = curr_conditions.pressure / \
(GAS_CONSTANT * curr_conditions.temperature)
air_density = curr_conditions.pressure / (GAS_CONSTANT * curr_conditions.temperature)

# outputs to output_array if enough time has elapsed
if (next_output_time <= curr_time):
Expand Down Expand Up @@ -229,7 +228,7 @@ def loadJson(self, path_to_json):
camp_path = os.path.join(os.path.dirname(path_to_json), self.config_file)

# Initalize the musica solver
self.solver = musica.create_solver(camp_path, musica.micmsolver.rosenbrock, 1)
self.solver = musica.create_solver(camp_path, musica.micmsolver.rosenbrock_standard_order, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why has the solver type changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vector ordered solver has a default vector lenght of 4. It is the callers responsibility to appropriately size the input array to match what musica expects to write the results to. In this case, musica blindly copies the output values

https://github.com/NCAR/musica/blob/1debffba28d0601cbd646e475cd6751d06e5a8b3/src/micm/micm.cpp#L464-L465

So, if we have only 1 grid cell and 2 species, micm would internally hold a state array of length 8 (species 1 cell 1, specie 1 cell 2, specie 1 cell 3, species 1, cell 4, species 2 cell 1, species 2 cell 2, species 3 cell 3, species 4 cell 4). Thus, music box would need to correctly calculate the size of this array.

It's easiest to use the standard ordered solver because we don't have to care about those empty cells

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for the detailed explanation!


@staticmethod
def order_reaction_rates(curr_conditions, rate_constant_ordering):
Expand Down
Loading