crange-1.6.2
|
Source code for crange. More...
#include <crange.h>
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
Main crange program. More... | |
gsl_complex | complex_hyperg (gsl_complex a, gsl_complex b, gsl_complex z) |
Confluent hypergeometric function. More... | |
gsl_complex | complex_lngamma (gsl_complex z) |
Complex logarithm of the Gamma function. More... | |
double | effective_charge (double z0, double e1, double z2, short sswitch) |
Computes effective projectile charge. More... | |
double | djdx (double e1, double z0, double I0, double f0, double K, short sswitch, tdata *target) |
Computes primary ionization. More... | |
double | dedx (double e1, double rel0, double z0, double a1, short sswitch, tdata *target) |
Computes dE/dx. More... | |
double | delta (double g, tdata *target) |
Computes the density effect. More... | |
double | olddelta (double g, tdata *target) |
Computes an obsolete version of the density effect. More... | |
double | bma (double z1, double b) |
Computes the Bloch, Mott and Ahlen corrections. More... | |
double | relbloch (double z12, double b1, double lambda, double theta0) |
Compute the relativistic Bloch correction. More... | |
double | lindhard (double zz, double aa, double bb, short sswitch) |
Compute the Lindhard-Sørensen correction. More... | |
double | Fbrems (double x) |
Compute a mathematical function related to bremsstrahlung. More... | |
double | range (double e, double z1, double a1, short sswitch, tdata *target, int *tno) |
Computes total range given initial energy. More... | |
double | qrange (double e, double z1, double a1, short sswitch, tdata *target) |
Computes total range by direct integration of dE/dx. More... | |
double | benton (double e, double z1, double a1, tdata *target) |
Computes ranges at low energies. More... | |
double | renergy (double e, double r0, double z1, double a1, short sswitch, tdata *target) |
Extract energies from range tables. More... | |
void | run_range (FILE *finput, FILE *foutput, short sswitch, tdata *extratargets) |
Parses and executes the task list. More... | |
short | init_switch (char *switchfile) |
Initializes the value of of the switch bit field. More... | |
tdata * | init_target (char *targetfile) |
Read optional target data file. More... | |
void | init_table (void) |
Initialize range-energy tables. More... | |
double | energy_table (int i) |
Returns the energy corresponding to a value in a range table. More... | |
tdata * | find_target (char *target, tdata *extratargets) |
Finds target data corresponding to a target name. More... | |
void | print_target (tdata *target) |
Prints a target table entry in INI format. More... | |
Source code for crange.
This file contains all source code for the crange executable.
Definition in file crange.c.
double benton | ( | double | e, |
double | z1, | ||
double | a1, | ||
tdata * | target | ||
) |
Computes ranges at low energies.
This function is the result of empirical fits to very low energy 1 A MeV < E < 8 A MeV ion ranges. It follows the methods of Barkas & Berger, [5]. A simplified discussion, with a more complicated formula is given in Benton & Henke, [6]. As yet I know of no nicer way to deal with these low energies.
e | Projectile kinetic energy in A MeV. |
z1 | Projectile charge. |
a1 | Projectile atomic mass. |
target | A pointer to a TDATA structure. |
double bma | ( | double | z1, |
double | b | ||
) |
Computes the Bloch, Mott and Ahlen corrections.
This function computes the Mott correction of Ahlen, [1], the Bloch correction of F. Bloch, [8], and the Ahlen correction of Ahlen, [3]. All three of these corrections are rendered obsolete by the Lindhard-Sørensen correction, and are included here for historical interest and comparison with older calculations.
z1 | The projectile charge. |
b | The projectile velocity in units of the speed of light (i.e. ![]() |
gsl_complex complex_hyperg | ( | gsl_complex | a, |
gsl_complex | b, | ||
gsl_complex | z | ||
) |
Confluent hypergeometric function.
Computes the confluent hypergeometric function. All input parameters are complex numbers. Uses the formula:
where
is the Pochhammer Symbol.
a | First parameter of the hypergeometric function. |
b | Second parameter of the hypergeometric function. |
z | A complex number. |
gsl_complex complex_lngamma | ( | gsl_complex | z | ) |
Complex logarithm of the Gamma function.
Computes the fully complex logarithm of the fully complex Gamma function. Works in all portions of the complex plane, including the negative real axis.
z | A complex number. |
double dedx | ( | double | e1, |
double | rel0, | ||
double | z0, | ||
double | a1, | ||
short | sswitch, | ||
tdata * | target | ||
) |
Computes dE/dx.
This is the core of the whole package, the dE/dx calculator. I have based this largely on the work of Salamon, [20]. Values of certain physical constants have been updated, as well as some of the corrections to the basic stopping power formula.
If the restricted energy loss parameter rel0 is non-zero, dedx() computes restricted energy loss instead.
The dE/dx calculator includes a number of effects that are controlled by switches encoded in a bit field. Below we describe each bit field and the effect it controls.
e1 | The projectile kinetic energy in A MeV. |
rel0 | Restricted energy loss parameter in eV. |
z0 | The projectile charge. |
a1 | The projectile atomic number. |
sswitch | The switch bit field. |
target | A pointer to a TDATA structure. |
double delta | ( | double | g, |
tdata * | target | ||
) |
Computes the density effect.
This function implements the density effect correction as formulated in Sternheimer & Peierls, [21] and as extended in Sternheimer, Berger & Seltzer, [22]. This version can distinguish between solids and gasses, and between metals and insulators. For conducting materials, there is a low-energy density effect.
g | Projectile Lorentz factor. |
target | A pointer to a TDATA structure. |
double djdx | ( | double | e1, |
double | z0, | ||
double | I0, | ||
double | f0, | ||
double | K, | ||
short | sswitch, | ||
tdata * | target | ||
) |
Computes primary ionization.
This computes the primary ionization, the number of delta-rays produced per unit length. The formula is based on Bethe [7], as well as Fleischer et al., [10].
e1 | The projectile kinetic energy in A MeV. |
z0 | The projectile charge. |
I0 | The binding energy of outermost electron in eV. |
f0 | The fraction of electrons in the outermost state. |
K | A constant that depends on the target. |
sswitch | The switch bit field. |
target | A pointer to a TDATA structure. |
double effective_charge | ( | double | z0, |
double | e1, | ||
double | z2, | ||
short | sswitch | ||
) |
Computes effective projectile charge.
This is the modification of projectile charge due to electron capture. Hubert, Bimbot & Gauvin, [12], give an empirically determined function which depends on the target material. This version is used if SSWITCH_EC is set. Two older versions, from Anthony & Landford, [4], and Pierce & Blann, [19] are also available.
z0 | The bare projectile charge. |
e1 | The projectile kinetic energy in A MeV. |
z2 | The target mean nuclear charge. |
sswitch | The switch bit field. |
double energy_table | ( | int | i | ) |
Returns the energy corresponding to a value in a range table.
This utility returns an energy value from a (virtual) vector containing A logarithmically uniform distribution of energies between a minimum and maximum energy (defined by LOGTENEMIN and LOGTENEMAX), with a number of entries given by MAXE.
i | The index of the vector. |
double Fbrems | ( | double | x | ) |
Compute a mathematical function related to bremsstrahlung.
This function is used in an obsolete version of projectile slowing due to nuclear-nuclear bremsstrahlung. It appears in Heitler's treatment of bremsstrahlung, [11], which was adapted by Weaver & Westphal, [27].
x | The input parameter. |
Finds target data corresponding to a target name.
This function returns a pointer to a structure containing the target data corresponding to the input name. There is a built-in list. The built-in list may be added to or overridden by supplying an INI-type file on the command line, which will then be parsed & passed to this function. If the special target name "List" is passed to this function, the built-in list will be printed as an INI-type file.
target | The name of a target. |
extratargets | A pointer to an array of TDATA structures. |
short init_switch | ( | char * | switchfile | ) |
Initializes the value of of the switch bit field.
This utility reads an INI-type file and sets the switch bit field accordingly.
switchfile | The name of an INI-type file containing switch configuration. |
void init_table | ( | void | ) |
Initialize range-energy tables.
Sets all data in the array of RANGE_TABLE structures trange to zero.
tdata* init_target | ( | char * | targetfile | ) |
Read optional target data file.
This utility reads an INI-type file and returns an array of pointers to TDATA structures.
targetfile | the name of an INI-type file containing target data. |
double lindhard | ( | double | zz, |
double | aa, | ||
double | bb, | ||
short | sswitch | ||
) |
Compute the Lindhard-Sørensen correction.
This is the Lindhard-Sørensen correction including finite nuclear size effects as described in Lindhard & Sørensen, [17]. The defined variable SSWITCH_NS will turn off the nuclear size effect if it is set to zero. For values of the Lorentz factor above 10/R, where R is the nuclear size divided by the electron Compton wavelength, the correction is set to its asymptotic value which is described by Sørensen, [23]. This also avoids some difficulties with the evaluation of the confluent hypergeometric function (A. H. Sørensen, private communication).
zz | The projectile charge. |
aa | The projectile atomic mass. |
bb | The projectile velocity in units of the speed of light (i.e. ![]() |
sswitch | The switch bit field. |
int main | ( | int | argc, |
char ** | argv | ||
) |
double olddelta | ( | double | g, |
tdata * | target | ||
) |
Computes an obsolete version of the density effect.
This function implements the density effect correction as originally formulated in Sternheimer & Peierls, [21]. Although it is now obsolete, I have included it here for compatibility with earlier codes.
g | Projectile Lorentz factor. |
target | A pointer to a TDATA structure. |
void print_target | ( | tdata * | target | ) |
double qrange | ( | double | e, |
double | z1, | ||
double | a1, | ||
short | sswitch, | ||
tdata * | target | ||
) |
Computes total range by direct integration of dE/dx.
This function computes total range by direct integration of the dedx() function. It does not create a range table or do table interpolation.
e | Initial energy in A MeV. |
z1 | Projectile charge. |
a1 | Projectile mass. |
sswitch | The switch bit field. |
target | A pointer to a TDATA structure. |
double range | ( | double | e, |
double | z1, | ||
double | a1, | ||
short | sswitch, | ||
tdata * | target, | ||
int * | tno | ||
) |
Computes total range given initial energy.
This function computes total range given initial energy. The technique is quite clever, in that if from one call to the next, the projectile and target material parameters do not change, the calculation of range is performed by table interpolation rather than direct integration. The savings in calculation time can be enormous. However, the range of valid energies is limited by the size of the table. The function dE/dx is evaluated at most of the energies defined by the function energy_table(). Results are stored in the RANGE_TABLE array trange. The size of trange (set by MAXAB) is arbitrary and should be set to whatever is most useful. Certainly it should be no smaller than the number of target materials being used.
e | Initial projectile kinetic energy in A MeV. |
z1 | Projectile charge. |
a1 | Projectile atomic mass. |
sswitch | The switch bit field. |
target | A pointer to a TDATA structure. |
tno | A pointer to the index of the most recently generated or used table. |
double relbloch | ( | double | z12, |
double | b1, | ||
double | lambda, | ||
double | theta0 | ||
) |
Compute the relativistic Bloch correction.
This is the relativistic Bloch (or Ahlen) correction of Ahlen, [3]. The evaluation of this correction has been enormously simplified by the use of fully complex arithmetic.
z12 | The projectile charge. |
b1 | The projectile velocity in units of the speed of light (i.e. ![]() |
lambda | A free parameter, described in bma(). |
theta0 | A free parameter, described in bma(). |
double renergy | ( | double | e, |
double | r0, | ||
double | z1, | ||
double | a1, | ||
short | sswitch, | ||
tdata * | target | ||
) |
Extract energies from range tables.
This function extracts energies from a range table by table interpolation. It calls range() to initialze the range table or to find the correct table if it has already been computed.
e | Projectile kinetic energy [A MeV]. |
r0 | Range [g cm-2]. |
z1 | Projectile charge. |
a1 | Projectile atomic mass. |
sswitch | The switch bit field. |
target | A pointer to a TDATA structure. |
void run_range | ( | FILE * | finput, |
FILE * | foutput, | ||
short | sswitch, | ||
tdata * | extratargets | ||
) |
Parses and executes the task list.
This utility function steps through the range, energy and dE/dx tasks specified in the input data file. The tasks are denoted by a single letter:
The task letter should be followed by the energy (or range) at which to compute range (or energy), the charge and mass of the particle, and the name of the target material. Names of target materials can be found in the target.ini file. Target material names may be up to NAMEWIDTH characters in length and should contain no whitespace.
finput | An open file pointer containing the task list. |
foutput | An open file pointer to write results to. |
sswitch | The switch bit field. |
extratargets | A pointer to an array of TDATA structures. |