Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
K20shores committed Jan 23, 2024
2 parents 365d5b9 + 64f86a0 commit d2b7c88
Show file tree
Hide file tree
Showing 36 changed files with 1,690 additions and 66 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,13 @@ concurrency:
cancel-in-progress: true

jobs:
xcode_macos_12:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-12
strategy:
matrix:
# all available versions of xcode: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
xcode: ['13.1', '14.1']
build_type: [Debug, Release]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer

steps:
- uses: actions/checkout@v3

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --parallel 10

- name: Run tests
run: |
cd build
ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -j 10
xcode_macos_13:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: macos-13
strategy:
matrix:
# all available versions of xcode: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
xcode: ['14.1', '15.0']
xcode: ['15.0']
build_type: [Debug, Release]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
Expand All @@ -63,7 +38,6 @@ jobs:
strategy:
matrix:
compiler:
- { cpp: g++-11, c: gcc-11}
- { cpp: g++-12, c: gcc-12}
- { cpp: clang++, c: clang}
build_type: [Debug, Release]
Expand Down
12 changes: 4 additions & 8 deletions examples/full_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
"species": [
"H2O2_aq",
"H2O_aq",
"ethanol_aq"
"ethanol_aq",
"A",
"B",
"C"
]
},
{
Expand Down Expand Up @@ -121,13 +124,11 @@
},
{
"type": "AQUEOUS_EQUILIBRIUM",
"gas phase": "gas",
"aerosol phase": "aqueous aerosol",
"aerosol-phase water": "H2O_aq",
"A": 1.14e-2,
"C": 2300.0,
"k_reverse": 0.32,
"ion pair": "B-C",
"reactants": [
{
"species name": "A",
Expand Down Expand Up @@ -208,10 +209,6 @@
{
"species name": "H2O2_aq",
"coefficient": 1
},
{
"species name": "H2O_aq",
"coefficient": 1
}
],
"products": [
Expand Down Expand Up @@ -360,7 +357,6 @@
},
{
"type": "WET_DEPOSITION",
"gas phase": "gas",
"aerosol phase": "cloud",
"name": "rxn cloud",
"scaling factor": 12.3
Expand Down
3 changes: 2 additions & 1 deletion include/open_atmos/mechanism_configuration/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ namespace open_atmos
ReactionRequiresUnknownSpecies,
UnknownPhase,
RequestedAerosolSpeciesNotIncludedInAerosolPhase,
TooManyReactionComponents
TooManyReactionComponents,
InvalidIonPair
};
std::string configParseStatusToString(const ConfigParseStatus &status);

Expand Down
59 changes: 53 additions & 6 deletions include/open_atmos/mechanism_configuration/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ namespace open_atmos
const std::string Photolysis_key = "PHOTOLYSIS";
const std::string scaling_factor = "scaling factor";

// Condensed Phae Photolysis
const std::string CondensedPhasePhotolysis_key = "CONDENSED_PHASE_PHOTOLYSIS";
// also
// scaling factor
// aerosol phase
// aerosol-phase water

// Emissions
const std::string Emission_key = "EMISSION";
// also scaling factor
Expand All @@ -119,13 +126,36 @@ namespace open_atmos
// aserosol-phase species
// B

// Aqueous Equilibrium
const std::string AqueousPhaseEquilibrium_key = "AQUEOUS_EQUILIBRIUM";
// also
// aerosol phase
// aerosol-phase water
// A
// C
const std::string k_reverse = "k_reverse";

// Wet Deposition
const std::string WetDeposition_key = "WET_DEPOSITION";
// also
// scaling factor
// aerosol phase

// Henry's Law Phase Transfer
const std::string HenrysLaw_key = "HL_PHASE_TRANSFER";
// also
// gas phase
// aerosol phase
// aerosol-phase water
// aerosol-phase species

} keys;

struct Configuration
struct Mechanism
{
const std::vector<std::string> required_keys{ keys.version, keys.species, keys.phases, keys.reactions };
const std::vector<std::string> optional_keys{ keys.name };
} configuration;
} mechanism;

struct Species
{
Expand Down Expand Up @@ -195,6 +225,12 @@ namespace open_atmos
const std::vector<std::string> optional_keys{ keys.name, keys.scaling_factor };
} photolysis;

struct CondensedPhasePhotolysis
{
const std::vector<std::string> required_keys{ keys.reactants, keys.products, keys.type, keys.aerosol_phase, keys.aerosol_phase_water };
const std::vector<std::string> optional_keys{ keys.name, keys.scaling_factor };
} condensed_phase_photolysis;

struct Emission
{
const std::vector<std::string> required_keys{ keys.products, keys.type, keys.gas_phase };
Expand All @@ -213,11 +249,22 @@ namespace open_atmos
const std::vector<std::string> optional_keys{ keys.name };
} simpol_phase_transfer;

struct Mechanism
struct WetDeposition
{
const std::vector<std::string> required_keys{};
const std::vector<std::string> optional_keys{};
} mechanism;
const std::vector<std::string> required_keys{ keys.aerosol_phase, keys.type };
const std::vector<std::string> optional_keys{ keys.name, keys.scaling_factor };
} wet_deposition;

