On 3/3/15 5:59 AM, Kester Wong wrote:
Dear all, I would like to construct a code to describe the center of mass of a droplet, with water and ions. For the following GROMACS trajectory file (confout.gro), we can have water coordinates as: 57SOL OW 36289 17.563 14.835 0.520 57SOL HW1 36290 17.602 14.916 0.487 57SOL HW2 36291 17.571 14.843 0.615 58SOL OW 36292 17.588 14.547 0.457 58SOL HW1 36293 17.573 14.642 0.458 58SOL HW2 36294 17.521 14.512 0.516 59SOL OW 36295 11.747 17.611 1.159 59SOL HW1 36296 11.714 17.522 1.174 59SOL HW2 36297 11.740 17.624 1.064 To describe the center of mass of each molecule, we can have the following for-loop: for i = 1:length(x)/3 xcm(i) = (x(i*3-2)*massO + x(i*3-1)*massH + x(i*3)*massH)/massWater; ycm(i) = (y(i*3-2)*massO + y(i*3-1)*massH + y(i*3)*massH)/massWater; zcm(i) = (z(i*3-2)*massO + z(i*3-1)*massH + z(i*3)*massH)/massWater; end Then, the center of mass of a droplet (100% water) can be defined by: cmx = sum(xcm)/length(x)*3; cmy =sum(ycm)/length(y)*3; cmz = sum(zcm)/length(z)*3; For a droplet consisting of H2O, H3O, and Chloride ions, how does one describe the center of mass of each molecule/ion using the for-loop, and then using the xcm(i), ycm(i), and zcm(i) to determine the center of the droplet?
Look at the code for gmx traj. It does these calculations with gmx traj -ox -com. Save some time and use existing software rather than reinventing the wheel :)
-Justin
Below is an example of the coordinate file: 2015SOL OW 42163 17.143 16.975 0.502 2015SOL HW1 42164 17.175 17.038 0.567 2015SOL HW2 42165 17.222 16.937 0.464 2016SOL OW 42166 16.088 17.097 0.778 2016SOL HW1 42167 16.094 17.182 0.734 2016SOL HW2 42168 16.159 17.098 0.843 . . . 2035H3O OW 42241 17.895 20.054 0.561 2035H3O H31 42242 17.836 20.100 0.492 2035H3O H32 42243 17.970 20.114 0.593 2035H3O H33 42244 17.930 19.964 0.527 2036H3O OW 42245 13.948 17.327 0.503 2036H3O H31 42246 13.875 17.348 0.571 2036H3O H32 42247 13.978 17.410 0.452 2036H3O H33 42248 14.026 17.276 0.544 . . . 2037CLA CL 42249 13.862 17.882 1.754 2038CLA CL 42250 16.686 17.457 0.667 Thanks in advance. Regards, Kester
-- ================================================== Justin A. Lemkul, Ph.D. Ruth L. Kirschstein NRSA Postdoctoral Fellow Department of Pharmaceutical Sciences School of Pharmacy Health Sciences Facility II, Room 629 University of Maryland, Baltimore 20 Penn St. Baltimore, MD 21201 jalem...@outerbanks.umaryland.edu | (410) 706-7441 http://mackerell.umaryland.edu/~jalemkul ================================================== -- Gromacs Users mailing list * Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before posting! * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists * For (un)subscribe requests visit https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or send a mail to gmx-users-requ...@gromacs.org.