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

Parse branched #18

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions examples/full_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
{
"name": "C"
},
{
"name": "M"
},
{
"name": "H2O2",
"HLC(298K) [mol m-3 Pa-1]": 1.011596348,
Expand Down
32 changes: 32 additions & 0 deletions include/open_atmos/mechanism_configuration/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ namespace open_atmos
const std::string E = "E";
const std::string Ea = "Ea";

// Troe
const std::string Troe_key = "TROE";
const std::string k0_A = "k0_A";
const std::string k0_B = "k0_B";
const std::string k0_C = "k0_C";
const std::string kinf_A = "kinf_A";
const std::string kinf_B = "kinf_B";
const std::string kinf_C = "kinf_C";
const std::string Fc = "Fc";
const std::string N = "N";

// Branched
const std::string Branched_key = "BRANCHED_NO_RO2";
const std::string X = "X";
const std::string Y = "Y";
const std::string a0 = "a0";
const std::string n = "n";
const std::string nitrate_products = "nitrate products";
const std::string alkoxy_products = "alkoxy products";

} keys;

struct Configuration
Expand Down Expand Up @@ -89,6 +109,18 @@ namespace open_atmos
const std::vector<std::string> optional_keys{ keys.A, keys.B, keys.C, keys.D, keys.E, keys.Ea, keys.name };
} arrhenius;

struct Troe
{
const std::vector<std::string> required_keys{ keys.products, keys.reactants, keys.type, keys.gas_phase };
const std::vector<std::string> optional_keys{ keys.name, keys.k0_A, keys.k0_B, keys.k0_C, keys.kinf_A, keys.kinf_B, keys.kinf_C, keys.Fc, keys.N };
} troe;

struct Branched
{
const std::vector<std::string> required_keys{ keys.nitrate_products, keys.alkoxy_products, keys.reactants, keys.type, keys.gas_phase };
const std::vector<std::string> optional_keys{ keys.name, keys.X, keys.Y, keys.a0, keys.n };
} branched;

struct Mechanism
{
const std::vector<std::string> required_keys{};
Expand Down
60 changes: 58 additions & 2 deletions include/open_atmos/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ namespace open_atmos
struct Species
{
std::string name;

std::map<std::string, double> optional_numerical_properties;

/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Phase
{
std::string name;
std::vector<std::string> species;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct ReactionComponent
{
std::string species_name;
double coefficient;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

Expand All @@ -47,7 +48,36 @@ namespace open_atmos
double D{ 300 };
/// @brief A factor that determines pressure dependence [Pa-1]
double E{ 0 };
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @brief A list of products
std::vector<ReactionComponent> products;
/// @brief An identifier, optional, uniqueness not enforced
std::string name;
/// @brief An identifier indicating which gas phase this reaction takes place in
std::string gas_phase;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Troe
{
/// @brief low-pressure pre-exponential factor
double k0_A = 1.0;
/// @brief low-pressure temperature-scaling parameter
double k0_B = 0.0;
/// @brief low-pressure exponential factor
double k0_C = 0.0;
/// @brief high-pressure pre-exponential factor
double kinf_A = 1.0;
/// @brief high-pressure temperature-scaling parameter
double kinf_B = 0.0;
/// @brief high-pressure exponential factor
double kinf_C = 0.0;
/// @brief Troe F_c parameter
double Fc = 0.6;
/// @brief Troe N parameter
double N = 1.0;
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @brief A list of products
Expand All @@ -56,13 +86,39 @@ namespace open_atmos
std::string name;
/// @brief An identifier indicating which gas phase this reaction takes place in
std::string gas_phase;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Branched
{
/// @brief pre-exponential factor
double X;
/// @brief exponential factor
double Y;
/// @brief branching factor
double a0;
/// @brief number of heavy atoms in the RO2 reacting species (excluding the peroxy moiety)
int n;
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @brief A list of nitrate products
std::vector<ReactionComponent> nitrate_products;
/// @brief A list of alkoxy products
std::vector<ReactionComponent> alkoxy_products;
/// @brief An identifier, optional, uniqueness not enforced
std::string name;
/// @brief An identifier indicating which gas phase this reaction takes place in
std::string gas_phase;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Reactions
{
std::vector<types::Arrhenius> arrhenius;
std::vector<types::Troe> troe;
std::vector<types::Branched> branched;
};

struct Mechanism
Expand Down
Loading