SIMLIB/C++
3.07
Main Page
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
x
y
z
+
Variables
_
a
c
e
f
i
l
m
n
o
p
r
s
t
z
Typedefs
Enumerations
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
+
Related Functions
a
e
f
i
l
m
o
q
r
s
w
z
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
Functions
Variables
Enumerations
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
+
Macros
_
a
c
d
e
h
i
m
r
s
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
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
}
Generated on Tue Oct 5 2021 16:04:52 for SIMLIB/C++ by
1.8.13