Skip to content

Commit 55f452b

Browse files
angelapakK20shores
andauthored
add user guide (#353)
* contributors updated * set up user guide header page * replace subpages with subheaders * minor section reformatting * complete box model page * update output and visualization * update running examples page * link tutorial notebooks * add reaction formulae and examples * update installation guide * add reaction rate parameters in drop down and example usages * fix minor formatting inconsistencies * minor grammatical/formatting fixes * add links to premade examples * fix pyproject error * Update docs/source/user_guide/output/index.rst Co-authored-by: Kyle Shores <kyle.shores44@gmail.com> * Update docs/source/user_guide/box_model/index.rst Co-authored-by: Kyle Shores <kyle.shores44@gmail.com> * set up intersphinx links to micm and mechanism configuration * clean redunant reaction info * Update docs/source/user_guide/installation/index.rst Co-authored-by: Kyle Shores <kyle.shores44@gmail.com> * acom_music_box underscore consistency * set up intersphinx links to micm and musica and sphinx references to musicbox objects * Update docs/source/user_guide/species/index.rst Co-authored-by: Kyle Shores <kyle.shores44@gmail.com> * minor rewording/reorg in Defining chemical systems section * add species concentration units --------- Co-authored-by: Kyle Shores <kyle.shores44@gmail.com>
1 parent 183412f commit 55f452b

File tree

18 files changed

+263
-37
lines changed

18 files changed

+263
-37
lines changed

CITATION.cff

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ authors:
2323
given-names: Montek
2424
- family-names: Kiran
2525
given-names: Aditya
26+
- family-names: Winney
27+
given-names: Aidan
28+
- family-names: Pak
29+
given-names: Angela
2630
license: Apache-2.0
2731
url: "https://github.com/NCAR/music-box"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Copyright (C) 2020 National Science Foundation - National Center for Atmospheric
1515

1616
# Installation
1717
```
18-
pip install acom-music-box
18+
pip install acom_music_box
1919
```
2020
# Using the MusicBox API
2121

docs/source/api/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _api-ref:
2+
13
###############
24
API Reference
35
###############

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
intersphinx_mapping = {
4444
'musica': ('https://ncar.github.io/musica/api/', None),
45+
'micm': ('https://ncar.github.io/micm/', None),
46+
'mc': ('https://ncar.github.io/MechanismConfiguration/', None)
4547
}
4648

4749
# -- Options for HTML output -------------------------------------------------

docs/source/getting_started.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Getting started
33
###############
44

5-
MusicBox User Tutorial
6-
----------------------
7-
Hello, and welcome to the MusicBox user tutorial! Here, we will be covering some basic usages of the MusicBox library.
5+
Hello, and welcome to MusicBox! Here, we will be covering some basic usages of the MusicBox library.
86

97
What is MusicBox?
108
------------------

docs/source/user_guide/box_model/conditions.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/source/user_guide/box_model/configurations.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,94 @@
11
Box model
22
=========
3+
.. note::
4+
5+
MusicBox uses the Model-Independent Chemical Module (MICM) as its core chemistry solver. For more information about available reaction types,
6+
species configuration, and solver behavior, see the `MICM documentation <micm:index>`_.
37

4-
This section details the components of the box model, including reactions, mechanisms, conditions, and solutions.
8+
This section details the components of the box model, a mechanism (the set of reactions and species), conditions, and solutions. To use the MusicBox model,
9+
import the :class:`acom_music_box.music_box.MusicBox` class::
10+
11+
from acom_music_box import MusicBox, Conditions
512

6-
.. toctree::
7-
:maxdepth: 1
13+
Using the previously defined in-code mechanism (see :ref:`Defining chemical systems <species>`), a box model can now be created and initialized with it::
14+
15+
box_model = MusicBox()
16+
box_model.load_mechanism(mechanism)
817

9-
reactions
10-
Chemical mechanisms <mechanisms>
11-
Initial and evolving conditions <conditions>
12-
Configuration options <configurations>
18+
Initial and evolving conditions
19+
--------------------------------
20+
Use :class:`acom_music_box.conditions.Conditions` to set environmental parameters and species concentrations (:math:`\textsf{mol m}^{-3}`). Initial conditions define the environment that
21+
the mechanism takes place in at the start of the simulation through the parameters temperature (K), pressure (Pa), and optionally
22+
air density. Without an air density provided, the Ideal Gas Law is used to calculate this parameter. The initial concentrations of each
23+
Species is also included::
24+
25+
box_model.initial_conditions = Conditions( temperature=298.15, pressure=101325.0, species_concentrations={"X": 3.75, "Y": 5.0, "Z": 2.5,})
1326

27+
Evolving conditions (see :class:`acom_music_box.evolving_conditions.EvolvingConditions`) change the environment of the mechanism at a defined time value (Seconds), its first argument. Like importnitial conditions,
28+
these changes can also include temperature, pressure, air density, and Species concentrations::
29+
30+
box_model.add_evolving_condition(100.0, Conditions(temperature=310.0, pressure=100100.0))
31+
32+
Additional model options
33+
-------------------------
34+
Each box model also contains three time parameters that must be defined:
35+
36+
* simulation_length: the number of seconds that the simulation lasts for
37+
* chem_step_time: the number of time steps between each simulation calculation
38+
* output_step_time: the number of seconds between each output of the model
39+
40+
See :mod:`acom_music_box.model_options` for further details. The time parameters can be used as follows::
41+
42+
box_model.box_model_options.simulation_length = 200 # Units: Seconds (s)
43+
box_model.box_model_options.chem_step_time = 1 # Units: Seconds (s)
44+
box_model.box_model_options.output_step_time = 20 # Units: Seconds (s)
45+
46+
For further descriptions of these MusicBox attributes, please see the `API Reference <https://ncar.github.io/music-box/branch/main/api/index.html>`_.
47+
48+
Solving
49+
--------
50+
Once all components of the box model have been defined, it can be solved by calling::
51+
52+
df = box_model.solve()
53+
54+
This returns the following dataframe of the conditions and Species concentrations as they've varied across time steps.
55+
56+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
57+
| | time.s | ENV.temperature.K | ENV.pressure.Pa | ENV.air number density.mol m-3 | CONC.X.mol m-3 | CONC.Y.mol m-3 | CONC.Z.mol m-3 |
58+
+====+==========+=====================+===================+==================================+==================+==================+==================+
59+
| 0 | 0 | 298.15 | 101325 | 40.874 | 3.75 | 5 | 2.5 |
60+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
61+
| 1 | 20 | 298.15 | 101325 | 40.874 | 3.41149 | 4.8714 | 2.96711 |
62+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
63+
| 2 | 40 | 298.15 | 101325 | 40.874 | 3.10354 | 4.72528 | 3.42118 |
64+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
65+
| 3 | 60 | 298.15 | 101325 | 40.874 | 2.82338 | 4.56584 | 3.86077 |
66+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
67+
| 4 | 80 | 298.15 | 101325 | 40.874 | 2.56852 | 4.39669 | 4.28479 |
68+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
69+
| 5 | 100 | 298.15 | 101325 | 40.874 | 2.33666 | 4.22086 | 4.69247 |
70+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
71+
| 6 | 120 | 310 | 100100 | 38.8363 | 2.12702 | 4.04212 | 5.08087 |
72+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
73+
| 7 | 140 | 310 | 100100 | 38.8363 | 1.93618 | 3.86147 | 5.45235 |
74+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
75+
| 8 | 160 | 310 | 100100 | 38.8363 | 1.76247 | 3.6807 | 5.80683 |
76+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
77+
| 9 | 180 | 310 | 100100 | 38.8363 | 1.60434 | 3.50128 | 6.14438 |
78+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
79+
| 10 | 200 | 310 | 100100 | 38.8363 | 1.4604 | 3.32443 | 6.46517 |
80+
+----+----------+---------------------+-------------------+----------------------------------+------------------+------------------+------------------+
81+
82+
83+
Loading premade configurations (optional)
84+
------------------------------------------
85+
As an alternative to using the steps thus far to define a chemical configuration in code, MusicBox
86+
also supports definitions via a configuration file in JSON format. This example assumes you are using a file called
87+
"custom_box_model.json" in a "config" subfolder::
88+
89+
import sys
90+
91+
box_model = MusicBox()
92+
conditions_path = "config/custom_box_model.json"
93+
box_model.loadJson(conditions_path)
94+
df = box_model.solve()

docs/source/user_guide/box_model/mechanisms.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/source/user_guide/box_model/reactions.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)