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

Remove solver_.parameters_ #668

Merged
merged 55 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
263af07
draft of 621
montythind Sep 24, 2024
da7cd22
second draft
montythind Sep 30, 2024
32a16e2
third draft
montythind Oct 1, 2024
f125b16
darft fourth
montythind Oct 1, 2024
c580d79
Merge branch 'main' into allowSolversToModify_621
montythind Oct 1, 2024
03a8105
test fixed
montythind Oct 2, 2024
0904e97
fix cuda test
montythind Oct 2, 2024
f4cf73a
fix cuda tests
montythind Oct 2, 2024
d67add6
fix again
montythind Oct 2, 2024
ecb857a
cuda test fix
montythind Oct 3, 2024
fefab05
removed params
montythind Oct 14, 2024
c481a0b
added tolerance back
montythind Oct 14, 2024
fdb1fb6
fix cuda tests
montythind Oct 16, 2024
1bc0df6
Merge branch 'main' into allowSolversToModify_621
montythind Oct 17, 2024
9f4b7b3
trying to copy tolerances from state
K20shores Oct 30, 2024
4c84691
updating usage of absolute tolerance
K20shores Nov 6, 2024
1b67f79
removed compile errors
K20shores Nov 7, 2024
3e0d09f
moving relative tolerance
K20shores Nov 7, 2024
a5796b1
fixed some backward euler stuff
K20shores Nov 7, 2024
752519e
removing debug print statements
K20shores Nov 8, 2024
601b79e
correctly setting oregonator tolerances
K20shores Nov 8, 2024
aee4f4f
correctly using tolerances
K20shores Nov 8, 2024
f42bfca
updating jit constructor
K20shores Nov 8, 2024
96ddc42
passing the number of species to the constructor
K20shores Nov 8, 2024
96fbfd0
correcting jit tests
K20shores Nov 11, 2024
09c4df2
uncommenting tests
K20shores Nov 11, 2024
f3c71f7
removing comment
K20shores Nov 11, 2024
59460c6
using same calling convention for analytical tests
K20shores Nov 11, 2024
4b81426
simplifying cuda analytical test interface
K20shores Nov 11, 2024
6112c2c
added tests
montythind Nov 13, 2024
bd1829e
move the copy of absolute tolerance into the cuda state constructor
sjsprecious Nov 15, 2024
130b83c
Merge branch 'allowSolversToModify_621' of github.com:NCAR/micm into …
sjsprecious Nov 15, 2024
5a612d6
fix broken CI test
sjsprecious Nov 15, 2024
bacb558
uncomment a GPU test
sjsprecious Nov 18, 2024
009f6ae
handling merge
K20shores Jan 8, 2025
543d57a
removing more template parameters
K20shores Jan 8, 2025
316d005
removing template parameters
K20shores Jan 8, 2025
a450599
removing template parameters
K20shores Jan 8, 2025
d00baca
removing another
K20shores Jan 8, 2025
ae93072
adding typename
K20shores Jan 8, 2025
8f83390
fixing merge conflict in cuda files
K20shores Jan 8, 2025
b63e8c7
trying to get cuda to compile
K20shores Jan 9, 2025
c6e89ab
getting cuda to compile
K20shores Jan 9, 2025
eceb9a8
merging main
K20shores Jan 9, 2025
10b8ab0
merging again
K20shores Jan 9, 2025
7fb1560
removing variable
K20shores Jan 9, 2025
d2770cf
removing getter
K20shores Jan 9, 2025
69fbc05
Merge branch 'allowSolversToModify_621' of https://github.com/NCAR/mi…
K20shores Jan 9, 2025
f34dfca
merging main
K20shores Jan 13, 2025
bc1ea2f
addressing PR comments
K20shores Jan 13, 2025
8aef106
adding a more explicit test
K20shores Jan 13, 2025
bb6d0b5
correcting cuda build
K20shores Jan 13, 2025
63615bf
correcting timing difference between main and this branch
K20shores Jan 13, 2025
37a8870
initializing relative tolerance
K20shores Jan 14, 2025
757e613
removing std::move
K20shores Jan 14, 2025
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
7 changes: 7 additions & 0 deletions include/micm/solver/solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ namespace micm
return solver_.Solve(time_step, state);
}

