Skip to content

Commit 10fc0eb

Browse files
committed
-added RTEuler
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25425 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 9d6750f commit 10fc0eb

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#if defined(__vxworks)
4+
5+
#define BOOST_EXTENSION_SOLVER_DECL
6+
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL
7+
8+
#elif defined(RUNTIME_STATIC_LINKING) && (defined(OMC_BUILD) || defined(SIMSTER_BUILD))
9+
10+
#define BOOST_EXTENSION_SOLVER_DECL
11+
#define BOOST_EXTENSION_STATESELECT_DECL
12+
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL
13+
#define BOOST_EXTENSION_MONITOR_DECL
14+
15+
#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD)
16+
17+
#define BOOST_EXTENSION_SOLVER_DECL BOOST_EXTENSION_IMPORT_DECL
18+
#define BOOST_EXTENSION_STATESELECT_DECL BOOST_EXTENSION_IMPORT_DECL
19+
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL BOOST_EXTENSION_IMPORT_DECL
20+
#define BOOST_EXTENSION_MONITOR_DECL BOOST_EXTENSION_IMPORT_DECL
21+
#else
22+
error "operating system not supported"
23+
#endif
24+
25+
26+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#pragma once
2+
3+
#include "FactoryExport.h"
4+
#include <Core/Solver/SolverDefaultImplementation.h>
5+
6+
class IEulerSettings;
7+
8+
/*****************************************************************************/
9+
/**
10+
11+
Euler method for the solution of a non-stiff initial value problem of a system
12+
of ordinary differantial equations of the form
13+
14+
z' = f(t,z).
15+
16+
Dense output may be used. Zero crossing are detected by bisection or linear
17+
interpolation.
18+
19+
\date 01.09.2008
20+
\author
21+
22+
23+
*/
24+
/*****************************************************************************
25+
Copyright (c) 2008, OSMC
26+
*****************************************************************************/
27+
class RTEuler : public ISolver, public SolverDefaultImplementation
28+
{
29+
public:
30+
RTEuler(IMixedSystem* system, ISolverSettings* settings);
31+
virtual ~RTEuler();
32+
33+
/// Set start time for numerical solution
34+
virtual void setStartTime(const double& t);
35+
36+
/// Set end time for numerical solution
37+
virtual void setEndTime(const double& t);
38+
39+
/// Set the initial step size (needed for reinitialization after external zero search)
40+
virtual void setInitStepSize(const double& h);
41+
42+
/// (Re-) initialize the solver
43+
virtual void initialize();
44+
45+
/// Approximation of the numerical solution in a given time interval
46+
virtual void solve(const SOLVERCALL command = UNDEF_CALL);
47+
48+
/// Provides the status of the solver after returning
49+
virtual ISolver::SOLVERSTATUS getSolverStatus();
50+
51+
/// Write out statistical information (statistical information of last simulation, e.g. time, number of steps, etc.)
52+
virtual void writeSimulationInfo();
53+
54+
/// Indicates whether a solver error occurred during integration, returns type of error and provides error message
55+
virtual const int reportErrorMessage(ostream& messageStream);
56+
virtual bool stateSelection();
57+
virtual void setTimeOut(unsigned int time_out);
58+
59+
virtual void stop();
60+
61+
private:
62+
63+
/// Encapsulation of determination of right hand side
64+
void calcFunction(const double& t, const double* z, double* zDot);
65+
66+
void doRK1();
67+
68+
// Member variables
69+
//---------------------------------------------------------------
70+
ISolverSettings
71+
*_eulerSettings; ///< Settings for the solver
72+
73+
long int
74+
_dimSys; ///< Temp - (total) Dimension of systems (=number of ODE)
75+
76+
77+
double _tHelp;
78+
double
79+
*_z, ///< Temp - State vector
80+
*_zInit, ///< Temp - Initial state vector
81+
*_f; ///< Temp - function evaluation ///< Temp - yhelp and fhelp only provided in order to avoid multiple generation of save
82+
83+
ISystemProperties* _properties;
84+
IContinuous* _continuous_system;
85+
IEvent* _event_system;
86+
IMixedSystem* _mixed_system;
87+
ITime* _time_system;
88+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
#include "FactoryExport.h"
3+
#include <Core/Solver/SolverSettings.h>
4+
5+
6+
/*****************************************************************************/
7+
/**
8+
9+
Encapsulation of settings for euler solver
10+
11+
\date October, 1st, 2008
12+
\author
13+
14+
15+
*/
16+
/*****************************************************************************
17+
Copyright (c) 2008, OSMC
18+
*****************************************************************************/
19+
class RTEulerSettings : public SolverSettings
20+
{
21+
22+
public:
23+
RTEulerSettings(IGlobalSettings* globalSettings);
24+
25+
virtual void load(std::string xml_file);
26+
private:
27+
28+
29+
};

0 commit comments

Comments
 (0)