crange-1.6.2
crange.h
Go to the documentation of this file.
1 
8 /*
9  * Standard includes here to keep crange.c clean
10  */
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <math.h>
14 #include <string.h>
15 #include <unistd.h> /* to get getopt() */
16 #include <errno.h>
17 #include <time.h>
18 /*
19  * Include headers for various complex arithmetic functions.
20  */
21 #include <gsl/gsl_complex.h>
22 #include <gsl/gsl_complex_math.h>
23 /*
24  * Include config.h
25  */
26 #include <config.h>
27 /*
28  * Include header for parsing ini files.
29  */
30 #ifdef HAVE_INIPARSER_H
31 #include <iniparser.h>
32 #endif
33 /*
34  * These values define the range-energy tables
35  */
36 #define LOGTENEMIN 0.0
37 #define LOGTENEMAX 6.0
38 #define MAXE 200
39 #define MAXAB 50
40 /*
41  * M_PI, M_PI_2 and M_LN10 should be defined in math.h.
42  */
43 #ifndef M_PI
44 #define M_PI 3.14159265358979323846264338327950288
45 #endif
46 #ifndef M_PI_2
47 #define M_PI_2 1.57079632679489661923132169163975144
48 #endif
49 #ifndef M_LN10
50 #define M_LN10 2.30258509299404568402
51 #endif
52 /*
53  * Physical constants.
54  */
55 #ifdef ALPHA
56 #undef ALPHA
57 #endif
58 #ifndef ALPHA
59 #define ALPHA 7.29735301383e-3
60 #endif
61 #ifdef ATOMICMASSUNIT
62 #undef ATOMICMASSUNIT
63 #endif
64 #ifndef ATOMICMASSUNIT
65 #define ATOMICMASSUNIT 931.4943
66 #endif
67 #ifdef PROTONMASS
68 #undef PROTONMASS
69 #endif
70 #ifndef PROTONMASS
71 #define PROTONMASS 938.2723
72 #endif
73 #ifdef ELECTRONMASS
74 #undef ELECTRONMASS
75 #endif
76 #ifndef ELECTRONMASS
77 #define ELECTRONMASS 0.511003e+6
78 #endif
79 /*
80  * These define the values in the switch bit field.
81  */
82 #define SSWITCH_BA 0x001
83 #define SSWITCH_SH 0x002
84 #define SSWITCH_LE 0x004
85 #define SSWITCH_ND 0x008
86 #define SSWITCH_EC 0x010
87 #define SSWITCH_NS 0x020
88 #define SSWITCH_KI 0x040
89 #define SSWITCH_RA 0x080
90 #define SSWITCH_PA 0x100
91 #define SSWITCH_BR 0x200
92 #define SSWITCH_DEFAULT (SSWITCH_ND | SSWITCH_NS)
93 /*
94  *
95  */
96 #define NAMEWIDTH 8
97 /*
98  *
99  */
100 
105 struct TDATA {
110  char name[NAMEWIDTH+1];
116  double z2;
117  double a2;
118  double iadj;
119  double rho;
120  double pla;
121  double etad;
122  double bind;
128  double X0;
129  double X1;
130  double a;
131  double m;
132  double d0;
134 };
141 typedef struct TDATA tdata;
147 struct RANGE_TABLE {
148  double z1;
149  double a1;
150  short sswitch;
152  time_t timestamp;
153  double range[MAXE];
154 };
160 typedef struct RANGE_TABLE range_table;
167 /*
168  * Delcare all the functions in crange.c
169  */
170 gsl_complex complex_hyperg( gsl_complex a, gsl_complex b, gsl_complex z );
171 gsl_complex complex_lngamma( gsl_complex z );
172 double effective_charge( double z0, double e1, double z2, short sswitch );
173 double djdx( double e1, double z0, double I0, double f0, double K, short sswitch, tdata *target);
174 double dedx( double e1, double rel0, double z0, double a1, short sswitch, tdata *target );
175 double delta( double g, tdata *target );
176 double olddelta( double g, tdata *target );
177 double bma( double z1, double b );
178 double relbloch( double z12, double b1, double lambda, double theta0 );
179 double lindhard( double zz, double aa, double bb, short sswitch );
180 double Fbrems( double x );
181 double range( double e, double z1, double a1, short sswitch, tdata *target, int *tno );
182 double qrange( double e, double z1, double a1, short sswitch, tdata *target );
183 double benton( double e, double z1, double a1, tdata *target );
184 double renergy( double e, double r0, double z1, double a1, short sswitch, tdata *target );
185 void run_range( FILE *finput, FILE *foutput, short sswitch, tdata *extratargets );
186 short init_switch( char *switchfile);
187 tdata *init_target( char *targetfile );
188 void init_table(void);
189 double energy_table( int i );
190 tdata *find_target( char *target, tdata *extratargets );
191 void print_target( tdata *target );
double rho
Definition: crange.h:119
double a2
Definition: crange.h:117
double bma(double z1, double b)
Computes the Bloch, Mott and Ahlen corrections.
Definition: crange.c:768
double olddelta(double g, tdata *target)
Computes an obsolete version of the density effect.
Definition: crange.c:692
double delta(double g, tdata *target)
Computes the density effect.
Definition: crange.c:657
double lindhard(double zz, double aa, double bb, short sswitch)
Compute the Lindhard-Sørensen correction.
Definition: crange.c:897
tdata * find_target(char *target, tdata *extratargets)
Finds target data corresponding to a target name.
Definition: crange.c:1596
void print_target(tdata *target)
Prints a target table entry in INI format.
Definition: crange.c:1677
double Fbrems(double x)
Compute a mathematical function related to bremsstrahlung.
Definition: crange.c:1039
double iadj
Definition: crange.h:118
double renergy(double e, double r0, double z1, double a1, short sswitch, tdata *target)
Extract energies from range tables.
Definition: crange.c:1348
double effective_charge(double z0, double e1, double z2, short sswitch)
Computes effective projectile charge.
Definition: crange.c:366
double dedx(double e1, double rel0, double z0, double a1, short sswitch, tdata *target)
Computes dE/dx.
Definition: crange.c:545
double z2
Definition: crange.h:116
tdata * target
Definition: crange.h:151
void run_range(FILE *finput, FILE *foutput, short sswitch, tdata *extratargets)
Parses and executes the task list.
Definition: crange.c:1396
gsl_complex complex_hyperg(gsl_complex a, gsl_complex b, gsl_complex z)
Confluent hypergeometric function.
Definition: crange.c:267
Structure containing target data.
Definition: crange.h:105
gsl_complex complex_lngamma(gsl_complex z)
Complex logarithm of the Gamma function.
Definition: crange.c:299
range_table trange[MAXAB]
The range-energy table.
Definition: crange.h:166
double djdx(double e1, double z0, double I0, double f0, double K, short sswitch, tdata *target)
Computes primary ionization.
Definition: crange.c:437
double X1
Definition: crange.h:129
double etad
Definition: crange.h:121
double energy_table(int i)
Returns the energy corresponding to a value in a range table.
Definition: crange.c:1569
#define MAXE
Definition: crange.h:38
short init_switch(char *switchfile)
Initializes the value of of the switch bit field.
Definition: crange.c:1441
double X0
Definition: crange.h:128
double qrange(double e, double z1, double a1, short sswitch, tdata *target)
Computes total range by direct integration of dE/dx.
Definition: crange.c:1183
double d0
Definition: crange.h:132
short sswitch
Definition: crange.h:150
Structure to store range tables.
Definition: crange.h:147
double range[MAXE]
Definition: crange.h:153
#define NAMEWIDTH
Definition: crange.h:96
double z1
Definition: crange.h:148
double a
Definition: crange.h:130
double relbloch(double z12, double b1, double lambda, double theta0)
Compute the relativistic Bloch correction.
Definition: crange.c:838
tdata * init_target(char *targetfile)
Read optional target data file.
Definition: crange.c:1481
char name[NAMEWIDTH+1]
Definition: crange.h:110
double m
Definition: crange.h:131
double pla
Definition: crange.h:120
time_t timestamp
Definition: crange.h:152
double a1
Definition: crange.h:149
void init_table(void)
Initialize range-energy tables.
Definition: crange.c:1543
double benton(double e, double z1, double a1, tdata *target)
Computes ranges at low energies.
Definition: crange.c:1247
#define MAXAB
Definition: crange.h:39
double bind
Definition: crange.h:122
double range(double e, double z1, double a1, short sswitch, tdata *target, int *tno)
Computes total range given initial energy.
Definition: crange.c:1086