OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
SystemSC.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenModelica.
3  *
4  * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5  * c/o Linköpings universitet, Department of Computer and Information Science,
6  * SE-58183 Linköping, Sweden.
7  *
8  * All rights reserved.
9  *
10  * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11  * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12  * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13  * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14  * ACCORDING TO RECIPIENTS CHOICE.
15  *
16  * The OpenModelica software and the Open Source Modelica
17  * Consortium (OSMC) Public License (OSMC-PL) are obtained
18  * from OSMC, either from the above address,
19  * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20  * http://www.openmodelica.org, and in the OpenModelica distribution.
21  * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22  *
23  * This program is distributed WITHOUT ANY WARRANTY; without
24  * even the implied warranty of MERCHANTABILITY or FITNESS
25  * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26  * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27  *
28  * See the full OSMC Public License conditions for more details.
29  *
30  */
31 
32 #ifndef _OMS_SYSTEM_SC_H_
33 #define _OMS_SYSTEM_SC_H_
34 
35 #include "ComRef.h"
36 #include "System.h"
37 #include "Types.h"
38 
39 #include "cvode/cvode.h" /* prototypes for CVODE fcts., consts. */
40 #include "nvector/nvector_serial.h" /* serial N_Vector types, fcts., macros */
41 
42 namespace oms
43 {
44  class Model;
45  class ComponentFMUME;
46  int cvode_rhs(realtype t, N_Vector y, N_Vector ydot, void* user_data);
47 
48  class SystemSC : public System
49  {
50  public:
51  ~SystemSC();
52 
54  oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node& node) const;
55  oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node& node);
56 
61  oms_status_enu_t stepUntil(double stopTime, void (*cb)(const char* ident, double time, oms_status_enu_t status));
62 
63  double getTime() const {return time;}
64 
66  oms_status_enu_t solveAlgLoop(DirectedGraph& graph, const std::vector< std::pair<int, int> >& SCC);
67 
68  std::string getSolverName() const;
69  oms_status_enu_t setSolverMethod(std::string);
70 
72 
73  protected:
74  SystemSC(const ComRef& cref, Model* parentModel, System* parentSystem);
75 
76  // stop the compiler generating methods copying the object
77  SystemSC(SystemSC const& copy);
78  SystemSC& operator=(SystemSC const& copy);
79 
80  private:
81  double time;
82 
83  std::vector<ComponentFMUME*> fmus;
84 
85  std::vector<fmi2_boolean_t> callEventUpdate;
86  std::vector<fmi2_boolean_t> terminateSimulation;
87  std::vector<size_t> nStates;
88  std::vector<size_t> nEventIndicators;
89 
90  std::vector<double*> states;
91  std::vector<double*> states_der;
92  std::vector<double*> states_nominal;
93  std::vector<double*> event_indicators;
94  std::vector<double*> event_indicators_prev;
95 
97  {
98  };
99 
101  {
102  void *mem;
103  N_Vector y;
104  N_Vector abstol;
105  };
106 
108  {
111  } solverData;
112 
113  friend int oms::cvode_rhs(realtype t, N_Vector y, N_Vector ydot, void* user_data);
114  };
115 }
116 
117 #endif
oms_solver_enu_t
Definition: Types.h:84
Definition: Types.h:44
oms_solver_enu_t solverMethod
Definition: System.h:166
Definition: Model.h:48
std::vector< double * > states
Definition: SystemSC.h:90
std::vector< fmi2_boolean_t > terminateSimulation
Definition: SystemSC.h:86
SolverDataEuler_t euler
Definition: SystemSC.h:109
oms_status_enu_t terminate()
Definition: SystemSC.cpp:327
std::vector< ComponentFMUME * > fmus
Definition: SystemSC.h:83
union oms::SystemSC::SolverData_t solverData
double getTime() const
Definition: SystemSC.h:63
oms_status_enu_t initialize()
Definition: SystemSC.cpp:217
N_Vector abstol
Definition: SystemSC.h:104
oms_status_enu_t
Definition: Types.h:43
std::vector< double * > event_indicators
Definition: SystemSC.h:93
ComRef cref
Definition: System.h:174
oms_status_enu_t solveAlgLoop(DirectedGraph &graph, const std::vector< std::pair< int, int > > &SCC)
Definition: SystemSC.cpp:671
std::vector< fmi2_boolean_t > callEventUpdate
Definition: SystemSC.h:85
oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node &node)
Definition: SystemSC.cpp:155
N_Vector y
Definition: SystemSC.h:103
Definition: Types.h:47
void * mem
Definition: SystemSC.h:102
Definition: SystemSC.h:100
std::vector< double * > event_indicators_prev
Definition: SystemSC.h:94
Definition: Types.h:89
ComRef - component reference.
Definition: ComRef.h:43
static System * NewSystem(const oms::ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemSC.cpp:97
oms_status_enu_t stepUntil(double stopTime, void(*cb)(const char *ident, double time, oms_status_enu_t status))
Definition: SystemSC.cpp:433
Definition: SystemSC.h:107
oms_status_enu_t setSolver(oms_solver_enu_t solver)
Definition: SystemSC.h:71
Definition: SystemSC.h:96
oms_status_enu_t updateInputs(DirectedGraph &graph)
Definition: SystemSC.cpp:609
Definition: Types.h:86
int cvode_rhs(realtype t, N_Vector y, N_Vector ydot, void *user_data)
Definition: SystemSC.cpp:47
SystemSC & operator=(SystemSC const &copy)
not implemented
Definition: SystemSC.h:48
Definition: BusConnector.h:15
SystemSC(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemSC.cpp:88
oms_status_enu_t reset()
Definition: SystemSC.cpp:389
std::vector< size_t > nEventIndicators
Definition: SystemSC.h:88
oms_status_enu_t setSolverMethod(std::string)
Definition: SystemSC.cpp:128
oms_status_enu_t instantiate()
Definition: SystemSC.cpp:168
std::vector< size_t > nStates
Definition: SystemSC.h:87
oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node &node) const
Definition: SystemSC.cpp:140
Model * parentModel
Definition: System.h:176
std::vector< double * > states_nominal
Definition: SystemSC.h:92
SolverDataCVODE_t cvode
Definition: SystemSC.h:110
std::vector< double * > states_der
Definition: SystemSC.h:91
double time
Definition: SystemSC.h:81
Definition: System.h:58
System * parentSystem
Definition: System.h:177
std::string getSolverName() const
Definition: SystemSC.cpp:115
Definition: DirectedGraph.h:48
~SystemSC()
Definition: SystemSC.cpp:93