15 |
|
double xmin, xmax, x; |
16 |
|
double ymin, ymax, y; |
17 |
|
double zmin, zmax, z; |
18 |
< |
double r, theta, phi, f, s, w, w0; |
19 |
< |
double fp, sp, wp, tot; |
20 |
< |
double rup, ru, rlow; |
18 |
> |
double r, theta, phi, costheta; |
19 |
> |
double sigmaShape, sShape, epsShape; |
20 |
> |
double sigmaProbe, sProbe, epsProbe; |
21 |
> |
double sigma, s, eps; |
22 |
> |
double rTerm, r6, r12; |
23 |
> |
double energy; |
24 |
> |
double range; |
25 |
> |
|
26 |
|
char* shapeFileName; |
27 |
+ |
char* outputFileName; |
28 |
|
SHAPE* shape; |
29 |
< |
FILE* my_file; |
29 |
> |
FILE* outputFile; |
30 |
|
|
31 |
|
//parse the command line options |
32 |
|
if (cmdline_parser (argc, argv, &args_info) != 0) |
43 |
|
shape = new SHAPE(); |
44 |
|
shape->readSHAPEfile(shapeFileName); |
45 |
|
|
40 |
– |
|
41 |
– |
// grid has a default value (default=51), so it is always given |
42 |
– |
npts = args_info.grid_arg; |
46 |
|
|
47 |
< |
|
47 |
> |
if (args_info.output_given){ |
48 |
> |
outputFileName = args_info.output_arg; |
49 |
> |
} |
50 |
> |
else{ |
51 |
> |
std::cerr << "Does not have output file name" << endl; |
52 |
> |
exit(1); |
53 |
> |
} |
54 |
|
|
55 |
+ |
outputFile = fopen(outputFileName, "w"); |
56 |
|
|
57 |
< |
my_file = fopen("junk.dat", "w"); |
58 |
< |
if (my_file == NULL) { |
49 |
< |
(void) fprintf(stderr, "No File\n"); |
57 |
> |
if (outputFile == NULL) { |
58 |
> |
(void) fprintf(stderr, "Unable to open outputFile %s!\n", outputFileName); |
59 |
|
exit(8); |
60 |
|
} |
61 |
+ |
|
62 |
+ |
// grid has a default value (default=51), so it is always given |
63 |
+ |
npts = args_info.grid_arg; |
64 |
+ |
range = args_info.range_arg; |
65 |
|
|
66 |
< |
npts = 51; |
66 |
> |
xmin = -range; |
67 |
> |
xmax = range; |
68 |
|
|
69 |
< |
xmin = -5.0; |
70 |
< |
xmax = 5.0; |
69 |
> |
ymin = -range; |
70 |
> |
ymax = range; |
71 |
|
|
72 |
< |
ymin = -5.0; |
73 |
< |
ymax = 5.0; |
72 |
> |
zmin = -range; |
73 |
> |
zmax = range; |
74 |
|
|
75 |
< |
zmin = -5.0; |
76 |
< |
zmax = 5.0; |
75 |
> |
//sigmaProbe = 2.28; |
76 |
> |
//sProbe = 2.28; |
77 |
> |
//epsProbe = 0.020269601874; |
78 |
> |
sigmaProbe = 0.0; |
79 |
> |
sProbe = 0.0; |
80 |
> |
epsProbe = 1.0; |
81 |
|
|
64 |
– |
rup = 4.0; |
65 |
– |
ru = 3.35; |
66 |
– |
rlow = 2.75; |
67 |
– |
w0 = 0.07715; |
68 |
– |
|
82 |
|
for (i = 0; i < npts; i++) { |
83 |
< |
x = xmin + (xmax-xmin) * (double)i/(double)npts; |
83 |
> |
x = xmin + (xmax-xmin) * (double)i/(double)(npts-1); |
84 |
|
|
85 |
|
for (j = 0; j < npts; j++) { |
86 |
< |
y = ymin + (ymax-ymin) * (double)j/(double)npts; |
86 |
> |
y = ymin + (ymax-ymin) * (double)j/(double)(npts-1); |
87 |
|
|
88 |
|
for (k = 0; k < npts; k++) { |
89 |
< |
z = zmin + (zmax-zmin) * (double)k/(double)npts; |
89 |
> |
z = zmin + (zmax-zmin) * (double)k/(double)(npts-1); |
90 |
|
|
91 |
|
r = sqrt(x*x + y*y + z*z); |
92 |
< |
theta = acos(z/r); |
93 |
< |
phi = atan(y/x); |
81 |
< |
|
82 |
< |
fp = pow((cos(theta) - 0.6),2) * pow((cos(theta) + 0.8),2); |
92 |
> |
costheta = z/r; |
93 |
> |
phi = atan2(y,x); |
94 |
|
|
95 |
< |
sp = (rup + 2.0*r - 3.0*rlow) * pow((rup - r),2) / pow((rup -rlow),3); |
95 |
> |
sigmaShape = shape->getSigmaAt(costheta, phi); |
96 |
> |
sShape = shape->getSAt(costheta, phi); |
97 |
> |
epsShape = shape->getEpsAt(costheta, phi); |
98 |
|
|
99 |
< |
if (r > rup) sp = 0.0; |
87 |
< |
if (r < rlow) sp = 1.0; |
99 |
> |
// Lorentz-Berthellot combining rules: |
100 |
|
|
101 |
< |
wp = sp*(fp - w0); |
101 |
> |
sigma = (sigmaShape + sigmaProbe) / 2.0; |
102 |
> |
s = (sShape + sProbe) / 2.0; |
103 |
> |
eps = sqrt(epsShape * epsProbe); |
104 |
|
|
105 |
< |
f = sin(theta)*sin(2.0*theta)*cos(2.0*phi); |
92 |
< |
|
93 |
< |
s = (ru + 2.0*r - 3.0*rlow) * pow((ru - r),2) / pow((ru -rlow),3); |
105 |
> |
rTerm = s / (r - sigma + s); |
106 |
|
|
107 |
< |
if (r > ru) s = 0.0; |
108 |
< |
if (r < rlow) s = 1.0; |
109 |
< |
|
110 |
< |
w = f*s; |
111 |
< |
|
112 |
< |
tot = w + wp; |
113 |
< |
|
102 |
< |
write_size = fwrite(&tot,1,8,my_file); |
103 |
< |
|
107 |
> |
r6 = pow(rTerm, 6); |
108 |
> |
r12 = r6*r6; |
109 |
> |
|
110 |
> |
energy = 4.0 * eps * (r12 - r6); |
111 |
> |
|
112 |
> |
write_size = fwrite(&energy,1,8,outputFile); |
113 |
> |
|
114 |
|
} |
115 |
|
} |
116 |
|
} |
117 |
< |
fclose(my_file); |
117 |
> |
fclose(outputFile); |
118 |
|
return(0); |
119 |
|
} |