lorenz.cc


//////////////////////////////////////////////////////////////////////////// // Model lorenz.cc SIMLIB/C++ // // Lorenz equation: // // dx1/dt = sigma * (x2 - x1) // dx2/dt = (1 + lambda - x3) * x1 - x2 // dx3/dt = x1 * x2 - b * x3 // // where: sigma=10, lambda=24 and b=2 are parameters // initial conditions: xi(0) = 1.0 // // Source: SimPack // #include "simlib.h" #include <stdlib.h> // atoi() const double StepPrn = 0.01; // output period struct Lorenz { Integrator x1, x2, x3; Lorenz(double sigma, double lambda, double b) : x1(sigma*(x2 - x1), 1), // dx1/dt = sigma * (x2 - x1) x2((1 + lambda - x3)*x1 - x2, 1), // dx2/dt = (1 + lambda - x3) * x1 - x2 x3(x1*x2 - b*x3, 1) {} // dx3/dt = x1 * x2 - b * x3 }; Lorenz L(10, 24, 2); // model // output: void Sample() { Print("%6.2f %g %g\n", T.Value(), L.x1.Value(), L.x2.Value()); } Sampler S(Sample, StepPrn); int main(int argc, char *argv[]) { // experiment if(argc!=2) { _Print("\nUsage: %s maxtime \n\n", argv[0]); return 1; } SetOutput("lorenz.dat"); _Print("# LORENZ - Lorenz equation \n"); Init(0,atoi(argv[1])); SetAccuracy(1e-3); // required accuracy Run(); // simulation }
[result1]
[result2]
Last modification: 21. March 2002

If you have some suggestions to improve this page, please mail to peringer AT fit.vutbr.cz