SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
examples/bessel.cc
////////////////////////////////////////////////////////////////////////////
// Model bessel.cc SIMLIB/C++
//
// Bessel diferential equation:
//
// y '' + (1/t) * y ' + (1 - 1/t*t) * y = 0
//
// Initial conditions: y(0.001)=0.001, y'(0.001)=0.49999
//
#include "
simlib.h
"
class
Bessel {
// model
Integrator yi, y;
// state variables
public
:
Bessel():
yi( -(1/T)*yi+(1/(T*T)-1)*y , 0.49999),
y( yi , 0.001) {}
double
Y() {
return
y.Value(); }
double
YI() {
return
yi.Value(); }
};
Bessel bes;
void
Sample
() {
// sampling
Print(
"%-8g %g %g\n"
, T.
Value
(), bes.Y(), bes.YI());
}
Sampler
S
(
Sample
,0.2);
// periodic event
int
main
() {
// experiment
SetOutput
(
"bessel.dat"
);
Print
(
"# Bessel diferential equation \n"
);
Print
(
"# Time y y'\n"
);
SetStep
(1e-6, 0.1);
// stepsize interval
Init
(0.001, 50);
// init time and simulator
Run
();
// simulation run
SIMLIB_statistics
.
Output
();
// print run statistics
}
S
Sampler S(Sample, 1)
Sample
void Sample()
Definition
_test_.cc:38
main
int main()
Definition
_test_.cc:44
simlib3::aContiBlock::Value
virtual double Value()=0
simlib3::SetOutput
void SetOutput(const char *name)
Definition
print.cc:50
simlib3::SetStep
void SetStep(double _dtmin, double _dtmax)
Definition
intg.cc:92
simlib3::Run
void Run()
run simulation experiment
Definition
run.cc:228
simlib3::Print
int Print(const char *fmt,...)
for Output methods, can be redirected
Definition
print.cc:92
simlib3::Init
void Init(double t0, double t1=SIMLIB_MAXTIME)
Definition
simlib.h:186
simlib3::SIMLIB_statistics
const SIMLIB_statistics_t & SIMLIB_statistics
interface to internal run-time statistics structure
Definition
run.cc:78
simlib.h
Main SIMLIB/C++ interface.
simlib3::SIMLIB_statistics_t::Output
void Output() const
print run-time statistics to output
Definition
output1.cc:63
Generated on
for SIMLIB/C++ by
1.18.0