Lorenz equation.
#include <cstdlib>
const double DEFAULT_T1 = 30.0;
struct Lorenz {
Integrator x1, x2, x3;
Lorenz(double sigma, double lambda, double b) :
x1(sigma*(x2 - x1), 1),
x2((1 + lambda - x3)*x1 - x2, 1),
x3(x1*x2 - b*x3, 1) {}
};
Lorenz L(10, 24, 2);
Print(
"%6.2f %.5g %.5g %.5g\n", T.
Value(), L.x1.Value(), L.x2.Value(), L.x3.Value());
}
int main(
int argc,
char *argv[]) {
double maxtime = DEFAULT_T1;
if (argc > 1)
maxtime = std::atof(argv[1]);
if (maxtime < 1.0) {
_Print(
"\nUsage: %s [maxtime>=1,default=%g] \n\n", argv[0], DEFAULT_T1);
return 1;
}
Print(
"# Lorenz equation output (maxtime=%g) \n", maxtime);
Print(
"# Time x1 x2 \n");
}
virtual double Value()=0
get block output value this method should be defined in classes derived from aContiBlock
void SetAccuracy(double _abserr, double _relerr)
set max.
void SetOutput(const char *name)
redirects Output(), Print() to file
int _Print(const char *fmt,...)
output of messages to stdout, too
void Run()
run simulation experiment
int Print(const char *fmt,...)
for Output methods, can be redirected
void Init(double t0, double t1=SIMLIB_MAXTIME)
Initialize simulator and model time.
const SIMLIB_statistics_t & SIMLIB_statistics
interface to internal run-time statistics structure
Main SIMLIB/C++ interface.
void Output() const
print run-time statistics to output