|
| 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 | +}; |
0 commit comments