SIMLIB/C++ 3.09
Loading...
Searching...
No Matches
numint.cc
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2//! \file numint.cc Numerical integration methods
3//
4// Copyright (c) 1991-2016 Petr Peringer
5// Copyright (c) 1996-1997 David Leska
6//
7// This library is licensed under GNU Library GPL. See the file COPYING.
8//
9
10//
11// numerical integration methods base
12//
13
14
15////////////////////////////////////////////////////////////////////////////
16// interface
17//
18#include "simlib.h"
19#include "internal.h"
20#include "ni_abm4.h"
21#include "ni_euler.h"
22#include "ni_fw.h"
23#include "ni_rke.h"
24#include "ni_rkf3.h"
25#include "ni_rkf5.h"
26#include "ni_rkf8.h"
27#include <cstddef>
28#include <cstring>
29
30
31////////////////////////////////////////////////////////////////////////////
32// implementation
33//
34
35namespace simlib3 {
36
38
39// stack options in Borland C++ compiler
40#ifdef __BORLANDC__
41 // increase stack size
42 // WARNING: under MS-Windows must be specified in *.DEF file ###
43 // extern unsigned _stklen = 0xA000;
44 // set option 'check stack owerflow' on
45# pragma option -N
46#endif
47
48
49////////////////////////////////////////////////////////////////////////////
50////////////////////////////////////////////////////////////////////////////
51/// step of numerical integration method
53{
54 Dprintf(("==================== continuous step BEGIN %.15g",Time));
55#ifndef NDEBUG
56 double Step_StartTime = Time;
57#endif
58 SIMLIB_DynamicFlag = true; // numerical integration is running
59 if(Prepare()) { // initialize integration step (condition is not changed)
60 if(IntegratorContainer::isAny()) { // are there any integrators?
61 CurrentMethodPtr->Integrate(); // * numerical integration *
62 } else { // model without integrators
63 Iterate(); // compute new values of state blocks
64 }
65 Summarize(); // set up new state in the system
66 }
67 SIMLIB_DynamicFlag = false; // end of numerical integration
68 Dprintf((" Step length = %g ", Time - Step_StartTime ));
69 Dprintf(("==================== continuous step END %.15g",Time));
70}
71
72
73////////////////////////////////////////////////////////////////////////////
74/// set method which will be used
75void IntegrationMethod::SetMethod(const char* name)
76{
77 Dprintf(("SetMethod(%s, %s)", name));
79 SIMLIB_error(NI_CantSetMethod); // can't in 'dynamic section' !!!
80 }
81 CurrentMethodPtr->TurnOff(); // suspend present method
82 CurrentMethodPtr=SearchMethod(name); // set new method
83}
84
85
86////////////////////////////////////////////////////////////////////////////
87/// compute new values of state blocks in model without integrators
89{
90 Dprintf(("IntegrationMethod::Iterate()"));
91 while(1) {
93 SIMLIB_ContractStepFlag = false; // don't reduce step
94 SIMLIB_ContractStep = 0.5*SIMLIB_StepSize; // implicitly reduce to half
97
98 SIMLIB_Dynamic(); // evaluate new state of model - only state blocks
99 Condition::TestAll(); // check on changes of state conditions
100
102 break;
104 break;
105 IsEndStepEvent = false; // no event will be at end of step
108 }
109}
110
111
112////////////////////////////////////////////////////////////////////////////
113/// set up new state after execution of integration step
115{
116 Dprintf(("IntegrationMethod::Summarize()"));
118 SIMLIB_DeltaTime = 0.0;
121 if(IsEndStepEvent) // event at the end of step
122 _SetTime(Time, NextTime); // suppress inaccuracy of float
123} // IntegrationMethod::Summarize
124
125
126////////////////////////////////////////////////////////////////////////////
127/// initialize integration step
129{
130 SIMLIB_StepSize = SIMLIB_OptStep; // optimal step size at start
131
132 Dprintf(("IntegrationMethod::Prepare()"));
133
134 // If an event is scheduled within the step,
135 // set on flag, that will be event at the end of the step
136 IsEndStepEvent=(bool)(double(Time)+1.01*SIMLIB_StepSize>=NextTime);//1.1???
137 // and adjust step size, so that event will take place at end of step
139 SIMLIB_StepSize = double(NextTime)-double(Time);
140
141 // set up auxiliary variables
142 SIMLIB_StepStartTime = Time; // start time of integration
143 SIMLIB_DeltaTime = 0.0; // time since beginning of integration
144
145 if(SIMLIB_ResetStatus) { // initialization of integration is requested
146 // eg. on event - non-continuous change of state
147
148 // --------------- initialization of step sequence ----------------
149
150 IntegratorContainer::NtoL();// store initial value ...
152
153 SIMLIB_Dynamic(); // compute new (initial) state (0)
154 Condition::TestAll(); // check on changes of state conditions
155
156 IntegratorContainer::NtoL();// store new value ...
158
159 SIMLIB_ResetStatus=false; // clear reset flag
161 return false; // condition has been changed => terminate step
162 }
163
164 if(SIMLIB_StepSize<=0)
165 SIMLIB_error(NI_IlStepSize); // error of integration
166
167 CurrentMethodPtr->PrepareStep(); // prepare current method for single step
168
169 return true;
170}
171
172
173////////////////////////////////////////////////////////////////////////////
174/// check on changes of state conditions
176{
177 Dprintf(("IntegrationMethod::StateCond()"));
178
179 Condition::TestAll(); // check on changes
180
182 // step reducing is requested and it is possible
183 SIMLIB_StepSize = SIMLIB_ContractStep; // reduce step to demanded size
184 // implicitly to quater of step
185 IsEndStepEvent = false; // no event will be scheduled at end of step
186 return true;
187 }
188 return false;
189}
190
191
192////////////////////////////////////////////////////////////////////////////
193/// register method to list of methods and name it
195 PrevINum(0)
196{
197 Dprintf(("constructor[IntegrationMethod]: \"%s\"(%p)", name, MthLstPtr));
198
199 // name the method
200 char *Name = new char[strlen(name) + 1];
201 strcpy(Name, name);
202 method_name = Name;
203
204 // is list of methods not created?
205 if (MthLstPtr == NULL) {
206 MthLstPtr = new std::list < IntegrationMethod * >; // create it
207 }
208 //TODO use map<name,method> ?
209 // registrate the method in list
210 for (ItList = MthLstPtr->begin(); ItList != MthLstPtr->end(); ++ItList) {
211 if (strcmp((*ItList)->method_name, method_name) == 0) { // name should be unique
213 }
214 }
215 ItList = MthLstPtr->insert(MthLstPtr->end(), this); // insert method into list
216 PtrMList = &MList; // initialize pointer to list of memory buffers
217}
218
219
220////////////////////////////////////////////////////////////////////////////
221/// destroy integration method (remove from list)
223 Dprintf(("destructor[IntegrationMethod]"));
224 // is list of methods not created?
225 if(MthLstPtr==NULL) {
226 SIMLIB_internal_error(); // internal error (probably impossible)
227 }
228 MthLstPtr->erase(ItList); // unregistrate the method
229 delete[] method_name; // free dynamic data
230 if(MthLstPtr->empty()) { // destroy the list
231 delete MthLstPtr;
232 MthLstPtr=NULL;
233 }
234}
235
236
237////////////////////////////////////////////////////////////////////////////
238/// search method in the list of registrated methods
240{
241 std::list<IntegrationMethod*>::iterator it; // iterator for searching in the list
242 std::list<IntegrationMethod*>::iterator end_it; // iterator to end of the list
243
244 Dprintf(("IntegrationMethod::SearchMethod(\"%s\")", name));
245 // is list of methods created?
246 if(MthLstPtr!=NULL) {
247 // search for method in the list of registrated methods
248 for(it=MthLstPtr->begin(), end_it=MthLstPtr->end(); it!=end_it; ++it) {
249 if(strcmp((*it)->method_name,name)==0) { // find?
250 return *it; // return pointer to the method
251 }
252 }
253 }
254 SIMLIB_error(NI_UnknownMeth); // name is unknown (or list is not created)
255 return 0; // never reached
256}
257
258
259////////////////////////////////////////////////////////////////////////////
260/// turn off integration method: flush memories etc...
262{
263 Dprintf(("IntegrationMethod::TurnOff()"));
264 Resize(0); // flush memories
265 PrevINum=0; // remember it for next usage
266}
267
268
269////////////////////////////////////////////////////////////////////////////
270/// resize all the memories to the given size
272{
273 Dprintf(("IntegrationMethod::Resize(%lu)", (long unsigned)size));
274 for(std::list<Memory*>::iterator it=MList.begin(); it!=MList.end(); ++it) {
275 (*it)->Resize(size);
276 }
277}
278
279
280////////////////////////////////////////////////////////////////////////////
281/// prepare object for integration step
283{
284 Dprintf(("IntegrationMethod::PrepareStep()"));
285 // has # of integrators been changed?
287 PrevINum=IntegratorContainer::Size(); // retain # of integrators
288 Resize(PrevINum); // change size of auxiliary memories
289 return true; // there are changes in system
290 } else {
291 return false; // no changes
292 }
293}
294
295
296////////////////////////////////////////////////////////////////////////////
297/// initialize step
298void IntegrationMethod::InitStep(double step_frag)
299{
301 SIMLIB_StepSize = min(SIMLIB_StepSize, SIMLIB_MaxStep); // high step limit
302 SIMLIB_ContractStepFlag = false; // clear reduce step flag
303 // implicitly reduce to half step
305}
306
307void IntegrationMethod::SetOptStep(double opt_step)
308{ // set optimal step size
309 SIMLIB_OptStep = opt_step;
310}
311
312void IntegrationMethod::SetStepSize(double step_size)
313{ // set step size
314 SIMLIB_StepSize = step_size;
315}
316
318{ // any changes of condition vector?
320}
321
323{ // return # of errors
324 return SIMLIB_ERRNO;
325}
326
327void SetErrNo(int num)
328{ // set # of errors
329 SIMLIB_ERRNO = num;
330}
331
332
333////////////////////////////////////////////////////////////////////////////
334// IntegrationMethod::FunCall
335// evaluate y'(t) = f(t, y(t))
336//
337void IntegrationMethod::FunCall(double step_frag)
338{
339 if(step_frag==1.0) { // accuracy!
340 // substep time
343 } else {
344 // substep time
347 }
348 SIMLIB_Dynamic(); // evaluate new state of model
349}
350
351
352////////////////////////////////////////////////////////////////////////////
353////////////////////////////////////////////////////////////////////////////
354/// change size of array to cs, content will be undefined!
356{
357 Dprintf(("IntegrationMethod::Memory::Resize(%lu)",(long unsigned)cs));
358 if(cs == 0) { // zero size
359 delete[] arr;
360 arr = NULL;
361 mem_size = 0;
362 } else {
363 cs = (1+(cs-1)/page_size)*page_size; // round new size to page size
364 if(cs != mem_size) { // demanded size is too small or too large
365 delete[] arr; // new allocation
366 arr = new double[cs];
367// if(arr==NULL) { // cannot allocate memory
368// SIMLIB_internal_error(); // there is an exception in new versions of C++
369// }
370
371#ifdef __BCPLUSPLUS__
372 // problems with stupid MeS-DOS segment memory model!
373 if(cs > 0xFFFF/sizeof(double) ) SIMLIB_internal_error();
374#endif
375
376 mem_size = cs;
377
378 Dprintf(("##### reallocation to mem_size=%lu",(long unsigned)mem_size));
379
380 }
381 }
382} // Memory::Resize
383
384
385////////////////////////////////////////////////////////////////////////////
386/// create empty memory, put object into list
387IntegrationMethod::Memory::Memory(std::list<Memory*>* PtrList) :
388 arr(NULL), mem_size(0), ListPtr(PtrList)
389{
390// Dprintf(("constructor: IntegrationMethod::Memory::Memory(%p)", PtrList));
391 it_list=ListPtr->insert(ListPtr->end(),this); // put memory into list
392}
393
394
395////////////////////////////////////////////////////////////////////////////
396/// free dynamic data, remove object from list of memories
398{
399// Dprintf(("destructor: IntegrationMethod::Memory::~Memory()"));
400 delete[] arr; // free allocated memory
401 arr=NULL;
402 mem_size=0;
403 ListPtr->erase(it_list); // remove object from list
404}
405
406
407////////////////////////////////////////////////////////////////////////////
408////////////////////////////////////////////////////////////////////////////
409/// initialize multistep method
410MultiStepMethod::MultiStepMethod(const char* name, const char* slave_name) :
411 IntegrationMethod(name),
412 Slave_Ptr(NULL)
413{
414 Dprintf(("constructor[MultiStepMethod](%s, %s)", name, slave_name));
415 // name the starting method
416 SlaveName=new char[strlen(slave_name)+1];
417 strcpy(SlaveName, slave_name);
418 // note: cannot initialize Slave_Ptr here,
419 // slave need not exist now because it is a global object
420 // you must determine it by a name
421} // MultiStepMethod::MultiStepMethod
422
423
424////////////////////////////////////////////////////////////////////////////
425/// free dynamic data
427{
428 Dprintf(("destructor[MultiStepMethod]"));
429 delete[] SlaveName; // free dynamic data
430} // MultiStepMethod::~MultiStepMethod
431
432
433////////////////////////////////////////////////////////////////////////////
434/// return pointer to the starting method (initialize it also)
436{
437 if(Slave_Ptr == nullptr) {
438 Slave_Ptr = dynamic_cast<SingleStepMethod*>(SearchMethod(SlaveName)); // obtain method
439 if(Slave_Ptr == nullptr) { // not a single-step method?
441 }
442 }
443 return Slave_Ptr;
444}
445
446
447////////////////////////////////////////////////////////////////////////////
448/// prepare the object for the step of integration
450{
451 bool ichanges;
452 Dprintf(("MultiStepMethod::PrepareStep()"));
453 // prepare inherited part & test if # of integrators has been changed
455 SlavePtr()->SetStartMode(true); // called method is used for starting
456 (void)SlavePtr()->PrepareStep(); // prepare your slave
457 return ichanges; // indicate changes
458} // MultiStepMethod::PrepareStep
459
460
461////////////////////////////////////////////////////////////////////////////
462/// turn off integration method and its slave (starter)
464{
465 Dprintf(("MultiStepMethod::TurnOff()"));
466 IntegrationMethod::TurnOff(); // turn off inherited part
467 SlavePtr()->SetStartMode(false); // free slave
468 SlavePtr()->TurnOff(); // turn off your slave
469} // MultiStepMethod::TurnOff
470
471
472////////////////////////////////////////////////////////////////////////////
473/// set starting method for given multi-step method
474void MultiStepMethod::SetStarter(const char* name, const char* slave_name)
475{
476 Dprintf(("SetStarter(%s, %s)", name, slave_name));
477 MultiStepMethod* ptr=dynamic_cast<MultiStepMethod*>(SearchMethod(name));
478 if(ptr==nullptr) { // not multistep method:
480 }
481 ptr->SetStarter(slave_name); // set it
482} // MultiStepMethod::SetStarter
483
484
485////////////////////////////////////////////////////////////////////////////
486/// set starting method for the multi-step method
487void MultiStepMethod::SetStarter(const char* slave_name)
488{
489 Dprintf(("SetStarter(%s)", slave_name));
491 SIMLIB_error(NI_CantSetStarter); // can't in 'dynamic section' !!!
492 }
493 // name the starting method
494 delete[] SlaveName;
495 SlaveName=new char[strlen(slave_name)+1];
496 strcpy(SlaveName, slave_name);
497 Slave_Ptr=NULL; // throw away old starting method
498} // MultiStepMethod::SetStarter
499
500
501////////////////////////////////////////////////////////////////////////////
502/// obtain the name of the starting method of given method
503const char* MultiStepMethod::GetStarter(const char* name)
504{
505 Dprintf(("GetStarter(%s)", name));
506 MultiStepMethod* ptr=dynamic_cast<MultiStepMethod*>(SearchMethod(name));
507 if(ptr==nullptr) { // not multistep method:
508 return nullptr; // NULL: no starter
509 }
510 return ptr->SlaveName; // name of starter method
511} // MultiStepMethod::GetStarter
512
513
514////////////////////////////////////////////////////////////////////////////
515////////////////////////////////////////////////////////////////////////////
516/// initialization
518 SingleStepMethod(name),
519 PrevStatusNum(0)
520{
521 Dprintf(("constructor[StatusIntegrationMethod]: \"%s\"", name));
522 PtrStatusMList=&StatusMList; // initialize
523} // StatusMethod
524
525
526////////////////////////////////////////////////////////////////////////////
527/// turn off integration method: flush memories etc...
529{
530 Dprintf(("StatusMethod::TurnOff()"));
531 IntegrationMethod::TurnOff(); // turn off inherited part
532 StatusResize(0); // flush status memories
533 PrevStatusNum=0; // remember it for next usage
534} // TurnOff
535
536
537////////////////////////////////////////////////////////////////////////////
538/// prepare object for integration step
540{
541 Dprintf(("StatusMethod::PrepareStep()"));
542 // prepare inherited part -- test for changes of # of integrators
543 bool ichanges = IntegrationMethod::PrepareStep();
544 // has # of status variables been changed?
546 PrevStatusNum=StatusContainer::Size(); // retain # of status variables
547 StatusResize(PrevStatusNum); // change size of status auxiliary memories
548 return true; // there are changes in system
549 } else {
550 return ichanges; // changes would be only in iherited part
551 }
552} // PrepareStep
553
554
555////////////////////////////////////////////////////////////////////////////
556/// resize status memories to the given size
558{
559 Dprintf(("StatusMethod::StatusResize(%lu)", (long unsigned)size));
560 for(std::list<Memory*>::iterator it=StatusMList.begin();
561 it!=StatusMList.end();
562 ++it) {
563 (*it)->Resize(size);
564 }
565} // StatusResize
566
567
568////////////////////////////////////////////////////////////////////////////
569/// store state of integrators and status variables
571{
572 size_t i;
574 StatusContainer::iterator sp, status_end_it;
575
577 ip!=end_it;
578 ++ip, i++)
579 {
580 di[i]=(*ip)->GetDiff();
581 si[i]=(*ip)->GetState();
582 }
583
584 for(sp=StatusContainer::Begin(), status_end_it=StatusContainer::End(), i=0;
585 sp!=status_end_it; ++sp, i++)
586 {
587 xi[i]=(*sp)->GetState();
588 }
589} // StoreState
590
591
592////////////////////////////////////////////////////////////////////////////
593/// restore state of integrators and status variables
594void StatusMethod::RestoreState(double dthlf, Memory& di, Memory& si,
595 StatusMemory& xi)
596{
597 size_t i;
599 StatusContainer::iterator sp, status_end_it;
600
602 ip!=end_it;
603 ++ip, i++)
604 {
605 (*ip)->SetDiff(di[i]);
606 (*ip)->SetState(si[i]);
607 }
608
609 for(sp=StatusContainer::Begin(), status_end_it=StatusContainer::End(), i=0;
610 sp!=status_end_it; ++sp, i++)
611 {
612 (*sp)->SetState(xi[i]);
613 }
614
615 _SetTime(Time, SIMLIB_StepStartTime + dthlf); // half step
616 IsEndStepEvent = false; // no event will be scheduled at end of step
617} // RestoreState
618
619
620////////////////////////////////////////////////////////////////////////////
621/// move startpoint to given state
623{
624 size_t i;
626 StatusContainer::iterator sp, status_end_it;
627
629 ip!=end_it;
630 ++ip, i++)
631 {
632 (*ip)->SetOldDiff(di[i]);
633 (*ip)->SetOldState(si[i]);
634 }
635
636 for(sp=StatusContainer::Begin(), status_end_it=StatusContainer::End(), i=0;
637 sp!=status_end_it; ++sp, i++)
638 {
639 (*sp)->SetOldState(xi[i]);
640 }
641} // GoToState
642
643
644////////////////////////////////////////////////////////////////////////////
645// initialize static members of classes
646
647// size of memory page
648const size_t IntegrationMethod::Memory::page_size = 256;
649
650// flag - will be event at the end of the step?
652
653// list of registered methods
654std::list<IntegrationMethod*>* IntegrationMethod::MthLstPtr=NULL;
655
656// pointer to the filled list of memories
657std::list<IntegrationMethod::Memory*>* IntegrationMethod::PtrMList;
658
659// pointer to the filled list of status memories
660std::list<IntegrationMethod::Memory*>* StatusMethod::PtrStatusMList;
661
662
663////////////////////////////////////////////////////////////////////////////
664// instantiate integration methods
665
666/// Adams-Bashforth-Moulton, 4th order
667ABM4 abm4("abm4", "rkf5");
668/// Euler method
669EULER euler("euler");
670/// Fowler-Warten (Warning: needs testing, do not use)
671FW fw("fw");
672/// Runge-Kutta-England, 4th order?
673RKE rke("rke");
674/// Runge-Kutta-Fehlberg, 3rd order
675RKF3 rkf3("rkf3");
676/// Runge-Kutta-Fehlberg, 5th order
677RKF5 rkf5("rkf5");
678/// Runge-Kutta-Fehlberg, 8th order
679RKF8 rkf8("rkf8");
680
681/// pointer to the method currently used
682/// "rke" is a predefined method (historical reasons, we need rk45)
684
685} // namespace
686
static const size_t page_size
Definition: simlib.h:1096
std::list< Memory * >::iterator it_list
Definition: simlib.h:1099
virtual ~Memory()
free dynamic data, remove object from list of memories
Definition: numint.cc:397
Memory(const Memory &)=delete
virtual void Resize(size_t cs)
change size of array to cs, content will be undefined!
Definition: numint.cc:355
std::list< Memory * > * ListPtr
Definition: simlib.h:1100
IntegrationMethod - Abstract base class for integration methods.
Definition: simlib.h:1058
virtual void Resize(size_t size)
resize all the memories to the given size
Definition: numint.cc:271
static std::list< Memory * > * PtrMList
Definition: simlib.h:1072
static IntegrationMethod * CurrentMethodPtr
pointer to the method currently used "rke" is a predefined method (historical reasons,...
Definition: simlib.h:1062
static void Summarize(void)
set up new state after execution of integration step
Definition: numint.cc:114
const char * method_name
Definition: simlib.h:1065
virtual void Integrate(void)=0
virtual void TurnOff(void)
turn off integration method: flush memories etc...
Definition: numint.cc:261
static void Iterate(void)
compute new values of state blocks in model without integrators
Definition: numint.cc:88
virtual ~IntegrationMethod()
destroy integration method (remove from list)
Definition: numint.cc:222
static bool IsEndStepEvent
Definition: simlib.h:1079
static int GetErrNo(void)
Definition: numint.cc:322
static bool Prepare(void)
initialize integration step
Definition: numint.cc:128
static void InitStep(double step_frag)
initialize step
Definition: numint.cc:298
static IntegrationMethod * SearchMethod(const char *name)
search method in the list of registrated methods
Definition: numint.cc:239
static std::list< IntegrationMethod * > * MthLstPtr
Definition: simlib.h:1063
static bool StateCond(void)
check on changes of state conditions
Definition: numint.cc:175
virtual bool PrepareStep(void)
prepare object for integration step
Definition: numint.cc:282
static bool IsConditionFlag(void)
Definition: numint.cc:317
static void SetMethod(const char *name)
set method which will be used
Definition: numint.cc:75
static void SetOptStep(double opt_step)
Definition: numint.cc:307
static void StepSim(void)
step of numerical integration method
Definition: numint.cc:52
std::list< Memory * > MList
Definition: simlib.h:1071
static void SetStepSize(double step_size)
Definition: numint.cc:312
std::list< IntegrationMethod * >::iterator ItList
Definition: simlib.h:1064
static void FunCall(double step_frag)
Definition: numint.cc:337
static bool isAny(void)
Definition: simlib.h:994
static void NtoL()
Definition: intg.cc:316
static iterator End(void)
Definition: simlib.h:1006
static iterator Begin(void)
Definition: simlib.h:1002
std::list< Integrator * >::iterator iterator
Definition: simlib.h:992
static size_t Size(void)
Definition: simlib.h:998
base for multi-step integration method
Definition: simlib.h:1162
MultiStepMethod(const char *name, const char *slave_name)
initialize multistep method
Definition: numint.cc:410
SingleStepMethod * Slave_Ptr
Definition: simlib.h:1165
SingleStepMethod * SlavePtr(void)
return pointer to the starting method (initialize it also)
Definition: numint.cc:435
static const char * GetStarter(const char *name)
obtain the name of the starting method of given method
Definition: numint.cc:503
static void SetStarter(const char *name, const char *slave_name)
set starting method for given multi-step method
Definition: numint.cc:474
virtual void TurnOff(void) override
turn off integration method and its slave (starter)
Definition: numint.cc:463
virtual bool PrepareStep(void) override
prepare the object for the step of integration
Definition: numint.cc:449
~MultiStepMethod()
free dynamic data
Definition: numint.cc:426
base for single-step integration methods
Definition: simlib.h:1141
void SetStartMode(bool start_mode)
Definition: simlib.h:1151
static iterator Begin(void)
Definition: simlib.h:1037
static void NtoL()
Definition: intg.cc:527
std::list< Status * >::iterator iterator
Definition: simlib.h:1027
static void LtoN()
Definition: intg.cc:542
static iterator End(void)
Definition: simlib.h:1041
static size_t Size(void)
Definition: simlib.h:1033
static void StoreState(Memory &di, Memory &si, StatusMemory &xi)
store state of integrators and status variables
Definition: numint.cc:570
StatusMethod(const StatusMethod &)=delete
std::list< Memory * > StatusMList
Definition: simlib.h:1190
static std::list< Memory * > * PtrStatusMList
Definition: simlib.h:1191
virtual void StatusResize(size_t size)
resize status memories to the given size
Definition: numint.cc:557
static void RestoreState(double dthlf, Memory &di, Memory &si, StatusMemory &xi)
restore state of integrators and status variables
Definition: numint.cc:594
virtual void TurnOff(void) override
turn off integration method: flush memories etc...
Definition: numint.cc:528
static void GoToState(Memory &di, Memory &si, StatusMemory &xi)
move startpoint to given state
Definition: numint.cc:622
virtual bool PrepareStep(void) override
prepare object for integration step
Definition: numint.cc:539
static void TestAll()
Definition: cond.cc:123
@ NI_CantSetMethod
Definition: errors.h:83
@ NI_IlStepSize
Definition: errors.h:80
@ NI_CantSetStarter
Definition: errors.h:84
@ NI_NotSingleStep
Definition: errors.h:81
@ NI_MultDefMeth
Definition: errors.h:79
@ NI_UnknownMeth
Definition: errors.h:78
@ NI_NotMultiStep
Definition: errors.h:82
Internal header file for SIMLIB/C++.
#define Dprintf(f)
Definition: internal.h:100
#define SIMLIB_internal_error()
Definition: internal.h:167
#define _SetTime(t, x)
macro for simple assignement to internal time variables
Definition: internal.h:228
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
Definition: algloop.cc:32
const double & Time
model time (is NOT the block)
Definition: run.cc:48
EULER euler("euler")
Euler method.
ABM4 abm4("abm4", "rkf5")
Adams-Bashforth-Moulton, 4th order.
const double & NextTime
next-event time
Definition: run.cc:49
bool SIMLIB_DynamicFlag
in dynamic section
Definition: intg.cc:56
bool SIMLIB_ConditionFlag
Definition: cond.cc:30
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
Definition: error.cc:38
RKF5 rkf5("rkf5")
Runge-Kutta-Fehlberg, 5th order.
double SIMLIB_OptStep
optimal step
Definition: intg.cc:37
RKF3 rkf3("rkf3")
Runge-Kutta-Fehlberg, 3rd order.
SIMLIB_IMPLEMENTATION
Definition: algloop.cc:34
RKE rke("rke")
Runge-Kutta-England, 4th order?
void SetErrNo(int num)
Definition: numint.cc:327
bool SIMLIB_ContractStepFlag
requests shorter step
Definition: intg.cc:58
FW fw("fw")
Fowler-Warten (Warning: needs testing, do not use)
void SIMLIB_Dynamic()
performs evaluation of integrators and status blocks
Definition: continuous.cc:35
bool SIMLIB_ResetStatus
flag set if there is a need for integration method restart
Definition: intg.cc:86
double min(double a, double b)
Definition: internal.h:285
double max(double a, double b)
Definition: internal.h:286
RKF8 rkf8("rkf8")
Runge-Kutta-Fehlberg, 8th order.
double SIMLIB_MinStep
minimal step
Definition: intg.cc:38
double SIMLIB_MaxStep
max. step
Definition: intg.cc:39
int SIMLIB_ERRNO
Definition: intg.cc:32
double SIMLIB_ContractStep
requested step size
Definition: intg.cc:59
double SIMLIB_StepStartTime
last step time
Definition: intg.cc:34
double SIMLIB_StepSize
actual step
Definition: intg.cc:40
double SIMLIB_DeltaTime
Time-SIMLIB_StepStartTime.
Definition: intg.cc:35
Adams-Bashforth-Moulton 4th order.
Modified Euler method.
Fowler-Warten method.
Runge-Kutta-England method (default)
Runge-Kutta-Fehlberg 3rd order.
Runge-Kutta-Fehlberg 5th order.
Runge-Kutta-Fehlberg 8th order.
Main SIMLIB/C++ interface.