struct HenrysLaw
{
const std::vector<std::string> required_keys{ keys.type, keys.gas_phase, keys.gas_phase_species, keys.aerosol_phase, keys.aerosol_phase_species, keys.aerosol_phase_water };
const std::vector<std::string> optional_keys{ keys.name };
} henrys_law;

struct AqueousEquilibrium
{
const std::vector<std::string> required_keys{ keys.type, keys.reactants, keys.products, keys.aerosol_phase, keys.aerosol_phase_water, keys.k_reverse };
const std::vector<std::string> optional_keys{ keys.name, keys.A, keys.C };
} aqueous_equilibrium;
} // namespace validation
} // namespace open_atmos
95 changes: 87 additions & 8 deletions include/open_atmos/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include <string>
#include <unordered_map>
#include <array>
#include <vector>
#include <optional>


namespace open_atmos
{
Expand Down Expand Up @@ -182,7 +186,7 @@ namespace open_atmos
struct Photolysis
{
/// @brief Scaling factor to apply to user-provided rate constants
double scaling_factor_{ 1.0 };
double scaling_factor{ 1.0 };
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @brief A list of products
Expand All @@ -195,10 +199,28 @@ namespace open_atmos
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Emission
struct CondensedPhasePhotolysis
{
/// @brief Scaling factor to apply to user-provided rate constants
double scaling_factor_{ 1.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 aerosol phase this reaction takes place in
std::string aerosol_phase;
/// @brief An identifier indicating the species label of aqueous phase water
std::string aerosol_phase_water;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct Emission
{
/// @brief Scaling factor to apply to user-provided rate constants
double scaling_factor{ 1.0 };
/// @brief A list of products
std::vector<ReactionComponent> products;
/// @brief An identifier, optional, uniqueness not enforced
Expand All @@ -212,13 +234,66 @@ namespace open_atmos
struct FirstOrderLoss
{
/// @brief Scaling factor to apply to user-provided rate constants
double scaling_factor_{ 1.0 };
double scaling_factor{ 1.0 };
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @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 AqueousEquilibrium
{
/// @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 An identifier indicating which aerosol phase this reaction takes place in
std::string aerosol_phase;
/// @brief An identifier indicating the species label of aqueous phase water
std::string aerosol_phase_water;
/// @brief A list of reactants
std::vector<ReactionComponent> reactants;
/// @brief A list of products
std::vector<ReactionComponent> products;
/// @brief Pre-exponential factor (s-1)
double A{ 1 };
/// @brief A constant
double C{ 0 };
/// @brief Reverse reation rate constant (s-1)
double k_reverse{ 0 };
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct WetDeposition
{
/// @brief Scaling factor to apply to user-provided rate constants
double scaling_factor{ 1.0 };
/// @brief An identifier, optional, uniqueness not enforced
std::string name;
/// @brief An identifier indicating which aerosol phase this reaction takes place in
std::string aerosol_phase;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};

struct HenrysLaw
{
/// @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 An identifier indicating which gas phase species this reaction involves
std::string gas_phase_species;
/// @brief An identifier indicating which aerosol phase this reaction takes place in
std::string aerosol_phase;
/// @brief An identifier indicating the species label of aqueous phase water
std::string aerosol_phase_water;
/// @brief An identifier indicating which aerosol phase species this reaction involves
std::string aerosol_phase_species;
/// @brief Unknown properties, prefixed with two underscores (__)
std::unordered_map<std::string, std::string> unknown_properties;
};
Expand All @@ -244,15 +319,19 @@ namespace open_atmos
struct Reactions
{
std::vector<types::Arrhenius> arrhenius;
std::vector<types::CondensedPhaseArrhenius> condensed_phase_arrhenius;
std::vector<types::Troe> troe;
std::vector<types::Branched> branched;
std::vector<types::Tunneling> tunneling;
std::vector<types::Surface> surface;
std::vector<types::Photolysis> photolysis;
std::vector<types::CondensedPhaseArrhenius> condensed_phase_arrhenius;
std::vector<types::CondensedPhasePhotolysis> condensed_phase_photolysis;
std::vector<types::Emission> emission;
std::vector<types::FirstOrderLoss> first_order_loss;
std::vector<types::SimpolPhaseTransfer> simpol_phase_transfer;
std::vector<types::AqueousEquilibrium> aqueous_equilibrium;
std::vector<types::WetDeposition> wet_deposition;
std::vector<types::HenrysLaw> henrys_law;
std::vector<types::Photolysis> photolysis;
std::vector<types::Surface> surface;
std::vector<types::Troe> troe;
std::vector<types::Tunneling> tunneling;
};

struct Mechanism
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ configure_file(version.hpp.in ${PROJECT_SOURCE_DIR}/include/open_atmos/mechanism
add_library(mechanism_configuration)
add_library(open_atmos::mechanism_configuration ALIAS mechanism_configuration)

target_compile_features(mechanism_configuration PUBLIC cxx_std_20)
target_compile_features(mechanism_configuration PUBLIC cxx_std_17)

target_sources(mechanism_configuration
PRIVATE
Expand Down
Loading

0 comments on commit d2b7c88

Please sign in to comment.