01: /*
02:  *  2sp-osc.c
03:  *  dynamo.cgi
04:  *
05:  *  Created by ashley on 22/08/2009.
06:  *  Copyright 2009 __MyCompanyName__. All rights reserved.
07:  *
08:  */
09: 
10: //#include "2sp-osc.h"
11: 
12: #include <math.h>
13: #include <stdio.h>
14: #include <stdlib.h>
15: #include <strings.h>
16: #include "control.h"
17: #include "2sp-osc.h"
18: 
19: void fcn2sposc(int n, double t, double *y, double *yprime, void *fdata);
20: 
21: double _auxiliary0;
22: 
23: control *make2sposc()
24: {
25:         int nconstants = 2;
26:         int nvariables = 2;
27:         int nplots = 2;
28:         control *c = makecontrol(nvariables, nconstants, nplots);
29:         
30:         c->title = "Two Species Oscillator";
31:         c->description = "Two Species Biochemical Oscillator";
32: 
33:         c->integrator = dverkintegrator;
34:         c->fcn = fcn2sposc;
35: 
36:     c->variables[0]->value = 1;
37:     c->variables[1]->value = 1;
38:     c->parameters[0]->value = 0.1;
39:     c->parameters[1]->value = 0.5;
40: 
41:     c->parameters[0]->name = astrcpy("a");
42:     c->parameters[0]->info = astrcpy("Parameter 0");
43:     c->parameters[1]->name = astrcpy("b");
44:     c->parameters[1]->info = astrcpy("Parameter 1");
45: 
46:     c->variables[0]->name = astrcpy("x");
47:     c->variables[1]->name = astrcpy("y");
48: 
49:         int lines[] = {1, 2};
50:         c->plots[0] = makeplot(lineplot, 2, 0, lines);
51:         c->plots[0]->title = astrcpy("Time series");
52:         c->plots[0]->label = astrcpy("x-y Time Series Plot");
53:         c->plots[0]->xlabel = astrcpy("x");
54:         c->plots[0]->ylabel = astrcpy("t");
55: 
56:         int lines2[] = {2};
57:         c->plots[1] = makeplot(lineplot, 1, 1, lines2);
58:         c->plots[1]->title = astrcpy("Phase Space");
59:         c->plots[1]->label = astrcpy("x-y Phase Space Plot");
60:         c->plots[1]->xlabel = astrcpy("x");
61:         c->plots[1]->ylabel = astrcpy("y");
62: 
63:     c->t0 = 0.0;
64:     c->t1 = 100;
65:     c->dt = 1.0;
66:     c->tol = 1.0e-08;
67:         
68:         return c;
69: }
70: 
71: void fcn2sposc(int n, double t, double *s, double *g, void *fdata)
72: {
73:     control *ctrl = (control *)fdata;
74:     constant **c = ctrl->parameters;
75:     _auxiliary0 = (s[0]*s[0])*s[1];
76:     g[0] = (c[0]->value - s[0])+_auxiliary0;
77:     g[1] = c[1]->value - _auxiliary0;
78: }