OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
SystemWC.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_WC_H_
33 #define _OMS_SYSTEM_WC_H_
34 
35 #include "ComRef.h"
36 #include "DirectedGraph.h"
37 #include "SignalDerivative.h"
38 #include "StepSizeConfiguration.h"
39 #include "System.h"
40 #include "Types.h"
41 
42 #include <vector>
43 
44 namespace oms
45 {
46  class Model;
47 
48  class SystemWC : public System
49  {
50  public:
51  ~SystemWC();
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, const std::string& sspVersion);
56 
62  oms_status_enu_t stepUntil(double stopTime);
63  oms_status_enu_t stepUntilASSC(double stopTime);
64 
65  std::string getSolverName() const;
66  oms_status_enu_t setSolverMethod(std::string);
68 
69  oms_status_enu_t getInputs(DirectedGraph& graph, std::vector<double>& inputs);
70  oms_status_enu_t setInputsDer(oms::DirectedGraph& graph, const std::vector<double>& inputsDer);
71  oms_status_enu_t getInputAndOutput(DirectedGraph& graph, std::vector<double>& inputVect,std::vector<double>& outputVect,std::map<ComRef, Component*> FMUcomponents);
73 
76  unsigned int getMaxOutputDerivativeOrder();
77 
78  // Functions for configuring assc
81  oms_status_enu_t addStaticValueIndicator(const ComRef& signal, double lowerBound, double upperBound, double stepSize) {return stepSizeConfiguration.addStaticValueIndicator(signal, lowerBound, upperBound, stepSize);}
82  oms_status_enu_t addDynamicValueIndicator(const ComRef& signal,const ComRef& lower,const ComRef& upper,double stepSize) {return stepSizeConfiguration.addDynamicValueIndicator(signal, lower, upper, stepSize);}
83 
86 
87  protected:
88  SystemWC(const ComRef& cref, Model* parentModel, System* parentSystem);
89 
90  // stop the compiler generating methods copying the object
91  SystemWC(SystemWC const& copy);
92  SystemWC& operator=(SystemWC const& copy);
93 
94  private:
96 
97  unsigned int h_id;
98  unsigned int roll_iter_id;
99  unsigned int max_error_id;
100  unsigned int error_id;
101  double stepSize = 1e-4; // Default system stepsize. So first logging step works.
102  double maxError = 0.0;
103  double normError = 0.0;
104  unsigned int rollBackIt = 0;
105 
106  // oms_solver_wc_assc
107  std::vector<std::pair<ComRef, double>> assc_prevDoubleValues;
108  std::vector<std::pair<ComRef, int>> assc_prevIntValues;
109  std::vector<std::pair<ComRef, bool>> assc_prevBoolValues;
110 
111  // oms_solver_wc_ma
112  int masiMax;
113 
114  // oms_solver_wc_mav || oms_solver_wc_mav2
116  std::map<ComRef, Component*> mav_FMUcomponents;
117  std::map<ComRef, Component*> mav_canGetAndSetStateFMUcomponents;
118  };
119 }
120 
121 #endif
unsigned int getMaxOutputDerivativeOrder()
Definition: SystemWC.cpp:220
oms_status_enu_t setRealInputDerivative(const ComRef &cref, const SignalDerivative &der)
Definition: SystemWC.cpp:916
oms_solver_enu_t
Definition: Types.h:96
Definition: Types.h:44
oms_solver_enu_t solverMethod
Definition: System.h:229
Definition: ResultWriter.h:68
Definition: Model.h:56
oms_status_enu_t doStep()
Definition: SystemWC.cpp:367
std::vector< std::pair< ComRef, int > > assc_prevIntValues
Definition: SystemWC.h:108
oms_status_enu_t addStaticValueIndicator(const ComRef &signal, double lowerBound, double upperBound, double stepSize)
Definition: StepSizeConfiguration.cpp:15
oms_status_enu_t instantiate()
Definition: SystemWC.cpp:182
oms_status_enu_t addStaticValueIndicator(const ComRef &signal, double lowerBound, double upperBound, double stepSize)
Definition: SystemWC.h:81
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition: SystemWC.cpp:1099
oms_status_enu_t addEventIndicator(const ComRef &signal)
Definition: SystemWC.h:79
Definition: SystemWC.h:48
~SystemWC()
Definition: SystemWC.cpp:50
oms_status_enu_t reset()
Definition: SystemWC.cpp:352
unsigned int rollBackIt
Definition: SystemWC.h:104
Definition: Types.h:102
double stepSize
Definition: SystemWC.h:101
oms_status_enu_t
Definition: Types.h:43
unsigned int max_error_id
Definition: SystemWC.h:99
ComRef cref
Definition: System.h:241
oms_status_enu_t stepUntilASSC(double stopTime)
Definition: SystemWC.cpp:876
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &der)
Definition: SystemWC.cpp:901
bool mav_doDoubleStep
Definition: SystemWC.h:115
oms_status_enu_t updateSignals(ResultWriter &resultFile)
Definition: SystemWC.cpp:1161
Definition: Types.h:47
oms_status_enu_t updateInputs(DirectedGraph &graph)
Definition: SystemWC.cpp:1028
unsigned int roll_iter_id
Definition: SystemWC.h:98
int masiMax
Definition: SystemWC.h:112
oms_status_enu_t addDynamicValueIndicator(const ComRef &signal, const ComRef &lower, const ComRef &upper, double stepSize)
Definition: StepSizeConfiguration.cpp:41
oms_status_enu_t setSolver(oms_solver_enu_t solver)
Definition: SystemWC.h:67
ComRef - component reference.
Definition: ComRef.h:46
unsigned int error_id
Definition: SystemWC.h:100
oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node &node, const std::string &sspVersion)
Definition: SystemWC.cpp:132
Definition: Types.h:107
std::string getSolverName() const
Definition: SystemWC.cpp:72
oms_status_enu_t terminate()
Definition: SystemWC.cpp:339
oms_status_enu_t setSolverMethod(std::string)
Definition: SystemWC.cpp:89
std::vector< std::pair< ComRef, bool > > assc_prevBoolValues
Definition: SystemWC.h:109
oms_status_enu_t getInputAndOutput(DirectedGraph &graph, std::vector< double > &inputVect, std::vector< double > &outputVect, std::map< ComRef, Component *> FMUcomponents)
Definition: SystemWC.cpp:972
Definition: AlgLoop.h:44
SystemWC(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemWC.cpp:45
Definition: StepSizeConfiguration.h:10
oms_status_enu_t addDynamicValueIndicator(const ComRef &signal, const ComRef &lower, const ComRef &upper, double stepSize)
Definition: SystemWC.h:82
StepSizeConfiguration stepSizeConfiguration
Configuration data structure for assc.
Definition: SystemWC.h:95
static System * NewSystem(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemWC.cpp:54
const char * signal
Definition: Tags.cpp:38
oms_status_enu_t stepUntil(double stopTime)
Definition: SystemWC.cpp:813
oms_status_enu_t initialize()
Definition: SystemWC.cpp:234
std::map< ComRef, Component * > mav_FMUcomponents
Definition: SystemWC.h:116
double maxError
Definition: SystemWC.h:102
Model * parentModel
Definition: System.h:243
unsigned int h_id
Definition: SystemWC.h:97
oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node &node) const
Definition: SystemWC.cpp:105
oms_status_enu_t addTimeIndicator(const ComRef &signal)
Definition: StepSizeConfiguration.cpp:9
oms_status_enu_t getInputs(DirectedGraph &graph, std::vector< double > &inputs)
Definition: SystemWC.cpp:931
oms_status_enu_t setInputsDer(oms::DirectedGraph &graph, const std::vector< double > &inputsDer)
Definition: SystemWC.cpp:952
Definition: System.h:69
std::vector< std::pair< ComRef, double > > assc_prevDoubleValues
Definition: SystemWC.h:107
System * parentSystem
Definition: System.h:244
Definition: DirectedGraph.h:65
double normError
Definition: SystemWC.h:103
std::map< ComRef, Component * > mav_canGetAndSetStateFMUcomponents
Definition: SystemWC.h:117
oms_status_enu_t addTimeIndicator(const ComRef &signal)
Definition: SystemWC.h:80
SystemWC & operator=(SystemWC const &copy)
not implemented
Definition: SignalDerivative.h:41
oms_status_enu_t addEventIndicator(const ComRef &signal)
Definition: StepSizeConfiguration.cpp:3