ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/SHAPES/visualizer.cpp
(Generate patch)

Comparing trunk/SHAPES/visualizer.cpp (file contents):
Revision 1295 by gezelter, Thu Jun 24 15:31:52 2004 UTC vs.
Revision 1299 by gezelter, Thu Jun 24 15:56:05 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines