54 Dprintf((
"==================== continuous step BEGIN %.15g",
Time));
56 double Step_StartTime =
Time;
68 Dprintf((
" Step length = %g ",
Time - Step_StartTime ));
69 Dprintf((
"==================== continuous step END %.15g",
Time));
77 Dprintf((
"SetMethod(%s, %s)", name));
90 Dprintf((
"IntegrationMethod::Iterate()"));
116 Dprintf((
"IntegrationMethod::Summarize()"));
132 Dprintf((
"IntegrationMethod::Prepare()"));
177 Dprintf((
"IntegrationMethod::StateCond()"));
200 char *Name =
new char[strlen(name) + 1];
206 MthLstPtr =
new std::list < IntegrationMethod * >;
211 if (strcmp((*ItList)->method_name,
method_name) == 0) {
223 Dprintf((
"destructor[IntegrationMethod]"));
241 std::list<IntegrationMethod*>::iterator it;
242 std::list<IntegrationMethod*>::iterator end_it;
244 Dprintf((
"IntegrationMethod::SearchMethod(\"%s\")", name));
249 if(strcmp((*it)->method_name,name)==0) {
263 Dprintf((
"IntegrationMethod::TurnOff()"));
273 Dprintf((
"IntegrationMethod::Resize(%lu)", (
long unsigned)size));
274 for(std::list<Memory*>::iterator it=
MList.begin(); it!=
MList.end(); ++it) {
284 Dprintf((
"IntegrationMethod::PrepareStep()"));
357 Dprintf((
"IntegrationMethod::Memory::Resize(%lu)",(
long unsigned)cs));
363 cs = (1+(cs-1)/page_size)*page_size;
366 arr =
new double[cs];
371 #ifdef __BCPLUSPLUS__ 378 Dprintf((
"##### reallocation to mem_size=%lu",(
long unsigned)mem_size));
388 arr(NULL), mem_size(0), ListPtr(PtrList)
414 Dprintf((
"constructor[MultiStepMethod](%s, %s)", name, slave_name));
416 SlaveName=
new char[strlen(slave_name)+1];
428 Dprintf((
"destructor[MultiStepMethod]"));
452 Dprintf((
"MultiStepMethod::PrepareStep()"));
465 Dprintf((
"MultiStepMethod::TurnOff()"));
476 Dprintf((
"SetStarter(%s, %s)", name, slave_name));
489 Dprintf((
"SetStarter(%s)", slave_name));
495 SlaveName=
new char[strlen(slave_name)+1];
505 Dprintf((
"GetStarter(%s)", name));
521 Dprintf((
"constructor[StatusIntegrationMethod]: \"%s\"", name));
530 Dprintf((
"StatusMethod::TurnOff()"));
541 Dprintf((
"StatusMethod::PrepareStep()"));
559 Dprintf((
"StatusMethod::StatusResize(%lu)", (
long unsigned)size));
560 for(std::list<Memory*>::iterator it=
StatusMList.begin();
580 di[i]=(*ip)->GetDiff();
581 si[i]=(*ip)->GetState();
585 sp!=status_end_it; ++sp, i++)
587 xi[i]=(*sp)->GetState();
605 (*ip)->SetDiff(di[i]);
606 (*ip)->SetState(si[i]);
610 sp!=status_end_it; ++sp, i++)
612 (*sp)->SetState(xi[i]);
632 (*ip)->SetOldDiff(di[i]);
633 (*ip)->SetOldState(si[i]);
637 sp!=status_end_it; ++sp, i++)
639 (*sp)->SetOldState(xi[i]);
SingleStepMethod * Slave_Ptr
std::list< Integrator * >::iterator iterator
Runge-Kutta-Fehlberg 8th order.
std::list< Status * >::iterator iterator
static bool IsEndStepEvent
static void FunCall(double step_frag)
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
Runge-Kutta-Fehlberg 5th order.
IntegrationMethod - Abstract base class for integration methods.
RKF3 rkf3("rkf3")
Runge-Kutta-Fehlberg, 3rd order.
void SIMLIB_Dynamic()
performs evaluation of integrators and status blocks
double SIMLIB_StepStartTime
last step time
double SIMLIB_ContractStep
requested step size
MultiStepMethod(const char *name, const char *slave_name)
initialize multistep method
static void SetStarter(const char *name, const char *slave_name)
set starting method for given multi-step method
static iterator End(void)
static void Summarize(void)
set up new state after execution of integration step
static void StoreState(Memory &di, Memory &si, StatusMemory &xi)
store state of integrators and status variables
base for single-step integration methods
bool SIMLIB_ResetStatus
flag set if there is a need for integration method restart
std::list< Memory * >::iterator it_list
virtual void TurnOff(void) override
turn off integration method and its slave (starter)
bool SIMLIB_DynamicFlag
in dynamic section
virtual void StatusResize(size_t size)
resize status memories to the given size
static iterator Begin(void)
std::list< Memory * > * ListPtr
base for multi-step integration method
EULER euler("euler")
Euler method.
static int GetErrNo(void)
static std::list< IntegrationMethod * > * MthLstPtr
Adams-Bashforth-Moulton 4th order.
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
double max(double a, double b)
static void SetMethod(const char *name)
set method which will be used
static bool IsConditionFlag(void)
static void RestoreState(double dthlf, Memory &di, Memory &si, StatusMemory &xi)
restore state of integrators and status variables
static std::list< Memory * > * PtrMList
const double & Time
model time (is NOT the block)
virtual void Resize(size_t cs)
change size of array to cs, content will be undefined!
std::list< Memory * > StatusMList
~MultiStepMethod()
free dynamic data
double SIMLIB_StepSize
actual step
static void SetOptStep(double opt_step)
RKF8 rkf8("rkf8")
Runge-Kutta-Fehlberg, 8th order.
static std::list< Memory * > * PtrStatusMList
virtual bool PrepareStep(void)
prepare object for integration step
static iterator Begin(void)
static bool StateCond(void)
check on changes of state conditions
static IntegrationMethod * CurrentMethodPtr
pointer to the method currently used "rke" is a predefined method (historical reasons, we need rk45)
double min(double a, double b)
StatusMethod(const StatusMethod &)=delete
virtual ~IntegrationMethod()
destroy integration method (remove from list)
static iterator End(void)
virtual void Integrate(void)=0
Memory(const Memory &)=delete
#define SIMLIB_internal_error()
static IntegrationMethod * SearchMethod(const char *name)
search method in the list of registrated methods
bool SIMLIB_ContractStepFlag
requests shorter step
virtual void TurnOff(void)
turn off integration method: flush memories etc...
Internal header file for SIMLIB/C++.
RKE rke("rke")
Runge-Kutta-England, 4th order?
FW fw("fw")
Fowler-Warten (Warning: needs testing, do not use)
ABM4 abm4("abm4", "rkf5")
Adams-Bashforth-Moulton, 4th order.
const double & NextTime
next-event time
std::list< Memory * > MList
static void InitStep(double step_frag)
initialize step
static void StepSim(void)
step of numerical integration method
Main SIMLIB/C++ interface.
static bool Prepare(void)
initialize integration step
static const size_t page_size
#define _SetTime(t, x)
macro for simple assignement to internal time variables
virtual void Resize(size_t size)
resize all the memories to the given size
static void GoToState(Memory &di, Memory &si, StatusMemory &xi)
move startpoint to given state
bool SIMLIB_ConditionFlag
virtual void TurnOff(void) override
turn off integration method: flush memories etc...
double SIMLIB_MinStep
minimal step
SingleStepMethod * SlavePtr(void)
return pointer to the starting method (initialize it also)
static void Iterate(void)
compute new values of state blocks in model without integrators
static void SetStepSize(double step_size)
double SIMLIB_DeltaTime
Time-SIMLIB_StepStartTime.
static const char * GetStarter(const char *name)
obtain the name of the starting method of given method
Runge-Kutta-Fehlberg 3rd order.
Runge-Kutta-England method (default)
std::list< IntegrationMethod * >::iterator ItList
void SetStartMode(bool start_mode)
virtual ~Memory()
free dynamic data, remove object from list of memories
virtual bool PrepareStep(void) override
prepare the object for the step of integration
static void SetErrNo(int num)
double SIMLIB_OptStep
optimal step
RKF5 rkf5("rkf5")
Runge-Kutta-Fehlberg, 5th order.
virtual bool PrepareStep(void) override
prepare object for integration step
double SIMLIB_MaxStep
max. step