DPsim
Loading...
Searching...
No Matches
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
22namespace DPsim {
24class ODEintSolver : public Solver {
25
26protected:
28 CPS::ODEintInterface::Ptr mComponent;
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
42private:
44 inline static ODEintSolver *self = nullptr;
46 static void StateSpaceWrapper(const std::vector<double> &y,
47 std::vector<double> ydot, double t);
48
49public:
51 std::vector<Real> curSolution;
53 ODEintSolver(String name, CPS::ODEintInterface::Ptr comp, Real dt, Real t0);
54
56 Real step(Real time);
57
60};
61
62} // namespace DPsim
std::vector< CPS::ODEintInterface::stateFnc > system
ODE of Component.
std::vector< Real > times
Vector containing all timesteps.
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.
int ProbDim
Problem Size.
Real mTimestep
Constant time step.
Real step(Real time)
Solve system for the current time.
std::vector< std::vector< Real > > solution
Vector containing the solution at every timestep.
~ODEintSolver()
Deallocate all memory.
std::vector< Real > curSolution
Current solution vector.
CPS::ODEintInterface::Ptr mComponent
Pointer to current Component.