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 arrhenius #16

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
14 changes: 14 additions & 0 deletions include/open_atmos/constants.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (C) 2023-2024 National Center for Atmospheric Research, University of Illinois at Urbana-Champaign
//
// SPDX-License-Identifier: Apache-2.0

#pragma once
namespace open_atmos
{
namespace constants
{
static constexpr double boltzmann = 1.380649e-23; // J K^{-1}
static constexpr double avogadro = 6.02214076e23; // # mol^{-1}
static constexpr double R = boltzmann * avogadro; // J K^{-1} mol^{-1}
} // namespace constants
} // namespace open_atmos
5 changes: 4 additions & 1 deletion include/open_atmos/mechanism_configuration/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ namespace open_atmos
RequiredKeyNotFound,
MutuallyExclusiveOption,
InvalidVersion,
DuplicateSpeciesDetected
DuplicateSpeciesDetected,
DuplicatePhasesDetected,
PhaseRequiresUnknownSpecies,
ReactionRequiresUnknownSpecies,
};
std::string configParseStatusToString(const ConfigParseStatus &status);

Expand Down
40 changes: 36 additions & 4 deletions include/open_atmos/mechanism_configuration/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ namespace open_atmos
const std::string phase = "phase";
const std::string n_star = "N star";
const std::string density = "density [kg m-3]";

// Reactions
const std::string reactants = "reactants";
const std::string products = "products";
const std::string type = "type";
const std::string gas_phase = "gas phase";

// Reactant and product
const std::string species_name = "species name";
const std::string coefficient = "coefficient";

// Arrhenius
const std::string Arrhenius_key = "ARRHENIUS";
const std::string A = "A";
const std::string B = "B";
const std::string C = "C";
const std::string D = "D";
const std::string E = "E";
const std::string Ea = "Ea";

} keys;

struct Configuration
Expand All @@ -53,14 +73,26 @@ namespace open_atmos

struct Phase
{
const std::vector<std::string> required_keys {};
const std::vector<std::string> optional_keys {};
const std::vector<std::string> required_keys{ keys.name, keys.species };
const std::vector<std::string> optional_keys{};
} phase;

struct ReactionComponent
{
const std::vector<std::string> required_keys{ keys.species_name };
const std::vector<std::string> optional_keys{ keys.coefficient };
} reaction_component;

struct Arrhenius
{
const std::vector<std::string> required_keys{ keys.products, keys.reactants, keys.type, keys.gas_phase };
const std::vector<std::string> optional_keys{ keys.A, keys.B, keys.C, keys.D, keys.E, keys.Ea, keys.name };
} arrhenius;

struct Mechanism
{
const std::vector<std::string> required_keys {};
const std::vector<std::string> optional_keys {};
const std::vector<std::string> required_keys{};
const std::vector<std::string> optional_keys{};
} mechanism;

} // namespace validation
Expand Down
47 changes: 45 additions & 2 deletions include/open_atmos/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,56 @@ namespace open_atmos

struct Phase
{
std::string name;
std::vector<std::string> species;
std::unordered_map<std::string, std::string> unknown_properties;
};

struct ReactionComponent
{
std::string species_name;
double coefficient;
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Arrhenius
{
/// @brief Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1]
double A{ 1 };
/// @brief Unitless exponential factor
double B{ 0 };
/// @brief Activation threshold, expected to be the negative activation energy divided by the boltzman constant
/// [-E_a / k_b), K]
double C{ 0 };
/// @brief A factor that determines temperature dependence [K]
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;

std::unordered_map<std::string, std::string> unknown_properties;
};

struct Reactions
{
std::vector<types::Arrhenius> arrhenius;
};

struct Mechanism
{
std::string name; // optional
/// @brief An identifier, optional
std::string name;
std::vector<types::Species> species;
std::unordered_map<std::string, types::Phase> phases;
std::vector<types::Phase> phases;
Reactions reactions;
};

} // namespace types
Expand Down
Loading