How to construct the code for center of mass of a droplet

3 views (last 30 days)
Dear all,
I would like to construct a code to describe the center of mass of a droplet, with water and ions. For example, the following trajectory file shows the 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, I used: 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) defined by:
cmx = sum(xcm)/length(x)*3;
cmy = sum(ycm)/length(y)*3;
cmz = sum(zcm)/length(z)*3;
My question is, 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?
Below is an example coordinate file showing (partially) two water molecules, two H3O ions, and two Chloride ions:
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
  2 Comments
Image Analyst
Image Analyst on 4 Mar 2015
Can you attach a diagram? I know of center of mass for a photo but not for a trajectory. How does a trajectory have a center of mass?
Kester Wong
Kester Wong on 6 Mar 2015
Edited: Kester Wong on 6 Mar 2015
Hi Image Analyst,
Thank you for the reply. The trajectory is essentially XYZ coordinates of each water molecule; as we may know water has three atoms, hence the center of mass of a water molecule is extracted from the three XYZ coordinates.
The center of mass of each water molecule then gets represented by a "dot" as shown in the diagram, whereby the center of mass of the droplet can then be calculated.
In my water droplets, I also have H3O and Chloride ions, as mentioned in the post. As for chloride, the center of mass is unchanged (since it is represented by a XYZ coordinate). I would like to know how to construct such a code that collectively describes the center of mass of H2O, H3O, and chloride ions; then compute the center of mass of the droplet.

Sign in to comment.

Answers (0)

Categories

Find more on Physics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!