001: /*
002:  *  rossler.c
003:  *  dynamo.cgi
004:  *
005:  *  Created by ashley on 22/07/2009.
006:  *  Copyright 2009 __MyCompanyName__. All rights reserved.
007:  *
008:  */
009: 
010: #include <stdio.h>
011: #include <stdlib.h>
012: #include <math.h>
013: #include <strings.h>
014: #include "control.h"
015: #include "dverk.h"
016: #include "rossler.h"
017: 
018: void fcnrossler(int n, double t, double *y, double *yprime, void *fdata);
019: 
020: control *makerossler()
021: {
022:         int nconstants = 3;
023:         int nvariables = 3;
024:         int nplots = 4;
025:         control *c = makecontrol(nvariables, nconstants, nplots);
026:         
027:         c->title = "Rossler System";
028:         c->description = "The Rossler System.";
029: 
030:         c->integrator = dverkintegrator;
031:         c->fcn = fcnrossler;
032: 
033:         c->parameters[0]->value = 0.2;
034:         c->parameters[0]->name = astrcpy("a");
035:         c->parameters[0]->info = astrcpy("A parameter");
036:         
037:         c->parameters[1]->value = 0.2;
038:         c->parameters[1]->name = astrcpy("b");
039:         c->parameters[1]->info = astrcpy("B parameter");
040:         
041:         c->parameters[2]->value = 2.5;
042:         c->parameters[2]->name = astrcpy("c");
043:         c->parameters[2]->info = astrcpy("C parameter"); 
044:         
045:         c->variables[0]->name = astrcpy("x");
046:         c->variables[1]->name = astrcpy("y");
047:         c->variables[2]->name = astrcpy("z");
048:         c->variables[0]->value = 1.0;
049:         c->variables[1]->value = 1.0;
050:         c->variables[2]->value = 1.0;
051:         
052:         int lines[] = {1, 2, 3};
053:         c->plots[0] = makeplot(lineplot, 3, 0, lines);
054:         c->plots[0]->title = astrcpy("Time series");
055:         c->plots[0]->label = astrcpy("x-y-z Time Series Plot");
056:         c->plots[0]->xlabel = astrcpy("y");
057:         c->plots[0]->ylabel = astrcpy("t");
058: 
059:         int lines2[] = {3};
060:         c->plots[1] = makeplot(lineplot, 1, 2, lines2);
061:         c->plots[1]->title = astrcpy("Phase Space");
062:         c->plots[1]->label = astrcpy("z-y Phase Space Plot");
063:         c->plots[1]->xlabel = astrcpy("w");
064:         c->plots[1]->ylabel = astrcpy("y");
065: 
066:         int lines3[] = {2};
067:         c->plots[2] = makeplot(lineplot, 1, 1, lines3);
068:         c->plots[2]->title = astrcpy("Phase Space");
069:         c->plots[2]->label = astrcpy("x-y Phase Space Plot");
070:         c->plots[2]->xlabel = astrcpy("x");
071:         c->plots[2]->ylabel = astrcpy("y");
072:         
073:         int lines4[] = {3};
074:         c->plots[3] = makeplot(lineplot, 1, 1, lines4);
075:         c->plots[3]->title = astrcpy("Phase Space");
076:         c->plots[3]->label = astrcpy("z-w Phase Space Plot");
077:         c->plots[3]->xlabel = astrcpy("w");
078:         c->plots[3]->ylabel = astrcpy("y");
079:         
080:         c->t0 = 0.0;
081:         c->t1 = 25.0;
082:         c->dt = 0.05;
083:         c->tol = 1.0e-07;
084:         
085:         return c;
086: }
087:         
088: void fcnrossler(int n, double t, double *y, double *yprime, void *fdata)
089: {
090:         control *ctrl = (control *)fdata;
091:         constant **params = ctrl->parameters;
092:         double a = params[0]->value;
093:         double b = params[1]->value;
094:         double c = params[2]->value;
095: 
096:         yprime[0] = -(y[2] + y[1]);     
097:         yprime[1] = y[0] + a*y[1];
098:         yprime[2] = b + y[0]*y[2] - c*y[2];
099: }
100: 
101: