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);
75 oms_status_enu_t updateInputs(DirectedGraph& graph, bool* changed = nullptr);
76
77 oms_status_enu_t getRealOutputDerivative(const ComRef& cref, SignalDerivative& der);
78 oms_status_enu_t setRealInputDerivative(const ComRef& cref, const SignalDerivative& der);
79 unsigned int getMaxOutputDerivativeOrder();
80
81 oms_status_enu_t registerSignalsForResultFile(ResultWriter& resultFile);
82 oms_status_enu_t updateSignals(ResultWriter& resultFile);
83
84 protected:
85 SystemWC(const ComRef& cref, Model* parentModel, System* parentSystem);
86
87 // stop the compiler generating methods copying the object
88 SystemWC(SystemWC const& copy);
89 SystemWC& operator=(SystemWC const& copy);
90
91 private:
92 unsigned int h_id;
93 unsigned int roll_iter_id;
94 unsigned int max_error_id;
95 unsigned int error_id;
96 double stepSize = 1e-4; // Default system stepsize. So first logging step works.
97 double maxError = 0.0;
98 double normError = 0.0;
99 unsigned int rollBackIt = 0;
100
101 // oms_solver_wc_ma
102 int masiMax;
103
104 // oms_solver_wc_mav || oms_solver_wc_mav2
105 bool mav_doDoubleStep;
106 std::map<ComRef, Component*> mav_FMUcomponents;
107 std::map<ComRef, Component*> mav_canGetAndSetStateFMUcomponents;
108 };
109}
110
111#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:704
oms::SystemWC::mav_FMUcomponents
std::map< ComRef, Component * > mav_FMUcomponents
Definition SystemWC.h:106
oms::SystemWC::getSolverName
std::string getSolverName() const
Definition SystemWC.cpp:76
oms::SystemWC::updateInputs
oms_status_enu_t updateInputs(DirectedGraph &graph, bool *changed=nullptr)
Definition SystemWC.cpp:831
oms::SystemWC::stepUntil
oms_status_enu_t stepUntil(double stopTime)
Definition SystemWC.cpp:644
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:1010
oms::SystemWC::error_id
unsigned int error_id
Definition SystemWC.h:95
oms::SystemWC::roll_iter_id
unsigned int roll_iter_id
Definition SystemWC.h:93
oms::SystemWC::stepSize
double stepSize
Definition SystemWC.h:96
oms::SystemWC::mav_canGetAndSetStateFMUcomponents
std::map< ComRef, Component * > mav_canGetAndSetStateFMUcomponents
Definition SystemWC.h:107
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:734
oms::SystemWC::setInputsDer
oms_status_enu_t setInputsDer(oms::DirectedGraph &graph, const std::vector< double > &inputsDer)
Definition SystemWC.cpp:755
oms::SystemWC::setRealInputDerivative
oms_status_enu_t setRealInputDerivative(const ComRef &cref, const SignalDerivative &der)
Definition SystemWC.cpp:719
oms::SystemWC::max_error_id
unsigned int max_error_id
Definition SystemWC.h:94
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:105
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:775
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:92
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:97
oms::SystemWC::rollBackIt
unsigned int rollBackIt
Definition SystemWC.h:99
oms::SystemWC::normError
double normError
Definition SystemWC.h:98
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:102
oms::SystemWC::registerSignalsForResultFile
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition SystemWC.cpp:937
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:52