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

Auto-format code changes #32

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions include/open_atmos/mechanism_configuration/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ namespace open_atmos
const std::string aerosol_phase_water = "aerosol-phase water";
// also these
// aerosol phase
// A
// B
// C
// D
// E
// A
// B
// C
// D
// E
// Ea

// Troe
Expand Down
36 changes: 20 additions & 16 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ namespace open_atmos
{
for (const auto& spec : requested_species)
{
auto it =
std::find_if(existing_species.begin(), existing_species.end(), [&spec](const std::string& existing) { return existing == spec; });
auto it = std::find_if(existing_species.begin(), existing_species.end(), [&spec](const std::string& existing) { return existing == spec; });

if (it == existing_species.end())
{
Expand Down Expand Up @@ -432,7 +431,10 @@ namespace open_atmos
return { status, arrhenius };
}

std::pair<ConfigParseStatus, types::CondensedPhaseArrhenius> ParseCondensedPhaseArrhenius(const json& object, const std::vector<types::Species>& existing_species, const std::vector<types::Phase>& existing_phases)
std::pair<ConfigParseStatus, types::CondensedPhaseArrhenius> ParseCondensedPhaseArrhenius(
const json& object,
const std::vector<types::Species>& existing_species,
const std::vector<types::Phase>& existing_phases)
{
ConfigParseStatus status = ConfigParseStatus::Success;
types::CondensedPhaseArrhenius condensed_phase_arrhenius;
Expand Down Expand Up @@ -528,19 +530,20 @@ namespace open_atmos
status = ConfigParseStatus::ReactionRequiresUnknownSpecies;
}

auto phase_it = std::find_if(existing_phases.begin(), existing_phases.end(), [&aerosol_phase](const types::Phase& phase) {
return phase.name == aerosol_phase;
});
auto phase_it = std::find_if(
existing_phases.begin(), existing_phases.end(), [&aerosol_phase](const types::Phase& phase) { return phase.name == aerosol_phase; });

if (phase_it != existing_phases.end()) {
if (phase_it != existing_phases.end())
{
// check if all of the species for this reaction are actually in the aerosol phase
std::vector<std::string> aerosol_phase_species = {(*phase_it).species.begin(), (*phase_it).species.end()};
std::vector<std::string> aerosol_phase_species = { (*phase_it).species.begin(), (*phase_it).species.end() };
if (status == ConfigParseStatus::Success && RequiresUnknownSpecies(requested_species, aerosol_phase_species))
{
status = ConfigParseStatus::RequestedAerosolSpeciesNotIncludedInAerosolPhase;
}
}
else {
else
{
status = ConfigParseStatus::UnknownPhase;
}

Expand All @@ -554,7 +557,8 @@ namespace open_atmos
return { status, condensed_phase_arrhenius };
}

std::pair<ConfigParseStatus, types::Troe> ParseTroe(const json& object, const std::vector<types::Species>& existing_species, const std::vector<types::Phase> existing_phases)
std::pair<ConfigParseStatus, types::Troe>
ParseTroe(const json& object, const std::vector<types::Species>& existing_species, const std::vector<types::Phase> existing_phases)
{
ConfigParseStatus status = ConfigParseStatus::Success;
types::Troe troe;
Expand Down Expand Up @@ -1020,7 +1024,8 @@ namespace open_atmos
return { status, photolysis };
}

std::pair<ConfigParseStatus, types::Emission> ParseEmission(const json& object, const std::vector<types::Species> existing_species, const std::vector<types::Phase> existing_phases)
std::pair<ConfigParseStatus, types::Emission>
ParseEmission(const json& object, const std::vector<types::Species> existing_species, const std::vector<types::Phase> existing_phases)
{
ConfigParseStatus status = ConfigParseStatus::Success;
types::Emission emission;
Expand Down Expand Up @@ -1071,8 +1076,7 @@ namespace open_atmos
}

std::string gas_phase = object[validation::keys.gas_phase].get<std::string>();
auto it =
std::find_if(existing_phases.begin(), existing_phases.end(), [&gas_phase](const auto& phase) { return phase.name == gas_phase; });
auto it = std::find_if(existing_phases.begin(), existing_phases.end(), [&gas_phase](const auto& phase) { return phase.name == gas_phase; });
if (status == ConfigParseStatus::Success && it == existing_phases.end())
{
status = ConfigParseStatus::UnknownPhase;
Expand All @@ -1086,7 +1090,8 @@ namespace open_atmos
return { status, emission };
}

std::pair<ConfigParseStatus, types::FirstOrderLoss> ParseFirstOrderLoss(const json& object, const std::vector<types::Species> existing_species, const std::vector<types::Phase> existing_phases)
std::pair<ConfigParseStatus, types::FirstOrderLoss>
ParseFirstOrderLoss(const json& object, const std::vector<types::Species> existing_species, const std::vector<types::Phase> existing_phases)
{
ConfigParseStatus status = ConfigParseStatus::Success;
types::FirstOrderLoss first_order_loss;
Expand Down Expand Up @@ -1137,8 +1142,7 @@ namespace open_atmos
}

std::string gas_phase = object[validation::keys.gas_phase].get<std::string>();
auto it =
std::find_if(existing_phases.begin(), existing_phases.end(), [&gas_phase](const auto& phase) { return phase.name == gas_phase; });
auto it = std::find_if(existing_phases.begin(), existing_phases.end(), [&gas_phase](const auto& phase) { return phase.name == gas_phase; });
if (status == ConfigParseStatus::Success && it == existing_phases.end())
{
status = ConfigParseStatus::UnknownPhase;
Expand Down