Layers
Diffusion in heterogeneous environments
header.h
Go to the documentation of this file.
1 
12 // Constants
13 
15 #define MAXNUM_LINES 10000
16 
18 #define MAX_LINELENGTH 100
19 
21 #define MAXNUM_COMMENTLINES 1000
22 
24 #define MAX_COMMAND_LENGTH 1000
25 
27 #define FALSE 0
28 
30 #define TRUE 1
31 
33 #ifdef M_PI
34 # define PI M_PI
35 #else
36 # define PI (4*atan(1.0))
37 #endif
38 
40 #define FARADAY 96485.3399
41 
43 #ifdef DBL_EPSILON
44 # define SMALLNUM DBL_EPSILON
45 #elif defined GSL_DBL_EPSILON
46 # define SMALLNUM GSL_DBL_EPSILON
47 #else
48 # define SMALLNUM 2.2204460492503131e-16
49 #endif
50 
51 
52 // Macros
53 
58 #define IS_ZERO(x) (fabs(x) < (SMALLNUM) ? (TRUE) : (FALSE))
59 
66 #define STREQ(s1,s2) (strcmp(s1,s2) == 0)
67 
72 #define SQR(x) ((x) * (x))
73 
78 #define MAX(x,y) ((x) > (y) ? (x) : (y))
79 
84 #define MIN(x,y) ((x) < (y) ? (x) : (y))
85 
86 /* Define a macro for calculating the 1D index of the arrays
87  * from the 2D indices i and j, in order to make the code simpler.
88  * The 2D indices are: i corresponds to z and j corresponds to r.
89  * The number of rows in most of these matrices is (nr+1)
90  */
95 #define INDEX(i,j) ((i)*(nr+1)+(j))
96 
97 
98 // Function prototypes
99 
100 // convo.c
101 void convolve3(int M, int N, double *a, double scale1, double scale2, double *invr, double *out);
102 
103 // extras.c
104 void error(char *errorstring, ...);
105 
106 void print_usage_fit_layer(char *program);
107 
108 void check_filename(char *in, char *out);
109 
110 double *create_array(int N, char *string);
111 
112 int assemble_command(int argc, char *argv[], char *command);
113 
114 // model.c
115 void calc_diffusion_curve_layer_fit_layer(int nt, int nz, int nr, int iprobe, int jprobe, int iz1, int iz2, int nolayer, double dt, double dr, double sd, double st, double alpha_so, double theta_so, double kappa_so, double alpha_sp, double theta_sp, double kappa_sp, double alpha_sr, double theta_sr, double kappa_sr, double dfree, double *t, double *s, double *invr, double *p);
116 
void calc_diffusion_curve_layer_fit_layer(int nt, int nz, int nr, int iprobe, int jprobe, int iz1, int iz2, int nolayer, double dt, double dr, double sd, double st, double alpha_so, double theta_so, double kappa_so, double alpha_sp, double theta_sp, double kappa_sp, double alpha_sr, double theta_sr, double kappa_sr, double dfree, double *t, double *s, double *invr, double *p)
Calculates the concentration as a function of space and time and returns the probe concentration as a...
Definition: model.c:94
double * create_array(int N, char *string)
Create an array of doubles of the specified size.
Definition: extras.c:105
void print_usage_fit_layer(char *program)
Print usage message and exit with status EXIT_FAILURE.
Definition: extras.c:43
void convolve3(int M, int N, double *a, double scale1, double scale2, double *invr, double *out)
Calculates updates to the concentration in a layer by applying the Laplacian in cylindrical coordinat...
Definition: convo.c:133
int assemble_command(int argc, char *argv[], char *command)
Create a string containing the command used to run the program.
Definition: io.c:91
void error(char *errorstring,...)
Print an error message to stderr and exit with status EXIT_FAILURE.
Definition: extras.c:20
void check_filename(char *in, char *out)
Make sure that the filename is not too long.
Definition: extras.c:103