Skip to content

Adding Measurements

jspngler edited this page Aug 8, 2024 · 1 revision

MD.cpp

Adding a measurement is simple in the MD.cpp file. Simply locate the measurement section:

                if(i%measureint==0 && i!=startInt)
                {

And perform measurements of values from the System blob. A frequently accessed value, position, is held by the pointer p. To find the distance between the first and second particle, for example, one might add:

                     double dx=p[0].x-p[1].x;
                     double dy=p[0].y-p[1].y;
                     double dz=p[0].z-p[1].z;
                     threeVector<double> size=System.readSize();
                     if(dx>size.x) dx-=size.x;
                     if(dy>size.y) dy-=size.y;
                     if(dz>size.z) dz-=size.z;
                     if(dx<-size.x) dx+=size.x;
                     if(dy<-size.y) dy+=size.y;
                     if(dz<-size.z) dz+=size.z;
                     double pD=std::sqrt(dx*dx+dy*dy+dz*dz);
                     std::fstream dOut("particle_distance.dat",std::ios::out | std::ios::app);
                     dOut << System.readInitialTime() << ' ' << pD << std::endl;

Then, every measureInterval, the distance between the first two particles will be output.

Clone this wiki locally