DPsim
ODEInterface.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 <dpsim-models/AttributeList.h>
12 #include <dpsim-models/Definitions.h>
13 #include <vector>
14 
15 namespace CPS {
16 class ODEInterface {
17 public:
18  using Ptr = std::shared_ptr<ODEInterface>;
19  //typedef std::vector<Ptr> List;
20 
21  const CPS::AttributeList::Ptr mAttributeList;
22 
23  const CPS::Attribute<Matrix>::Ptr mOdePreState;
24  const CPS::Attribute<Matrix>::Ptr mOdePostState;
25 
27  using StSpFn = std::function<void(double, const double *, double *)>;
28 
29  using JacFn = std::function<void(double, const double *, double *, double *,
30  double *, double *, double *)>;
31 
32  // #### ODE Section ####
34  virtual void odeStateSpace(double t, const double y[], double ydot[]) = 0;
35 
37  virtual void odeJacobian(double t, const double y[], double fy[], double J[],
38  double tmp1[], double tmp2[], double tmp3[]) = 0;
39 
40 protected:
41  explicit ODEInterface(AttributeList::Ptr attrList)
42  : mAttributeList(attrList),
43  mOdePreState(attrList->create<Matrix>("ode_pre_state")),
44  mOdePostState(attrList->create<Matrix>("ode_post_state")) {}
45 };
46 } // namespace CPS
virtual void odeStateSpace(double t, const double y[], double ydot[])=0
State Space Equation System for ODE Solver.
std::function< void(double, const double *, double *)> StSpFn
Use this to pass the individual components StateSpace implementation to the ODESolver class.
Definition: ODEInterface.h:27
virtual void odeJacobian(double t, const double y[], double fy[], double J[], double tmp1[], double tmp2[], double tmp3[])=0
Jacobian Matrix (of State Space System) needed for implicit solve.