21 |
|
double sigma, s, eps; |
22 |
|
double rTerm, r6, r12; |
23 |
|
double energy; |
24 |
+ |
double range; |
25 |
|
|
26 |
|
char* shapeFileName; |
27 |
|
char* outputFileName; |
32 |
|
if (cmdline_parser (argc, argv, &args_info) != 0) |
33 |
|
exit(1) ; |
34 |
|
|
35 |
< |
if (args_info.shape_given){ |
36 |
< |
shapeFileName = args_info.shape_arg; |
37 |
< |
} |
38 |
< |
else{ |
35 |
> |
|
36 |
> |
if (args_info.inputs_num > 0) { |
37 |
> |
shapeFileName = args_info.inputs[0]; |
38 |
> |
} else { |
39 |
|
std::cerr << "Does not have shape file name" << endl; |
40 |
|
exit(1); |
41 |
|
} |
43 |
|
shape = new SHAPE(); |
44 |
|
shape->readSHAPEfile(shapeFileName); |
45 |
|
|
46 |
< |
|
47 |
< |
if (args_info.output_given){ |
48 |
< |
outputFileName = args_info.output_arg; |
46 |
> |
if (args_info.inputs_num > 1) { |
47 |
> |
outputFileName = args_info.inputs[1]; |
48 |
> |
} else { |
49 |
> |
std::cerr << "No output file name specified." << endl; |
50 |
> |
outputFileName = strdup(shapeFileName); |
51 |
> |
strcat(outputFileName, ".viz"); |
52 |
> |
std::cerr << "Using: " << outputFileName << endl; |
53 |
|
} |
49 |
– |
else{ |
50 |
– |
std::cerr << "Does not have output file name" << endl; |
51 |
– |
exit(1); |
52 |
– |
} |
54 |
|
|
55 |
|
outputFile = fopen(outputFileName, "w"); |
56 |
|
|
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 |
< |
xmin = -10.0; |
67 |
< |
xmax = 10.0; |
66 |
> |
xmin = -range; |
67 |
> |
xmax = range; |
68 |
|
|
69 |
< |
ymin = -10.0; |
70 |
< |
ymax = 10.0; |
69 |
> |
ymin = -range; |
70 |
> |
ymax = range; |
71 |
|
|
72 |
< |
zmin = -10.0; |
73 |
< |
zmax = 10.0; |
72 |
> |
zmin = -range; |
73 |
> |
zmax = range; |
74 |
|
|
75 |
|
//sigmaProbe = 2.28; |
76 |
|
//sProbe = 2.28; |
80 |
|
epsProbe = 1.0; |
81 |
|
|
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 |
|
costheta = z/r; |
93 |
< |
phi = atan(y/x); |
93 |
> |
phi = atan2(y,x); |
94 |
|
|
95 |
|
sigmaShape = shape->getSigmaAt(costheta, phi); |
96 |
|
sShape = shape->getSAt(costheta, phi); |