|
1 | | -#include <cstdarg> |
2 | | -#include <cstdint> |
3 | | -#include <cstdlib> |
4 | | -#include <ostream> |
5 | | -#include <new> |
6 | | -#include <cmath> |
7 | | - |
8 | | -static const double PI = M_PI; |
9 | | - |
10 | | -static const double FRAC_2_SQRT_PI = M_2_PI; |
11 | | - |
12 | | -static const double SQRT_2 = M_SQRT2; |
13 | | - |
14 | | -///Fundamental charge in Coulombs. |
15 | | -static const double Q = 1.602176634e-19; |
16 | | - |
17 | | -/// One electron-volt in Joules. |
18 | | -static const double EV = Q; |
19 | | - |
20 | | -/// One atomic mass unit in kilograms. |
21 | | -static const double AMU = 1.66053906660e-27; |
22 | | - |
23 | | -/// One Angstrom in meters. |
24 | | -static const double ANGSTROM = 1e-10; |
25 | | - |
26 | | -/// One micron in meters. |
27 | | -static const double MICRON = 1e-6; |
28 | | - |
29 | | -/// One nanometer in meters. |
30 | | -static const double NM = 1e-9; |
31 | | - |
32 | | -/// One centimeter in meters. |
33 | | -static const double CM = 1e-2; |
34 | | - |
35 | | -/// Vacuum permitivity in Farads/meter. |
36 | | -static const double EPS0 = 8.8541878128e-12; |
37 | | - |
38 | | -/// Bohr radius in meters. |
39 | | -static const double A0 = 5.29177210903e-11; |
40 | | - |
41 | | -/// Electron mass in kilograms. |
42 | | -static const double ME = 9.1093837015e-31; |
43 | | - |
44 | | -/// sqrt(pi). |
45 | | -static const double SQRTPI = (2. / FRAC_2_SQRT_PI); |
46 | | - |
47 | | -/// sqrt(2 * pi). |
48 | | -static const double SQRT2PI = ((2. * SQRT_2) / FRAC_2_SQRT_PI); |
49 | | - |
50 | | -/// Speed of light in meters/second. |
51 | | -static const double C = 299792458.; |
52 | | - |
53 | | -/// Bethe-Bloch electronic stopping prefactor, in SI units. |
54 | | -static const double BETHE_BLOCH_PREFACTOR = ((((((4. * PI) * ((Q * Q) / ((4. * PI) * EPS0))) * ((Q * Q) / ((4. * PI) * EPS0))) / ME) / C) / C); |
55 | | - |
56 | | -/// Lindhard-Scharff electronic stopping prefactor, in SI units. |
57 | | -static const double LINDHARD_SCHARFF_PREFACTOR = (((1.212 * ANGSTROM) * ANGSTROM) * Q); |
58 | | - |
59 | | -/// Lindhard reduced energy prefactor, in SI units. |
60 | | -static const double LINDHARD_REDUCED_ENERGY_PREFACTOR = ((((4. * PI) * EPS0) / Q) / Q); |
61 | | - |
62 | | -struct OutputBCA { |
63 | | - uintptr_t len; |
64 | | - double (*particles)[9]; |
65 | | -}; |
66 | | - |
67 | | -struct InputSimpleBCA { |
68 | | - uintptr_t len; |
69 | | - /// vx, vy, vz |
70 | | - double (*velocities)[3]; |
71 | | - double Z1; |
72 | | - double m1; |
73 | | - double Ec1; |
74 | | - double Es1; |
75 | | - double Z2; |
76 | | - double m2; |
77 | | - double n2; |
78 | | - double Ec2; |
79 | | - double Es2; |
80 | | - double Eb2; |
81 | | -}; |
82 | | - |
83 | | -struct InputCompoundBCA { |
84 | | - uintptr_t len; |
85 | | - /// vx, vy, vz |
86 | | - double (*velocities)[3]; |
87 | | - double Z1; |
88 | | - double m1; |
89 | | - double Ec1; |
90 | | - double Es1; |
91 | | - uintptr_t num_species_target; |
92 | | - double *Z2; |
93 | | - double *m2; |
94 | | - double *n2; |
95 | | - double *Ec2; |
96 | | - double *Es2; |
97 | | - double *Eb2; |
98 | | -}; |
99 | | - |
100 | | -extern "C" { |
101 | | - |
102 | | -OutputBCA simple_bca_list_c(InputSimpleBCA input); |
103 | | - |
104 | | -OutputBCA compound_bca_list_c(InputCompoundBCA input); |
105 | | - |
106 | | -OutputBCA simple_bca_c(double x, |
107 | | - double y, |
108 | | - double z, |
109 | | - double ux, |
110 | | - double uy, |
111 | | - double uz, |
112 | | - double E1, |
113 | | - double Z1, |
114 | | - double m1, |
115 | | - double Ec1, |
116 | | - double Es1, |
117 | | - double Z2, |
118 | | - double m2, |
119 | | - double Ec2, |
120 | | - double Es2, |
121 | | - double n2, |
122 | | - double Eb2); |
123 | | - |
124 | | -} // extern "C" |
| 1 | +#include <cstdarg> |
| 2 | +#include <cstdint> |
| 3 | +#include <cstdlib> |
| 4 | +#include <ostream> |
| 5 | +#include <new> |
| 6 | +#include <cmath> |
| 7 | + |
| 8 | +static const double PI = M_PI; |
| 9 | + |
| 10 | +static const double FRAC_2_SQRT_PI = M_2_PI; |
| 11 | + |
| 12 | +static const double SQRT_2 = M_SQRT2; |
| 13 | + |
| 14 | +///Fundamental charge in Coulombs. |
| 15 | +static const double Q = 1.602176634e-19; |
| 16 | + |
| 17 | +/// One electron-volt in Joules. |
| 18 | +static const double EV = Q; |
| 19 | + |
| 20 | +/// One atomic mass unit in kilograms. |
| 21 | +static const double AMU = 1.66053906660e-27; |
| 22 | + |
| 23 | +/// One Angstrom in meters. |
| 24 | +static const double ANGSTROM = 1e-10; |
| 25 | + |
| 26 | +/// One micron in meters. |
| 27 | +static const double MICRON = 1e-6; |
| 28 | + |
| 29 | +/// One nanometer in meters. |
| 30 | +static const double NM = 1e-9; |
| 31 | + |
| 32 | +/// One centimeter in meters. |
| 33 | +static const double CM = 1e-2; |
| 34 | + |
| 35 | +/// Vacuum permitivity in Farads/meter. |
| 36 | +static const double EPS0 = 8.8541878128e-12; |
| 37 | + |
| 38 | +/// Bohr radius in meters. |
| 39 | +static const double A0 = 5.29177210903e-11; |
| 40 | + |
| 41 | +/// Electron mass in kilograms. |
| 42 | +static const double ME = 9.1093837015e-31; |
| 43 | + |
| 44 | +/// sqrt(pi). |
| 45 | +static const double SQRTPI = (2. / FRAC_2_SQRT_PI); |
| 46 | + |
| 47 | +/// sqrt(2 * pi). |
| 48 | +static const double SQRT2PI = ((2. * SQRT_2) / FRAC_2_SQRT_PI); |
| 49 | + |
| 50 | +/// Speed of light in meters/second. |
| 51 | +static const double C = 299792458.; |
| 52 | + |
| 53 | +/// Bethe-Bloch electronic stopping prefactor, in SI units. |
| 54 | +static const double BETHE_BLOCH_PREFACTOR = ((((((4. * PI) * ((Q * Q) / ((4. * PI) * EPS0))) * ((Q * Q) / ((4. * PI) * EPS0))) / ME) / C) / C); |
| 55 | + |
| 56 | +/// Lindhard-Scharff electronic stopping prefactor, in SI units. |
| 57 | +static const double LINDHARD_SCHARFF_PREFACTOR = (((1.212 * ANGSTROM) * ANGSTROM) * Q); |
| 58 | + |
| 59 | +/// Lindhard reduced energy prefactor, in SI units. |
| 60 | +static const double LINDHARD_REDUCED_ENERGY_PREFACTOR = ((((4. * PI) * EPS0) / Q) / Q); |
| 61 | + |
| 62 | +struct OutputBCA { |
| 63 | + uintptr_t len; |
| 64 | + double (*particles)[9]; |
| 65 | +}; |
| 66 | + |
| 67 | +struct InputSimpleBCA { |
| 68 | + uintptr_t len; |
| 69 | + /// vx, vy, vz |
| 70 | + double (*velocities)[3]; |
| 71 | + double Z1; |
| 72 | + double m1; |
| 73 | + double Ec1; |
| 74 | + double Es1; |
| 75 | + double Z2; |
| 76 | + double m2; |
| 77 | + double n2; |
| 78 | + double Ec2; |
| 79 | + double Es2; |
| 80 | + double Eb2; |
| 81 | +}; |
| 82 | + |
| 83 | +struct InputCompoundBCA { |
| 84 | + uintptr_t len; |
| 85 | + /// vx, vy, vz |
| 86 | + double (*velocities)[3]; |
| 87 | + double Z1; |
| 88 | + double m1; |
| 89 | + double Ec1; |
| 90 | + double Es1; |
| 91 | + uintptr_t num_species_target; |
| 92 | + double *Z2; |
| 93 | + double *m2; |
| 94 | + double *n2; |
| 95 | + double *Ec2; |
| 96 | + double *Es2; |
| 97 | + double *Eb2; |
| 98 | +}; |
| 99 | + |
| 100 | +extern "C" { |
| 101 | + |
| 102 | +OutputBCA simple_bca_list_c(InputSimpleBCA input); |
| 103 | + |
| 104 | +OutputBCA compound_bca_list_c(InputCompoundBCA input); |
| 105 | + |
| 106 | +OutputBCA simple_bca_c(double x, |
| 107 | + double y, |
| 108 | + double z, |
| 109 | + double ux, |
| 110 | + double uy, |
| 111 | + double uz, |
| 112 | + double E1, |
| 113 | + double Z1, |
| 114 | + double m1, |
| 115 | + double Ec1, |
| 116 | + double Es1, |
| 117 | + double Z2, |
| 118 | + double m2, |
| 119 | + double Ec2, |
| 120 | + double Es2, |
| 121 | + double n2, |
| 122 | + double Eb2); |
| 123 | + |
| 124 | +} // extern "C" |
0 commit comments