ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/dipmom.c
(Generate patch)
# Line 7 | Line 7
7   EXTERN struct t_dipolemom {
8          double total, xdipole, ydipole, zdipole;
9         }  dipolemom;
10 EXTERN struct t_dmomv {
11        float xn,yn,zn,xp,yp,zp;
12        }       dmomv;
10   struct t_quadmom {
11          double xx,xy,xz,yx,yy,yz,zx,zy,zz;
12         } quadmom;
# Line 25 | Line 22
22      int i;
23      double weight, xcenter, ycenter, zcenter;
24      double xsum, ysum, zsum, debye;
28    double cu;
25  
26      debye = 4.8033324;
27  
# Line 44 | Line 40
40      ycenter /= weight;
41      zcenter /= weight;
42  
47    xsum = 0.0;
48    ysum = 0.0;
49    zsum = 0.0;
50    dmomv.xp = 0.0;
51    dmomv.yp = 0.0;
52    dmomv.xp = 0.0;
53    dmomv.xn = 0.0;
54    dmomv.yn = 0.0;
55    dmomv.zn = 0.0;
43      for(i=1; i <= natom; i++)
44      {
45          xsum += (atom[i].x-xcenter)*atom[i].charge;
46          ysum += (atom[i].y-ycenter)*atom[i].charge;
47          zsum += (atom[i].z-zcenter)*atom[i].charge;
61
62        cu = atom[i].charge;
63        if ( cu < 0.0)
64        {
65            dmomv.xn -= atom[i].x*cu;
66            dmomv.yn -= atom[i].y*cu;
67            dmomv.zn -= atom[i].z*cu;
68        } else if (cu > 0.0)
69        {
70            dmomv.xp += atom[i].x*cu;
71            dmomv.yp += atom[i].y*cu;
72            dmomv.zp += atom[i].z*cu;
73        }
74        
48      }
49      dipolemom.xdipole = xsum*debye;
50      dipolemom.ydipole = ysum*debye;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines