OMSimulatorLib The OMSimulator project is a FMI-based co-simulation environment.

Loading...
Searching...
No Matches
SystemWC.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, 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 AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36#ifndef _OMS_SYSTEM_WC_H_
37#define _OMS_SYSTEM_WC_H_
38
39#include "ComRef.h"
40#include "DirectedGraph.h"
41#include "SignalDerivative.h"
42#include "System.h"
43#include "OMSimulator/Types.h"
44
45#include <vector>
46
47 namespace oms
48{
49 class Model;
50
51 class SystemWC : public System
52 {
53 public:
54 ~SystemWC();
55
56 static System* NewSystem(const ComRef& cref, Model* parentModel, System* parentSystem);
57 oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node& node) const;
58 oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node& node, const std::string& sspVersion);
59
60 oms_status_enu_t instantiate();
61 oms_status_enu_t initialize();
62 oms_status_enu_t terminate();
63 oms_status_enu_t reset();
64 oms_status_enu_t doStep();
65 oms_status_enu_t stepUntil(double stopTime);
66
67 std::string getSolverName() const;
68 oms_status_enu_t setSolverMethod(std::string);
69 oms_status_enu_t setSolver(oms_solver_enu_t solver) {if (solver > oms_solver_wc_min && solver < oms_solver_wc_max) {solverMethod=solver; return oms_status_ok;} return oms_status_error;}
70
71 oms_status_enu_t getInputs(DirectedGraph& graph, std::vector<double>& inputs);
72 oms_status_enu_t setInputsDer(oms::DirectedGraph& graph, const std::vector<double>& inputsDer);
73 oms_status_enu_t getInputAndOutput(DirectedGraph& graph, std::vector<double>& inputVect,std::vector<double>& outputVect,std::map<ComRef, Component*> FMUcomponents);
74 oms_status_enu_t updateInputs(DirectedGraph& graph);
75
76 oms_status_enu_t getRealOutputDerivative(const ComRef& cref, SignalDerivative& der);
77 oms_status_enu_t setRealInputDerivative(const ComRef& cref, const SignalDerivative& der);
78 unsigned int getMaxOutputDerivativeOrder();
79
80 oms_status_enu_t registerSignalsForResultFile(ResultWriter& resultFile);
81 oms_status_enu_t updateSignals(ResultWriter& resultFile);
82
83 protected:
84 SystemWC(const ComRef& cref, Model* parentModel, System* parentSystem);
85
86 // stop the compiler generating methods copying the object
87 SystemWC(SystemWC const& copy);
88 SystemWC& operator=(SystemWC const& copy);
89
90 private:
91 unsigned int h_id;
92 unsigned int roll_iter_id;
93 unsigned int max_error_id;
94 unsigned int error_id;
95 double stepSize = 1e-4; // Default system stepsize. So first logging step works.
96 double maxError = 0.0;
97 double normError = 0.0;
98 unsigned int rollBackIt = 0;
99
100 // oms_solver_wc_ma
101 int masiMax;
102
103 // oms_solver_wc_mav || oms_solver_wc_mav2
104 bool mav_doDoubleStep;
105 std::map<ComRef, Component*> mav_FMUcomponents;
106 std::map<ComRef, Component*> mav_canGetAndSetStateFMUcomponents;
107 };
108}
109
110#endif
ComRef.h
DirectedGraph.h
SignalDerivative.h
System.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:51
oms::DirectedGraph
Definition DirectedGraph.h:71
oms::Model
Definition Model.h:57
oms::ResultWriter
Definition ResultWriter.h:73
oms::SignalDerivative
Definition SignalDerivative.h:46
oms::SystemWC
Definition SystemWC.h:52
oms::SystemWC::getRealOutputDerivative
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &der)
Definition SystemWC.cpp:699
oms::SystemWC::mav_FMUcomponents
std::map< ComRef, Component * > mav_FMUcomponents
Definition SystemWC.h:105
oms::SystemWC::getSolverName
std::string getSolverName() const
Definition SystemWC.cpp:76
oms::SystemWC::updateInputs
oms_status_enu_t updateInputs(DirectedGraph &graph)
Definition SystemWC.cpp:826
oms::SystemWC::stepUntil
oms_status_enu_t stepUntil(double stopTime)
Definition SystemWC.cpp:639
oms::SystemWC::setSolver
oms_status_enu_t setSolver(oms_solver_enu_t solver)
Definition SystemWC.h:69
oms::SystemWC::~SystemWC
~SystemWC()
Definition SystemWC.cpp:54
oms::SystemWC::operator=
SystemWC & operator=(SystemWC const &copy)
not implemented
oms::SystemWC::terminate
oms_status_enu_t terminate()
Definition SystemWC.cpp:304
oms::SystemWC::updateSignals
oms_status_enu_t updateSignals(ResultWriter &resultFile)
Definition SystemWC.cpp:970
oms::SystemWC::error_id
unsigned int error_id
Definition SystemWC.h:94
oms::SystemWC::roll_iter_id
unsigned int roll_iter_id
Definition SystemWC.h:92
oms::SystemWC::stepSize
double stepSize
Definition SystemWC.h:95
oms::SystemWC::mav_canGetAndSetStateFMUcomponents
std::map< ComRef, Component * > mav_canGetAndSetStateFMUcomponents
Definition SystemWC.h:106
oms::SystemWC::reset
oms_status_enu_t reset()
Definition SystemWC.cpp:317
oms::SystemWC::getInputs
oms_status_enu_t getInputs(DirectedGraph &graph, std::vector< double > &inputs)
Definition SystemWC.cpp:729
oms::SystemWC::setInputsDer
oms_status_enu_t setInputsDer(oms::DirectedGraph &graph, const std::vector< double > &inputsDer)
Definition SystemWC.cpp:750
oms::SystemWC::setRealInputDerivative
oms_status_enu_t setRealInputDerivative(const ComRef &cref, const SignalDerivative &der)
Definition SystemWC.cpp:714
oms::SystemWC::max_error_id
unsigned int max_error_id
Definition SystemWC.h:93
oms::SystemWC::doStep
oms_status_enu_t doStep()
Definition SystemWC.cpp:332
oms::SystemWC::NewSystem
static System * NewSystem(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition SystemWC.cpp:58
oms::SystemWC::mav_doDoubleStep
bool mav_doDoubleStep
Definition SystemWC.h:104
oms::SystemWC::instantiate
oms_status_enu_t instantiate()
Definition SystemWC.cpp:179
oms::SystemWC::initialize
oms_status_enu_t initialize()
Definition SystemWC.cpp:231
oms::SystemWC::getInputAndOutput
oms_status_enu_t getInputAndOutput(DirectedGraph &graph, std::vector< double > &inputVect, std::vector< double > &outputVect, std::map< ComRef, Component * > FMUcomponents)
Definition SystemWC.cpp:770
oms::SystemWC::setSolverMethod
oms_status_enu_t setSolverMethod(std::string)
Definition SystemWC.cpp:91
oms::SystemWC::importFromSSD_SimulationInformation
oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node &node, const std::string &sspVersion)
Definition SystemWC.cpp:131
oms::SystemWC::h_id
unsigned int h_id
Definition SystemWC.h:91
oms::SystemWC::SystemWC
SystemWC(SystemWC const &copy)
not implemented
oms::SystemWC::getMaxOutputDerivativeOrder
unsigned int getMaxOutputDerivativeOrder()
Definition SystemWC.cpp:217
oms::SystemWC::maxError
double maxError
Definition SystemWC.h:96
oms::SystemWC::rollBackIt
unsigned int rollBackIt
Definition SystemWC.h:98
oms::SystemWC::normError
double normError
Definition SystemWC.h:97
oms::SystemWC::exportToSSD_SimulationInformation
oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node &node) const
Definition SystemWC.cpp:105
oms::SystemWC::masiMax
int masiMax
Definition SystemWC.h:101
oms::SystemWC::registerSignalsForResultFile
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition SystemWC.cpp:901
oms::System
Definition System.h:66
oms::System::cref
ComRef cref
Definition System.h:232
oms::System::solverMethod
oms_solver_enu_t solverMethod
Definition System.h:221
oms::System::parentSystem
System * parentSystem
Definition System.h:235
oms::System::parentModel
Model * parentModel
Definition System.h:234
oms
Definition AlgLoop.h:49