// Overloaded Solve function to change parameters
SolverResult Solve(double time_step, StatePolicy& state, RosenbrockSolverParameters params)
{
solver_.parameters_.h_start_ = params.h_start_;
return solver_.Solve(time_step, state);
}
montythind marked this conversation as resolved.
Show resolved Hide resolved

/// @brief Returns the number of grid cells
/// @return
std::size_t GetNumberOfGridCells() const
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cuda/solver/test_cuda_rosenbrock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ TEST(RosenbrockSolver, SingularSystemZeroInBottomRightOfU)
// so H needs to be 1 / ( (-k1 - k2) * gamma)
// since H is positive we need -k1 -k2 to be positive, hence the smaller, negative value for k1
double H = 1 / ((-k1 - k2) * params.gamma_[0]);
vector_solver.solver_.parameters_.h_start_ = H;
params.h_start_ = H;

vector_solver.CalculateRateConstants(vector_state);
vector_state.SyncInputsToDevice();

auto vector_result = vector_solver.Solve(2 * H, vector_state);
auto vector_result = vector_solver.Solve(2 * H, vector_state, params);
vector_state.SyncOutputsToHost();
EXPECT_NE(vector_result.stats_.singular_, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/jit/solver/test_jit_rosenbrock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ TEST(JitRosenbrockSolver, SingularSystemZeroInBottomRightOfU)
// so H needs to be 1 / ( (-k1 - k2) * gamma)
// since H is positive we need -k1 -k2 to be positive, hence the smaller, negative value for k1
double H = 1 / ((-k1 - k2) * params.gamma_[0]);
vector_solver.solver_.parameters_.h_start_ = H;
params.h_start_ = H;

vector_solver.CalculateRateConstants(vector_state);

auto vector_result = vector_solver.Solve(2 * H, vector_state);
auto vector_result = vector_solver.Solve(2 * H, vector_state, params);
EXPECT_NE(vector_result.stats_.singular_, 0);
}

Expand Down
11 changes: 5 additions & 6 deletions test/unit/solver/test_rosenbrock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void testNormalizedErrorDiff(SolverBuilderPolicy builder, std::size_t number_of_
{
builder = getSolver(builder);
auto solver = builder.SetNumberOfGridCells(number_of_grid_cells).Build();
std::vector<double> atol = solver.solver_.parameters_.absolute_tolerance_;
std::vector<double> atol = solver.solver_.parameters_.absolute_tolerance_;
double rtol = solver.solver_.parameters_.relative_tolerance_;

auto state = solver.GetState();
Expand Down Expand Up @@ -172,18 +172,17 @@ TEST(RosenbrockSolver, SingularSystemZeroInBottomRightOfU)
// alpha is 1 / (H * gamma), where H is the time step and gamma is the gamma value from
// the rosenbrock paramters
// so H needs to be 1 / ( (-k1 - k2) * gamma)
// since H is positive we need -k1 -k2 to be positive, hence the smaller, negative value for k1
// since H is positive we need -k1 -k2 to be positive, hence the smaller, negative value for k1
double H = 1 / ((-k1 - k2) * params.gamma_[0]);
standard_solver.solver_.parameters_.h_start_ = H;
vector_solver.solver_.parameters_.h_start_ = H;
params.h_start_ = H;

standard_solver.CalculateRateConstants(standard_state);
vector_solver.CalculateRateConstants(vector_state);

auto standard_result = standard_solver.Solve(2 * H, standard_state);
auto standard_result = standard_solver.Solve(2 * H, standard_state, params);
EXPECT_NE(standard_result.stats_.singular_, 0);

auto vector_result = vector_solver.Solve(2 * H, vector_state);
auto vector_result = vector_solver.Solve(2 * H, vector_state, params);
EXPECT_NE(vector_result.stats_.singular_, 0);
}

Expand Down
Loading