-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoodwin.html
308 lines (253 loc) · 11 KB
/
goodwin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Applet Oscillateur de Goodwin</title>
<!--MATHJAX typing maths like in latex-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- MATHJAX-->
<!-- jQuery -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- JSXgraph -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jsxgraph/0.99.3/jsxgraphcore.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- style for JSXgraph -->
<style>
.jxgbox {
width:400px;
height:300px;
}
@media screen and (min-width: 600px) {
.jxgbox {
width:600px;
height:400px;
}
}
</style>
<!--<body style="padding-top: 50px;">-->
<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0px;">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html" class="active">Home</a></li>
<!--drop-down-->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Exemples<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li> <a href="reseau_hopfield.html">Réseau Hopfield</a></li>
<li> <a href="fitzhughnagumo.html">Fitzhugh-Nagumo</a></li>
<li> <a href="goodwin.html">Oscillateur de Goodwin</a></li>
<li> <a href="oscillateurs.html">Oscillateurs couplés</a></li>
</ul>
</li>
<!--drop-down-->
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container-fluid">
<div class="row">
<!--CONTENT HERE-->
<div class="col-xs-12 col-sm-12 col-md-12" id="applet">
<h3>Applet Oscillateur de Goodwin</h3>
<div id="goodwinboxtime" class="jxgbox" ></div>
<div id="goodwinboxphase" class="jxgbox" ></div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<h2>Modèle de Goodwin</h2>
<p>Le modèle d'oscillateur de Goodwin s'écrit</p>
$$\dot x = \frac{P \theta^h}{\theta^h+z^h} - kx,$$
$$\dot y = k(x-y),$$
$$\dot z = k(y-z).$$
<p>Le paramètre $P$ est la production maximale de $x$; $\theta$ est un coefficient de saturation; $k$ est le taux de dégradation de $x$, $y$, et $z$; et $h$ est le coefficient de Hill de la function de production de $x$. Les taux de production de $y$ et $z$ ont été normalisés. Pour certaines valeurs de $P$, $\theta$, $k$ et $h$, le système montre des oscillations entretenues.</p>
</div>
</div><!--row-->
</div><!--container-fluid-->
<script>
// Initialise boardtime
boardtime = JXG.JSXGraph.initBoard('goodwinboxtime', {boundingbox: [-1.0, 4.0, 192.0, -1.0], axis: true, grid: false});
// Define sliders to dynamically change parameters of the equations and create text elements to describe them
hillcoeff = boardtime.createElement('slider', [[130.0,3.5],[170.0,3.5],[1.0,4,20]],{name:'h',strokeColor:'black',fillColor:'black'});
hillText = boardtime.createElement('text', [130,3.3, "coefficient de Hill"], {fixed:true});
degradation = boardtime.createElement('slider', [[130.0,3.1],[170.0,3.1],[0.0,0.4,1.0]],{name:'k',strokeColor:'black',fillColor:'black'});
degradationText = boardtime.createElement('text', [130,2.9, "taux de degradation"], {fixed:true});
theta = boardtime.createElement('slider', [[130.0,2.7],[170.0,2.7],[0.0,1.0,4.0]],{name:'θ',strokeColor:'black',fillColor:'black'});
thetaText = boardtime.createElement('text', [130,2.5, "coefficient de saturation"], {fixed:true});
prodmax = boardtime.createElement('slider', [[130.0,2.3],[170.0,2.3],[0.0,1.0,5.0]],{name:'P',strokeColor:'black',fillColor:'black'});
prodmaxText = boardtime.createElement('text', [130,2.1, "production maximale"], {fixed:true});
// Dynamic initial value as gliders on the y-axis
startX = boardtime.createElement('glider', [0, 0.1, boardtime.defaultAxes.y], {name:'x',strokeColor:'blue',fillColor:'blue'});
startY = boardtime.createElement('glider', [0, 1.0, boardtime.defaultAxes.y], {name:'y',strokeColor:'green',fillColor:'green'});
startZ = boardtime.createElement('glider', [0, 2.0, boardtime.defaultAxes.y], {name:'z',strokeColor:'red',fillColor:'red'});
// initialise boardphase
boardphase = JXG.JSXGraph.initBoard('goodwinboxphase', {boundingbox: [-1.0, 4.0, 4.0, -1.0], axis: true, grid: false});
// add a child to board boardtime
boardtime.addChild(boardphase);
// Variables for the JXG.Curves
var g1 = null;
var g2 = null;
var g3 = null;
var curveProd = null;
var curveDegrad = null;
var curvePhase = null;
// Initialise ODE and solve it with JXG.Math.Numerics.rungeKutta()
function ode() {
// evaluation interval
var tspan = [0, 192];
// Number of steps. 1000 should be enough
var N = 1000;
// Right hand side of the ODE dx/dt = f(t, x)
var f = function(t, xx) {
var k = degradation.Value();
var p = prodmax.Value();
var h = hillcoeff.Value();
var th = theta.Value();
var dxdt = [];
dxdt[0] = p*Math.pow(th,h)/(Math.pow(th,h) + Math.pow(xx[2],h)) - k*xx[0];
dxdt[1] = k*(xx[0] - xx[1]);
dxdt[2] = k*(xx[1] - xx[2]);
return dxdt;
}
// Initial value
var x0 = [startX.Y(), startY.Y(), startZ.Y()];
// Solve ode
var data = JXG.Math.Numerics.rungeKutta('rk4', x0, tspan, N, f);
// to plot the data against time we need the times where the equations were solved
var t = [];
var q = tspan[0];
var h = (tspan[1]-tspan[0])/N;
for(var i=0; i<data.length; i++) {
data[i].push(q);
q += h;
}
return data;
}
// get data points
var data = ode();
// copy data to arrays so we can plot it using JXG.Curve
var t = [];
var dataX = [];
var dataY = [];
var dataZ = [];
for(var i=0; i<data.length; i++) {
t[i] = data[i][3];
dataX[i] = data[i][0];
dataY[i] = data[i][1];
dataZ[i] = data[i][2];
}
// Plot X
g1 = boardtime.createElement('curve', [t, dataX], {strokeColor:'blue', strokeWidth:'2px'});
g1.updateDataArray = function() {
var data = ode();
this.dataX = [];
this.dataY = [];
for(var i=0; i<data.length; i++) {
this.dataX[i] = t[i];
this.dataY[i] = data[i][0];
}
}
// Plot Y
g2 = boardtime.createElement('curve', [t, dataY], {strokeColor:'green', strokeWidth:'2px'});
g2.updateDataArray = function() {
var data = ode();
this.dataX = [];
this.dataY = [];
for(var i=0; i<data.length; i++) {
this.dataX[i] = t[i];
this.dataY[i] = data[i][1];
}
}
// Plot Z
g3 = boardtime.createElement('curve', [t, dataZ], {strokeColor:'red', strokeWidth:'2px'});
g3.updateDataArray = function() {
var data = ode();
this.dataX = [];
this.dataY = [];
for(var i=0; i<data.length; i++) {
this.dataX[i] = t[i];
this.dataY[i] = data[i][2];
}
}
// Plot Nullclines
function nullclineFuncX(z) {
var p = prodmax.Value();
var h = hillcoeff.Value();
var k = degradation.Value();
var th = theta.Value();
return p*Math.pow(th,h)/(Math.pow(th,h) + Math.pow(z,h))/k;
}
function nullclineFuncZ(z) {
return z;
}
var nz = [];
var nullX = [];
var nullZ = [];
for(i=0;i<100;i++) {
nz[i]=0.0+4.0*i/99;
nullX[i] = nullclineFuncX(nz[i]);
nullZ[i] = nullclineFuncZ(nz[i]);
}
curveNullclineX = boardphase.createElement('curve', [nullX,nz], {strokeColor:'green',strokeWidth:'2px'});
curveNullclineX.updateDataArray = function() {
this.dataX = [];
this.dataY = [];
for(i=0;i<100;i++) {
this.dataY[i]=0.0+4.0*i/99;
this.dataX[i] = nullclineFuncX(this.dataY[i]);
}
}
curveNullclineY = boardphase.createElement('curve', [nullZ,nz], {strokeColor:'red',strokeWidth:'2px'});
curveNullclineY.updateDataArray = function() {
this.dataX = [];
this.dataY = [];
for(i=0;i<100;i++) {
this.dataY[i]=0.0+4.0*i/99;
this.dataX[i] = nullclineFuncZ(this.dataY[i]);
}
}
// Plot phase
curvePhase = boardphase.createElement('curve', [dataX, dataZ], {strokeColor:'black', strokeWidth:'2px'});
curvePhase.updateDataArray = function() {
var data = ode();
this.dataX = [];
this.dataY = [];
for(var i=0; i<data.length; i++) {
this.dataX[i] = data[i][0];
this.dataY[i] = data[i][2];
}
}
</script>
<hr>
<footer>
<!--<p>© Company 2014</p>-->
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>