Skip to content
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: 1 addition & 2 deletions include/micm/Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

#include <micm/util/constants.hpp>
#include <micm/util/error.hpp>
#include <micm/util/internal_error.hpp>
#include <micm/util/micm_exception.hpp>
#include <micm/util/jacobian.hpp>
#include <micm/util/matrix.hpp>
#include <micm/util/matrix_error.hpp>
#include <micm/util/property_keys.hpp>
#include <micm/util/random_string.hpp>
#include <micm/util/sparse_matrix.hpp>
Expand Down
58 changes: 0 additions & 58 deletions include/micm/constraint/constraint_error.hpp

This file was deleted.

21 changes: 13 additions & 8 deletions include/micm/constraint/constraint_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include <micm/constraint/constraint.hpp>
#include <micm/constraint/constraint_error.hpp>
#include <micm/util/micm_exception.hpp>
#include <micm/util/matrix.hpp>
#include <micm/util/sparse_matrix.hpp>

Expand All @@ -12,8 +12,6 @@
#include <memory>
#include <set>
#include <string>
#include <stdexcept>
#include <system_error>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -135,15 +133,20 @@ namespace micm
auto row_it = variable_map.find(algebraic_species);
if (row_it == variable_map.end())
{
throw std::system_error(
make_error_code(MicmConstraintErrc::UnknownSpecies),
throw MicmException(
MicmSeverity::Error,
MICM_ERROR_CATEGORY_CONSTRAINT,
MICM_CONSTRAINT_ERROR_CODE_UNKNOWN_SPECIES,
"Constraint '" + constraint.GetName() + "' targets unknown algebraic species '" + algebraic_species + "'");
}
info.constraint_row_ = row_it->second;

if (!algebraic_variable_ids_.insert(info.constraint_row_).second)
{
throw std::runtime_error(
throw MicmException(
MicmSeverity::Error,
MICM_ERROR_CATEGORY_CONSTRAINT,
MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY,
"Multiple constraints map to the same algebraic species row '" + algebraic_species + "'");
}

Expand All @@ -163,8 +166,10 @@ namespace micm
auto it = variable_map.find(species_name);
if (it == variable_map.end())
{
throw std::system_error(
make_error_code(MicmConstraintErrc::UnknownSpecies),
throw MicmException(
MicmSeverity::Error,
MICM_ERROR_CATEGORY_CONSTRAINT,
MICM_CONSTRAINT_ERROR_CODE_UNKNOWN_SPECIES,
"Constraint '" + constraint.GetName() + "' depends on unknown species '" + species_name + "'");
}
dependency_ids_.push_back(it->second);
Expand Down
13 changes: 6 additions & 7 deletions include/micm/constraint/equilibrium_constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <micm/constraint/constraint_error.hpp>
#include <micm/constraint/constraint.hpp>
#include <micm/system/stoich_species.hpp>

#include <cmath>
#include <cstddef>
#include <string>
#include <system_error>
#include <vector>

namespace micm
Expand Down Expand Up @@ -69,28 +68,28 @@ namespace micm
{
if (reactants_.empty())
{
throw std::system_error(make_error_code(MicmConstraintErrc::EmptyReactants));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_REACTANTS, "Equilibrium constraint requires at least one reactant");
}
if (products_.empty())
{
throw std::system_error(make_error_code(MicmConstraintErrc::EmptyProducts));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_PRODUCTS, "Equilibrium constraint requires at least one product");
}
if (equilibrium_constant_ <= 0)
{
throw std::system_error(make_error_code(MicmConstraintErrc::InvalidEquilibriumConstant));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_EQUILIBRIUM_CONSTANT, "Equilibrium constant must be positive");
}
for (const auto& r : reactants_)
{
if (r.coefficient_ <= 0)
{
throw std::system_error(make_error_code(MicmConstraintErrc::InvalidStoichiometry));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "Stoichiometric coefficients must be positive");
}
}
for (const auto& p : products_)
{
if (p.coefficient_ <= 0)
{
throw std::system_error(make_error_code(MicmConstraintErrc::InvalidStoichiometry));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_INVALID_STOICHIOMETRY, "Stoichiometric coefficients must be positive");
}
}

Expand Down
5 changes: 2 additions & 3 deletions include/micm/constraint/linear_constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <micm/constraint/constraint_error.hpp>
#include <micm/util/micm_exception.hpp>
#include <micm/system/stoich_species.hpp>

#include <cstddef>
#include <string>
#include <system_error>
#include <vector>

namespace micm
Expand Down Expand Up @@ -51,7 +50,7 @@ namespace micm
{
if (terms_.empty())
{
throw std::system_error(make_error_code(MicmConstraintErrc::EmptyReactants));
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_CONSTRAINT, MICM_CONSTRAINT_ERROR_CODE_EMPTY_REACTANTS, "");
}
for (const auto& term : terms_)
{
Expand Down
7 changes: 2 additions & 5 deletions include/micm/process/chemical_reaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <micm/process/process_error.hpp>
#include <micm/process/rate_constant/rate_constant.hpp>
#include <micm/solver/lu_decomposition.hpp>
#include <micm/solver/state.hpp>
Expand Down Expand Up @@ -58,8 +57,7 @@ namespace micm
if (this != &other)
{
if (!other.rate_constant_)
throw std::system_error(
make_error_code(MicmProcessErrc::RateConstantIsNotSet),
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_RATE_CONSTANT_IS_NOT_SET,
"Cannot copy from a ChemicalReaction with null rate constant");

reactants_ = other.reactants_;
Expand Down Expand Up @@ -101,8 +99,7 @@ namespace micm
void Validate() const
{
if (!rate_constant_)
throw std::system_error(
make_error_code(MicmProcessErrc::RateConstantIsNotSet), "Rate Constant pointer cannot be null");
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_RATE_CONSTANT_IS_NOT_SET, "Rate Constant pointer cannot be null");
}
};

