Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25425 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
SimulationRuntime/cpp/Include/Solver/RTEuler/FactoryExport.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#if defined(__vxworks) | ||
|
||
#define BOOST_EXTENSION_SOLVER_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL | ||
|
||
#elif defined(RUNTIME_STATIC_LINKING) && (defined(OMC_BUILD) || defined(SIMSTER_BUILD)) | ||
|
||
#define BOOST_EXTENSION_SOLVER_DECL | ||
#define BOOST_EXTENSION_STATESELECT_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL | ||
#define BOOST_EXTENSION_MONITOR_DECL | ||
|
||
#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD) | ||
|
||
#define BOOST_EXTENSION_SOLVER_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_STATESELECT_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_MONITOR_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#else | ||
error "operating system not supported" | ||
#endif | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#pragma once | ||
|
||
#include "FactoryExport.h" | ||
#include <Core/Solver/SolverDefaultImplementation.h> | ||
|
||
class IEulerSettings; | ||
|
||
/*****************************************************************************/ | ||
/** | ||
Euler method for the solution of a non-stiff initial value problem of a system | ||
of ordinary differantial equations of the form | ||
z' = f(t,z). | ||
Dense output may be used. Zero crossing are detected by bisection or linear | ||
interpolation. | ||
\date 01.09.2008 | ||
\author | ||
*/ | ||
/***************************************************************************** | ||
Copyright (c) 2008, OSMC | ||
*****************************************************************************/ | ||
class RTEuler : public ISolver, public SolverDefaultImplementation | ||
{ | ||
public: | ||
RTEuler(IMixedSystem* system, ISolverSettings* settings); | ||
virtual ~RTEuler(); | ||
|
||
/// Set start time for numerical solution | ||
virtual void setStartTime(const double& t); | ||
|
||
/// Set end time for numerical solution | ||
virtual void setEndTime(const double& t); | ||
|
||
/// Set the initial step size (needed for reinitialization after external zero search) | ||
virtual void setInitStepSize(const double& h); | ||
|
||
/// (Re-) initialize the solver | ||
virtual void initialize(); | ||
|
||
/// Approximation of the numerical solution in a given time interval | ||
virtual void solve(const SOLVERCALL command = UNDEF_CALL); | ||
|
||
/// Provides the status of the solver after returning | ||
virtual ISolver::SOLVERSTATUS getSolverStatus(); | ||
|
||
/// Write out statistical information (statistical information of last simulation, e.g. time, number of steps, etc.) | ||
virtual void writeSimulationInfo(); | ||
|
||
/// Indicates whether a solver error occurred during integration, returns type of error and provides error message | ||
virtual const int reportErrorMessage(ostream& messageStream); | ||
virtual bool stateSelection(); | ||
virtual void setTimeOut(unsigned int time_out); | ||
|
||
virtual void stop(); | ||
|
||
private: | ||
|
||
/// Encapsulation of determination of right hand side | ||
void calcFunction(const double& t, const double* z, double* zDot); | ||
|
||
void doRK1(); | ||
|
||
// Member variables | ||
//--------------------------------------------------------------- | ||
ISolverSettings | ||
*_eulerSettings; ///< Settings for the solver | ||
|
||
long int | ||
_dimSys; ///< Temp - (total) Dimension of systems (=number of ODE) | ||
|
||
|
||
double _tHelp; | ||
double | ||
*_z, ///< Temp - State vector | ||
*_zInit, ///< Temp - Initial state vector | ||
*_f; ///< Temp - function evaluation ///< Temp - yhelp and fhelp only provided in order to avoid multiple generation of save | ||
|
||
ISystemProperties* _properties; | ||
IContinuous* _continuous_system; | ||
IEvent* _event_system; | ||
IMixedSystem* _mixed_system; | ||
ITime* _time_system; | ||
}; |
29 changes: 29 additions & 0 deletions
29
SimulationRuntime/cpp/Include/Solver/RTEuler/RTEulerSettings.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "FactoryExport.h" | ||
#include <Core/Solver/SolverSettings.h> | ||
|
||
|
||
/*****************************************************************************/ | ||
/** | ||
Encapsulation of settings for euler solver | ||
\date October, 1st, 2008 | ||
\author | ||
*/ | ||
/***************************************************************************** | ||
Copyright (c) 2008, OSMC | ||
*****************************************************************************/ | ||
class RTEulerSettings : public SolverSettings | ||
{ | ||
|
||
public: | ||
RTEulerSettings(IGlobalSettings* globalSettings); | ||
|
||
virtual void load(std::string xml_file); | ||
private: | ||
|
||
|
||
}; |