1 /*
2  *  - - - - - - - - - - - - - - - -
3  *   g a l _ r k f s 7 8 _ t e s t
4  *  - - - - - - - - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *     Test gal_rkfs78 routine.
11  *
12  *  Status:
13  *
14  *     Internal test routine
15  *
16  *  Called:
17  *
18  *     gal_rkfs78
19  *     gal_rkf
20  *     gal_vdv
21  *
22  *  This Revision:
23  *
24  *     2008 May 18
25  *
26  *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
27  */
28 
29 #include "gal_rkfs78_test.h"
30 #include "gal_rkfs78.h"
31 #include "gal_rkf.h"
32 #include "gal_test.h"
33 
derivs(double x,double y[1],double dydx[1],int * derivsp)34 static void derivs
35   (
36     double x,
37     double y[1],
38     double dydx[1],
39     int *derivsp
40   )
41 
42 {
43 
44 /*
45  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46  */
47 
48  dydx[0] = 0.25 * y[0] * ( 1.0 - y[0] / 20.0 ) ;
49 
50 /*
51  * Finished.
52  */
53 
54 }
55 
56 void
gal_rkfs78_test()57 gal_rkfs78_test
58  (
59  )
60 
61 {
62 
63   extern int gal_tfunc ;
64 
65   double y[1] ;
66 
67   int i ;
68 
69 /*
70  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
71  */
72 
73 /*
74  * This is a test routine for RKF
75  *
76  * SAMPLE RUN:
77  *
78  * TEST 1
79  * Solve a scalar equation:
80  *
81  *  Y' = 0.25 * Y * ( 1 - Y / 20 )
82  *
83  *       T       Y_Exact
84  *
85  *    0.00000    1.00000
86  *    4.00000    2.50322
87  *    8.00000    5.60009
88  *   12.00000   10.27773
89  *   16.00000   14.83683
90  *   20.00000   17.73017
91  *
92  * Reference:
93  *
94  * http://perso.orange.fr/jean-pierre.moreau/Pascal/trkf45_pas.txt
95  *
96  */
97 
98   y[0] = 1.0 ;
99   gal_rkf ( y, 1, 0.0, 4.0, 1e-6, 1e-6, 1e-12, derivs, gal_rkfs78, &i ) ;
100   gal_vdv ( y[0] , 2.50322, 1e-7, "gal_rkfs78", "y 0" ) ;
101 
102   gal_rkf ( y, 1, 4.0, 8.0, 1e-6, 1e-6, 1e-12, derivs, gal_rkfs78, &i ) ;
103   gal_vdv ( y[0] , 5.60009, 1e-5, "gal_rkfs78", "y 1" ) ;
104 
105   gal_rkf ( y, 1, 8.0, 12.0, 1e-6, 1e-6, 1e-12, derivs, gal_rkfs78, &i ) ;
106   gal_vdv ( y[0] , 10.27773, 1e-5, "gal_rkfs78", "y 2" ) ;
107 
108   gal_rkf ( y, 1, 12.0, 16.0, 1e-6, 1e-6, 1e-12, derivs, gal_rkfs78, &i ) ;
109   gal_vdv ( y[0] , 14.83683, 1e-5, "gal_rkfs78", "y 3" ) ;
110 
111   gal_rkf ( y, 1, 16.0, 20.0, 1e-6, 1e-6, 1e-12, derivs, gal_rkfs78, &i ) ;
112   gal_vdv ( y[0] , 17.73017 , 1e-5, "gal_rkfs78", "y 4" ) ;
113 
114   gal_tfunc++ ;
115 
116 /*
117  * Finished.
118  */
119 
120 }
121 
122 /*
123  *  gal - General Astrodynamics Library
124  *  Copyright (C) 2008 Paul C. L. Willmott
125  *
126  *  This program is free software; you can redistribute it and/or modify
127  *  it under the terms of the GNU General Public License as published by
128  *  the Free Software Foundation; either version 2 of the License, or
129  *  (at your option) any later version.
130  *
131  *  This program is distributed in the hope that it will be useful,
132  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
133  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
134  *  GNU General Public License for more details.
135  *
136  *  You should have received a copy of the GNU General Public License along
137  *  with this program; if not, write to the Free Software Foundation, Inc.,
138  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
139  *
140  *  Contact:
141  *
142  *  Paul Willmott
143  *  vp9mu@amsat.org
144  */
145 
146