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 #include <vector>
42 
43 namespace oms
44 {
45  class Model;
46 
47  class SystemWC : public System
48  {
49  public:
50  ~SystemWC();
51 
53  oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node& node) const;
54  oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node& node, const std::string& sspVersion);
55 
60  oms_status_enu_t stepUntil(double stopTime, void (*cb)(const char* ident, double time, oms_status_enu_t status));
61  oms_status_enu_t stepUntilASSC(double stopTime, void (*cb)(const char* ident, double time, oms_status_enu_t status));
62 
63  std::string getSolverName() const;
64  oms_status_enu_t setSolverMethod(std::string);
66 
67  oms_status_enu_t getInputs(DirectedGraph& graph, std::vector<double>& inputs);
68  oms_status_enu_t setInputsDer(oms::DirectedGraph& graph, const std::vector<double>& inputsDer);
69  oms_status_enu_t getInputAndOutput(DirectedGraph& graph, std::vector<double>& inputVect,std::vector<double>& outputVect,std::map<ComRef, Component*> FMUcomponents);
71 
74  unsigned int getMaxOutputDerivativeOrder();
75 
76  // Functions for configuring assc
79  oms_status_enu_t addStaticValueIndicator(const ComRef& signal, double lowerBound, double upperBound, double stepSize) {return stepSizeConfiguration.addStaticValueIndicator(signal, lowerBound, upperBound, stepSize);}
80  oms_status_enu_t addDynamicValueIndicator(const ComRef& signal,const ComRef& lower,const ComRef& upper,double stepSize) {return stepSizeConfiguration.addDynamicValueIndicator(signal, lower, upper, stepSize);}
81 
84 
85  protected:
86  SystemWC(const ComRef& cref, Model* parentModel, System* parentSystem);
87 
88  // stop the compiler generating methods copying the object
89  SystemWC(SystemWC const& copy);
90  SystemWC& operator=(SystemWC const& copy);
91 
92  private:
94 
95  unsigned int h_id;
96  unsigned int roll_iter_id;
97  unsigned int max_error_id;
98  unsigned int error_id;
99  double stepSize = 1e-4; // Default system stepsize. So first logging step works.
100  double maxError = 0.0;
101  double normError = 0.0;
102  unsigned int rollBackIt = 0;
103  };
104 }
105 
106 #endif
unsigned int getMaxOutputDerivativeOrder()
Definition: SystemWC.cpp:183
oms_status_enu_t setRealInputDerivative(const ComRef &cref, const SignalDerivative &der)
Definition: SystemWC.cpp:904
oms_solver_enu_t
Definition: Types.h:96
Definition: Types.h:44
oms_solver_enu_t solverMethod
Definition: System.h:192
Definition: ResultWriter.h:68
Definition: Model.h:54
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:145
oms_status_enu_t addStaticValueIndicator(const ComRef &signal, double lowerBound, double upperBound, double stepSize)
Definition: SystemWC.h:79
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition: SystemWC.cpp:1077
oms_status_enu_t addEventIndicator(const ComRef &signal)
Definition: SystemWC.h:77
Definition: SystemWC.h:47
~SystemWC()
Definition: SystemWC.cpp:51
oms_status_enu_t reset()
Definition: SystemWC.cpp:238
unsigned int rollBackIt
Definition: SystemWC.h:102
Definition: Types.h:102
double stepSize
Definition: SystemWC.h:99
oms_status_enu_t
Definition: Types.h:43
unsigned int max_error_id
Definition: SystemWC.h:97
ComRef cref
Definition: System.h:207
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &der)
Definition: SystemWC.cpp:889
oms_status_enu_t updateSignals(ResultWriter &resultFile)
Definition: SystemWC.cpp:1139
Definition: Types.h:47
oms_status_enu_t updateInputs(DirectedGraph &graph)
Definition: SystemWC.cpp:1014
unsigned int roll_iter_id
Definition: SystemWC.h:96
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:65
ComRef - component reference.
Definition: ComRef.h:43
unsigned int error_id
Definition: SystemWC.h:98
oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node &node, const std::string &sspVersion)
Definition: SystemWC.cpp:120
Definition: Types.h:107
std::string getSolverName() const
Definition: SystemWC.cpp:73
oms_status_enu_t terminate()
Definition: SystemWC.cpp:225
oms_status_enu_t setSolverMethod(std::string)
Definition: SystemWC.cpp:90
oms_status_enu_t getInputAndOutput(DirectedGraph &graph, std::vector< double > &inputVect, std::vector< double > &outputVect, std::map< ComRef, Component *> FMUcomponents)
Definition: SystemWC.cpp:960
Definition: AlgLoop.h:44
SystemWC(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemWC.cpp:46
Definition: StepSizeConfiguration.h:10
oms_status_enu_t addDynamicValueIndicator(const ComRef &signal, const ComRef &lower, const ComRef &upper, double stepSize)
Definition: SystemWC.h:80
StepSizeConfiguration stepSizeConfiguration
Configuration data structure for assc.
Definition: SystemWC.h:93
static System * NewSystem(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition: SystemWC.cpp:55
double time
Definition: System.h:178
const char * signal
Definition: Tags.cpp:38
oms_status_enu_t initialize()
Definition: SystemWC.cpp:197
double maxError
Definition: SystemWC.h:100
Model * parentModel
Definition: System.h:209
unsigned int h_id
Definition: SystemWC.h:95
oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node &node) const
Definition: SystemWC.cpp:106
oms_status_enu_t stepUntil(double stopTime, void(*cb)(const char *ident, double time, oms_status_enu_t status))
Definition: SystemWC.cpp:253
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:919
oms_status_enu_t setInputsDer(oms::DirectedGraph &graph, const std::vector< double > &inputsDer)
Definition: SystemWC.cpp:940
oms_status_enu_t stepUntilASSC(double stopTime, void(*cb)(const char *ident, double time, oms_status_enu_t status))
Definition: SystemWC.cpp:679
Definition: System.h:67
System * parentSystem
Definition: System.h:210
Definition: DirectedGraph.h:55
double normError
Definition: SystemWC.h:101
oms_status_enu_t addTimeIndicator(const ComRef &signal)
Definition: SystemWC.h:78
SystemWC & operator=(SystemWC const &copy)
not implemented
Definition: SignalDerivative.h:41
oms_status_enu_t addEventIndicator(const ComRef &signal)
Definition: StepSizeConfiguration.cpp:3