diff --git a/.github/workflows/CI_Tests.yml b/.github/workflows/CI_Tests.yml index 01bae148..b789a186 100644 --- a/.github/workflows/CI_Tests.yml +++ b/.github/workflows/CI_Tests.yml @@ -39,5 +39,8 @@ jobs: - name: Run the smoke tests run: | - music_box configFile=tests/configs/analytical_config/my_config.json outputDir=tests/configs/analytical_config + music_box -c src/acom_music_box/examples/configs/analytical/my_config.json -o output.csv + music_box -e Analytical -o output.csv + music_box -e Analytical -o output.csv -vv --color-output + diff --git a/examples/camp_examples/bright_chamber/use_case_7/camp_data/config.json b/examples/camp_examples/bright_chamber/use_case_7/camp_data/config.json deleted file mode 100644 index 4629149f..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/camp_data/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "camp-files" : [ - "camp_data/species.json", - "camp_data/mechanism.json" - ] -} diff --git a/examples/camp_examples/bright_chamber/use_case_7/camp_data/mechanism.json b/examples/camp_examples/bright_chamber/use_case_7/camp_data/mechanism.json deleted file mode 100644 index bc6b69de..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/camp_data/mechanism.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "camp-data" : [ - { - "name" : "Chapman", - "type" : "MECHANISM", - "reactions" : [ - { - "type" : "PHOTOLYSIS", - "reactants" : { - "O2" : { } - }, - "products" : { - "O" : { "yield" : 2.0 } - }, - "MUSICA name" : "O2_1" - }, - { - "type" : "PHOTOLYSIS", - "reactants" : { - "O3" : { } - }, - "products" : { - "O1D" : { }, - "O2" : { } - }, - "MUSICA name" : "O3_1" - }, - { - "type" : "PHOTOLYSIS", - "reactants" : { - "O3" : { } - }, - "products" : { - "O" : { }, - "O2" : { } - }, - "MUSICA name" : "O3_2" - }, - { - "type" : "ARRHENIUS", - "reactants" : { - "O1D" : { }, - "N2" : { } - }, - "products" : { - "O" : { }, - "N2" : { } - }, - "A" : 2.15e-11, - "C" : 110.0 - }, - { - "type" : "ARRHENIUS", - "reactants" : { - "O1D" : { }, - "O2" : { } - }, - "products" : { - "O" : { }, - "O2" : { } - }, - "A" : 3.3e-11, - "C" : 55.0 - }, - { - "type" : "ARRHENIUS", - "reactants" : { - "O" : { }, - "O3" : { } - }, - "products" : { - "O2" : { "yield" : 2.0 } - }, - "A" : 8.0e-12, - "C" : -2060.00 - }, - { - "type" : "ARRHENIUS", - "reactants" : { - "O" : { }, - "O2" : { }, - "M" : { } - }, - "products" : { - "O3" : { }, - "M" : { } - }, - "A" : 6.0e-34, - "B" : 2.4 - }, - { - "type" : "EMISSION", - "species" : "O1D", - "MUSICA name" : "O1D" - }, - { - "type" : "EMISSION", - "species" : "O", - "MUSICA name" : "O" - }, - { - "type" : "EMISSION", - "species" : "O3", - "MUSICA name" : "O3" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "N2", - "MUSICA name" : "N2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "O2", - "MUSICA name" : "O2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "CO2", - "MUSICA name" : "CO2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "Ar", - "MUSICA name" : "Ar" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "H2O", - "MUSICA name" : "H2O" - } - ] - } - ] -} - diff --git a/examples/camp_examples/bright_chamber/use_case_7/camp_data/species.json b/examples/camp_examples/bright_chamber/use_case_7/camp_data/species.json deleted file mode 100644 index 948aca00..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/camp_data/species.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "camp-data" : [ - { - "type" : "RELATIVE_TOLERANCE", - "value" : 1.0e-4 - }, - { - "name" : "M", - "type" : "CHEM_SPEC", - "tracer type" : "CONSTANT" - }, - { - "name" : "Ar", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "CO2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "H2O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "N2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O1D", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O3", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - } - ] -} - diff --git a/examples/camp_examples/bright_chamber/use_case_7/emissions.csv b/examples/camp_examples/bright_chamber/use_case_7/emissions.csv deleted file mode 100644 index 2553005b..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/emissions.csv +++ /dev/null @@ -1,5 +0,0 @@ -time.hr, EMIS.O1D, EMIS.O, EMIS.O3 -0.0, 0.0, 0.0, 0.0 -0.2, 0.1, 0.05, 0.05 -1.0, 0.2, 0.1, 0.1 -1.5, 0.0, 0.0, 0.0 diff --git a/examples/camp_examples/bright_chamber/use_case_7/initial.csv b/examples/camp_examples/bright_chamber/use_case_7/initial.csv deleted file mode 100644 index 2af07f8d..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/initial.csv +++ /dev/null @@ -1,2 +0,0 @@ -CONC.N2& CONC.O2& CONC.Ar& CONC.CO2& ENV.temperature& ENV.pressure.atm -3.29e1& 8.84& 3.92e-1& 1.69e-2& 298.0& 1.0 diff --git a/examples/camp_examples/bright_chamber/use_case_7/parking_lot_photo_rates.nc b/examples/camp_examples/bright_chamber/use_case_7/parking_lot_photo_rates.nc deleted file mode 100644 index fd3ba0f2..00000000 Binary files a/examples/camp_examples/bright_chamber/use_case_7/parking_lot_photo_rates.nc and /dev/null differ diff --git a/examples/camp_examples/bright_chamber/use_case_7/use_case_7_config.json b/examples/camp_examples/bright_chamber/use_case_7/use_case_7_config.json deleted file mode 100644 index 6cd6ef43..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/use_case_7_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "box model options" : { - "grid" : "box", - "chemistry time step [min]" : 5.0, - "output time step [hr]" : 1.0, - "simulation length [hr]" : 2.5, - "simulation start" : { - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - }, - "initial conditions" : { - "initial.csv" : { - "delimiter" : "&" - } - }, - "evolving conditions" : { - "emissions.csv" : { - "properties" : { - "time.hr" : { - "shift first entry to" :{ - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - } - } - }, - "wall_loss_rates_011519.txt" : { - "delimiter" : ";", - "time axis" : "columns", - "properties" : { - "simtime" : { - "MusicBox name" : "time", - "units" : "hr", - "shift first entry to" :{ - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - }, - "*" : { - "MusicBox name" : "LOSS.*", - "units" : "min-1" - } - } - }, - "parking_lot_photo_rates.nc" : { - "time offset" : { "years" : 15 }, - "properties" : { - "*" : { "MusicBox name" : "PHOT.*" }, - "time" : { - "MusicBox name" : "time", - "shift first entry to" : { - "year" : 2020, - "month" : 1, - "day" : 1, - "time zone" : "UTC-8" - } - } - } - } - }, - "model components" : [ - { - "type" : "CAMP", - "configuration file" : "camp_data/config.json", - "override species" : { - "M" : { "mixing ratio mol mol-1" : 1.0 } - }, - "suppress output" : { - "M" : { } - } - } - ] -} diff --git a/examples/camp_examples/bright_chamber/use_case_7/wall_loss_rates_011519.txt b/examples/camp_examples/bright_chamber/use_case_7/wall_loss_rates_011519.txt deleted file mode 100644 index fa5182fa..00000000 --- a/examples/camp_examples/bright_chamber/use_case_7/wall_loss_rates_011519.txt +++ /dev/null @@ -1,6 +0,0 @@ -simtime; 0.0; 0.3; 0.6; 0.9; 1.2 -N2; 0.010; 0.012; 0.013; 0.014; 0.015 -O2; 0.015; 0.016; 0.017; 0.018; 0.019 -Ar; 0.015; 0.016; 0.017; 0.018; 0.019 -CO2; 0.010; 0.012; 0.013; 0.014; 0.015 -H2O; 0.010; 0.012; 0.013; 0.014; 0.015 diff --git a/examples/camp_examples/bright_chamber/use_case_8/camp_data/config.json b/examples/camp_examples/bright_chamber/use_case_8/camp_data/config.json deleted file mode 100644 index 4629149f..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/camp_data/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "camp-files" : [ - "camp_data/species.json", - "camp_data/mechanism.json" - ] -} diff --git a/examples/camp_examples/bright_chamber/use_case_8/camp_data/mechanism.json b/examples/camp_examples/bright_chamber/use_case_8/camp_data/mechanism.json deleted file mode 100644 index d3a78ae3..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/camp_data/mechanism.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "camp-data" : [ - { - "name" : "Chapman", - "type" : "MECHANISM", - "reactions" : [ - { - "type" : "EMISSION", - "species" : "O1D", - "MUSICA name" : "O1D" - }, - { - "type" : "EMISSION", - "species" : "O", - "MUSICA name" : "O" - }, - { - "type" : "EMISSION", - "species" : "O3", - "MUSICA name" : "O3" - }, - { - "type" : "EMISSION", - "species" : "N2", - "MUSICA name" : "N2" - }, - { - "type" : "EMISSION", - "species" : "Ar", - "MUSICA name" : "Ar" - }, - { - "type" : "EMISSION", - "species" : "O2", - "MUSICA name" : "O2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "N2", - "MUSICA name" : "N2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "O2", - "MUSICA name" : "O2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "CO2", - "MUSICA name" : "CO2" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "Ar", - "MUSICA name" : "Ar" - }, - { - "type" : "FIRST_ORDER_LOSS", - "species" : "H2O", - "MUSICA name" : "H2O" - } - ] - } - ] -} - diff --git a/examples/camp_examples/bright_chamber/use_case_8/camp_data/species.json b/examples/camp_examples/bright_chamber/use_case_8/camp_data/species.json deleted file mode 100644 index 948aca00..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/camp_data/species.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "camp-data" : [ - { - "type" : "RELATIVE_TOLERANCE", - "value" : 1.0e-4 - }, - { - "name" : "M", - "type" : "CHEM_SPEC", - "tracer type" : "CONSTANT" - }, - { - "name" : "Ar", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "CO2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "H2O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "N2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O1D", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O3", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - } - ] -} - diff --git a/examples/camp_examples/bright_chamber/use_case_8/emissions.csv b/examples/camp_examples/bright_chamber/use_case_8/emissions.csv deleted file mode 100644 index 2553005b..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/emissions.csv +++ /dev/null @@ -1,5 +0,0 @@ -time.hr, EMIS.O1D, EMIS.O, EMIS.O3 -0.0, 0.0, 0.0, 0.0 -0.2, 0.1, 0.05, 0.05 -1.0, 0.2, 0.1, 0.1 -1.5, 0.0, 0.0, 0.0 diff --git a/examples/camp_examples/bright_chamber/use_case_8/emit_all.csv b/examples/camp_examples/bright_chamber/use_case_8/emit_all.csv deleted file mode 100644 index 0f4445c6..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/emit_all.csv +++ /dev/null @@ -1,4 +0,0 @@ -time, EMIS.O, EMIS.O1D, EMIS.O3, EMIS.N2, EMIS.Ar, EMIS.O2 -0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 -20.0, 2.0, 1.0, 1.0, 2.0, 1.0, 1.0 -30.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 diff --git a/examples/camp_examples/bright_chamber/use_case_8/initial.csv b/examples/camp_examples/bright_chamber/use_case_8/initial.csv deleted file mode 100644 index 98cf0ff3..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/initial.csv +++ /dev/null @@ -1,2 +0,0 @@ -CONC.O& CONC.O1D& CONC.O3 &CONC.N2& CONC.O2& CONC.Ar& CONC.CO2& ENV.temperature& ENV.pressure.atm -1.0e-7& 1.0e-6& 1.0e-4& 3.29e1& 8.84& 3.92e-1& 1.69e-2& 298.0& 1.0 diff --git a/examples/camp_examples/bright_chamber/use_case_8/parking_lot_photo_rates.nc b/examples/camp_examples/bright_chamber/use_case_8/parking_lot_photo_rates.nc deleted file mode 100644 index fd3ba0f2..00000000 Binary files a/examples/camp_examples/bright_chamber/use_case_8/parking_lot_photo_rates.nc and /dev/null differ diff --git a/examples/camp_examples/bright_chamber/use_case_8/use_case_8_config.json b/examples/camp_examples/bright_chamber/use_case_8/use_case_8_config.json deleted file mode 100644 index 77c4a885..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/use_case_8_config.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "box model options" : { - "grid" : "box", - "chemistry time step [min]" : 5.0, - "output time step [hr]" : 1.0, - "simulation length [hr]" : 2.5, - "simulation start" : { - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - }, - "initial conditions" : { - "initial.csv" : { - "delimiter" : "&", - "properties" : { - "CONC.O3" : { "variability" : "tethered" } - }, - "linear combinations" : { - "atomic oxygen" : { - "properties" : { - "CONC.O" : { }, - "CONC.O1D" : { } - }, - "scale factor" : 1.2 - } - } - } - }, - "evolving conditions" : { - "emissions.csv" : { - "properties" : { - "time.hr" : { - "shift first entry to" :{ - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - } - } - }, - "wall_loss_rates_011519.txt" : { - "delimiter" : ";", - "time axis" : "columns", - "properties" : { - "simtime" : { - "MusicBox name" : "time", - "units" : "hr", - "shift first entry to" :{ - "time zone" : "UTC-8", - "year" : 2020, - "month" : 6, - "day" : 10, - "hour" : 13 - } - }, - "*" : { - "MusicBox name" : "LOSS.*", - "units" : "min-1" - } - } - }, - "parking_lot_photo_rates.nc" : { - "time offset" : { "years" : 15 }, - "properties" : { - "*" : { "MusicBox name" : "PHOT.*" }, - "time" : { - "MusicBox name" : "time", - "shift first entry to" : { - "year" : 2020, - "month" : 1, - "day" : 1, - "time zone" : "UTC-8" - } - } - } - } - }, - "model components" : [ - { - "type" : "CAMP", - "configuration file" : "camp_data/config.json", - "override species" : { - "M" : { "mixing ratio mol mol-1" : 1.0 } - }, - "suppress output" : { - "M" : { } - } - } - ] -} diff --git a/examples/camp_examples/bright_chamber/use_case_8/wall_loss_rates_011519.txt b/examples/camp_examples/bright_chamber/use_case_8/wall_loss_rates_011519.txt deleted file mode 100644 index fa5182fa..00000000 --- a/examples/camp_examples/bright_chamber/use_case_8/wall_loss_rates_011519.txt +++ /dev/null @@ -1,6 +0,0 @@ -simtime; 0.0; 0.3; 0.6; 0.9; 1.2 -N2; 0.010; 0.012; 0.013; 0.014; 0.015 -O2; 0.015; 0.016; 0.017; 0.018; 0.019 -Ar; 0.015; 0.016; 0.017; 0.018; 0.019 -CO2; 0.010; 0.012; 0.013; 0.014; 0.015 -H2O; 0.010; 0.012; 0.013; 0.014; 0.015 diff --git a/examples/camp_examples/dark_chamber/use_case_1/camp_data/config.json b/examples/camp_examples/dark_chamber/use_case_1/camp_data/config.json deleted file mode 100644 index af4e8619..00000000 --- a/examples/camp_examples/dark_chamber/use_case_1/camp_data/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "camp-files" : [ - "camp_data/species.json" - ] -} diff --git a/examples/camp_examples/dark_chamber/use_case_1/camp_data/species.json b/examples/camp_examples/dark_chamber/use_case_1/camp_data/species.json deleted file mode 100644 index 948aca00..00000000 --- a/examples/camp_examples/dark_chamber/use_case_1/camp_data/species.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "camp-data" : [ - { - "type" : "RELATIVE_TOLERANCE", - "value" : 1.0e-4 - }, - { - "name" : "M", - "type" : "CHEM_SPEC", - "tracer type" : "CONSTANT" - }, - { - "name" : "Ar", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "CO2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "H2O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "N2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O1D", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O3", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - } - ] -} - diff --git a/examples/camp_examples/dark_chamber/use_case_1/use_case_1_config.json b/examples/camp_examples/dark_chamber/use_case_1/use_case_1_config.json deleted file mode 100644 index b1ae76a7..00000000 --- a/examples/camp_examples/dark_chamber/use_case_1/use_case_1_config.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "box model options" : { - "grid" : "box", - "chemistry time step [min]" : 5.0, - "output time step [hr]" : 1.0, - "simulation length [hr]" : 2.5 - }, - "chemical species" : { - "N2" : { "initial value [mol m-3]" : 3.29e1 }, - "O2" : { "initial value [mol m-3]" : 8.84e0 }, - "Ar" : { "initial value [mol m-3]" : 3.92e-1 }, - "CO2" : { "initial value [mol m-3]" : 1.69e-2 }, - "O" : { "initial value [mol m-3]" : 1.0e-5 } - }, - "environmental conditions" : { - "temperature" : { "initial value [K]" : 298.0 }, - "pressure" : { "initial value [atm]" : 1.0 } - }, - "model components" : [ - { - "type" : "CAMP", - "configuration file" : "camp_data/config.json", - "override species" : { - "M" : { "mixing ratio mol mol-1" : 1.0 } - }, - "suppress output" : { - "M" : { } - } - } - ] -} - diff --git a/examples/camp_examples/dark_chamber/use_case_2/camp_data/config.json b/examples/camp_examples/dark_chamber/use_case_2/camp_data/config.json deleted file mode 100644 index af4e8619..00000000 --- a/examples/camp_examples/dark_chamber/use_case_2/camp_data/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "camp-files" : [ - "camp_data/species.json" - ] -} diff --git a/examples/camp_examples/dark_chamber/use_case_2/camp_data/species.json b/examples/camp_examples/dark_chamber/use_case_2/camp_data/species.json deleted file mode 100644 index 948aca00..00000000 --- a/examples/camp_examples/dark_chamber/use_case_2/camp_data/species.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "camp-data" : [ - { - "type" : "RELATIVE_TOLERANCE", - "value" : 1.0e-4 - }, - { - "name" : "M", - "type" : "CHEM_SPEC", - "tracer type" : "CONSTANT" - }, - { - "name" : "Ar", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "CO2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "H2O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "N2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O1D", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O3", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - } - ] -} - diff --git a/examples/camp_examples/dark_chamber/use_case_2/initial.csv b/examples/camp_examples/dark_chamber/use_case_2/initial.csv deleted file mode 100644 index f422d6fa..00000000 --- a/examples/camp_examples/dark_chamber/use_case_2/initial.csv +++ /dev/null @@ -1,2 +0,0 @@ -CONC.N2, CONC.O2, CONC.Ar, CONC.CO2, CONC.O, ENV.temperature, ENV.pressure -3.29e1, 8.84, 3.92e-1, 1.69e-2, 1.0e-5, 298.0, 1.0 diff --git a/examples/camp_examples/dark_chamber/use_case_2/use_case_2_config.json b/examples/camp_examples/dark_chamber/use_case_2/use_case_2_config.json deleted file mode 100644 index d6f6ed3d..00000000 --- a/examples/camp_examples/dark_chamber/use_case_2/use_case_2_config.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "box model options" : { - "grid" : "box", - "chemistry time step [min]" : 5.0, - "output time step [hr]" : 1.0, - "simulation length [hr]" : 2.5 - }, - "initial conditions" : { - "initial.csv" : { - "properties" : { - "ENV.pressure" : { "units" : "atm" } - } - } - }, - "model components" : [ - { - "type" : "CAMP", - "configuration file" : "camp_data/config.json", - "override species" : { - "M" : { "mixing ratio mol mol-1" : 1.0 } - }, - "suppress output" : { - "M" : { } - } - } - ] -} diff --git a/examples/camp_examples/dark_chamber/use_case_3/camp_data/config.json b/examples/camp_examples/dark_chamber/use_case_3/camp_data/config.json deleted file mode 100644 index af4e8619..00000000 --- a/examples/camp_examples/dark_chamber/use_case_3/camp_data/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "camp-files" : [ - "camp_data/species.json" - ] -} diff --git a/examples/camp_examples/dark_chamber/use_case_3/camp_data/species.json b/examples/camp_examples/dark_chamber/use_case_3/camp_data/species.json deleted file mode 100644 index 948aca00..00000000 --- a/examples/camp_examples/dark_chamber/use_case_3/camp_data/species.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "camp-data" : [ - { - "type" : "RELATIVE_TOLERANCE", - "value" : 1.0e-4 - }, - { - "name" : "M", - "type" : "CHEM_SPEC", - "tracer type" : "CONSTANT" - }, - { - "name" : "Ar", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "CO2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "H2O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "N2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O1D", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O2", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - }, - { - "name" : "O3", - "type" : "CHEM_SPEC", - "absolute tolerance" : 1.0e-12 - } - ] -} - diff --git a/examples/camp_examples/dark_chamber/use_case_3/initial.csv b/examples/camp_examples/dark_chamber/use_case_3/initial.csv deleted file mode 100644 index d53e9b6d..00000000 --- a/examples/camp_examples/dark_chamber/use_case_3/initial.csv +++ /dev/null @@ -1,2 +0,0 @@ -CONC.N2& CONC.O2& CONC.Ar& CONC.CO2& CONC.O& ENV.temperature& ENV.pressure.atm -3.29e1& 8.84& 3.92e-1& 1.69e-2& 1.0e-5& 298.0& 1.0 diff --git a/examples/camp_examples/dark_chamber/use_case_3/use_case_3_config.json b/examples/camp_examples/dark_chamber/use_case_3/use_case_3_config.json deleted file mode 100644 index 26285c60..00000000 --- a/examples/camp_examples/dark_chamber/use_case_3/use_case_3_config.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "box model options" : { - "grid" : "box", - "chemistry time step [min]" : 5.0, - "output time step [hr]" : 1.0, - "simulation length [hr]" : 2.5 - }, - "initial conditions" : { - "initial.csv" : { - "delimiter" : "&" - } - }, - "model components" : [ - { - "type" : "CAMP", - "configuration file" : "camp_data/config.json", - "override species" : { - "M" : { "mixing ratio mol mol-1" : 1.0 } - }, - "suppress output" : { - "M" : { } - } - } - ] -} diff --git a/pyproject.toml b/pyproject.toml index bb75bd54..9732f59a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,9 @@ classifiers = ["License :: OSI Approved :: Apache Software License"] dynamic = ["version", "description"] dependencies = [ - "musica==0.7.3" + "musica==0.7.3", + "colorlog", + "pandas" ] [project.urls] diff --git a/src/acom_music_box/__init__.py b/src/acom_music_box/__init__.py index dec1591c..f7274688 100644 --- a/src/acom_music_box/__init__.py +++ b/src/acom_music_box/__init__.py @@ -19,3 +19,4 @@ from .evolving_conditions import EvolvingConditions from .music_box import MusicBox +from .examples import Examples \ No newline at end of file diff --git a/src/acom_music_box/examples/__init__.py b/src/acom_music_box/examples/__init__.py new file mode 100644 index 00000000..cccf6e33 --- /dev/null +++ b/src/acom_music_box/examples/__init__.py @@ -0,0 +1 @@ +from .examples import Examples \ No newline at end of file diff --git a/tests/configs/analytical_config/camp_data/config.json b/src/acom_music_box/examples/configs/analytical/camp_data/config.json similarity index 100% rename from tests/configs/analytical_config/camp_data/config.json rename to src/acom_music_box/examples/configs/analytical/camp_data/config.json diff --git a/tests/configs/analytical_config/camp_data/reactions.json b/src/acom_music_box/examples/configs/analytical/camp_data/reactions.json similarity index 100% rename from tests/configs/analytical_config/camp_data/reactions.json rename to src/acom_music_box/examples/configs/analytical/camp_data/reactions.json diff --git a/tests/configs/analytical_config/camp_data/species.json b/src/acom_music_box/examples/configs/analytical/camp_data/species.json similarity index 100% rename from tests/configs/analytical_config/camp_data/species.json rename to src/acom_music_box/examples/configs/analytical/camp_data/species.json diff --git a/tests/configs/analytical_config/evolving_conditions.csv b/src/acom_music_box/examples/configs/analytical/evolving_conditions.csv similarity index 100% rename from tests/configs/analytical_config/evolving_conditions.csv rename to src/acom_music_box/examples/configs/analytical/evolving_conditions.csv diff --git a/tests/configs/analytical_config/my_config.json b/src/acom_music_box/examples/configs/analytical/my_config.json similarity index 100% rename from tests/configs/analytical_config/my_config.json rename to src/acom_music_box/examples/configs/analytical/my_config.json diff --git a/tests/configs/chapman_config/camp_data/config.json b/src/acom_music_box/examples/configs/carbon_bond_5/camp_data/config.json similarity index 100% rename from tests/configs/chapman_config/camp_data/config.json rename to src/acom_music_box/examples/configs/carbon_bond_5/camp_data/config.json diff --git a/tests/configs/full_gas_phase_mechanism_config/camp_data/reactions.json b/src/acom_music_box/examples/configs/carbon_bond_5/camp_data/reactions.json similarity index 100% rename from tests/configs/full_gas_phase_mechanism_config/camp_data/reactions.json rename to src/acom_music_box/examples/configs/carbon_bond_5/camp_data/reactions.json diff --git a/tests/configs/full_gas_phase_mechanism_config/camp_data/species.json b/src/acom_music_box/examples/configs/carbon_bond_5/camp_data/species.json similarity index 100% rename from tests/configs/full_gas_phase_mechanism_config/camp_data/species.json rename to src/acom_music_box/examples/configs/carbon_bond_5/camp_data/species.json diff --git a/tests/configs/full_gas_phase_mechanism_config/initial_conditions.csv b/src/acom_music_box/examples/configs/carbon_bond_5/initial_conditions.csv similarity index 100% rename from tests/configs/full_gas_phase_mechanism_config/initial_conditions.csv rename to src/acom_music_box/examples/configs/carbon_bond_5/initial_conditions.csv diff --git a/tests/configs/full_gas_phase_mechanism_config/my_config.json b/src/acom_music_box/examples/configs/carbon_bond_5/my_config.json similarity index 100% rename from tests/configs/full_gas_phase_mechanism_config/my_config.json rename to src/acom_music_box/examples/configs/carbon_bond_5/my_config.json diff --git a/tests/configs/full_gas_phase_mechanism_config/camp_data/config.json b/src/acom_music_box/examples/configs/chapman/camp_data/config.json similarity index 100% rename from tests/configs/full_gas_phase_mechanism_config/camp_data/config.json rename to src/acom_music_box/examples/configs/chapman/camp_data/config.json diff --git a/tests/configs/chapman_config/camp_data/reactions.json b/src/acom_music_box/examples/configs/chapman/camp_data/reactions.json similarity index 100% rename from tests/configs/chapman_config/camp_data/reactions.json rename to src/acom_music_box/examples/configs/chapman/camp_data/reactions.json diff --git a/tests/configs/chapman_config/camp_data/species.json b/src/acom_music_box/examples/configs/chapman/camp_data/species.json similarity index 100% rename from tests/configs/chapman_config/camp_data/species.json rename to src/acom_music_box/examples/configs/chapman/camp_data/species.json diff --git a/tests/configs/chapman_config/evolving_conditions.csv b/src/acom_music_box/examples/configs/chapman/evolving_conditions.csv similarity index 100% rename from tests/configs/chapman_config/evolving_conditions.csv rename to src/acom_music_box/examples/configs/chapman/evolving_conditions.csv diff --git a/tests/configs/chapman_config/my_config.json b/src/acom_music_box/examples/configs/chapman/my_config.json similarity index 100% rename from tests/configs/chapman_config/my_config.json rename to src/acom_music_box/examples/configs/chapman/my_config.json diff --git a/tests/configs/wall_loss_config/camp_data/config.json b/src/acom_music_box/examples/configs/flow_tube/camp_data/config.json similarity index 100% rename from tests/configs/wall_loss_config/camp_data/config.json rename to src/acom_music_box/examples/configs/flow_tube/camp_data/config.json diff --git a/tests/configs/wall_loss_config/camp_data/reactions.json b/src/acom_music_box/examples/configs/flow_tube/camp_data/reactions.json similarity index 100% rename from tests/configs/wall_loss_config/camp_data/reactions.json rename to src/acom_music_box/examples/configs/flow_tube/camp_data/reactions.json diff --git a/tests/configs/wall_loss_config/camp_data/species.json b/src/acom_music_box/examples/configs/flow_tube/camp_data/species.json similarity index 100% rename from tests/configs/wall_loss_config/camp_data/species.json rename to src/acom_music_box/examples/configs/flow_tube/camp_data/species.json diff --git a/tests/configs/wall_loss_config/evolving_conditions.csv b/src/acom_music_box/examples/configs/flow_tube/evolving_conditions.csv similarity index 100% rename from tests/configs/wall_loss_config/evolving_conditions.csv rename to src/acom_music_box/examples/configs/flow_tube/evolving_conditions.csv diff --git a/tests/configs/wall_loss_config/initial_conditions.csv b/src/acom_music_box/examples/configs/flow_tube/initial_conditions.csv similarity index 100% rename from tests/configs/wall_loss_config/initial_conditions.csv rename to src/acom_music_box/examples/configs/flow_tube/initial_conditions.csv diff --git a/tests/configs/wall_loss_config/my_config.json b/src/acom_music_box/examples/configs/flow_tube/my_config.json similarity index 100% rename from tests/configs/wall_loss_config/my_config.json rename to src/acom_music_box/examples/configs/flow_tube/my_config.json diff --git a/src/acom_music_box/examples/examples.py b/src/acom_music_box/examples/examples.py new file mode 100644 index 00000000..b6e1a3db --- /dev/null +++ b/src/acom_music_box/examples/examples.py @@ -0,0 +1,55 @@ +import os + +class Example: + def __init__(self, name, short_name, description, path): + self.name = name + self.short_name = short_name + self.description = description + self.path = path + + def __str__(self): + return f'{self.name}: {self.description}' + + def __repr__(self): + return f'{self.name}: {self.description}' + + @classmethod + def from_config(cls, display_name, folder_name, short_name, description): + path = os.path.join(os.path.dirname(__file__), 'configs', folder_name, 'my_config.json') + return cls(name=display_name, short_name = short_name, description=description, path=path) + +class _Examples: + CarbonBond5 = Example.from_config( + display_name='Carbon Bond IV', + short_name='CB5', + folder_name='carbon_bond_5', + description='Carbon bond 5') + Chapman = Example.from_config( + display_name='Chapman', + short_name='Chapman', + folder_name='chapman', + description='The Chapman cycle with conditions over Boulder, Colorado') + FlowTube = Example.from_config( + display_name='Flow Tube', + short_name='FlowTube', + folder_name='flow_tube', + description='A fictitious flow tube experiment') + Analytical = Example.from_config( + display_name='Analytical', + short_name='Analytical', + folder_name='analytical', + description='An example of an analytical solution to a simple chemical system') + + @classmethod + def get_all(cls): + return [cls.CarbonBond5, cls.Chapman, cls.FlowTube, cls.Analytical] + + def __iter__(self): + return iter(self.get_all()) + + def __getattr__(self, item): + if hasattr(self, item): + return getattr(self, item) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{item}'") + +Examples = _Examples() \ No newline at end of file diff --git a/src/acom_music_box/main.py b/src/acom_music_box/main.py index d3f1c01c..e1baa9f8 100644 --- a/src/acom_music_box/main.py +++ b/src/acom_music_box/main.py @@ -1,98 +1,156 @@ import os import argparse -from acom_music_box import MusicBox - - -import math +from acom_music_box import MusicBox, Examples import datetime import sys - import logging -logger = logging.getLogger(__name__) - - -# configure argparse for key-value pairs -class KeyValueAction(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - for value in values: - key, val = value.split('=') - setattr(namespace, key, val) - -# Retrieve named arguments from the command line and -# return in a dictionary of keywords. -# argPairs = list of arguments, probably from sys.argv[1:] -# named arguments are formatted like this=3.14159 -# return dictionary of keywords and values +import colorlog +import subprocess +import tempfile +def format_examples_help(examples): + return '\n'.join(f"{e.short_name}: {e.description}" for e in examples) -def getArgsDictionary(argPairs): +def parse_arguments(): parser = argparse.ArgumentParser( - description='Process some key=value pairs.') + description='MusicBox simulation runner.', + formatter_class=argparse.RawTextHelpFormatter + ) + parser.add_argument( + '-c', '--config', + type=str, + help='Path to the configuration file. If --example is provided, this argument is ignored.' + ) + parser.add_argument( + '-e', '--example', + type=str, + choices=[e.short_name for e in Examples], + help=f'Name of the example to use. Overrides --config.\nAvailable examples:\n{format_examples_help(Examples)}' + ) + parser.add_argument( + '-o', '--output', + type=str, + help='Path to save the output file, including the file name. If not provided, result will be printed to the console.' + ) + parser.add_argument( + '-v', '--verbose', + action='count', + default=0, + help='Increase logging verbosity. Use -v for info, -vv for debug.' + ) parser.add_argument( - 'key_value_pairs', - nargs='+', # This means one or more arguments are expected - action=KeyValueAction, - help="Arguments in key=value format. Example: configFile=my_config.json" + '--color-output', + action='store_true', + help='Enable color output for logs.' ) + parser.add_argument( + '--plot', + type=str, + help='Plot a comma-separated list of species if gnuplot is available (e.g., CONC.A,CONC.B).' + ) + return parser.parse_args() + +def setup_logging(verbosity, color_output): + if verbosity >= 2: + log_level = logging.DEBUG + elif verbosity == 1: + log_level = logging.INFO + else: + log_level = logging.CRITICAL + + formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(module)s.%(funcName)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') + if color_output: + color_formatter = colorlog.ColoredFormatter('%(log_color)s%(asctime)s - %(levelname)s - %(module)s.%(funcName)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S', log_colors={'DEBUG': 'green', 'INFO': 'cyan', 'WARNING': 'yellow', 'ERROR': 'red', 'CRITICAL': 'bold_red'}) + console_handler = logging.StreamHandler() + console_handler.setLevel(log_level) + console_handler.setFormatter(color_formatter) + logging.basicConfig(level=log_level, handlers=[console_handler]) + else: + console_handler = logging.StreamHandler() + console_handler.setLevel(log_level) + console_handler.setFormatter(formatter) + logging.basicConfig(level=log_level, handlers=[console_handler]) + +def plot_with_gnuplot(data, species_list): + # Prepare columns and data for plotting + columns = ['time'] + species_list + data_to_plot = data[columns] + + data_csv = data_to_plot.to_csv(index=False) + + try: + with tempfile.NamedTemporaryFile(delete=False, suffix='.csv') as data_file: + data_file.write(data_csv.encode()) + data_file_path = data_file.name + + plot_commands = ',\n\t'.join(f"'{data_file_path}' using 1:{i+2} with lines title '{species}'" for i, species in enumerate(species_list)) + + gnuplot_command = f""" + set datafile separator ","; + set terminal dumb size 120,25; + set xlabel 'Time'; + set ylabel 'Value'; + set title 'Time vs Species'; + plot {plot_commands} + """ + + subprocess.run(['gnuplot', '-e', gnuplot_command], check=True) + except FileNotFoundError: + logging.critical("gnuplot is not installed. Skipping plotting.") + except subprocess.CalledProcessError as e: + logging.error(f"Error occurred while plotting: {e}") + finally: + # Clean up the temporary file + if data_file_path: + os.remove(data_file_path) + +def main(): + start = datetime.datetime.now() - argDict = vars(parser.parse_args(argPairs)) # return dictionary + args = parse_arguments() + setup_logging(args.verbose, args.color_output) - return (argDict) + logger = logging.getLogger(__name__) + logger.debug(f"{__file__}") + logger.info(f"Start time: {start}") -def main(): - logging.basicConfig(stream=sys.stdout, level=logging.INFO) - logger.info("{}".format(__file__)) - logger.info("Start time: {}".format(datetime.datetime.now())) - - logger.info("Hello, MusicBox World!") - logger.info("Working directory = {}".format(os.getcwd())) - - # retrieve and parse the command-line arguments - myArgs = getArgsDictionary(sys.argv[1:]) - logger.info("Command line = {}".format(myArgs)) - - # set up the home configuration file - musicBoxConfigFile = None - if ("configFile" in myArgs): - musicBoxConfigFile = myArgs.get("configFile") - - # set up the output directory - musicBoxOutputDir = ".\\" # default - if ("outputDir" in myArgs): - musicBoxOutputDir = myArgs.get("outputDir") - - # check for required arguments and provide examples - if (musicBoxConfigFile is None): - errorString = "Error: The configFile parameter is required." - errorString += ( - " Example: configFile={}" .format( - os.path.join( - "tests", - "configs", - "analytical_config", - "my_config.json"))) - raise Exception(errorString) - - # create and load a MusicBox object + logger.debug(f"Working directory = {os.getcwd()}") + + if args.example: + example = next(e for e in Examples if e.short_name == args.example) + musicBoxConfigFile = example.path + logger.info(f"Using example: {example}") + else: + musicBoxConfigFile = args.config + + musicBoxOutputPath = args.output + plot_species_list = args.plot.split(',') if args.plot else None + + # Create and load a MusicBox object myBox = MusicBox() - logging.info("configuration file = {}".format(musicBoxConfigFile)) + logger.debug(f"Configuration file = {musicBoxConfigFile}") myBox.readConditionsFromJson(musicBoxConfigFile) - logger.info("myBox = {}".format(myBox)) - # create solver and solve, writing output to requested directory - campConfig = os.path.join( + # Create solver and solve + config_path = os.path.join( os.path.dirname(musicBoxConfigFile), myBox.config_file) - logger.info("CAMP config = {}".format(campConfig)) - myBox.create_solver(campConfig) - logger.info("myBox.solver = {}".format(myBox.solver)) - mySolution = myBox.solve(os.path.join(musicBoxOutputDir, "mySolution.csv")) - # logger.info("mySolution = {}".format(mySolution)) + myBox.create_solver(config_path) + result = myBox.solve(musicBoxOutputPath) + + if musicBoxOutputPath is None: + print(result.to_csv(index=False)) + + if plot_species_list: + # Prepare data for plotting + plot_with_gnuplot(result, plot_species_list) + + end = datetime.datetime.now() + logger.info(f"End time: {end}") + logger.info(f"Elapsed time: {end - start} seconds") - logger.info("End time: {}".format(datetime.datetime.now())) sys.exit(0) - if __name__ == "__main__": main() diff --git a/src/acom_music_box/music_box.py b/src/acom_music_box/music_box.py index 3eb0f922..14245bb7 100644 --- a/src/acom_music_box/music_box.py +++ b/src/acom_music_box/music_box.py @@ -8,9 +8,9 @@ from .evolving_conditions import EvolvingConditions import json import os +import pandas as pd import logging -logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) @@ -552,16 +552,25 @@ def solve(self, output_path=None): # increments time curr_time += self.box_model_options.chem_step_time + df = pd.DataFrame(output_array[1:], columns=output_array[0]) # outputs to file if output is present - if (output_path is not None): - logger.info("path_to_output = {}".format(output_path)) - os.makedirs(os.path.dirname(output_path), exist_ok=True) - with open(output_path, 'w', newline='') as output: - writer = csv.writer(output) - writer.writerows(output_array) - - # returns output_array - return output_array + if output_path is not None: + + # Check if the output_path is a full path or just a file name + if os.path.dirname(output_path) == '': + # If output_path is just a filename, use the current directory + output_path = os.path.join(os.getcwd(), output_path) + elif not os.path.basename(output_path): + raise ValueError(f"Invalid output path: '{output_path}' does not contain a filename.") + + # Ensure the directory exists + dir_path = os.path.dirname(output_path) + if dir_path and not os.path.exists(dir_path): + os.makedirs(dir_path, exist_ok=True) + + df.to_csv(output_path, index=False) + + return df def readFromUIJson(self, path_to_json): """ diff --git a/tests/test_analytical.py b/tests/test_analytical.py index c3eceb56..de0fd464 100644 --- a/tests/test_analytical.py +++ b/tests/test_analytical.py @@ -1,21 +1,25 @@ -from acom_music_box import MusicBox +from acom_music_box import MusicBox, Examples +import os import math - class TestAnalytical: def test_run(self): box_model = MusicBox() # configures box model - conditions_path = "configs/analytical_config/my_config.json" - camp_path = "configs/analytical_config/camp_data" - + conditions_path = Examples.Analytical.path box_model.readConditionsFromJson(conditions_path) + + camp_path = os.path.join( + os.path.dirname(conditions_path), + box_model.config_file) + box_model.create_solver(camp_path) # solves and saves output - output = box_model.solve() + df = box_model.solve() + output = [df.columns.values.tolist()] + df.values.tolist() conc_a_index = output[0].index("CONC.A") conc_b_index = output[0].index("CONC.B") diff --git a/tests/test_full_gas_phase_mechanism.py b/tests/test_carbon_bond_5.py similarity index 88% rename from tests/test_full_gas_phase_mechanism.py rename to tests/test_carbon_bond_5.py index 2f104601..fdb82f01 100644 --- a/tests/test_full_gas_phase_mechanism.py +++ b/tests/test_carbon_bond_5.py @@ -1,22 +1,27 @@ -from acom_music_box import MusicBox +from acom_music_box import MusicBox, Examples +import os import csv import math -class TestFullGassPhaseMechanism: +class TestCarbonBond5: def test_run(self): box_model = MusicBox() # configures box model - conditions_path = "configs/full_gas_phase_mechanism_config/my_config.json" - camp_path = "configs/full_gas_phase_mechanism_config/camp_data" - + conditions_path = Examples.CarbonBond5.path box_model.readConditionsFromJson(conditions_path) + + camp_path = os.path.join( + os.path.dirname(conditions_path), + box_model.config_file) + box_model.create_solver(camp_path) # solves and saves output - model_output = box_model.solve() + df = box_model.solve() + model_output = [df.columns.values.tolist()] + df.values.tolist() # read wall_loss_test.csv into test_output with open("expected_results/full_gas_phase_mechanism.csv", "r") as file: @@ -116,5 +121,5 @@ def test_run(self): if __name__ == "__main__": - test = TestFullGassPhaseMechanism() + test = TestCarbonBond5() test.test_run() diff --git a/tests/test_chapman.py b/tests/test_chapman.py index 58e06175..765144da 100644 --- a/tests/test_chapman.py +++ b/tests/test_chapman.py @@ -1,4 +1,6 @@ -from acom_music_box import MusicBox +from acom_music_box import MusicBox, Examples + +import os import csv import math @@ -8,15 +10,18 @@ def test_run(self): box_model = MusicBox() # configures box model - conditions_path = "configs/chapman_config/my_config.json" - camp_path = "configs/chapman_config/camp_data" - + conditions_path = Examples.Chapman.path box_model.readConditionsFromJson(conditions_path) + camp_path = os.path.join( + os.path.dirname(conditions_path), + box_model.config_file) + box_model.create_solver(camp_path) # solves and saves output - model_output = box_model.solve() + df = box_model.solve() + model_output = [df.columns.values.tolist()] + df.values.tolist() # read chapman_test.csv into test_output with open("expected_results/chapman_test.csv", "r") as file: diff --git a/tests/test_wall_loss.py b/tests/test_flow_tube.py similarity index 82% rename from tests/test_wall_loss.py rename to tests/test_flow_tube.py index f269054b..7fff3148 100644 --- a/tests/test_wall_loss.py +++ b/tests/test_flow_tube.py @@ -1,4 +1,5 @@ -from acom_music_box import MusicBox +from acom_music_box import MusicBox, Examples +import os import csv import math @@ -9,14 +10,18 @@ def test_run(self): box_model = MusicBox() # configures box model - conditions_path = "configs/wall_loss_config/my_config.json" - camp_path = "configs/wall_loss_config/camp_data" - + conditions_path = Examples.FlowTube.path box_model.readConditionsFromJson(conditions_path) + + camp_path = os.path.join( + os.path.dirname(conditions_path), + box_model.config_file) + box_model.create_solver(camp_path) # solves and saves output - model_output = box_model.solve() + df = box_model.solve() + model_output = [df.columns.values.tolist()] + df.values.tolist() # read wall_loss_test.csv into test_output with open("expected_results/wall_loss_test.csv", "r") as file: