OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
rk.h
Go to the documentation of this file.
1 /* rk.h
2  Runge-Kutta integration implementation
3 
4  Project: Beam Envelope Tracker (BET)
5 
6  Revision history
7  Date Description Programmer
8  ------------ -------------------------------------------- --------------
9  07-03-06 Created Rene Bakker
10 
11  Last Revision:
12  $Id: rk.h 29 2007-04-14 17:03:18Z l_bakker $
13 */
14 
15 
16 #ifndef _RK_DEF
17 #define _RK_DEF
18 
19 #include <stdio.h>
20 
21 /* rk4()
22  Given values for the variables y[0..n-1] use the fourth-order Runge-Kutta
23  method to advance the solution over an interval h and return the
24  incremented variables in y[0..n-1]. The user supplies the routine
25  derivs(x,y,dydx), which returns derivatives dydx at x.t
26 */
27 void rk4(
28  double y[], // initial condition
29  int n, // number of equations
30  double x, // start
31  double h, // interval
32  void (*derivs)(double, double [], double []));
33 
34 /* odeint
35  Runge-Kutta driver with adaptive stepsize control.
36 
37  Integrate starting values ystart[0..nvar-1]
38  from x1 to x2 with accuracy eps,
39 
40  storing intermediate results in global variables.
41  h1 should be set as a guessed first stepsize,
42  hmin as the minimum allowed stepsize (can be zero).
43 
44  On output:
45  - nok and nbad are the number of good and bad (but retried and fixed)
46  steps taken
47  - ystart is replaced by values at the end of the integration interval.
48  - RETURNS 0 on success and 1 on failure
49 
50  derivs is the user-supplied routine for calculating the right-hand side
51  derivative.
52 
53  rkqs is the name of the stepper routine (see above).
54 */
55 int odeint(
56  double ystart[], // initial condition
57  int nvar, // number of equations
58  double x1, // start
59  double x2, // end
60  double eps, // accuracy
61  double h1, // guessed first step-size
62  double hmin, // minimum step-size
63  int *nok, // number of good steps
64  int *nbad, // number of bad steps
65  void (*derivs)(double, double [], double []));
66 
67 void rkActivateBuffer(int); // > 0, 0 - deactivates
68 void rkPrintBuffer(FILE *f = stdout);
69 
70 #endif
void rk4(double y[], int n, double x, double h, void(*derivs)(double, double[], double[]))
Definition: rk.cpp:263
void rkActivateBuffer(int max)
Definition: rk.cpp:395
void rkPrintBuffer(FILE *f)
Definition: rk.cpp:408
int odeint(double ystart[], int nvar, double x1, double x2, double eps, double h1, double hmin, int *nok, int *nbad, void(*derivs)(double, double[], double[]))
Definition: rk.cpp:323