5 double NumDiff = 0.001;
6 double **Plot = (
double **)calloc(NType,
sizeof(
double));
10 for(
int t=0;t<3;t++) Plot[t] = (
double *)calloc(CUB(
NEdge),
sizeof(
double));
15 if(
Open(cFile[f],BF_NO))
return;
17 for(
int p=0;p<
pNPart();p++){
19 v[d] = (int)((
pPos(p,d)+NumDiff)*InvLatLim[d]*
NEdge);
20 if(v[d] < 0 || v[d] >=NEdge)
continue;
23 for(
int t=0;t<NType;t++)
24 Plot[t][vTot] +=
pVel(p,t);
27 sprintf(FileName,
"Av%s",cFile[NFile[0]]);
28 FILE *FileToWrite = fopen(FileName,
"w");
29 if(FileToWrite == NULL){printf(
"Can't open %s\n",FileName);
return;}
30 fprintf(FileToWrite,
"# l(%.1f %.1f %.1f) r(%.2f %.2f %.2f) v[%d] d[color]\n",LatLim[0],LatLim[1],LatLim[2],
Nano->
Pos[0],
Nano->
Pos[1],
Nano->
Pos[2],
NEdge);
31 double NEdgeInv = 1./(double)
NEdge;
37 for(
int t=0;t<NType;t++){
41 for(
int vx=0;vx<
NEdge;vx++)
42 for(
int vy=0;vy<
NEdge;vy++)
43 for(
int vz=0;vz<
NEdge;vz++){
44 int vTot = vx + NEdge*(vy + NEdge*vz);
45 double x = vx*LatLim[0]*NEdgeInv;
46 double y = vy*LatLim[1]*NEdgeInv;
47 double z = vz*LatLim[2]*NEdgeInv;
48 if(fabs(Plot[0][vTot] + Plot[1][vTot] + Plot[2][vTot]) > 0.){
49 fprintf(FileToWrite,
"{x(%.3f %.3f %.3f) v(%lf %.2f %.2f)}\n",
51 Plot[0][vTot]*FNorma,Plot[1][vTot]*FNorma,Plot[2][vTot]*FNorma);
54 for(
int t=0;t<NType;t++)
63 double *Plot = (
double *)calloc(NZed*NRad*NType,
sizeof(
double));
68 for(
int p=0;p<
pNPart();p++){
75 double RadDist = sqrt(Rad);
76 int vr = (int)(RadDist/
pEdge(3)*NRad);
78 if(vr < 0 || vr >= NRad)
continue;
79 if(vz < 0 || vz >= NZed)
continue;
81 Plot[(vr*NZed+vz)*NType+t] +=
pVel(p,t);
85 double *VolContr = (
double *)calloc(NRad,
sizeof(
double));
88 double InvNZed = 1./(double)NZed;
89 for(
int t=0,n=0;t<NType;t++){
91 for(
int vz=0;vz<NZed;vz++){
92 for(
int vr=0;vr<NRad;vr++){
93 Plot[(vr*NZed+vz)*NType+t] /= VolContr[vr]*3.;
94 if(Bound[t] < Plot[(vr*NZed+vz)*NType+t])
95 Bound[t] = Plot[(vr*NZed+vz)*NType+t];
98 if(Bound[t] < 0.) Bound[t] = 1.;
102 FILE *PRadial = fopen(
"ContourPress.xvl",
"w");
104 FILE *PNormal = fopen(
"PressNormal.dat",
"w");
105 for(
int vr=0;vr<NRad;vr++){
106 double PRad[3] = {0.,0.,0.};
107 double r = vr*
pEdge(3)/(double)NRad;
108 for(
int vz=0;vz<NZed;vz++){
111 double Press = Plot[(vr*NZed+vz)*NType+0];
112 double Phob = Plot[(vr*NZed+vz)*NType+1];
113 double Phil = Plot[(vr*NZed+vz)*NType+2];
114 if(ABS( Press + Phob + Phil) > 0.)
115 fprintf(PRadial,
"{x(%lf %lf 0.) v(%lf %lf %lf)}\n",r,z,Press,Phob,Phil);
116 PRad[0] += Press;PRad[1] += Phob;PRad[2] += Phil;
118 fprintf(PNormal,
"%lf %lf %lf %lf\n",r,PRad[0]*InvNZed,PRad[1]*InvNZed,PRad[2]*InvNZed);
128 double *TensRad = (
double *)calloc(
NEdge*
NEdge*NType,
sizeof(
double));
129 double *TensNorm = (
double *)calloc(
NEdge*
NEdge*NType,
sizeof(
double));
130 double *TensAng = (
double *)calloc(
NEdge*
NEdge*NType,
sizeof(
double));
132 double *TensRadTemp = (
double *)calloc(
NEdge*
NEdge*3,
sizeof(
double));
135 if(
Open(cFile[f],BF_PART))
return 1;
136 for(
int p=0;p<
pNPart();p++){
139 int vTot = (vr*NEdge+vz)*NType;
141 TensRadTemp[vTot+f] +=
pVel(p,0);
143 TensRad[vTot+1] +=
pVel(p,1)/3.;
145 TensRad[vTot+2] +=
pVel(p,2)/3.;
148 for(
int vr=0;vr<
NEdge;vr++){
149 for(
int vz=0;vz<
NEdge;vz++){
150 int vTot = (vr*NEdge+vz)*NType;
151 double Rad = sqrt(SQR(TensRadTemp[vTot+0])+SQR(TensRadTemp[vTot+1]));
152 double Trace = TensRadTemp[vTot+0] + TensRadTemp[vTot+1] + TensRadTemp[vTot+2];
153 double Ang = .5*(Trace - Rad);
155 TensRad[vTot+0] = Rad - .5*(Ang+TensRadTemp[vTot+2]);
157 TensNorm[vTot] = TensRadTemp[vTot+2] - .5*(TensRadTemp[vTot+0]+TensRadTemp[vTot+1]);
158 TensAng[vTot+0] = Ang - .5*(Rad+TensRadTemp[vTot+2]);
161 FILE *RadSurfTens = fopen(
"SurfTensRad.xvl",
"w");
162 FILE *NormSurfTens = fopen(
"SurfTensNorm.xvl",
"w");
163 FILE *AngSurfTens = fopen(
"SurfTensAng.xvl",
"w");
167 for(
int vr=0;vr<
NEdge;vr++){
168 for(
int vz=0;vz<
NEdge;vz++){
169 int vTot = (vr*NEdge+vz)*NType;
172 if(fabs(TensRad[vTot+0]+TensRad[vTot+1]+TensRad[vTot+2])>0.){
173 fprintf(RadSurfTens,
"{x(%.4f %.4f %.4f) v(%lf %lf %lf)}\n",
174 r,z,0.,TensRad[vTot+0],TensRad[vTot+1],TensRad[vTot+2]);
175 fprintf(NormSurfTens,
"{x(%.4f %.4f %.4f) v(%lf %lf %lf)}\n",
176 r,z,0.,TensNorm[vTot],TensRad[vTot+1],TensRad[vTot+2]);
177 fprintf(AngSurfTens,
"{x(%.4f %.4f %.4f) v(%lf %lf %lf)}\n",
178 r,z,0.,TensAng[vTot],TensRad[vTot+1],TensRad[vTot+2]);
187 fclose(NormSurfTens);
192 double **TensRad = (
double **)calloc(NBin,
sizeof(
double));
193 double **NormRad = (
double **)calloc(NBin,
sizeof(
double));
194 double **TensAng = (
double **)calloc(NBin,
sizeof(
double));
195 double **NormAng = (
double **)calloc(NBin,
sizeof(
double));
196 double **TensNorm= (
double **)calloc(
NEdge,
sizeof(
double));
197 double **NormNorm= (
double **)calloc(
NEdge,
sizeof(
double));
198 double **TensCart = (
double **)calloc(NBin,
sizeof(
double));
199 double **NormCart = (
double **)calloc(NBin,
sizeof(
double));
200 for(
int v=0;v<NBin;v++){
201 TensRad[v] = (
double *)calloc(NType,
sizeof(
double));
202 NormRad[v] = (
double *)calloc(NType,
sizeof(
double));
203 TensNorm[v] = (
double *)calloc(NType,
sizeof(
double));
204 NormNorm[v] = (
double *)calloc(NType,
sizeof(
double));
205 TensAng[v] = (
double *)calloc(NType,
sizeof(
double));
206 NormAng[v] = (
double *)calloc(NType,
sizeof(
double));
207 TensCart[v] = (
double *)calloc(NType,
sizeof(
double));
208 NormCart[v] = (
double *)calloc(NType,
sizeof(
double));
212 double *VolContr = (
double *)calloc(NBin,
sizeof(
double));
220 if(
Open(cFile[f],BF_PART))
return 0;
226 for(
int p=0;p<
pNPart();p++){
227 for(
int d=0;d<3;d++){
230 double RadDist = ABS(Dist.
PerpTo3(&PosRel,&NanoAxis));
231 int vr = (int)(RadDist/
pEdge(3)*NBin);
233 if(vr < 0 || vr >= NBin){
continue;}
234 if(vz < 0 || vz >=
NEdge){printf(
"%d out of %d\n",vz,NBin);
continue;}
235 for(
int t=1;t<3;t++){
236 TensRad[vr][t] +=
pVel(p,t);
237 NormRad[vr][t] += 1.;
238 TensNorm[vz][t] +=
pVel(p,t);
239 NormNorm[vz][t] += 1.;
242 TensRad[vr][0] +=
pVel(p,0);
243 NormRad[vr][0] += 1.;
244 TensNorm[vz][0] +=
pVel(p,0);
245 NormNorm[vz][0] += 1.;
248 TensCart[vr][f] +=
pVel(p,0);
249 NormCart[vr][f] += 1.;
252 TensNorm[vz][0] -= .5*vPre;
254 TensNorm[vz][3] -= .5*vPre*
pPos(p,
CNorm);
255 NormNorm[vz][3] += 1.;
259 NormNorm[vz][4] += 1.;
267 TensNorm[vz][0] += vPre;
270 NormNorm[vz][3] += 1.;
274 NormNorm[vz][4] += 1.;
277 NormNorm[vz][0] += 1.;
283 FILE *File2Write = fopen(
"TensRadial.dat",
"w");
284 for(
int v=0;v<NBin;v++){
285 for(
int d=0;d<3;d++){
286 TensCart[v][d] /= NormCart[v][d] > 0. ? VolContr[v]*NormCart[v][d] : 1.;
288 TensRad[v][0] = sqrt( SQR(TensCart[v][
CLat1])+SQR(TensCart[v][
CLat2]) );
289 TensRad[v][0] -= 5.*.5*(TensCart[v][0]+TensCart[v][1]+TensCart[v][2]-sqrt( SQR(TensCart[v][CLat1])+SQR(TensCart[v][CLat2])) );
291 TensRad[v][0] -= .5*TensCart[v][
CNorm];
293 for(
int v=0;v<NBin;v++){
294 fprintf(File2Write,
"%lf ",v/(
double)NBin*
pEdge(3));
295 for(
int t=0;t<NType;t++){
296 TensRad[v][t] /= NormRad[v][t] > 0. ? NormRad[v][t]: 1.;
297 fprintf(File2Write,
"%lf ",TensRad[v][t]);
299 fprintf(File2Write,
"\n");
302 File2Write = fopen(
"TensNormal.dat",
"w");
303 fprintf(File2Write,
"#Press DensPhob DensPhil SponCurv SaddleSplay \n");
304 for(
int v=0;v<
NEdge;v++){
305 fprintf(File2Write,
"%lf ",v/(
double)NEdge*
pEdge(
CNorm));
306 for(
int t=0;t<NType;t++){
307 TensNorm[v][t] /= NormNorm[v][t] > 0. ? VolElm*NormNorm[v][t] : 1.;
308 fprintf(File2Write,
"%lf ",TensNorm[v][t]);
310 fprintf(File2Write,
"\n");
313 File2Write = fopen(
"TensAngle.dat",
"w");
314 fprintf(File2Write,
"#Press DensPhob DensPhil SponCurv SaddleSplay \n");
315 for(
int v=0;v<
NEdge;v++){
316 fprintf(File2Write,
"%lf ",v/(
double)NEdge*
pEdge(
CNorm));
317 for(
int t=0;t<NType;t++){
318 TensAng[v][t] /= NormNorm[v][t] > 0. ? VolElm*NormNorm[v][t] : 1.;
319 fprintf(File2Write,
"%lf ",TensNorm[v][t]);
321 fprintf(File2Write,
"\n");
324 for(
int v=0;v<NBin;v++){
328 for(
int v=0;v<
NEdge;v++){
341 double *Sum = (
double *)calloc(NType*CUBE(
NEdge),
sizeof(double));
343 printf(
"Just three files\n");
348 if(
Open(cFile[f],BF_NO))
return 1;
349 for(
int p=0;p<
pNPart();p++){
353 if(vx < 0 || vx >=
NEdge)
continue;
354 if(vy < 0 || vy >=
NEdge)
continue;
355 if(vz < 0 || vz >=
NEdge)
continue;
357 Sum[vTot*NType+0] +=
pVel(p,0)/3.;
358 Sum[vTot*NType+1] +=
pVel(p,1)/3.;
359 Sum[vTot*NType+2] +=
pVel(p,2)/3.;
363 FILE *FileToWrite = fopen(
"PressTrace.xvl",
"w");
365 for(
int vx=0;vx<
NEdge;vx++){
367 for(
int vy=0;vy<
NEdge;vy++){
369 for(
int vz=0;vz<
NEdge;vz++){
371 int v = (vx*NEdge+vy)*NEdge+vz;
372 if(Sum[v*NType+0] + Sum[v*NType+1] + Sum[v*NType+2] < 0.1)
continue;
373 fprintf(FileToWrite,
"{x(%.2f %.2f %.2f)",x,y,z);
374 fprintf(FileToWrite,
" v( %lf %.2f %.2f)}\n",Sum[v*NType+0],Sum[v*NType+1],Sum[v*NType+2]);
384 double Round = 0.00001;
385 double InvNBin = 1./(double)NBin;
386 double **Plot1 = (
double **)calloc(NType,
sizeof(
double));
387 for(
int t=0;t<NType;t++){
388 Plot1[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
390 double *Count1 = (
double *)calloc(NType*NBin*NBin,
sizeof(
double));
391 double *Count2 = (
double *)calloc(NType*NBin*NBin,
sizeof(
double));
393 double InvLatDim[2] = {1./LatDim[0],1./LatDim[1]};
395 for(
int p=0;p<
pNPart();p++){
396 int vr = (int)((
pPos(p,
CLat1)+Round)*InvLatDim[0]*NBin);
397 if (vr < 0 || vr >= NBin)
continue;
398 int vz = (int)((
pPos(p,
CLat2)+Round)*InvLatDim[1]*NBin);
399 if (vz < 0 || vz >= NBin)
continue;
401 for(
int t=0;t<3;t++){
402 Plot1[t][(vr*NBin+vz)] +=
pVel(p,t);
403 Count1[(vr*NBin+vz)*NType+t] += 1.;
406 FILE *FTecPlot = fopen(
"TecPlotPressDiff.dat",
"w");
407 fprintf(FTecPlot,
"VARIABLES = \"R\", \"Z\", \"diff\", \"d1\",\"d2\"\n");
408 fprintf(FTecPlot,
"ZONE J=%d, K=%d, F=POINT\n",NBin,NBin);
409 for(
int vx=0;vx<NBin;vx++){
410 for(
int vy=0;vy<NBin;vy++){
411 double r = vx*
pEdge(0)/(double)NBin;
412 double z = vy*
pEdge(1)/(double)NBin -
pEdge(1)*.5;
414 double Diff = Plot1[0][vx*NBin+vy] - Plot1[1][vx*NBin+vy] - Plot1[2][vx*NBin+vy];
415 fprintf(FTecPlot,
"%lf %lf %lf %lf %lf\n",r,z,Diff,Plot1[1][vx*NBin+vy],Plot1[2][vx*NBin+vy]);
420 FILE *Difference = fopen(
"PressDifference.xvl",
"w");
422 int link[4] = {0,0,0,0};
423 for(
int t=0,p=0,c=0;t<NType;t++){
424 for(
int vx=0;vx<NBin-1;vx++){
425 for(
int vy=0;vy<NBin-1;vy++){
426 double Diff = Plot1[0][vx*NBin+vy] - Plot1[1][vx*NBin+vy] - Plot1[2][vx*NBin+vy];
427 fprintf(Difference,
"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf)}\n",p,c,t,vx*InvNBin*
pEdge(0),vy*InvNBin*
pEdge(1),0.,Diff,Plot1[1][vx*NBin+vy],Plot1[2][vx*NBin+vy]);
433 for(
int t=0;t<NType;t++){
441 printf(
"The number of files must be two\n");
445 double Round = 0.00001;
446 NBin = MIN(NBin,
NEdge);
447 double InvNBin = 1./(double)NBin;
448 double **Plot1 = (
double **)calloc(NType,
sizeof(
double));
449 double **Plot2 = (
double **)calloc(NType,
sizeof(
double));
450 double **PlotDiff = (
double **)calloc(NType,
sizeof(
double));
451 for(
int t=0;t<NType;t++){
452 Plot1[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
453 Plot2[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
454 PlotDiff[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
456 double *Count1 = (
double *)calloc(NType*NBin*NBin,
sizeof(
double));
457 double *Count2 = (
double *)calloc(NType*NBin*NBin,
sizeof(
double));
459 double InvLatDim[2] = {1./LatDim[0],1./LatDim[1]};
461 for(
int p=0;p<
pNPart();p++){
462 int vr = (int)((
pPos(p,
CLat1)+Round)*InvLatDim[0]*NBin);
463 if(vr < 0 || vr >= NBin)
continue;
464 int vz = (int)((
pPos(p,
CLat2)+Round)*InvLatDim[1]*NBin);
465 if(vz < 0 || vz >= NBin)
continue;
467 for(
int t=0;t<3;t++){
468 Plot1[t][vr*NBin+vz] +=
pVel(p,t);
469 Count1[(vr*NBin+vz)*NType+t] += 1.;
474 Plot1[t][vr*NBin+vz] +=
pPos(p,2);
475 Count1[(vr*NBin+vz)*NType+t] += 1.;
478 if(
Open(cFile[
NFile[1]-1],BF_NO))
return 1;
479 for(
int p=0;p<
pNPart();p++){
480 int vr = (int)((
pPos(p,
CLat1)+Round+1.)*InvLatDim[0]*NBin);
481 if (vr < 0 || vr >= NBin)
continue;
482 int vz = (int)((
pPos(p,
CLat2)+Round)*InvLatDim[1]*NBin);
483 if (vz < 0 || vz >= NBin)
continue;
485 for(
int t=0;t<3;t++){
486 Plot2[t][vr*NBin+vz] +=
pVel(p,t);
487 Count2[(vr*NBin+vz)*NType+t] += 1.;
492 Plot2[t][vr*NBin+vz] +=
pPos(p,2);
493 Count2[(vr*NBin+vz)*NType+t] += 1.;
497 Mask.FillGaussian(.5,3.);
499 for(
int t=0;t<NType;t++){
505 for(
int vr=0;vr<NBin;vr++){
506 for(
int vz=0;vz<NBin;vz++){
507 for(
int t=0;t<NType;t++){
508 Plot1[t][(vr*NBin+vz)] /= Count1[(vr*NBin+vz)*NType+t] > 0. ? Count1[(vr*NBin+vz)*NType+t] : 1.;
509 Plot2[t][(vr*NBin+vz)] /= Count2[(vr*NBin+vz)*NType+t] > 0. ? Count2[(vr*NBin+vz)*NType+t] : 1.;
510 PlotDiff[t][(vr*NBin+vz)] = Plot1[t][(vr*NBin+vz)] - Plot2[t][(vr*NBin+vz)];
517 for(
int t=0;t<NType;t++){
518 Mask.ConvoluteMatrix(PlotDiff[t],NBin,NDim,IfMinImConv);
522 FILE *FTecPlot = fopen(
"TecPlotDiff.dat",
"w");
523 fprintf(FTecPlot,
"VARIABLES = \"R\", \"Z\", \"diff\", \"d1\",\"d2\"\n");
524 fprintf(FTecPlot,
"ZONE J=%d, K=%d, F=POINT\n",NBin,NBin);
527 if(How) Difference = fopen(
"DensDifference.rzd",
"w");
528 else Difference = fopen(
"PressDifference.xvl",
"w");
530 PrintDens(Difference,PlotDiff,LatDim,NBin);
531 for(
int vx=0;vx<NBin;vx++){
532 for(
int vy=0;vy<NBin;vy++){
533 double r = vx*LatDim[0]/(double)NBin;
534 double z = vy*LatDim[1]/(double)NBin - LatDim[1]*.5;
535 fprintf(FTecPlot,
"%lf %lf %lf %lf %lf\n",r,z,PlotDiff[0][vx*NBin+vy],Plot1[0][vx*NBin+vy],Plot2[0][vx*NBin+vy]);
540 fprintf(Difference,
"# l(%.1f %.1f %.1f) v[%d] d[color]\n",LatDim[0],LatDim[1],LatDim[2],NBin);
541 for(
int vr=0;vr<NBin;vr++){
542 for(
int vz=0;vz<NBin;vz++){
543 double NanoAdded = Plot1[2][(vr*NBin+vz)];
544 double Phob = PlotDiff[0][(vr*NBin+vz)];
545 double Phil = PlotDiff[1][(vr*NBin+vz)];
546 double r = (vr)*InvNBin*LatDim[0];
547 double z = (vz)*InvNBin*LatDim[1];
548 double dens = (PlotDiff[2][(vr*NBin+vz)]);
549 fprintf(Difference,
"{x(%lf %lf %lf) v(%lf %lf %lf)}\n",r,z,dens,NanoAdded,Phob,Phil);
550 double z1 = vz*LatDim[1]/(double)NBin - LatDim[1]*.5;
551 fprintf(FTecPlot,
"%lf %lf %lf %lf %lf\n",r,z1,PlotDiff[0][vr*NBin+vz],Plot1[1][vr*NBin+vz],Plot2[1][vr*NBin+vz]);
557 for(
int t=0;t<NType;t++){
int PressTrace()
Trace of the pressure profile.
double pVel(int p, int d)
Return the velocity.
int Tens2dCartRad()
Change the pressure profile from cartesian to radial.
NANO * Nano
Extra particle.
Geometrical operations on vectors.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
int PressRadial()
Contour plot around the inclusion.
double pCm(int d)
Center of mass of the system.
int CLat2
lateral coordinate
int Diff2Files(int NBin, int How)
Density and thickness profile arond the nanoparticle.
void SumTens()
Sum more tension profile files.
double PerpTo3(Vettore *Pos, Vettore *Axis)
The vector perpendicolar in three dimension (faster)
bool Open(char *InFile, int BF)
Open the.
void ConvoluteMatrix(double *Plot, int NGrid, int NDim, int IfMinImConv)
Convolute with a matrix.
int SurfTens(int NBin)
Radial summation of the 3d tension profile.
double pNanoPos(int n, int d)
Return back folded nano position.
double pEdge(int d)
xyzr edges of the simulation box
void RestPress(int NBin)
Pressure difference between the virial and the ideal gas term.
int NEdge
Number of particles per edge.
void FillGaussian(double Sigma, double CutOff)
Fill the entries for the Gauss blur.
void PrintDens(FILE *FileToWrite, double **Plot, double *LatDim, int NBin)
Print the density profile in the surfaces representation.
Matrice computes the algebric operations on matrices.
char * ChooseDraw(int ExtWhat2Draw)
Convert the internal definition for the menu of ElPoly in string.
double pPos(int p, int d)
Return back folded position.
int NFile[2]
First and last file of the list.
int CLat1
lateral coordinate
PART * Pm
Particle information of all particle.
void Print()
Print the entries.
void Set(double Val, int Col)
Set the N column.
void Processing(int f)
Information on the current file elaborated.
void VolumeCircSlab(double *VolContr, int NSample)
Fill an array of.
void SetEdge(double Val, int d)
Set Edge.
int CNorm
Normal coordinate.
int pNPart()
Number of particle.