Add Rosenbrock integrators#479
Conversation
3d9d33b to
e8405a0
Compare
ca6fca6 to
b0ec169
Compare
|
@pelesh I've updated the PR to make use of GridKit's own |
Using a linear solver from Re::Solve is a good thing :). We can add bare KLU interface in a separate PR, if needed. |
5075077 to
cd9e7b8
Compare
shakedregev
left a comment
There was a problem hiding this comment.
Fix the minor issues and good to merge. I tested it.
3155142 to
7c16628
Compare
pelesh
left a comment
There was a problem hiding this comment.
This is very nice work and we can merge it to the feature branch provided the comments below are addressed:
Rosenbrockclass needs to inherit fromDynamicSolverclass so it can be called interchangeably with IDA (and I understand there will be some additional work there but we need to open that door now).- Files
Rosenbrock.*ppshould stay inGridKit/Solver/Dynamicdirectory. For all other files, I suggest moving them to a new directoryGridKit/Solver/Dynamic/Rosenbrock. Rosenbrockand related classes should be inAnalysisManagernamespace, and theIntegratornamespace should be within that to make it consistent with IDA interface.- Consider renaming
Integratornamespace with something likeNativeDynamicSolveror something similar to describe these are solvers native to GridKit, not third party ones (such as SUNDIALS). - File
ResolveMemoryUtils.hppshould not be needed if the linear solver interface is implemented correctly but we can handle that in #489. - A few minor comments below.
| virtual RealT errorNorm(State& err, State& y, State& yprev, GridKit::LinearAlgebra::VectorHandler<ScalarT, IdxT>& handler, GridKit::memory::MemorySpace memspace) const = 0; | ||
| }; |
There was a problem hiding this comment.
Why is this pure virtual? Also, have you considered adding errorNorm as a method in Rosenbrock proper?
There was a problem hiding this comment.
ErrorNorm is just an interface which is implemented by InfNorm. There are different error norms one could want to use. This PR only includes the infinity norm, but the 2 norm is also quite common.
| struct Parameters | ||
| { | ||
| /** | ||
| * @brief The minimum multiple by which the step size can be multiplied to obtain the new step size. | ||
| * Increasing this can allow the integrator to be slightly more conservative in selecting the step size | ||
| * - decreasing the number of steps taken but increasing the risk of failing the next step. | ||
| * |
There was a problem hiding this comment.
Do we really need a nested struct in this class? The class itself is small, nesting a structure with 3 real numbers looks like an overkill to me.
There was a problem hiding this comment.
The nice thing about having a nested Struct is that it is very easy to set default parameters. The user can create an instance of Parameters with all of the defaults and then change a single one of them with 2 lines of code. But then once the parameters are given to the step controller, they are no longer editable.
To support the same operation with these as normal class members of AdaptiveStep would involve having to write getters/setters for every single one of the parameters.
To me a nested struct isn't "overkill" - it doesn't add any maintenance burden or anything. In my opinion it actually removes maintenance burden in this case.
| struct Parameters | ||
| { | ||
| /** | ||
| * @brief A vector of absolute tolerances for each component. The norm will attempt to reject errors | ||
| * in each component above this tolerance. | ||
| * | ||
| */ | ||
| std::unique_ptr<State> abs_tol_; | ||
|
|
||
| /** | ||
| * @brief The relative tolerance. The norm will attempt to reject any error larger in percentage of | ||
| * the solution's maximum element than this. | ||
| * | ||
| */ | ||
| RealT rel_tol_; | ||
| } params_; |
There was a problem hiding this comment.
As previously suggested, a nested struct may be an overkill here.
| class Rosenbrock | ||
| { |
There was a problem hiding this comment.
I think either Rosenbrock or its public interface should inherit from DynamicSolver class. The DynamicSolver should be the one to own the GridKit model.
|
I'm not sure what to do about implementing |
This was an unused artifact - everything has been moved to the ResolveSystemSolver.
Description
Add Rosenbrock integrators, which are lighter-weight alternatives to IDA that work well with co-simulation.
Proposed changes
The current version depends on ReSolve and needs porting work to be used with GridKit vectors. The operations used by the Rosenbrock integrators are:
This PR also need's ReSolve's
SystemSolverto be ported.As well, I think some more testing wouldn't go amiss... An integration test on an example power grid would work nicely.
Checklist
-Wall -Wpedantic -Wconversion -Wextra.Further comments