1#include "Vector/vector_dist.hpp"
2#include "Decomposition/CartDecomposition.hpp"
3#include "data_type/aggregate.hpp"
4#include "Plot/GoogleChart.hpp"
5#include "Plot/util.hpp"
36constexpr int velocity = 0;
37constexpr int force = 1;
79template<
typename VerletList>
84 auto itg = vd.getDomainAndGhostIterator();
91 vd.getProp<force>(p)[0] = 0.0;
92 vd.getProp<force>(p)[1] = 0.0;
93 vd.getProp<force>(p)[2] = 0.0;
101 auto it2 = vd.getDomainIterator();
116 auto Np = NN.template getNNIterator<NO_CHECK>(p.getKey());
125 if (q == p.getKey()) {++Np;
continue;};
134 double rn = norm2(r);
136 if (rn > r_cut * r_cut) {++Np;
continue;}
139 Point<3,double> f = 24.0*(2.0 *sigma12 / (rn*rn*rn*rn*rn*rn*rn) - sigma6 / (rn*rn*rn*rn)) * r;
142 vd.template getProp<force>(p)[0] += f.get(0);
143 vd.template getProp<force>(p)[1] += f.get(1);
144 vd.template getProp<force>(p)[2] += f.get(2);
149 vd.template getProp<force>(q)[0] -= f.get(0);
150 vd.template getProp<force>(q)[1] -= f.get(1);
151 vd.template getProp<force>(q)[2] -= f.get(2);
166 vd.ghost_put<
add_,force>();
190template<
typename VerletList>
195 double rc = r_cut*r_cut;
196 double shift = 4.0 * ( sigma12 / (rc*rc*rc*rc*rc*rc) - sigma6 / ( rc*rc*rc) );
199 auto it2 = vd.getDomainIterator();
211 auto Np = NN.template getNNIterator<NO_CHECK>(p.getKey());
222 if (q == p.getKey()) {++Np;
continue;};
228 double rn = norm2(xp - xq);
230 if (rn >= r_cut*r_cut) {++Np;
continue;}
233 E += 4.0 * ( sigma12 / (rn*rn*rn*rn*rn*rn) - sigma6 / ( rn*rn*rn) ) -
shift;
240 E += (vd.template getProp<velocity>(p)[0]*vd.template getProp<velocity>(p)[0] +
241 vd.template getProp<velocity>(p)[1]*vd.template getProp<velocity>(p)[1] +
242 vd.template getProp<velocity>(p)[2]*vd.template getProp<velocity>(p)[2]) / 2;
254int main(
int argc,
char* argv[])
278 double r_cut = 3.0*sigma;
279 double r_gskin = 1.3*r_cut;
280 double sigma12 = pow(sigma,12);
281 double sigma6 = pow(sigma,6);
286 openfpm_init(&argc,&argv);
290 size_t sz[3] = {10,10,10};
296 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
304 size_t start = vd.accum();
306 auto it = vd.getGridIterator(sz);
314 vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
315 vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
316 vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
318 vd.template getLastProp<velocity>()[0] = 0.0;
319 vd.template getLastProp<velocity>()[1] = 0.0;
320 vd.template getLastProp<velocity>()[2] = 0.0;
322 vd.template getLastProp<force>()[0] = 0.0;
323 vd.template getLastProp<force>()[1] = 0.0;
324 vd.template getLastProp<force>()[2] = 0.0;
339 auto NN = vd.getVerletSym(r_gskin);
344 calc_forces(vd,NN,sigma12,sigma6,r_cut);
345 unsigned long int f = 0;
348 double max_disp = 0.0;
351 for (
size_t i = 0; i < 10000 ; i++)
354 auto it3 = vd.getDomainIterator();
356 double max_displ = 0.0;
364 vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
365 vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
366 vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
368 Point<3,double> disp({vd.template getProp<velocity>(p)[0]*dt,vd.template getProp<velocity>(p)[1]*dt,vd.template getProp<velocity>(p)[2]*dt});
371 vd.getPos(p)[0] += disp.
get(0);
372 vd.getPos(p)[1] += disp.get(1);
373 vd.getPos(p)[2] += disp.get(2);
375 if (disp.norm() > max_displ)
376 max_displ = disp.norm();
381 if (max_disp < max_displ)
382 max_disp = max_displ;
388 vd.template ghost_get<>();
390 vd.updateVerlet(NN,r_gskin,VL_SYMMETRIC);
394 vd.template ghost_get<>(SKIP_LABELLING);
400 calc_forces(vd,NN,sigma12,sigma6,r_cut);
403 auto it4 = vd.getDomainIterator();
410 vd.template getProp<velocity>(p)[0] += 0.5*dt*vd.template getProp<force>(p)[0];
411 vd.template getProp<velocity>(p)[1] += 0.5*dt*vd.template getProp<force>(p)[1];
412 vd.template getProp<velocity>(p)[2] += 0.5*dt*vd.template getProp<force>(p)[2];
422 vd.write(
"particles_",f);
429 double energy = calc_energy(vd,NN,sigma12,sigma6,r_cut);
430 auto & vcl = create_vcluster();
441 if (vcl.getProcessUnitID() == 0)
442 std::cout <<
"Energy: " << energy <<
" " << max_disp <<
" " << std::endl;
451 std::cout <<
"Time: " << tsim.
getwct() << std::endl;
459 options.
title = std::string(
"Energy with time");
462 options.
yAxis = std::string(
"Energy");
465 options.
xAxis = std::string(
"iteration");
478 cg.
write(
"gc_plot2_out.html");
This class represent an N-dimensional box.
Small class to produce graph with Google chart in HTML.
void write(std::string file)
It write the graphs on file in html format using Google charts.
void AddLinesGraph(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add a simple lines graph.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Implementation of VCluster class.
Class for Verlet list implementation.
Implementation of 1-D std::vector like structure.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
std::string xAxis
X axis name.
size_t lineWidth
Width of the line.
std::string title
Title of the chart.
std::string yAxis
Y axis name.
This structure define the operation add to use with copy general.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...