1#include "Vector/vector_dist.hpp"
2#include "Plot/GoogleChart.hpp"
3#include "Operators/Vector/vector_dist_operators.hpp"
5constexpr int velocity = 0;
6constexpr int force = 1;
10 double sigma12,sigma6;
12 ln_potential(
double sigma12_,
double sigma6_) {sigma12 = sigma12_, sigma6 = sigma6_;}
16 double rn = norm2(xp - xq);
18 Point<2,double> E({4.0 * ( sigma12 / (rn*rn*rn*rn*rn*rn) - sigma6 / ( rn*rn*rn) ),
27 double sigma12,sigma6;
29 ln_force(
double sigma12_,
double sigma6_) {sigma12 = sigma12_; sigma6 = sigma6_;}
36 return 24.0*(2.0 * sigma12 / (rn*rn*rn*rn*rn*rn*rn) - sigma6 / (rn*rn*rn*rn)) * r;
40int main(
int argc,
char* argv[])
42 double dt = 0.0005, sigma = 0.1, r_cut = 0.3;
44 double sigma6 = pow(sigma,6), sigma12 = pow(sigma,12);
50 openfpm_init(&argc,&argv);
53 size_t sz[3] = {10,10,10};
55 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
63 auto v_force = getV<force>(vd);
64 auto v_velocity = getV<velocity>(vd);
65 auto v_pos = getV<PROP_POS>(vd);
67 auto it = vd.getGridIterator(sz);
75 vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
76 vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
77 vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
85 auto NN = vd.getCellList(r_cut);
87 vd.updateCellList(NN);
88 v_force = applyKernel_in_sim(vd,NN,lf);
89 unsigned long int f = 0;
92 for (
size_t i = 0; i < 10000 ; i++)
94 assign(v_velocity, v_velocity + 0.5*dt*v_force,
95 v_pos, v_pos + v_velocity*dt);
98 vd.template ghost_get<>();
101 vd.updateCellList(NN);
102 v_force = applyKernel_in_sim(vd,NN,lf);
104 v_velocity = v_velocity + 0.5*dt*v_force;
109 vd.write(
"particles_",f);
112 Point<2,double> E = rsum(applyKernel_in_sim(vd,NN,lp) + (v_velocity * v_velocity)/2.0,vd).get();
122 std::cout <<
"Energy Total: " << E.
get(0) <<
" Kinetic: " << E.
get(1) <<
" Potential: " << E.
get(0) - E.
get(1) << std::endl;
129 options.
title = std::string(
"Energy with time");
130 options.
yAxis = std::string(
"Energy");
131 options.
xAxis = std::string(
"iteration");
136 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.
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
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.