DPsim
ODEintSolver.h
1 /* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2  * EONERC, RWTH Aachen University
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7  *********************************************************************************/
8 
9 #pragma once
10 
11 #include <iostream>
12 #include <list>
13 #include <vector>
14 
15 #include <dpsim-models/Solver/ODEintInterface.h>
16 #include <dpsim-models/SystemTopology.h>
17 #include <dpsim/Solver.h>
18 
19 #include <boost/numeric/odeint/integrate/integrate_const.hpp> //ODEInt Integrator with constant time step
20 #include <boost/numeric/odeint/stepper/runge_kutta4.hpp> //ODEInt Runge-Kutta stepper
21 
22 namespace DPsim {
24 class ODEintSolver : public Solver {
25 
26 protected:
28  CPS::ODEintInterface::Ptr mComponent;
30  Real mTimestep;
32  int ProbDim;
34  boost::numeric::odeint::runge_kutta4<std::vector<Real>> stepper;
36  std::vector<std::vector<Real>> solution;
38  std::vector<Real> times;
40  std::vector<CPS::ODEintInterface::stateFnc> system;
41 
42 private:
44  inline static ODEintSolver *self = nullptr;
46  static void StateSpaceWrapper(const std::vector<double> &y,
47  std::vector<double> ydot, double t);
48 
49 public:
51  std::vector<Real> curSolution;
53  ODEintSolver(String name, CPS::ODEintInterface::Ptr comp, Real dt, Real t0);
54 
56  Real step(Real time);
57 
59  ~ODEintSolver();
60 };
61 
62 } // namespace DPsim
Solver class which uses ODE systems.
Definition: ODEintSolver.h:24
std::vector< CPS::ODEintInterface::stateFnc > system
ODE of Component.
Definition: ODEintSolver.h:40
std::vector< Real > times
Vector containing all timesteps.
Definition: ODEintSolver.h:38
ODEintSolver(String name, CPS::ODEintInterface::Ptr comp, Real dt, Real t0)
Create solve object with given parameters.
boost::numeric::odeint::runge_kutta4< std::vector< Real > > stepper
Stepper needed by ODEint.
Definition: ODEintSolver.h:34
int ProbDim
Problem Size.
Definition: ODEintSolver.h:32
Real mTimestep
Constant time step.
Definition: ODEintSolver.h:30
Real step(Real time)
Solve system for the current time.
std::vector< std::vector< Real > > solution
Vector containing the solution at every timestep.
Definition: ODEintSolver.h:36
~ODEintSolver()
Deallocate all memory.
std::vector< Real > curSolution
Current solution vector.
Definition: ODEintSolver.h:51
CPS::ODEintInterface::Ptr mComponent
Pointer to current Component.
Definition: ODEintSolver.h:28
Base class for more specific solvers such as MNA, ODE or IDA.
Definition: Solver.h:30