-
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 #17 from open-atmos/parse_troe
Parse troe
- Loading branch information
Showing
11 changed files
with
385 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
{ | ||
"name": "C" | ||
}, | ||
{ | ||
"name": "M" | ||
}, | ||
{ | ||
"name": "H2O2", | ||
"HLC(298K) [mol m-3 Pa-1]": 1.011596348, | ||
|
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,68 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <open_atmos/mechanism_configuration/parser.hpp> | ||
|
||
using namespace open_atmos::mechanism_configuration; | ||
|
||
TEST(JsonParser, CanParseValidTroeReaction) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/troe/valid.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::Success); | ||
|
||
EXPECT_EQ(mechanism.reactions.troe.size(), 2); | ||
|
||
EXPECT_EQ(mechanism.reactions.troe[0].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.troe[0].k0_A, 1.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].k0_B, 0.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].k0_C, 0.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].kinf_A, 1.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].kinf_B, 0.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].kinf_C, 0.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].Fc, 0.6); | ||
EXPECT_EQ(mechanism.reactions.troe[0].N, 1.0); | ||
EXPECT_EQ(mechanism.reactions.troe[0].reactants.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.troe[0].reactants[0].species_name, "A"); | ||
EXPECT_EQ(mechanism.reactions.troe[0].reactants[0].coefficient, 1); | ||
EXPECT_EQ(mechanism.reactions.troe[0].products.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.troe[0].products[0].species_name, "C"); | ||
EXPECT_EQ(mechanism.reactions.troe[0].products[0].coefficient, 1); | ||
EXPECT_EQ(mechanism.reactions.troe[0].unknown_properties.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.troe[0].unknown_properties["__my object"], "{\"a\":1.0}"); | ||
|
||
EXPECT_EQ(mechanism.reactions.troe[1].name, "my troe"); | ||
EXPECT_EQ(mechanism.reactions.troe[1].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.troe[1].k0_A, 32.1); | ||
EXPECT_EQ(mechanism.reactions.troe[1].k0_B, -2.3); | ||
EXPECT_EQ(mechanism.reactions.troe[1].k0_C, 102.3); | ||
EXPECT_EQ(mechanism.reactions.troe[1].kinf_A, 63.4); | ||
EXPECT_EQ(mechanism.reactions.troe[1].kinf_B, -1.3); | ||
EXPECT_EQ(mechanism.reactions.troe[1].kinf_C, 908.5); | ||
EXPECT_EQ(mechanism.reactions.troe[1].Fc, 1.3); | ||
EXPECT_EQ(mechanism.reactions.troe[1].N, 32.1); | ||
EXPECT_EQ(mechanism.reactions.troe[1].reactants.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.troe[1].reactants[0].species_name, "C"); | ||
EXPECT_EQ(mechanism.reactions.troe[1].reactants[0].coefficient, 1); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products.size(), 2); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[0].species_name, "A"); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[0].coefficient, 0.2); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[0].unknown_properties.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[0].unknown_properties["__optional thing"], "\"hello\""); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[1].species_name, "B"); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[1].coefficient, 1.2); | ||
EXPECT_EQ(mechanism.reactions.troe[1].products[1].unknown_properties.size(), 0); | ||
} | ||
|
||
TEST(JsonParser, TroeDetectsUnknownSpecies) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/troe/unknown_species.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::ReactionRequiresUnknownSpecies); | ||
} | ||
|
||
TEST(JsonParser, TroeDetectsBadReactionComponent) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/troe/bad_reaction_component.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::RequiredKeyNotFound); | ||
} |
2 changes: 1 addition & 1 deletion
2
test/unit/unit_configs/reactions/arrhenius/bad_reaction_component.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
37 changes: 37 additions & 0 deletions
37
test/unit/unit_configs/reactions/troe/bad_reaction_component.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,37 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Bad reaction component", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "gas", | ||
"species": [ | ||
"A", | ||
"B" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "TROE", | ||
"gas phase": "gas", | ||
"reactants": [ | ||
{ | ||
"Species name": "A" | ||
} | ||
], | ||
"products": [ | ||
{ | ||
"species name": "B" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.