65 SIMLIB_ContractStepFlag =
true;
74 SIMLIB_ContractStepFlag =
true;
76 if (newCS<SIMLIB_ContractStep)
77 SIMLIB_ContractStep = newCS;
78 if (newCS<SIMLIB_MinStep)
92 void SetStep(
double _dtmin,
double _dtmax)
94 SIMLIB_MinStep = _dtmin;
95 SIMLIB_MaxStep = _dtmax;
99 Dprintf((
"SetStep: StepSize = %g .. %g ",SIMLIB_MinStep,SIMLIB_MaxStep));
108 SIMLIB_AbsoluteError = _abserr;
109 if(_relerr>1) _relerr=1;
110 SIMLIB_RelativeError = _relerr;
112 Dprintf((
"SetAccuracy: maxerror = %g + %g * X ",
113 SIMLIB_AbsoluteError,SIMLIB_RelativeError));
129 SIMLIB_DeltaTime = 0.0;
138 SIMLIB_DynamicFlag =
true;
140 SIMLIB_DynamicFlag =
false;
155 if(SIMLIB_DynamicFlag) {
161 SIMLIB_ResetStatus =
true;
176 Dprintf((
"Integrator[%p]::Integrator() #%d",
187 Dprintf((
"Integrator[%p]::Integrator(Input,%g) #%d",
200 Dprintf((
"Integrator[%p]::Integrator(Integrator[%p],%g) #%d",
211 Dprintf((
"destructor: Integrator[%p] #%d",
213 if(SIMLIB_DynamicFlag) {
224 SIMLIB_ResetStatus =
true;
233 SIMLIB_ResetStatus =
true;
279 Dprintf((
"IntegratorContainer::Instance()(%p)",ListPtr));
281 ListPtr =
new std::list<Integrator*>;
282 Dprintf((
"created: %p", ListPtr));
294 Dprintf((
"IntegratorContainer::Insert(%p)",ptr));
296 return ListPtr->insert(ListPtr->end(),ptr);
305 Dprintf((
"IntegratorContainer::Erase(...)"));
318 Dprintf((
"IntegratorContainer::NtoL()"));
321 for(
iterator ip=ListPtr->begin(); ip!=end_it; ++ip) {
333 Dprintf((
"IntegratorContainer::LtoN)"));
336 for(
iterator ip=ListPtr->begin(); ip!=end_it; ++ip) {
348 Dprintf((
"IntegratorContainer::InitAll)"));
351 for(
iterator ip=ListPtr->begin(); ip!=end_it; ++ip) {
352 (*ip)->SetState(0.0);
365 Dprintf((
"IntegratorContainer::EvaluateAll)"));
368 for(
iterator ip=ListPtr->begin(); ip!=end_it; ++ip) {
384 if(SIMLIB_DynamicFlag) {
391 SIMLIB_ResetStatus =
true;
410 if(SIMLIB_DynamicFlag) {
490 Dprintf((
"StatusContainer::Instance()(%p)",ListPtr));
492 ListPtr =
new std::list<Status*>;
493 Dprintf((
"created: %p", ListPtr));
505 Dprintf((
"StatusContainer::Insert(%p)",ptr));
507 return ListPtr->insert(ListPtr->end(),ptr);
516 Dprintf((
"StatusContainer::Erase(...)"));
529 Dprintf((
"StatusContainer::NtoL()"));
532 for(
iterator sp=ListPtr->begin(); sp!=end_it; ++sp) {
544 Dprintf((
"StatusContainer::LtoN)"));
547 for(
iterator sp=ListPtr->begin(); sp!=end_it; ++sp) {
559 Dprintf((
"StatusContainer::InitAll)"));
562 for(
iterator sp=ListPtr->begin(); sp!=end_it; ++sp) {
563 (*sp)->SetState(0.0);
575 Dprintf((
"StatusContainer::EvaluateAll)"));
578 for(
iterator sp=ListPtr->begin(); sp!=end_it; ++sp) {
591 Dprintf((
"StatusContainer::EvaluateAll)"));
594 for(
iterator sp=ListPtr->begin(); sp!=end_it; ++sp) {
595 (*sp)->SetValid(
false);
virtual void Eval() override
evaluate without loop detection
std::list< Integrator * >::iterator iterator
void Init()
use preset initial value
StatusContainer::iterator it_list
position in list of status variables
std::list< Status * >::iterator iterator
void Set(double value)
set state variable value (step change)
const double SIMLIB_MAXTIME
maximum time (1e30 works for float, too)
void SetAccuracy(double _abserr, double _relerr)
set max.
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
static void EvaluateAll()
const double & AbsoluteError
max. abs. error of integration
State variables (memory) base for blocks with internal state (Relay, ...)
virtual void _Eval()
evaluate block (with loop detection)
void Eval() override
evaluate integrator input
static void Erase(iterator it)
const double & StepSize
actual integration step
void SIMLIB_Dynamic()
performs evaluation of integrators and status blocks
double stl
status from previous step
double SIMLIB_StepStartTime
last step time
double SIMLIB_ContractStep
requested step size
Status(Input i, double initvalue=0)
const double & OptStep
optimal integration step
virtual double Value() override
value of state variable
void ContractStep()
contract step of integration
bool SIMLIB_ResetStatus
flag set if there is a need for integration method restart
bool SIMLIB_DynamicFlag
in dynamic section
static void Erase(iterator it)
static std::list< Status * > * Instance(void)
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
double SIMLIB_RelativeError
relative error
const double & RelativeError
max. rel. error
std::string SIMLIB_create_tmp_name(const char *fmt,...)
printf-like function to create temporary name (the length of temporary names is limited) used only ...
void SetStep(double _dtmin, double _dtmax)
Set integration step interval.
static void ClearAllValueOK()
double initval
initial value: y(t0)
double SIMLIB_StepSize
actual step
static iterator Insert(Status *ptr)
Integrator()
constructor for special cases (arrays of integrators) Input can be set using method Integrator::Set ...
abstract base for continuous blocks with single output suitable for expression-tree building and eval...
double SIMLIB_AbsoluteError
absolute error
void Set(double value)
set the integrator status value (step change)
bool SIMLIB_ContractStepFlag
requests shorter step
static iterator Insert(Integrator *ptr)
Internal header file for SIMLIB/C++.
void SIMLIB_ContinueInit()
static std::list< Integrator * > * Instance(void)
Main SIMLIB/C++ interface.
virtual std::string Name() const
get object name
Constant SIMLIB_Integrator_0input(0)
dummy input with zero value
Input input
input expression: f(t,y)
static std::list< Status * > * ListPtr
list of status variables
IntegratorContainer::iterator it_list
position in list of integrators
static std::list< Integrator * > * ListPtr
list of integrators
double SIMLIB_MinStep
minimal step
double InputValue()
current input value
block: constant (value can not be changed)
base for continuous blocks with single input and algebraic loop check
double SIMLIB_DeltaTime
Time-SIMLIB_StepStartTime.
block for numerical integration input is derivative, output is state
const double & MinStep
minimal integration step
~Integrator()
destructor removes integrator from list
const double & MaxStep
maximal integration step
double SIMLIB_OptStep
optimal step
double Value() override
the state of integrator
static void EvaluateAll()
double initval
initial value
double SIMLIB_MaxStep
max. step