Skip to content

Commit

Permalink
Merge pull request #180 from NCAR/158-add-integration-tests-for-simpl…
Browse files Browse the repository at this point in the history
…e-chemistry-systems

158 add integration tests for simple chemistry systems
  • Loading branch information
K20shores authored Aug 15, 2023
2 parents 2b9ad5d + b998285 commit a8eb895
Show file tree
Hide file tree
Showing 8 changed files with 1,608 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
**/CMakeFiles/
doc/html/
doc/latex/
.vscode
.vscode
xcode/
6 changes: 3 additions & 3 deletions include/micm/process/troe_rate_constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace micm
struct TroeRateConstantParameters
{
/// @brief low-pressure pre-exponential factor
double k0_A_;
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_;
double kinf_A_ = 1.0;
/// @brief high-pressure temperature-scaling parameter
double kinf_B_ = 0.0;
/// @brief high-pressure exponential factor
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace micm
parameters_.kinf_A_ * std::exp(parameters_.kinf_C_ / temperature) * pow(temperature / 300.0, parameters_.kinf_B_);

return k0 * air_number_density / (1.0 + k0 * air_number_density / kinf) *
pow(parameters_.Fc_, 1.0 / (1.0 + 1.0 / parameters_.N_ * pow(log10(k0 * air_number_density / kinf), 2)));
pow(parameters_.Fc_, 1.0 / (1.0 + (1.0 / parameters_.N_) * pow(log10(k0 * air_number_density / kinf), 2)));
}

} // namespace micm
6 changes: 6 additions & 0 deletions include/micm/solver/rosenbrock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ namespace micm
MatrixPolicy<double> temp(Y.size(), Y[0].size(), 0.0);
std::vector<MatrixPolicy<double>> K{};

// parameters_.h_max_ = time_step;
// parameters_.h_start_ = std::max(parameters_.h_min_, delta_min_);

stats_.Reset();
UpdateState(state);

Expand All @@ -727,6 +730,7 @@ namespace micm
double H =
std::min(std::max(std::abs(parameters_.h_min_), std::abs(parameters_.h_start_)), std::abs(parameters_.h_max_));


if (std::abs(H) <= 10 * parameters_.round_off_)
H = delta_min_;

Expand Down Expand Up @@ -772,6 +776,7 @@ namespace micm
{
// the first stage (stage 0), inlined to remove a branch in the following for loop
linear_solver_.template Solve<MatrixPolicy>(forcing, K[0]);
stats_.solves += 1;

// stages (1-# of stages)
for (uint64_t stage = 1; stage < parameters_.stages_; ++stage)
Expand All @@ -795,6 +800,7 @@ namespace micm
}
temp.AsVector().assign(K[stage].AsVector().begin(), K[stage].AsVector().end());
linear_solver_.template Solve<MatrixPolicy>(temp, K[stage]);
stats_.solves += 1;
}
}

Expand Down
3 changes: 3 additions & 0 deletions include/micm/solver/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace micm
std::vector<Conditions> conditions_;
std::map<std::string, std::size_t> variable_map_;
std::map<std::string, std::size_t> custom_rate_parameter_map_;
std::vector<std::string> variable_names_{};
MatrixPolicy<double> variables_;
MatrixPolicy<double> custom_rate_parameters_;
MatrixPolicy<double> rate_constants_;
Expand Down Expand Up @@ -85,6 +86,7 @@ namespace micm
const std::size_t process_size)
: conditions_(1),
variable_map_(),
variable_names_(),
custom_rate_parameter_map_(),
variables_(1, state_size, 0.0),
custom_rate_parameters_(1, custom_parameters_size, 0.0),
Expand All @@ -96,6 +98,7 @@ namespace micm
inline State<MatrixPolicy>::State(const StateParameters parameters)
: conditions_(parameters.number_of_grid_cells_),
variable_map_(),
variable_names_(parameters.state_variable_names_),
custom_rate_parameter_map_(),
variables_(parameters.number_of_grid_cells_, parameters.state_variable_names_.size(), 0.0),
custom_rate_parameters_(parameters.number_of_grid_cells_, parameters.custom_rate_parameter_labels_.size(), 0.0),
Expand Down
3 changes: 2 additions & 1 deletion test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ include(test_util)
################################################################################
# Tests

create_standard_test(NAME chapman_integration SOURCES chapman.cpp)
create_standard_test(NAME chapman_integration SOURCES chapman.cpp)
create_standard_test(NAME analytical_integration SOURCES analytical.cpp)
Loading

0 comments on commit a8eb895

Please sign in to comment.