/[ascend]/trunk/models/bvp.a4l
ViewVC logotype

Diff of /trunk/models/bvp.a4l

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1157 by johnpye, Tue May 9 03:42:08 2006 UTC revision 1158 by johnpye, Tue Jan 16 12:44:13 2007 UTC
# Line 1  Line 1 
1    (*  ASCEND modelling environment
2        Copyright (C) 1997 Benjamin A Allan
3        Copyright (C) 1998, 2007 Carnegie Mellon University
4    
5        This program is free software; you can redistribute it and/or modify
6        it under the terms of the GNU General Public License as published by
7        the Free Software Foundation; either version 2, or (at your option)
8        any later version.
9    
10        This program is distributed in the hope that it will be useful,
11        but WITHOUT ANY WARRANTY; without even the implied warranty of
12        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13        GNU General Public License for more details.
14        
15        You should have received a copy of the GNU General Public License
16        along with this program; if not, write to the Free Software
17        Foundation, Inc., 59 Temple Place - Suite 330,
18        Boston, MA 02111-1307, USA.
19    *)
20  REQUIRE "atoms.a4l";  REQUIRE "atoms.a4l";
 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)  
 PROVIDE "bvp.a4l";  
   
21  (*  (*
22   *  bvp.a4l      This file contains models that implement an integration scheme completely  
23   *  by Benjamin A Allan      within ASCEND as a system of equations. Because data points are all
24   *  remodeled from integration.a4l      stored in memory, this approach uses a lot more memory (although with  
25   *  by Peter Piela, Boyd T. Safrit, Joseph J. Zaher      relation sharing, sparse matrix storage, etc, it's not completely terrible)
  *  Part of the ASCEND Library  
  *  $Date: 1998/06/17 18:49:40 $  
  *  $Revision: 1.6 $  
  *  $Author: mthomas $  
  *  $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/bvp.a4l,v $  
  *  
  *  This file is part of the ASCEND Modeling Library.  
  *  
  *  Copyright (C) 1997 Benjamin A Allan  
  *  Copyright (C) 1998 Carnegie Mellon University  
  *  
  *  The ASCEND Modeling Library is free software; you can redistribute  
  *  it and/or modify it under the terms of the GNU General Public  
  *  License as published by the Free Software Foundation; either  
  *  version 2 of the License, or (at your option) any later version.  
  *  
  *  The ASCEND Modeling Library is distributed in hope that it  
  *  will be useful, but WITHOUT ANY WARRANTY; without even the implied  
  *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  *  See the GNU General Public License for more details.  
  *  
  *  You should have received a copy of the GNU General Public License  
  *  along with the program; if not, write to the Free Software  
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check  
  *  the file named COPYING.  
  *)  
26    
27  (*============================================================================*      @TODO more documentation here.
28    
29      B V P . A 4 L      @NOTE there is a test model implemented at the bottom of the file. See
30      -------------      'test_dynamics' and 'bvp_test'. Note also that the model 'plotbvp.a4c'
31        includes this test model and provides graphical output from the integration.
32    
33      AUTHORS:     Ben Allan      @NODE some old comments were removed here as they confused the issue by
34                   Peter Piela      referring to the LSODE integration engine.
                  Boyd T. Safrit  
                  Joseph J. Zaher  
   
     DATES:       07/91 - Original code.  
                  08/94 - Added the observations to LSODE.  
                  09/94 - Added ivp as base type for all initial value problem  
                          solvers. baa.  
                  10/94 - Added other integration methods to supplement lsode  
                          and provide a means for dynamic optimization.  
                  04/96 - Modified for the use of constants and function abs  
          03/97 - Decoupled from IVP, rewritten in ASCEND IV.  
   
     CONTENTS:    The bvp_point model definition that is required  
                  in the integration model.  
                  For boundary value  
                  problems and for dynamic optimization, a general integration  
                  model is supplied which enables users to specify any of a  
                  number of alternative integration techniques.  The user  
                  should be aware, however, that using the general integration  
                  model will substantially increase the size of a problem.  
                  When possible, an IVP library is preferable to use.  
35    
36        @NOTE The LSODE integration engine is provided as part of ASCEND and
37        offers a more efficient way to solve integration models. Note that you will
38        need to set up your model quite differently if you want to use that approach.
39    
40        Original code 1991.
41        Decoupled from IVP code, rewritten in ASCEND IV -- Ben Allan, Mar 1997
42    
43        by Peter Piela, Boyd T. Safrit, Joseph J. Zaher, 1991
44        remodelled by Benjamin A. Allan
45  *)  *)
46    
47  MODEL bvp_base REFINES cmumodel;  MODEL bvp_base REFINES cmumodel;
# Line 74  See example bvp_test. Line 53  See example bvp_test.
53  }  }
54  END NOTES;  END NOTES;
55  END bvp_base;  END bvp_base;
56  (* *********************************************************** *)  
57  (* ******  bvp_point: the collocation user MODEL interface *** *)  (*-------------------------------
58  (* *********************************************************** *)      bvp_point: the collocation user MODEL interface
59    *)
60  MODEL bvp_point REFINES bvp_base;  MODEL bvp_point REFINES bvp_base;
61  NOTES 'purpose' SELF {  NOTES 'purpose' SELF {
62  Generic definition of the differential equation system,  Generic definition of the differential equation system,
# Line 105  END NOTES; Line 85  END NOTES;
85          IS_A solver_var;          IS_A solver_var;
86    
87  METHODS  METHODS
88        METHOD default_self;
89  METHOD default_self;          (* do not assign anything as these are merged with
90      (* do not assign anything as these are merged with           * user's variables which are all assigned.
91       * user's variables which are all assigned.           *)
92       *)      END default_self;
93  END default_self;  
94        METHOD specify;
95  METHOD specify;          (* The state variables are set
96      (* The state variables are set          * TRUE, while their derivatives are FALSE.
97      * TRUE, while their derivatives are FALSE.          *)
98      *)          FIX x;
99      FIX x;          FIX y[1..n_eq];
100      FIX y[1..n_eq];          FREE dydx[1..n_eq];
101      FREE dydx[1..n_eq];      END specify;
 END specify;  
102  END bvp_point;  END bvp_point;
103    
104    (*-------------------------------
105  (* ******************************************************************** *)      BVP internal models
106  (* *********************  bvp internal models ************************* *)  *)
 (* ******************************************************************** *)  
107    
108  MODEL propagation(  MODEL propagation(
109      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
110      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
111      n_eq WILL_BE integer_constant;      n_eq WILL_BE integer_constant;
112  ) WHERE (  )WHERE(
113      n_eq == eval[0].n_eq;      n_eq == eval[0].n_eq;
114  ) REFINES bvp_base;  )REFINES bvp_base;
115    
116  (*      eval[0..n_point] ARE_ALIKE;  (*      eval[0..n_point] ARE_ALIKE;
117   * Eval[i] must be deeply alike, so use of ARE_ALIKE here is heuristic at best.   * Eval[i] must be deeply alike, so use of ARE_ALIKE here is heuristic at best.
118   * Formal type compatibility does not ensure a well defined BVP.   * Formal type compatibility does not ensure a well defined BVP.
# Line 173  END NOTES; Line 152  END NOTES;
152          final.x = initial.x + h;          final.x = initial.x + h;
153    
154  METHODS  METHODS
155  METHOD specify;      METHOD specify;
156      RUN eval[0..n_point].specify;          RUN eval[0..n_point].specify;
157      FIX h;          FIX h;
158      FREE final.x;          FREE final.x;
159      FREE eval[1..n_point].y[1..n_eq];          FREE eval[1..n_point].y[1..n_eq];
160      FREE eval[1..n_point].x;          FREE eval[1..n_point].x;
161  END specify;      END specify;
162  END propagation;  END propagation;
163    
164    
165    (*-------------------------------
166        Euler method
167    *)
168  MODEL euler(  MODEL euler(
169      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
170      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 197  The error in the euler method is O(h). Line 180  The error in the euler method is O(h).
180  }  }
181  END NOTES;  END NOTES;
182    
183          FOR i IN [1..n_eq] CREATE      FOR i IN [1..n_eq] CREATE
184              eval[1].y[i] = eval[0].y[i] + h*eval[0].dydx[i];          eval[1].y[i] = eval[0].y[i] + h*eval[0].dydx[i];
185          END FOR;      END FOR;
186    
187  METHODS  METHODS
188  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 END specify;  
 *)  
   
189  END euler;  END euler;
190    
191    (*-------------------------------
192        Trapezoidal method
193    *)
194  MODEL trapezoid(  MODEL trapezoid(
195      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
196      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 224  MODEL trapezoid( Line 200  MODEL trapezoid(
200      n_point == 1;      n_point == 1;
201  ) REFINES propagation();  ) REFINES propagation();
202    
203  NOTES      NOTES
204  'order of error' SELF {      'order of error' SELF {
205  The error in the trapezoidal rule is O(h^2).      The error in the trapezoidal rule is O(h^2).
206  }      }
207  END NOTES;      END NOTES;
208    
209          FOR i IN [1..n_eq] CREATE      FOR i IN [1..n_eq] CREATE
210              eval[1].y[i] = eval[0].y[i] + 0.5*h*          eval[1].y[i] = eval[0].y[i] + 0.5*h*
211                  (eval[0].dydx[i] + eval[1].dydx[i]);              (eval[0].dydx[i] + eval[1].dydx[i]);
212          END FOR;      END FOR;
   
     METHODS  
 (* specify inherited from propagation is correct *)  
 (*  
         METHOD specify;  
             RUN eval[0..n_point].specify;  
             FIX h;  
             FREE final.x;  
             FREE eval[1..n_point].y[1..n_eq];  
             FREE eval[1..n_point].x;  
         END specify;  
 *)  
213    
214    METHODS
215        (* 'specify' inherited from propagation is correct *)
216  END trapezoid;  END trapezoid;
217    
218    (*-------------------------------
219        Midpoint method
220    *)
221  MODEL midpoint(  MODEL midpoint(
222      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
223      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 273  END NOTES; Line 242  END NOTES;
242          END FOR;          END FOR;
243    
244  METHODS  METHODS
245  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 END specify;  
 *)  
246  END midpoint;  END midpoint;
247    
248    (*-------------------------------
249        Simpson's method
250    *)
251  MODEL simpsons(  MODEL simpsons(
252      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
253      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 313  END NOTES; Line 276  END NOTES;
276          END FOR;          END FOR;
277    
278  METHODS  METHODS
279  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 END specify;  
 *)  
   
280  END simpsons;  END simpsons;
281    
282    (*-------------------------------
283        4-point Runge-Kutta-Gill method
284    *)
285  MODEL runge_kutta_gill(  MODEL runge_kutta_gill(
286      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
287      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 341  The error in the 4 point Runge-Kutta-Gil Line 297  The error in the 4 point Runge-Kutta-Gil
297  }  }
298  END NOTES;  END NOTES;
299    
300          eval[1].x = eval[2].x;      eval[1].x = eval[2].x;
301          eval[3].x = eval[4].x;      eval[3].x = eval[4].x;
302          eval[1].x = initial.x + 0.5*h;      eval[1].x = initial.x + 0.5*h;
303          FOR i IN [1..n_eq] CREATE      FOR i IN [1..n_eq] CREATE
304              eval[1].y[i] = eval[0].y[i] + 0.5*h*          eval[1].y[i] = eval[0].y[i] + 0.5*h*
305                  eval[0].dydx[i];              eval[0].dydx[i];
306              eval[2].y[i] = eval[0].y[i] + 0.5*h*          eval[2].y[i] = eval[0].y[i] + 0.5*h*
307                  (0.41421356*eval[0].dydx[i] +              (0.41421356*eval[0].dydx[i] +
308                  0.58578644*eval[1].dydx[i]);              0.58578644*eval[1].dydx[i]);
309              eval[3].y[i] = eval[0].y[i] + h*          eval[3].y[i] = eval[0].y[i] + h*
310                  (-0.707106781*eval[1].dydx[i] +              (-0.707106781*eval[1].dydx[i] +
311                  1.707106781*eval[2].dydx[i]);              1.707106781*eval[2].dydx[i]);
312              eval[4].y[i] = eval[0].y[i] + h*          eval[4].y[i] = eval[0].y[i] + h*
313                  (0.166666667*eval[0].dydx[i] +              (0.166666667*eval[0].dydx[i] +
314                  0.097631073*eval[1].dydx[i] +              0.097631073*eval[1].dydx[i] +
315                  0.569035590*eval[2].dydx[i] +              0.569035590*eval[2].dydx[i] +
316                  0.166666667*eval[3].dydx[i]);              0.166666667*eval[3].dydx[i]);
317          END FOR;      END FOR;
318    
319  METHODS  METHODS
320  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 END specify;  
 *)  
   
321  END runge_kutta_gill;  END runge_kutta_gill;
322    
323    (*-------------------------------
324        4-point Gauss method
325    *)
326  MODEL gauss(  MODEL gauss(
327      n_point WILL_BE integer_constant;      n_point WILL_BE integer_constant;
328      eval[0..n_point] WILL_BE bvp_point;      eval[0..n_point] WILL_BE bvp_point;
# Line 389  The error in 4 point gauss method is O(h Line 338  The error in 4 point gauss method is O(h
338  }  }
339  END NOTES;  END NOTES;
340    
341          eval[1].x = initial.x + 0.11270167*h;      eval[1].x = initial.x + 0.11270167*h;
342          eval[2].x = initial.x + 0.5*h;      eval[2].x = initial.x + 0.5*h;
343          eval[3].x = initial.x + 0.88729833*h;      eval[3].x = initial.x + 0.88729833*h;
344          FOR i IN [1..n_eq] CREATE      FOR i IN [1..n_eq] CREATE
345              eval[1].y[i] = initial.y[i] + 0.11270167*h*          eval[1].y[i] = initial.y[i] + 0.11270167*h*
346                  (1.23236*eval[1].dydx[i] -              (1.23236*eval[1].dydx[i] -
347                  0.31922*eval[2].dydx[i] +              0.31922*eval[2].dydx[i] +
348                  0.08686*eval[3].dydx[i]);              0.08686*eval[3].dydx[i]);
349              eval[2].y[i] = initial.y[i] + 0.5*h*          eval[2].y[i] = initial.y[i] + 0.5*h*
350                  (0.60053*eval[1].dydx[i] +              (0.60053*eval[1].dydx[i] +
351                  0.44444*eval[2].dydx[i] -              0.44444*eval[2].dydx[i] -
352                  0.04497*eval[3].dydx[i]);              0.04497*eval[3].dydx[i]);
353              eval[3].y[i] = initial.y[i] + 0.88729833*h*          eval[3].y[i] = initial.y[i] + 0.88729833*h*
354                  (0.30203*eval[1].dydx[i] +              (0.30203*eval[1].dydx[i] +
355                  0.54144*eval[2].dydx[i] +              0.54144*eval[2].dydx[i] +
356                  0.15653*eval[3].dydx[i]);              0.15653*eval[3].dydx[i]);
357              eval[4].y[i] = initial.y[i] + h*          eval[4].y[i] = initial.y[i] + h*
358                  (0.27778*eval[1].dydx[i] +              (0.27778*eval[1].dydx[i] +
359                  0.44444*eval[2].dydx[i] +              0.44444*eval[2].dydx[i] +
360                  0.27778*eval[3].dydx[i]);              0.27778*eval[3].dydx[i]);
361          END FOR;      END FOR;
362    
363  METHODS  METHODS
364  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 specify;  
 *)  
   
365  END gauss;  END gauss;
366    
367    (*-------------------------------
368        Lobatto method
369    *)
370  MODEL lobatto(  MODEL lobatto(
371      n_point WILL_BE integer_constant;              n_point WILL_BE integer_constant;
372      eval[0..n_point] WILL_BE bvp_point;              eval[0..n_point] WILL_BE bvp_point;
373      n_eq WILL_BE integer_constant;              n_eq WILL_BE integer_constant;
374  ) WHERE (          ) WHERE (
375      n_eq == eval[0].n_eq;              n_eq == eval[0].n_eq;
376      n_point == 4;              n_point == 4;
377  ) REFINES propagation();          ) REFINES propagation();
378    
379  NOTES  NOTES
380  'order of error' SELF {  'order of error' SELF {
# Line 440  The error in the 4 lobatto point method Line 382  The error in the 4 lobatto point method
382  }  }
383  END NOTES;  END NOTES;
384    
385          eval[1].x = initial.x + 0.11270167*h;      eval[1].x = initial.x + 0.11270167*h;
386          eval[2].x = initial.x + 0.5*h;      eval[2].x = initial.x + 0.5*h;
387          eval[3].x = initial.x + 0.88729833*h;      eval[3].x = initial.x + 0.88729833*h;
388          FOR i IN [1..n_eq] CREATE      FOR i IN [1..n_eq] CREATE
389              eval[1].y[i] = initial.y[i] + 0.11270167*h*          eval[1].y[i] = initial.y[i] + 0.11270167*h*
390                  (0.428010*eval[0].dydx[i] +              (0.428010*eval[0].dydx[i] +
391                  0.602339*eval[1].dydx[i] -              0.602339*eval[1].dydx[i] -
392                  0.044301*eval[2].dydx[i] +              0.044301*eval[2].dydx[i] +
393                  0.029587*eval[3].dydx[i] -              0.029587*eval[3].dydx[i] -
394                  0.015635*eval[4].dydx[i]);              0.015635*eval[4].dydx[i]);
395              eval[2].y[i] = initial.y[i] + 0.5*h*          eval[2].y[i] = initial.y[i] + 0.5*h*
396                  (-0.06250*eval[0].dydx[i] +              (-0.06250*eval[0].dydx[i] +
397                  0.68122*eval[1].dydx[i] +              0.68122*eval[1].dydx[i] +
398                  0.44444*eval[2].dydx[i] -              0.44444*eval[2].dydx[i] -
399                  0.12566*eval[3].dydx[i] +              0.12566*eval[3].dydx[i] +
400                  0.06250*eval[4].dydx[i]);              0.06250*eval[4].dydx[i]);
401              eval[3].y[i] = initial.y[i] + 0.88729833*h*          eval[3].y[i] = initial.y[i] + 0.88729833*h*
402                  (0.001986*eval[0].dydx[i] +              (0.001986*eval[0].dydx[i] +
403                  0.309303*eval[1].dydx[i] +              0.309303*eval[1].dydx[i] +
404                  0.506524*eval[2].dydx[i] +              0.506524*eval[2].dydx[i] +
405                  0.236552*eval[3].dydx[i] -              0.236552*eval[3].dydx[i] -
406                  0.054365*eval[4].dydx[i]);              0.054365*eval[4].dydx[i]);
407              eval[4].y[i] = initial.y[i] + h*          eval[4].y[i] = initial.y[i] + h*
408                  (0.277778*eval[1].dydx[i] +              (0.277778*eval[1].dydx[i] +
409                  0.444444*eval[2].dydx[i] +              0.444444*eval[2].dydx[i] +
410                  0.277778*eval[3].dydx[i]);              0.277778*eval[3].dydx[i]);
411          END FOR;      END FOR;
412    
413  METHODS  METHODS
414  (* specify inherited from propagation is correct *)      (* 'specify' inherited from propagation is correct *)
 (*  
 METHOD specify;  
     RUN eval[0..n_point].specify;  
     FIX h;  
     FREE final.x;  
     FREE eval[1..n_point].y[1..n_eq];  
     FREE eval[1..n_point].x;  
 END specify;  
 *)  
   
415  END lobatto;  END lobatto;
416    
417    (*-------------------------------
418        INTEGRATION model
419    *)
420  MODEL integration(  MODEL integration(
421      nstep IS_A integer_constant;      nstep IS_A integer_constant;
422      npoint IS_A integer_constant;      npoint IS_A integer_constant;
# Line 573  END NOTES; Line 508  END NOTES;
508    
509    
510  METHODS  METHODS
511  METHOD default_self;      METHOD default_self;
512      RUN values;          RUN values;
513  END default_self;      END default_self;
514  METHOD values;      METHOD values;
515      step[1..nstep].h := stepsize;          step[1..nstep].h := stepsize;
516  END values;      END values;
517  METHOD specify;      METHOD specify;
518      FIX stepsize;          FIX stepsize;
519      FOR i IN [1..nstep] DECREASING DO          FOR i IN [1..nstep] DECREASING DO
520          RUN step[i].specify;              RUN step[i].specify;
521      END FOR;          END FOR;
522  END specify;      END specify;
   
523  END integration;  END integration;
524    
525  (************************************************************************)  (*-------------------------------
526  (************** demo and test models ************************************)      Demo and test models
527  (************************************************************************)  *)
528    
529  MODEL testbvp_base REFINES testcmumodel;  MODEL testbvp_base REFINES testcmumodel;
530  END testbvp_base;  END testbvp_base;
531    
# Line 600  MODEL test_dynamics REFINES testbvp_base Line 535  MODEL test_dynamics REFINES testbvp_base
535      xdot IS_A frequency;      xdot IS_A frequency;
536      xdot = 2{1/s} * x * exp(-2{1/s}*t) * cos(t*1{rad/s});      xdot = 2{1/s} * x * exp(-2{1/s}*t) * cos(t*1{rad/s});
537  METHODS  METHODS
538  METHOD default_self;      METHOD default_self;
539      RUN values;          RUN values;
540  END default_self;      END default_self;
541  METHOD specify;      METHOD specify;
542      FIX x;          FIX x;
543      FREE xdot;          FREE xdot;
544      FIX t;          FIX t;
545  END specify;      END specify;
546  METHOD values;      METHOD values;
547      xdot.lower_bound := -1e6{1/s};          xdot.lower_bound := -1e6{1/s};
548  END values;      END values;
549  END test_dynamics;  END test_dynamics;
550    
551    (*-------------------------------
552        'dynamic point'
553    *)
554  MODEL dynamic_point REFINES bvp_point;  MODEL dynamic_point REFINES bvp_point;
   
555      n_eq :== 1; (* you can have as many as you like *)      n_eq :== 1; (* you can have as many as you like *)
556    
557      (* replace the following line with an IS_A of your MODEL *)      (* replace the following line with an IS_A of your MODEL *)
# Line 634  MODEL dynamic_point REFINES bvp_point; Line 571  MODEL dynamic_point REFINES bvp_point;
571      dydx[1], your_model.xdot ARE_THE_SAME;      dydx[1], your_model.xdot ARE_THE_SAME;
572    
573  METHODS  METHODS
574        METHOD specify;
575  METHOD specify;          RUN your_model.specify;
576            (* If you write your_model correctly, you don't need
577      RUN your_model.specify;             to run bvp_point::specify because you've wired all
578      (* If you write your_model correctly, you don't need             the bvp variables into some of yours.
579         to run bvp_point::specify because you've wired all             (Not TRUE if your MODEL is autonomous, though).
580         the bvp variables into some of yours.              RUN bvp_point::specify;
581         (Not TRUE if your MODEL is autonomous, though).          *)
582          RUN bvp_point::specify;      END specify;
     *)  
   
 END specify;  
583  END dynamic_point;  END dynamic_point;
584    
585    
# Line 663  MODEL bvp_test REFINES testbvp_base; Line 597  MODEL bvp_test REFINES testbvp_base;
597      (* we don't tie the test MODEL to the ASCEND plot MODEL *)      (* we don't tie the test MODEL to the ASCEND plot MODEL *)
598    
599  METHODS  METHODS
600  METHOD default_self;      METHOD default_self;
601      stepsize := 0.05{s};          stepsize := 0.05{s};
602      initial.x := 0{s};          initial.x := 0{s};
603      initial.y[1] := 1;          initial.y[1] := 1;
604      RUN nodes[0..nstep*npoint].your_model.default_self;          RUN nodes[0..nstep*npoint].your_model.default_self;
605      RUN integral.default_self;          RUN integral.default_self;
606  END default_self;      END default_self;
607  METHOD specify;      METHOD specify;
608      FIX stepsize;          FIX stepsize;
609      RUN integral.specify;          RUN integral.specify;
610  END specify;      END specify;
611  METHOD values;      METHOD values;
612      stepsize := 0.05{s};          stepsize := 0.05{s};
613      initial.x := 0{s};          initial.x := 0{s};
614      initial.y[1] := 1;          initial.y[1] := 1;
615      RUN nodes[0..nstep*npoint].your_model.values;          RUN nodes[0..nstep*npoint].your_model.values;
616      RUN integral.values;          RUN integral.values;
617  END values;      END values;
   
618  END bvp_test;  END bvp_test;
619    (* :ex: set ts=4: *)

Legend:
Removed from v.1157  
changed lines
  Added in v.1158

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22