-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from open-atmos/parse_henrys_law
parsing henrys law
- Loading branch information
Showing
12 changed files
with
457 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <open_atmos/mechanism_configuration/parser.hpp> | ||
|
||
using namespace open_atmos::mechanism_configuration; | ||
|
||
TEST(JsonParser, CanParseValidHenrysLawReaction) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/henrys_law/valid.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::Success); | ||
|
||
EXPECT_EQ(mechanism.reactions.henrys_law.size(), 2); | ||
|
||
EXPECT_EQ(mechanism.reactions.henrys_law[0].name, "my henry's law"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].gas_phase_species, "A"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].aerosol_phase, "aqueous aerosol"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].aerosol_phase_species, "B"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].aerosol_phase_water, "H2O_aq"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].unknown_properties.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[0].unknown_properties["__comment"], "\"hi\""); | ||
|
||
EXPECT_EQ(mechanism.reactions.henrys_law[1].name, ""); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].gas_phase_species, "A"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].aerosol_phase, "aqueous aerosol"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].aerosol_phase_species, "B"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].aerosol_phase_water, "H2O_aq"); | ||
EXPECT_EQ(mechanism.reactions.henrys_law[1].unknown_properties.size(), 0); | ||
} | ||
|
||
TEST(JsonParser, HenrysLawDetectsUnknownSpecies) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/henrys_law/unknown_species.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::ReactionRequiresUnknownSpecies); | ||
} | ||
|
||
TEST(JsonParser, HenrysLawDetectsUnknownPhase) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/henrys_law/missing_phase.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::UnknownPhase); | ||
} | ||
|
||
TEST(JsonParser, HenrysLawDetectsUnknownAerosolPhaseWater) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/condensed_phase_arrhenius/missing_aerosol_phase_water.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::ReactionRequiresUnknownSpecies); | ||
} | ||
|
||
TEST(JsonParser, HenrysLawDetectsWhenRequestedSpeciesAreNotInAerosolPhase) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/condensed_phase_arrhenius/species_not_in_aerosol_phase.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::RequestedAerosolSpeciesNotIncludedInAerosolPhase); | ||
} |
46 changes: 46 additions & 0 deletions
46
test/unit/unit_configs/reactions/henrys_law/missing_aerosol_phase_water.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Missing condensed phase arrhenius aerosol phase water", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
}, | ||
{ | ||
"name": "H2O_aq" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "aqueous aerosol", | ||
"species": [ | ||
"A", | ||
"B", | ||
"C", | ||
"H2O_aq" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "CONDENSED_PHASE_ARRHENIUS", | ||
"aerosol phase": "aqueous aerosol", | ||
"aerosol-phase water": "H2O_a", | ||
"reactants": [ | ||
{ | ||
"species name": "A" | ||
} | ||
], | ||
"products": [ | ||
{ | ||
"species name": "C" | ||
} | ||
] | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
test/unit/unit_configs/reactions/henrys_law/missing_phase.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Missing phase", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
} | ||
], | ||
"phases": [ ], | ||
"reactions": [ | ||
{ | ||
"type": "HL_PHASE_TRANSFER", | ||
"gas phase": "gas", | ||
"gas-phase species": "H2O2", | ||
"aerosol phase": "aqueous aerosol", | ||
"aerosol-phase species": "H2O2_aq", | ||
"aerosol-phase water": "H2O_aq", | ||
"name": "my henry's law" | ||
} | ||
] | ||
} |
Oops, something went wrong.