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-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 "System.h"
39#include "OMSimulator/Types.h"
40
41#include <vector>
42
43 namespace oms
44{
45 class Model;
46
47 class SystemWC : public System
48 {
49 public:
50 ~SystemWC();
51
52 static System* NewSystem(const ComRef& cref, Model* parentModel, System* parentSystem);
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
56 oms_status_enu_t instantiate();
57 oms_status_enu_t initialize();
58 oms_status_enu_t terminate();
59 oms_status_enu_t reset();
60 oms_status_enu_t doStep();
61 oms_status_enu_t stepUntil(double stopTime);
62
63 std::string getSolverName() const;
64 oms_status_enu_t setSolverMethod(std::string);
65 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;}
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);
70 oms_status_enu_t updateInputs(DirectedGraph& graph);
71
72 oms_status_enu_t getRealOutputDerivative(const ComRef& cref, SignalDerivative& der);
73 oms_status_enu_t setRealInputDerivative(const ComRef& cref, const SignalDerivative& der);
74 unsigned int getMaxOutputDerivativeOrder();
75
76 oms_status_enu_t registerSignalsForResultFile(ResultWriter& resultFile);
77 oms_status_enu_t updateSignals(ResultWriter& resultFile);
78
79 protected:
80 SystemWC(const ComRef& cref, Model* parentModel, System* parentSystem);
81
82 // stop the compiler generating methods copying the object
83 SystemWC(SystemWC const& copy);
84 SystemWC& operator=(SystemWC const& copy);
85
86 private:
87 unsigned int h_id;
88 unsigned int roll_iter_id;
89 unsigned int max_error_id;
90 unsigned int error_id;
91 double stepSize = 1e-4; // Default system stepsize. So first logging step works.
92 double maxError = 0.0;
93 double normError = 0.0;
94 unsigned int rollBackIt = 0;
95
96 // oms_solver_wc_ma
97 int masiMax;
98
99 // oms_solver_wc_mav || oms_solver_wc_mav2
100 bool mav_doDoubleStep;
101 std::map<ComRef, Component*> mav_FMUcomponents;
102 std::map<ComRef, Component*> mav_canGetAndSetStateFMUcomponents;
103 };
104}
105
106#endif
ComRef.h
DirectedGraph.h
SignalDerivative.h
System.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:47
oms::DirectedGraph
Definition DirectedGraph.h:65
oms::Model
Definition Model.h:53
oms::ResultWriter
Definition ResultWriter.h:69
oms::SignalDerivative
Definition SignalDerivative.h:42
oms::SystemWC
Definition SystemWC.h:48
oms::SystemWC::getRealOutputDerivative
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &der)
Definition SystemWC.cpp:695
oms::SystemWC::mav_FMUcomponents
std::map< ComRef, Component * > mav_FMUcomponents
Definition SystemWC.h:101
oms::SystemWC::getSolverName
std::string getSolverName() const
Definition SystemWC.cpp:72
oms::SystemWC::updateInputs
oms_status_enu_t updateInputs(DirectedGraph &graph)
Definition SystemWC.cpp:822
oms::SystemWC::stepUntil
oms_status_enu_t stepUntil(double stopTime)
Definition SystemWC.cpp:635
oms::SystemWC::setSolver
oms_status_enu_t setSolver(oms_solver_enu_t solver)
Definition SystemWC.h:65
oms::SystemWC::~SystemWC
~SystemWC()
Definition SystemWC.cpp:50
oms::SystemWC::operator=
SystemWC & operator=(SystemWC const &copy)
not implemented
oms::SystemWC::terminate
oms_status_enu_t terminate()
Definition SystemWC.cpp:300
oms::SystemWC::updateSignals
oms_status_enu_t updateSignals(ResultWriter &resultFile)
Definition SystemWC.cpp:962
oms::SystemWC::error_id
unsigned int error_id
Definition SystemWC.h:90
oms::SystemWC::roll_iter_id
unsigned int roll_iter_id
Definition SystemWC.h:88
oms::SystemWC::stepSize
double stepSize
Definition SystemWC.h:91
oms::SystemWC::mav_canGetAndSetStateFMUcomponents
std::map< ComRef, Component * > mav_canGetAndSetStateFMUcomponents
Definition SystemWC.h:102
oms::SystemWC::reset
oms_status_enu_t reset()
Definition SystemWC.cpp:313
oms::SystemWC::getInputs
oms_status_enu_t getInputs(DirectedGraph &graph, std::vector< double > &inputs)
Definition SystemWC.cpp:725
oms::SystemWC::setInputsDer
oms_status_enu_t setInputsDer(oms::DirectedGraph &graph, const std::vector< double > &inputsDer)
Definition SystemWC.cpp:746
oms::SystemWC::setRealInputDerivative
oms_status_enu_t setRealInputDerivative(const ComRef &cref, const SignalDerivative &der)
Definition SystemWC.cpp:710
oms::SystemWC::max_error_id
unsigned int max_error_id
Definition SystemWC.h:89
oms::SystemWC::doStep
oms_status_enu_t doStep()
Definition SystemWC.cpp:328
oms::SystemWC::NewSystem
static System * NewSystem(const ComRef &cref, Model *parentModel, System *parentSystem)
Definition SystemWC.cpp:54
oms::SystemWC::mav_doDoubleStep
bool mav_doDoubleStep
Definition SystemWC.h:100
oms::SystemWC::instantiate
oms_status_enu_t instantiate()
Definition SystemWC.cpp:175
oms::SystemWC::initialize
oms_status_enu_t initialize()
Definition SystemWC.cpp:227
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:766
oms::SystemWC::setSolverMethod
oms_status_enu_t setSolverMethod(std::string)
Definition SystemWC.cpp:87
oms::SystemWC::importFromSSD_SimulationInformation
oms_status_enu_t importFromSSD_SimulationInformation(const pugi::xml_node &node, const std::string &sspVersion)
Definition SystemWC.cpp:127
oms::SystemWC::h_id
unsigned int h_id
Definition SystemWC.h:87
oms::SystemWC::SystemWC
SystemWC(SystemWC const &copy)
not implemented
oms::SystemWC::getMaxOutputDerivativeOrder
unsigned int getMaxOutputDerivativeOrder()
Definition SystemWC.cpp:213
oms::SystemWC::maxError
double maxError
Definition SystemWC.h:92
oms::SystemWC::rollBackIt
unsigned int rollBackIt
Definition SystemWC.h:94
oms::SystemWC::normError
double normError
Definition SystemWC.h:93
oms::SystemWC::exportToSSD_SimulationInformation
oms_status_enu_t exportToSSD_SimulationInformation(pugi::xml_node &node) const
Definition SystemWC.cpp:101
oms::SystemWC::masiMax
int masiMax
Definition SystemWC.h:97
oms::SystemWC::registerSignalsForResultFile
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition SystemWC.cpp:893
oms::System
Definition System.h:62
oms::System::cref
ComRef cref
Definition System.h:225
oms::System::solverMethod
oms_solver_enu_t solverMethod
Definition System.h:214
oms::System::parentSystem
System * parentSystem
Definition System.h:228
oms::System::parentModel
Model * parentModel
Definition System.h:227
oms
Definition AlgLoop.h:45