Expand Down
4 changes: 1 addition & 3 deletions include/micm/process/chemical_reaction_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <micm/process/chemical_reaction.hpp>
#include <micm/process/process.hpp>
#include <micm/process/process_error.hpp>
#include <micm/system/phase.hpp>
#include <micm/system/species.hpp>
#include <micm/system/stoich_species.hpp>
Expand Down Expand Up @@ -65,8 +64,7 @@ namespace micm
Process Build()
{
if (!rate_constant_)
throw std::system_error(
make_error_code(MicmProcessErrc::RateConstantIsNotSet), "Rate Constant pointer cannot be null.");
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_RATE_CONSTANT_IS_NOT_SET, "Rate Constant pointer cannot be null.");

ChemicalReaction reaction(std::move(reactants_), std::move(products_), std::move(rate_constant_), phase_);
return Process(std::move(reaction));
Expand Down
7 changes: 2 additions & 5 deletions include/micm/process/phase_transfer_process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <micm/process/process_error.hpp>
#include <micm/process/transfer_coefficient/transfer_coefficient.hpp>
#include <micm/system/phase.hpp>
#include <micm/system/species.hpp>
Expand Down Expand Up @@ -67,8 +66,7 @@ namespace micm
if (this != &other)
{
if (!other.coefficient_)
throw std::system_error(
make_error_code(MicmProcessErrc::TransferCoefficientIsNotSet),
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_TRANSFER_COEFFICIENT_IS_NOT_SET,
"Cannot copy from a PhaseTransferProcess with null coefficient");

gas_phase_ = other.gas_phase_;
Expand All @@ -87,8 +85,7 @@ namespace micm
void Validate() const
{
if (!coefficient_)
throw std::system_error(
make_error_code(MicmProcessErrc::TransferCoefficientIsNotSet),
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_TRANSFER_COEFFICIENT_IS_NOT_SET,
"Phase Transfer Coefficient pointer cannot be null");
}
};
Expand Down
3 changes: 1 addition & 2 deletions include/micm/process/phase_transfer_process_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ namespace micm
Process Build()
{
if (!coefficient_)
throw std::system_error(
make_error_code(MicmProcessErrc::TransferCoefficientIsNotSet),
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_TRANSFER_COEFFICIENT_IS_NOT_SET,
"Phase Transfer Coefficient pointer cannot be null");

PhaseTransferProcess process(
Expand Down
58 changes: 0 additions & 58 deletions include/micm/process/process_error.hpp

This file was deleted.

9 changes: 4 additions & 5 deletions include/micm/process/process_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <micm/external_model.hpp>
#include <micm/process/process.hpp>
#include <micm/process/process_error.hpp>
#include <micm/solver/state.hpp>
#include <micm/util/error.hpp>
#include <micm/util/sparse_matrix.hpp>
Expand Down Expand Up @@ -171,7 +170,7 @@ namespace micm
if (reactant.IsParameterized())
continue; // Skip reactants that are parameterizations
if (variable_map.count(reactant.name_) < 1)
throw std::system_error(make_error_code(MicmProcessErrc::ReactantDoesNotExist), reactant.name_);
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_REACTANT_DOES_NOT_EXIST, reactant.name_);
reactant_ids_.push_back(variable_map.at(reactant.name_));
++number_of_reactants;
}
Expand All @@ -181,7 +180,7 @@ namespace micm
if (product.species_.IsParameterized())
continue; // Skip products that are parameterizations
if (variable_map.count(product.species_.name_) < 1)
throw std::system_error(make_error_code(MicmProcessErrc::ProductDoesNotExist), product.species_.name_);
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_PRODUCT_DOES_NOT_EXIST, product.species_.name_);
product_ids_.push_back(variable_map.at(product.species_.name_));
yields_.push_back(product.coefficient_);
++number_of_products;
Expand Down Expand Up @@ -223,7 +222,7 @@ namespace micm
if (reactant.IsParameterized())
continue; // Skip reactants that are parameterizations
if (variable_map.count(reactant.name_) < 1)
throw std::system_error(make_error_code(MicmProcessErrc::ReactantDoesNotExist), reactant.name_);
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_REACTANT_DOES_NOT_EXIST, reactant.name_);
if (variable_map.at(reactant.name_) == independent_variable.second && !found)
{
found = true;
Expand All @@ -237,7 +236,7 @@ namespace micm
if (product.species_.IsParameterized())
continue; // Skip products that are parameterizations
if (variable_map.count(product.species_.name_) < 1)
throw std::system_error(make_error_code(MicmProcessErrc::ProductDoesNotExist), product.species_.name_);
throw MicmException(MicmSeverity::Error, MICM_ERROR_CATEGORY_PROCESS, MICM_PROCESS_ERROR_CODE_PRODUCT_DOES_NOT_EXIST, product.species_.name_);
jacobian_product_ids_.push_back(variable_map.at(product.species_.name_));
jacobian_yields_.push_back(product.coefficient_);
++info.number_of_products_;
Expand Down
Loading
Loading