CLASS MANUAL
evolver_ndf15.h
1 #ifndef __EVO__
2 #define __EVO__
3 #include "common.h"
4 // #include "perturbations.h"
5 #include "sparse.h"
6 #define TINY 1e-50
7 /**************************************************************/
8 
9 struct jacobian{
10 /*Stuff for normal method: */
11  double **dfdy;
12  double *jacvec; /*Stores experience gained from subsequent calls */
13  double **LU;
14  double *LUw;
15  int *luidx;
16  /*Sparse stuff:*/
17  int use_sparse;
18  int sparse_stuff_initialized;
19  int max_nonzero; /*Maximal number of non-zero entries to be considered sparse */
20  int repeated_pattern;
21  int trust_sparse; /* Number of times a pattern is repeated (actually included) before we trust it. */
22  int has_grouping;
23  int has_pattern;
24  int new_jacobian; /* True if sp_ludcmp has not been run on the current jacobian. */
25  int cnzmax;
26  int *col_group; /* Column grouping. Groups go from 0 to max_group*/
27  int *col_wi; /* Workarray for column grouping*/
28  int max_group; /*Number of columngroups -1 */
29  sp_mat *spJ; /* Stores the matrix we want to decompose */
30  double *xjac; /*Stores the values of the sparse jacobian. (Same pattern as spJ) */
31  sp_num *Numerical; /*Stores the LU decomposition.*/
32  int *Cp; /* Stores the column pointers of the spJ+spJ' sparsity pattern. */
33  int *Ci; /* Stores the row indices of the spJ+spJ' sparsity pattern. */
34 };
35 
36 struct numjac_workspace{
37  /* Allocate vectors and matrices: */
38  double *yscale;
39  double *del;
40  double * Difmax;
41  double * absFdelRm;
42  double * absFvalue;
43  double * absFvalueRm;
44  double * Fscale;
45  double * ffdel;
46  double * yydel;
47  double * tmp;
48 
49  double **ydel_Fdel;
50 
51  int * logj;
52  int * Rowmax;
53 };
54 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62  int initialize_jacobian(struct jacobian *jac, int neq, ErrorMsg error_message);
63  int uninitialize_jacobian(struct jacobian *jac);
64  int initialize_numjac_workspace(struct numjac_workspace * nj_ws,int neq, ErrorMsg error_message);
65  int uninitialize_numjac_workspace(struct numjac_workspace * nj_ws);
66  int calc_C(struct jacobian *jac);
67  int interp_from_dif(double tinterp,double tnew,double *ynew,double h,double **dif,int k, double *yinterp,
68  double *ypinterp, double *yppinterp, int* index, int neq, int output);
69  int new_linearisation(struct jacobian *jac,double hinvGak,int neq, ErrorMsg error_message);
70  int adjust_stepsize(double **dif, double abshdivabshlast, int neq,int k);
71  void eqvec(double *datavec,double *emptyvec, int n);
72  int lubksb(double **a, int n, int *indx, double b[]);
73  int ludcmp(double **a, int n, int *indx, double *d, double *vv);
74  int fzero_Newton(int (*func)(double *x,
75  int x_size,
76  void *param,
77  double *F,
78  ErrorMsg error_message),
79  double *x_inout,
80  double *dxdF,
81  int x_size,
82  double tolx,
83  double tolF,
84  void *param,
85  int *fevals,
86  ErrorMsg error_message);
87 
88  int numjac(int (*derivs)(double x,double * y,double * dy,void * parameters_and_workspace,ErrorMsg error_message),
89  double t, double *y, double *fval, struct jacobian *jac, struct numjac_workspace *nj_ws,
90  double thresh, int neq, int *nfe,
91  void * parameters_and_workspace_for_derivs, ErrorMsg error_message);
92 
93 
94 int evolver_ndf15(
95  int (*derivs)(double x,double * y,double * dy,
96  void * parameters_and_workspace, ErrorMsg error_message),
97  double x_ini,
98  double x_final,
99  double * y_inout,
100  int * used_in_output,
101  int neq,
102  void * parameters_and_workspace_for_derivs,
103  double rtol,
104  double minimum_variation,
105  int (*timescale_and_approximation)(double x,
106  void * parameters_and_workspace,
107  double * timescales,
108  ErrorMsg error_message),
109  double timestep_over_timescale,
110  double * t_vec,
111  int t_res,
112  int (*output)(double x,double y[],double dy[],int index_x,void * parameters_and_workspace,
113  ErrorMsg error_message),
114  int (*print_variables)(double x, double y[], double dy[], void *parameters_and_workspace,
115  ErrorMsg error_message),
116  ErrorMsg error_message);
117 
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 /**************************************************************/
124 
125 #endif
Definition: output.h:22