26 double *DensityAv = (
double *)calloc(NType*NBin,
sizeof(
double));
28 double ChDensMean = 0.;
29 double ChDensSqr = 0.;
31 double *VolEl = (
double *)calloc(NBin,
sizeof(
double));
33 if(Coord > 3 || Coord < 0)
return 1;
38 if(
OpenRisk(cFile[f],BF_PART))
return 0;
40 if(
OpenRisk(cFile[f],BF_NANO))
return 0;
50 int NPartition = NSample;
51 double *Density = (
double *)calloc(NPartition*NPartition*NType*NBin,
sizeof(
double));
55 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
56 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
59 for(
int d=0;d<3;d++) Pos[d] =
pPos(p,d);
62 if(vx < 0 || vx >= NBin)
continue;
64 if(vy < 0 || vy >= NBin)
continue;
66 if(vz < 0 || vz >= NBin)
continue;
68 if(!strncmp(
Block[b].Name,
"ADDED",5)) t = 2;
69 if(!strncmp(
Block[b].Name,
"CHOL",4)) t = 2;
70 Density[((vz*NType+t)*NPartition+vy)*NPartition+vx] += 1.;
73 for(
int vx=0;vx<NPartition;vx++){
74 for(
int vy=0;vy<NPartition;vy++){
77 for(
int v=0;v<NBin;v++){
78 Weight += Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
79 Media += v*Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
81 int vMedia = Weight > 0 ? (int)(Media/Weight) : NBin/2;
82 int vOffset = vMedia - NBin/2;
83 for(
int t=0;t<NType;t++){
84 for(
int v=0;v<NBin;v++){
85 int vOther = v + vOffset;
87 vOther = NBin - vOther;
89 vOther = vOther - NBin;
90 DensityAv[v*NType+t] += Density[((vOther*NType+t)*NPartition+vy)*NPartition+vx];
102 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
103 for(
int p=0;p<
pNPart();p++){
104 for(
int d=0;d<3;d++){
107 double RadDist = ABS(Dist.
PerpTo3(&PosRel,&NanoAxis));
108 int v = (int)(RadDist/
pEdge(3)*NBin);
109 if(v < 0 || v >= NBin)
continue;
111 if(CHAIN_IF_TYPE(
Ch[
pChain(p)].Type,CHAIN_ADDED)) t = 2;
112 DensityAv[v*NType+t] += 1.;
120 MPI_Allreduce(MPI_IN_PLACE,DensityAv,NBin, MPI_DOUBLE, MPI_SUM, Proc->CommGrid);
122 MPI_Comm_rank(Proc->CommGrid, &Rank);
126 double NormaF = (NFile[1] - NFile[0]);
128 for(
int v=0;v<NBin;v++){
129 for(
int t=0;t<NType;t++){
131 DensityAv[v*NType+t] /= VolumeSlab*NormaF;
133 DensityAv[v*NType+t] /= NormaF*VolEl[v];
137 sprintf(FileName,
"DensityChi%.0fKappa%.0fRho%.0f.dat",
pchiN(),
pkappaN(),
prho());
138 FILE *FileToWrite = fopen(FileName,
"w");
139 char cSystem[STRSIZE];
141 double ChDensErr = sqrt(ChDensSqr - SQR(ChDensMean)/NormaF )/NormaF;
142 fprintf(FileToWrite,
"# %s\n",cSystem);
143 fprintf(FileToWrite,
"# ChainDens %lf %lf\n",ChDensMean/NormaF,ChDensErr);
144 for(
int v=0;v<NBin;v++){
145 fprintf(FileToWrite,
"%lf %lf %lf %lf\n",(
double)v/(
double)NBin*
pEdge(Coord),DensityAv[v*NType],DensityAv[v*NType+1],DensityAv[v*NType+2]);
159 double *DensityAv = (
double *)calloc(NType*NBin,
sizeof(
double));
161 double ChDensMean = 0.;
162 double ChDensSqr = 0.;
164 double *VolEl = (
double *)calloc(NBin,
sizeof(
double));
166 if(Coord > 3 || Coord < 0)
return;
171 if(
OpenRisk(cFile[f],BF_PART))
return;
173 if(
OpenRisk(cFile[f],BF_NANO))
return;
183 int NPartition = NSample;
184 double *Density = (
double *)calloc(NPartition*NPartition*NType*NBin,
sizeof(
double));
188 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
189 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
196 if(vx < 0 || vx >= NBin)
continue;
198 if(vy < 0 || vy >= NBin)
continue;
200 if(vz < 0 || vz >= NBin)
continue;
201 if(CHAIN_IF_TYPE(
Ch[
pChain(p)].
Type,CHAIN_ADDED)) t = 2;
202 if(!strncmp(
Block[b].Name,
"ADDED",5)) t = 2;
203 if(!strncmp(
Block[b].Name,
"CHOL",4)) t = 2;
204 Density[((vz*NType+t)*NPartition+vy)*NPartition+vx] += 1.;
207 for(
int vx=0;vx<NPartition;vx++){
208 for(
int vy=0;vy<NPartition;vy++){
211 for(
int v=0;v<NBin;v++){
212 Weight += Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
213 Media += v*Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
215 int vMedia = Weight > 0 ? (int)(Media/Weight) : NBin/2;
216 int vOffset = vMedia - NBin/2;
217 for(
int t=0;t<NType;t++){
218 for(
int v=0;v<NBin;v++){
219 int vOther = v + vOffset;
221 vOther = NBin - vOther;
223 vOther = vOther - NBin;
224 DensityAv[v*NType+t] += Density[((vOther*NType+t)*NPartition+vy)*NPartition+vx];
236 if(!strncmp(
Block[b].Name,
"PEP",3))
continue;
237 for(
int p=0;p<
pNPart();p++){
238 for(
int d=0;d<3;d++){
241 double RadDist = ABS(Dist.
PerpTo3(&PosRel,&NanoAxis));
242 int v = (int)(RadDist/
pEdge(3)*NBin);
243 if(v < 0 || v >= NBin)
continue;
245 if(CHAIN_IF_TYPE(
Ch[
pChain(p)].Type,CHAIN_ADDED))
247 DensityAv[v*NType+t] += 1.;
255 MPI_Allreduce(MPI_IN_PLACE,DensityAv,NBin, MPI_DOUBLE, MPI_SUM, Proc->CommGrid);
257 MPI_Comm_rank(Proc->CommGrid, &Rank);
261 double NormaF = (NFile[1] - NFile[0]);
263 for(
int v=0;v<NBin;v++){
264 for(
int t=0;t<NType;t++){
266 DensityAv[v*NType+t] /= VolumeSlab*NormaF;
268 DensityAv[v*NType+t] /= NormaF*VolEl[v];
272 sprintf(FileName,
"DensityChi%.0fKappa%.0fRho%.0f.dat",
pchiN(),
pkappaN(),
prho());
273 FILE *FileToWrite = fopen(FileName,
"w");
274 char cSystem[STRSIZE];
276 double ChDensErr = sqrt(ChDensSqr - SQR(ChDensMean)/NormaF )/NormaF;
277 fprintf(FileToWrite,
"# %s\n",cSystem);
278 fprintf(FileToWrite,
"# ChainDens %lf %lf\n",ChDensMean/NormaF,ChDensErr);
279 for(
int v=0;v<NBin;v++){
280 fprintf(FileToWrite,
"%lf %lf %lf %lf\n",(
double)v/(
double)NBin*
pEdge(Coord),DensityAv[v*NType],DensityAv[v*NType+1],DensityAv[v*NType+2]);
294 printf(
"%d is not a lateral coordinate\n",Coord1,
CLat1,
CLat2);
298 double *Dens = (
double *) calloc(NBin,
sizeof(
double));
299 double *Temp = (
double *) calloc(NBin,
sizeof(
double));
300 double *Prof = (
double *) calloc(6*NBin,
sizeof(
double));
301 double **Plot = (
double **)calloc(3,
sizeof(
double));
302 for(
int t=0;t<3;t++){
303 Plot[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
305 double *Count = (
double *) calloc(6*NBin,
sizeof(
double));
312 if(
OpenRisk(cFile[f],BF_NO))
return;
320 for(
int d=0;d<3;d++){
326 InvEdge = 1./InvEdge;
331 if(!strncmp(
Block[b].Name,
"PEP",3) ) TypePlus = 1;
332 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
335 for(
int d=0;d<3;d++){
341 double LatDist = PosRel.
PerpTo(&Pos,&Axis);
342 if(LatDist >
Nano[nNano].Rad)
continue;
345 int t1 = TypePlus ? 2 :
pType(p);
349 int v = (int)(Dist*InvEdge*NBin);
350 if(v < 0 || v >= NBin)
continue;
352 if(z < 0 || z >= NBin)
continue;
353 Prof[v*6+t] +=
pPos(p,CNorm) -
pCm(CNorm);
355 Plot[t1][v*NBin+z] += 1.;
356 if(!TypePlus) Dens[v] += 1.;
363 for(
int b=0;b<NBin;b++){
364 for(
int t=0;t<6;t++){
365 Prof[b*6+t] /= Count[b*6+t] > 0. ? Count[b*6+t] : 1.;
368 double Norm = 1./(NFile[1]-NFile[0]);
369 for(
int v=0;v<SQR(NBin);v++){
370 for(
int t=0;t<3;t++){
381 FILE *FSlab = fopen(
"SlabProfile.dat",
"w");
382 FILE *FDens = fopen(
"SlabDensProfile.dat",
"w");
383 double InvNFile = 1./(double)(NFile[1]-NFile[0]);
384 for(
int b=0;b<NBin;b++){
385 double x = b/(double)NBin*
pEdge(Coord1);
387 fprintf(FSlab,
"%lf %lf %lf %lf %lf \n",x,Prof[b*6 ],Prof[b*6+1],Prof[b*6+2],Prof[b*6+3],Prof[b*6+4]);
388 fprintf(FDens,
"%lf %lf\n",x,Dens[b]*InvNFile);
398 for(
int t=0;t<3;t++){
402 FILE *FSlabProf = fopen(
"SlabDens.xzd",
"w");
415 int link[4] = {0,0,0,0};
416 double InvNBin = 1./(double)NBin;
417 fprintf(FileToWrite,
"#l(%lf %lf %lf) v[%d] d[%s]\n",LatDim[0],LatDim[1],LatDim[2],NBin,
ChooseDraw(EL_DENS));
418 double Dr = InvNBin*LatDim[0];
419 double Dz = InvNBin*LatDim[1];
420 for(
int t=0,p=0,c=0;t<3;t++){
421 for(
int vv=0;vv<NBin-1;vv++){
422 for(
int v=0;v<NBin-1;v++){
423 link[0] = (v+0)*NBin + (vv+0);
424 if(Plot[t][link[0]] < .02)
continue;
428 link[1] = (v+0)*NBin + (vv+1);
429 link[2] = (v+1)*NBin + (vv+0);
430 link[3] = (v+1)*NBin + (vv+1);
432 for(
int lx=0;lx<2;lx++){
433 for(
int ly=0;ly<2;ly++){
435 double NanoAdded = Plot[2][(link[l])];
436 double Phob = t == 0 ? Plot[0][(link[l])] : 0.;
437 double Phil = t == 1 ? Plot[1][(link[l])] : 0.;
438 double r = (v +lx)*Dr + .5*Dr;
439 double z = (vv+ly)*Dz + .5*Dz;
440 double dens = Plot[t][(link[l])];
441 int l1 = pRef + (p+1)%4;
442 int l2 = pRef + (p+2)%4;
443 int l3 = pRef + (p+3)%4;
444 fprintf(FileToWrite,
"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf) l[%d] l[%d] l[%d] }\n",p,c,t,r,z,dens,NanoAdded,Phob,Phil,l1,l2,l3);
458 double **Plot = (
double **)calloc(NType,
sizeof(
double));
459 for(
int t=0;t<NType;t++){
460 Plot[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
462 double NBinInv = 1./(double)NBin;
463 double InvNFile = 1./(double)(
NFile[1]-
NFile[0]);
471 for(
int p=0;p<
pNPart();p++){
474 if(Dy > Width)
continue;
476 if(vx<0 || vx>=NBin)
continue;
478 if(vz<0 || vz>=NBin)
continue;
484 Plot[t][vx*NBin+vz] += 1.;
490 for(
int v=0;v<NBin*NBin;v++)
for(
int t=0;t<NType;t++) Plot[t][v] *= InvNFile;
493 for(
int t=0;t<NType;t++){
497 sprintf(FName,
"CartDens.dat");
498 FILE *FileToWrite = fopen(FName,
"w");
502 double NAv = 1./(double)(NAvx*NAvz);
506 for(
int vx=0;vx<NBin*NBin;vx++) Plot[3][vx] = 1.;
507 for(
int t=0;t<2;t++){
509 sprintf(FName,
"LineLayer%d.dat",t);
510 FILE *FLine = fopen(FName,
"w");
512 fprintf(FLine,
"#l(%lf %lf %lf) v[%d] d[part]\n",
pEdge(0),
pEdge(1),
pEdge(2),NBin);
513 for(
int vx=0;vx<NBin;vx++){
514 for(
int vz=0;vz<NBin;vz++){
515 fprintf(FLine,
"{t[%d %d %d] x(%lf %lf %lf)}\n",p++,0,t,(
double)(vx*
pEdge(
CLat1)/(
double)NBin),(
double)(vz*
pEdge(
CNorm)/(
double)NBin),Plot[t][vx*NBin+vz],t);
519 for(
int vx=0;vx<NBin;vx+=NAvx){
520 for(
int vz=0;vz<NBin;vz+=NAvz){
521 for(
int vvx=0;vvx<NAvx;vvx++){
522 for(
int vvz=0;vvz<NAvz;vvz++){
523 int vTot = (vx+vvx)*NBin + vz+vvz;
524 if(vTot >= SQR(NBin))
break;
525 Plot[3][vTot] *= Plot[t][vTot];
526 double Weight = Plot[t][vTot];
527 if(Weight < 1.0)
continue;
528 Avx += (double)(vx*
pEdge(
CLat1)/(double)NBin)*Weight;
529 Avz += (double)(vz*
pEdge(
CNorm)/(double)NBin)*Weight;
534 fprintf(FLine,
"{t[%d %d %d] x(%lf %lf %lf) l[%d]}\n",p++,0,2,Avx/Av,Avz/Av,Av*NAv,p+1);
542 sprintf(FName,
"LineLayer2.dat");
543 FILE *FLine = fopen(FName,
"w");
544 for(
int vx=0;vx<NBin;vx++){
545 for(
int vz=0;vz<NBin;vz++){
546 double Weight = Plot[3][vx*NBin+vz];
547 if(Weight < 1.1)
continue;
548 fprintf(FLine,
"%lf %lf %lf\n",(
double)(vx*
pEdge(
CLat1)/(
double)NBin),(
double)(vz*
pEdge(
CNorm)/(
double)NBin),Weight);
551 for(
int t=0;t<NType;t++) free(Plot[t]);
559 printf(
"The specified nanoparticle doesn't exist\n");
563 double *Dens = (
double *)calloc(NBin,
sizeof(
double));
564 double **Plot = (
double **)calloc(NType,
sizeof(
double));
565 for(
int t=0;t<NType;t++){
566 Plot[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
576 double InvNBin = 1./(double)NBin;
577 double InvNFile = 1./(double)(
NFile[1]-
NFile[0]);
594 for(
int d=0;d<3;d++){
602 if(How == 0) TangInv = 0.;
607 Zed.
Set(0.,CLat1);Zed.
Set(0.,CLat2);Zed.
Set(1.,CNorm);
611 NanoAxis.
Set(0.,CLat1);
612 NanoAxis.
Set(0.,CLat2);
613 NanoAxis.
Set(1.,CNorm);
616 RotAxis.
VetV(&NanoAxis,&Zed);
622 if(!strncmp(
Block[b].Name,
"PEP",3) ) IfAdded = 2;
623 if(!strcmp(
Block[b].Name,
"STUFFING") )
continue;
624 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
625 if(!strcmp(
Block[b].Name,
"CHOL") ) IfAdded = 1;
626 if(!strcmp(
Block[b].Name,
"OIL") )
continue;
627 if(!strcmp(
Block[b].Name,
"ADDED") )
continue;
636 if(fabs(
Pm[p1].Pos[CNorm] -
Nano[0].Pos[CNorm]) < 3.5)
continue;
645 for(
int d=0;d<3;d++){
646 double Dist =
pPos(p,d) - RefPos[d];
650 double RadDist = fabs(Dist.
PerpTo3(&PosRel,&NanoAxis));
653 int vr = (int)(NBin*RadDist*
pInvEdge(3));
656 M.
Mult(PosRel,Rotated);
658 double PosNorm = PosRel.
Val(CNorm) + .5*
pEdge(CNorm);
659 int vz = (int)(NBin*(PosNorm)*
pInvEdge(CNorm));
660 if( vz < 0 || vz >= NBin){
661 printf(
"Axis %lf %lf %lf \n",
Nano[nNano].Axis[0],
Nano[nNano].Axis[1],
Nano[nNano].Axis[2]);
662 printf(
"Normal %lf > %lf %d > %d\n",PosNorm,
pEdge(CNorm),vz,NBin);
665 if( vr < 0 || vr >= NBin){
675 Plot[0][vr*NBin+vz] += 1.;
677 if(IfAdded==2) t = 3;
679 Plot[t][vr*NBin+vz] += 1.;
686 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
688 if(!strcmp(
Block[b].Name,
"STUFFING") )
continue;
689 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
690 if(!strcmp(
Block[b].Name,
"CHOL") ) IfAdded = 1;
691 if(!strcmp(
Block[b].Name,
"OIL") ) IfAdded = 1;
692 if(!strcmp(
Block[b].Name,
"ADDED") ) IfAdded = 1;
701 if( IfAdded ) Plot[2][vx*NBin+vy] += 1.;
702 else Plot[t][(vx*NBin+vy)] += 1.;
708 MPI_Allreduce(MPI_IN_PLACE,Plot, NType*NBin*NBin, MPI_DOUBLE, MPI_SUM, Proc->CommGrid);
710 MPI_Comm_rank(Proc->CommGrid, &Rank);
716 double *VolContr = (
double *)calloc(NBin,
sizeof(
double));
718 for(
int v=0;v<NBin;v++){
719 Dens[v] /= VolContr[v]*(NFile[1] - NFile[0]);
720 for(
int vv=0;vv<NBin;vv++){
721 for(
int t=0,n=0;t<NType;t++){
722 Plot[t][(v*NBin+vv)] /= VolContr[v]*(NFile[1]-NFile[0]);
729 for(
int v=0;v<NBin;v++){
730 Dens[v] /= (NFile[1] - NFile[0]);
731 for(
int vv=0;vv<NBin;vv++){
732 for(
int t=0,n=0;t<NType;t++){
733 Plot[t][(v*NBin+vv)] *= InvNFile;
739 Mask.FillGaussian(.5,3.);
743 if(How == 6) IfMinImConv = 1;
744 for(
int t=0;t<NType;t++){
745 Mask.ConvoluteMatrix(Plot[t],NBin,NDim,IfMinImConv);
746 Mask.ConvoluteMatrix(Plot[t],NBin,NDim,IfMinImConv);
752 sprintf(FileName,
"RadDistrCmR%.1fH%.1fh%.1f",
Nano[nNano].Rad,
Nano[nNano].Hamaker,
Nano[nNano].Height);
754 else if(How==1 || How == 4 || How == 5){
755 sprintf(FileName,
"RadDistrNanoR%.1fH%.1fh%.1f",
Nano[nNano].Rad,
Nano[nNano].Hamaker,
Nano[nNano].Height);
758 sprintf(FileName,
"RadDistrCmNR%.1fH%.1fh%.1f",
Nano[nNano].Rad,
Nano[nNano].Hamaker,
Nano[nNano].Height);
761 sprintf(FileName,
"CartDistrNanoR%.1fH%.1fh%.1f",
Nano[nNano].Rad,
Nano[nNano].Hamaker,
Nano[nNano].Height);
763 sprintf(FileName2,
"%s.rzd",FileName);
764 FILE *FileToWrite = fopen(FileName2,
"w");
767 sprintf(FileName,
"DensProfR%.1fH%.1fh%.1f.dat",
Nano[nNano].Rad,
Nano[nNano].Hamaker,
Nano[nNano].Height);
768 FILE *FToWrite = fopen(FileName,
"w");
769 for(
int v=0;v<NBin;v++){
770 double r = v*InvNBin*
pEdge(3);
771 fprintf(FToWrite,
"%lf %lf\n",r,Dens[v]);
776 for(
int t=0;t<NType;t++)
785 double **Plot = (
double **)calloc(NType,
sizeof(
double));
786 double **Count = (
double **)calloc(NType,
sizeof(
double));
787 for(
int t=0;t<3;t++){
788 Plot[t] = (
double *)calloc(SQR(NSample),
sizeof(double));
789 Count[t] = (
double *)calloc(SQR(NSample),
sizeof(double));
791 double InvNSample = 1./(double)NSample;
792 double Cm[4] = {0.,0.,0.,0.};
793 double Dist[4] = {0.,0.,0.,0.};
794 double Bond[4] = {0.,0.,0.,0.};
801 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
806 for(
int d=0;d<3;d++){
807 Cm[d] = .5*(
pPos(p,d) +
pPos(p+1,d));
809 Bond[3] += SQR(Bond[d]);
810 Dist[d] = Cm[d] -
Nano[0].
Pos[d];
813 double DistR = sqrt(SQR(Dist[
CLat1])+SQR(Dist[
CLat2]));
815 if(t !=
pType(p+1))
continue;
820 if(vz < 0 || vz >= NSample)
continue;
821 int vr = (int)(r*
pInvEdge(3)*NSample);
822 if(vr < 0 || vr >= NSample)
continue;
823 Plot[t][vr*NSample+vz] += sqrt(Bond[3]);
824 Count[t][vr*NSample+vz] += 1.;
833 double *VolContr = (
double *)calloc(NSample,
sizeof(
double));
835 for(
int v=0;v<NSample;v++){
836 for(
int vv=0;vv<NSample;vv++){
837 for(
int t=0,n=0;t<NType;t++){
838 Plot[t][(v*NSample+vv)] /= VolContr[v]*(NFile[1]-NFile[0]);
850 for(
int t=0;t<NType;t++){
855 sprintf(FileName2,
"BondDistr.rzd");
856 FILE *FileToWrite = fopen(FileName2,
"w");
858 PrintDens(FileToWrite,Plot,LatDim,NSample);
860 for(
int t=0;t<NType;t++){
872 double **Plot = (
double **)calloc(NType,
sizeof(
double));
873 double **Count = (
double **)calloc(NType,
sizeof(
double));
874 for(
int t=0;t<3;t++){
875 Plot[t] = (
double *)calloc(SQR(NSample),
sizeof(double));
876 Count[t] = (
double *)calloc(SQR(NSample),
sizeof(double));
878 double InvNSample = 1./(double)NSample;
879 double Cm[4] = {0.,0.,0.,0.};
880 double CmP[6] = {0.,0.,0.,0.,0.,0.};
881 double E2EP[6] = {0.,0.,0.,0.,0.,0.};
882 double GyrP[2] = {0.,0.};
883 double DistBA[4] = {0.,0.,0.,0.};
884 double DistCB[4] = {0.,0.,0.,0.};
886 int HalfLim = (int)(
Block[0].Asym*.5);
888 double Direct[6] = {0.,0.,0.,0.,0.,0.};
891 int pLimit[4] = {0,4,4,9};
892 double TailLength[2] = {1./4.,1./5.};
899 double *xc = (
double *)calloc(
pNPCh(b),
sizeof(double));
900 double *yc = (
double *)calloc(
pNPCh(b),
sizeof(double));
901 double *zc = (
double *)calloc(
pNPCh(b),
sizeof(double));
902 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
903 if(!strncmp(
Block[b].Name,
"ADDED",3) )
continue;
905 for(
int i=0;i<2;i++){
910 for(
int d=0;d<3;d++){
914 for(
int p=p1;p<p2;p++){
916 xc[ppc] =
Pm[p].
Pos[0];
917 yc[ppc] =
Pm[p].
Pos[1];
918 zc[ppc] =
Pm[p].
Pos[2];
920 for(
int d=0;d<3;d++){
921 CmP[i*3+d] +=
Pm[p].
Pos[d];
924 for(
int d=0;d<3;d++){
925 CmP[i*3+d] /= (double) NBead;
927 for(
int p=p1;p<p2;p++){
928 for(
int d=0;d<3;d++){
929 GyrP[i] += SQR(
Pm[p].Pos[d]-CmP[i*3+d]);
934 double x1 =
Pm[p1].
Pos[2]*rzx.
m + rzx.
q;
935 double x2 =
Pm[p2].
Pos[2]*rzx.
m + rzx.
q;
936 double y1 =
Pm[p1].
Pos[2]*rzy.
m + rzy.
q;
937 double y2 =
Pm[p2].
Pos[2]*rzy.
m + rzy.
q;
938 Direct[2*i+2] =
Pm[p1].
Pos[2] -
Pm[p2].
Pos[2];
939 Direct[2*i+1] = y1 - y2;
940 Direct[2*i+0] = x1 - x2;
942 Vettore Dir1(Direct[0],Direct[1],Direct[2]);
943 Vettore Dir2(Direct[3],Direct[4],Direct[5]);
945 if(isnan(Angle))
continue;
948 for(
int d=0;d<3;d++){
950 CmP[0+d] = CmP[0+d] -
Nano[0].
Pos[d];
952 CmP[3+d] = CmP[3+d] -
Nano[0].
Pos[d];
955 double E2E1 = sqrt(SQR(E2EP[0+0])+SQR(E2EP[0+1])+SQR(E2EP[0+2]));
956 double E2E2 = sqrt(SQR(E2EP[3+0])+SQR(E2EP[3+1])+SQR(E2EP[3+2]));
957 double DistR = sqrt(SQR(Cm[
CLat1])+SQR(Cm[
CLat2]));
961 if(vz < 0 || vz >= NSample)
continue;
962 int vr = (int)(r*
pInvEdge(3)*NSample);
963 if(vr < 0 || vr >= NSample)
continue;
964 Plot[0][vr*NSample+vz] +=
Angle;
965 Count[0][vr*NSample+vz] += 1.;
966 r = sqrt(SQR(CmP[0+CLat1])+SQR(CmP[0+CLat2]));
969 if(vz < 0 || vz >= NSample)
continue;
971 if(vr < 0 || vr >= NSample)
continue;
973 Plot[1][vr*NSample+vz] += E2E1*TailLength[0];
974 Count[1][vr*NSample+vz] += 1.;
975 Plot[2][vr*NSample+vz] += sqrt(GyrP[0]*TailLength[0]);
976 Count[2][vr*NSample+vz] += 1.;
977 r = sqrt(SQR(CmP[3+CLat1])+SQR(CmP[3+CLat2]));
980 if(vz < 0 || vz >= NSample)
continue;
982 if(vr < 0 || vr >= NSample)
continue;
984 Plot[1][vr*NSample+vz] += E2E2*TailLength[1];
985 Count[1][vr*NSample+vz] += 1.;
986 Plot[2][vr*NSample+vz] += sqrt(GyrP[1]*TailLength[1]);
987 Count[2][vr*NSample+vz] += 1.;
994 double *VolContr = (
double *)calloc(NSample,
sizeof(
double));
996 for(
int v=0;v<NSample;v++){
997 for(
int vv=0;vv<NSample;vv++){
998 for(
int t=0,n=0;t<NType;t++){
999 Plot[t][(v*NSample+vv)] /= VolContr[v]*(NFile[1]-NFile[0]);
1010 int IfMinImConv = 0;
1011 for(
int t=0;t<NType;t++){
1016 sprintf(FileName2,
"SplayDistr.rzd");
1017 FILE *FileToWrite = fopen(FileName2,
"w");
1019 PrintDens(FileToWrite,Plot,LatDim,NSample);
1020 fclose(FileToWrite);
1021 for(
int t=0;t<NType;t++){
1032 double *ThickProf = (
double *)calloc(3*NBin,
sizeof(
double));
1033 double *Count = (
double *)calloc(3*NBin,
sizeof(
double));
1034 double **Plot = (
double **)calloc(3,
sizeof(
double));
1035 for(
int t=0;t<3;t++){
1036 Plot[t] = (
double *)calloc(NBin*NBin,
sizeof(
double));
1039 double Cm[2] = {0.,0.};
1040 double CmCount[2] = {0.,0.};
1041 double InvNBin = 1./(double)NBin;
1042 for(
int sr=0;sr<NBin;sr++){
1043 for(
int sz=0;sz<NBin/2;sz++){
1044 double Pos = (sz-NBin/2)*
pEdge(1)*InvNBin;
1045 double Weight = Plot[0][sr*NBin+sz]*Plot[1][sr*NBin+sz];
1046 ThickProf[sr*3 ] += Pos*Weight;
1047 Count[sr*3 ] += Weight;
1049 for(
int sz=NBin/2;sz<NBin;sz++){
1050 double Pos = (sz-NBin/2)*
pEdge(1)*InvNBin;
1051 double Weight = Plot[0][sr*NBin+sz]*Plot[1][sr*NBin+sz];
1052 ThickProf[sr*3+1] += Pos*Weight;
1053 Count[sr*3+1] += Weight;
1055 for(
int sz=0;sz<NBin;sz++){
1056 ThickProf[sr*3+2] += Plot[2][sr*NBin+sz];
1057 Count[sr*3+2] += 1.;
1062 for(
int sr=0;sr<NBin;sr++){
1063 ThickProf[sr*3 ] /= Count[sr*3 ] > 0. ? Count[sr*3 ] : 1.;
1064 ThickProf[sr*3+1] /= Count[sr*3+1] > 0. ? Count[sr*3+1] : 1.;
1065 ThickProf[sr*3+2] /= Count[sr*3+2] > 0. ? Count[sr*3+2] : 1.;
1066 if(Max < ThickProf[sr*3+2]) Max = ThickProf[sr*3+2];
1068 for(
int sr=0;sr<NBin;sr++){
1069 if(ThickProf[sr*3+2] > .5*Max){
1070 ThickProf[sr*3 ] = 0.;
1071 ThickProf[sr*3+1] = 0.;
1075 sprintf(FName,
"ThickDensProf.dat",cFile[
NFile[0]]);
1076 FILE *F2Write = fopen(FName,
"w");
1077 for(
int sr=0;sr<NBin;sr++){
1078 double x = sr*
pEdge(0)/(double)NBin;
1079 fprintf(F2Write,
"%lf %lf %lf %lf %lf\n",x,.5*(-ThickProf[sr*3 ]+ThickProf[sr*3+1]),-ThickProf[sr*3 ],ThickProf[sr*3+1],ThickProf[sr*3+2]);
1081 for(
int t=0;t<3;t++)
1091 double *ThickProf = (
double *)calloc(NBin*NBin,
sizeof(
double));
1092 double *Count = (
double *)calloc(NBin*NBin,
sizeof(
double));
1093 double Round = 0.001;
1094 for(
int p=0;p<
pNPart();p++){
1095 if(
pType(p) != 1)
continue;
1098 ThickProf[sr*NBin+sz] +=
pPos(p,2);
1099 Count[sr*NBin+sz] += 1.;
1102 for(
int sr=0;sr<NBin;sr++){
1103 for(
int sz=0;sz<NBin;sz++){
1104 if(Norm < ThickProf[sr*NBin+sz]) Norm = ThickProf[sr*NBin+sz];
1109 sprintf(FName,
"ThickDensProf2d.dat",cFile[
NFile[0]]);
1110 FILE *F2Write = fopen(FName,
"w");
1111 fprintf(F2Write,
"%lf %lf %lf\n",0.,0.,0.);
1112 fprintf(F2Write,
"%lf %lf %lf\n",
pEdge(0),
pEdge(1),1.);
1113 for(
int sr=0;sr<NBin;sr++){
1114 double r = sr*
pEdge(0)/(double)NBin;
1115 for(
int sz=0;sz<NBin;sz++){
1116 double z = sz*
pEdge(1)/(double)NBin;
1118 if(ThickProf[sr*NBin+sz]*Norm < .3)
continue;
1119 fprintf(F2Write,
"%lf %lf %lf\n",r,z,ThickProf[sr*NBin+sz]*Norm);
1130 double Round = 0.001;
1131 double InvNBin = 1./(double)NBin;
1132 double *Plot = (
double *)calloc(NType*NBin*NBin,
sizeof(
double));
1133 double *Line = (
double *)calloc(2*NBin,
sizeof(
double));
1134 double *Count = (
double *)calloc(2*NBin,
sizeof(
double));
1135 for(
int p=0;p<
pNPart();p++){
1137 if (vr<0 || vr>NBin)
continue;
1139 if (vz<0 || vz>NBin)
continue;
1141 for(
int t=0;t<3;t++){
1142 Plot[(vr*NBin+vz)*NType+t] +=
pVel(p,t);
1145 for(
int vr=0;vr<NBin;vr++){
1146 for(
int vz=0;vz<NBin;vz++){
1147 double z = vz*InvNBin*
pEdge(1);
1148 double Weight = Plot[(vr*NBin+vz)*NType+1]*Plot[(vr*NBin+vz)*NType+2];
1151 Line[vr*2+t] += z*Weight;
1152 Count[vr*2+t] += Weight;
1155 FILE *FLine = fopen(
"ThickProf.dat",
"w");
1156 for(
int vr=0;vr<NBin;vr++){
1157 double r = vr*InvNBin*
pEdge(0);
1158 Line[vr*2] /= Count[vr*2] > 0. ? Count[vr*2] : 1.;
1159 Line[vr*2+1] /= Count[vr*2+1] > 0. ? Count[vr*2+1] : 1.;
1160 fprintf(FLine,
"%lf %lf %lf\n",r,Line[vr*2],Line[vr*2+1]);
1172 double *ProfAngle = (
double *)calloc(NAngle*NBin,
sizeof(
double));
1173 double *Count = (
double *)calloc(NAngle*NBin,
sizeof(
double));
1175 double BoxRad = sqrt( SQR(.5*
pEdge(0)) + SQR(.5*
pEdge(1)) ) ;
1176 double InvBoxRad = 1./BoxRad;
1177 int Coord1 = (Coord)%2;
1178 int Coord2 = (Coord+1)%2;
1179 FILE *Ciccia = fopen(
"SlabAngleSectors.dat",
"w");
1180 fprintf(Ciccia,
"#l(%lf %lf %lf) v[%d] d[part]\n",
pEdge(0),
pEdge(1),10.,NBin);
1181 for(
int p=0,p1=0;p<
pNPart();p++){
1184 double r = hypot(RelDist[0],RelDist[1]);
1185 int rb = (int)(r*InvBoxRad*NBin);
1186 if(rb < 0 || rb >= NBin)
continue;
1187 if(Coord == 2) RelDist[
CLat2] = - RelDist[
CLat2];
1189 double phi = fabs(atan2(RelDist[Coord1],RelDist[Coord2]));
1190 int phib = (int)(phi*NAngle/(M_PI*.5));
1191 if(phib < 0 || phib >= NAngle)
continue;
1192 ProfAngle[rb*NAngle+phib] +=
pPos(p,
CNorm);
1193 Count[rb*NAngle+phib] += 1.;
1194 fprintf(Ciccia,
"{t[%d 0 %d] x(%lf %lf %lf)}\n",p1++,phib,
pPos(p,0),
pPos(p,1),
pPos(p,2));
1197 FILE *FProf = fopen(
"SlabRadProfs.dat",
"w");
1198 for(
int rb=0;rb<NBin;rb++){
1199 double r = rb*BoxRad/(double)NBin;
1200 fprintf(FProf,
"%lf ",r);
1201 for(
int phib=0;phib<NAngle;phib++){
1202 double Norm = Count[rb*NAngle+phib] > 0. ? 1./Count[rb*NAngle+phib] : 1.;
1203 fprintf(FProf,
"%lf ",ProfAngle[rb*NAngle+phib]*Norm);
1205 fprintf(FProf,
"\n");
1216 int NVolume = NSample*NSample*NSample;
1218 double *Plot = (
double *) calloc(NVolume*NType,
sizeof(
double));
1219 double Border[3][2];
1221 Border[0][1]=
pEdge(0);
1223 Border[1][1]=
pEdge(1);
1225 Border[2][1]=
pEdge(2);
1229 if(
OpenRisk(cFile[f],BF_CHAIN))
return 1;
1232 if(
OpenRisk(cFile[f],BF_NANO))
return 1;
1238 int vx = (int)(NSample*(
pPos(p,0)-Border[0][0])/(Border[0][1]-Border[0][0]));
1239 if( vx < 0 || vx >= NSample)
continue;
1240 int vy = (int)(NSample*(
pPos(p,1)-Border[1][0])/(Border[1][1]-Border[1][0]));
1241 if( vy < 0 || vy >= NSample)
continue;
1242 int vz = (int)(NSample*(
pPos(p,2)-Border[2][0])/(Border[2][1]-Border[2][0]));
1243 if( vz < 0 || vz >= NSample)
continue;
1245 if( CHAIN_IF_TYPE(
Ch[
pChain(p)].Type,CHAIN_ADDED) ) t = 2;
1246 if( t < 0 || t > 3)
continue;
1247 Plot[((vx*NSample+vy)*NSample+vz)*NType+t] += 1.;
1253 Cm /= NFile[1] - NFile[0];
1254 FILE *FileToWrite = NULL;
1255 FileToWrite = fopen(
"Core.xvl",
"w");
1257 double *Norm = (
double *)calloc(NType,
sizeof(
double));
1258 for(
int t=0;t<NType;t++){
1259 for(
int v=0;v<NVolume;v++){
1260 if(Norm[t] < Plot[v*NType+t])
1261 Norm[t] = Plot[v*NType+t];
1263 Norm[t] = Norm[t] <= 0. ? 1. : Norm[t];
1266 for(
int vx=0;vx<NSample;vx++){
1267 for(
int vy=0;vy<NSample;vy++){
1268 for(
int vz=NSample-1;vz>0;vz--){
1269 double Dens0 = Plot[((vx*NSample+vy)*NSample+vz)*NType+2]/Norm[2];
1270 double Dens1 = Plot[((vx*NSample+vy)*NSample+vz)*NType+0]/Norm[0];
1271 double Dens2 = Plot[((vx*NSample+vy)*NSample+vz)*NType+1]/Norm[1];
1272 if(Dens0+Dens1+Dens2 <= 0.0)
continue;
1273 fprintf(FileToWrite,
"{x(%lf %lf %lf) ",
1274 Border[0][0]+vx/(
double)NSample*(Border[0][1]-Border[0][0]),
1275 Border[1][0]+vy/(
double)NSample*(Border[1][1] - Border[1][0]),
1276 Border[2][0]+vz/(
double)NSample*(Border[2][1] - Border[2][0]));
1277 fprintf(FileToWrite,
"v(%lf %lf %lf)}\n",Dens0,Dens1,Dens2);
1283 Volume /= NSample*NSample*NSample;
1284 Volume *= (Border[0][1] - Border[0][0])*(Border[1][1] - Border[1][0])*(Border[2][1] - Border[2][0]);
1285 fprintf(FileToWrite,
"#Volume %lf\n",Volume);
1286 fclose(FileToWrite);
void RadDens2Thick2d(int NBin)
Calculate the thickness from the radial density profile.
CHAIN * Ch
Information on all chains.
void SysDef(char *cSystem)
Print a string with the system definitions.
int Type
Type of the chain (see list CHAIN_)
bool OpenRisk(char *InFile, int BF)
Opens a file without reallocationg.
double prho()
Density coexistence.
double pVel(int p, int d)
Return the velocity.
void ThickFromDens(int NBin)
Calculate the thickness profile from the density plot.
BLOCK * Block
Information for every block.
NANO * Nano
Extra particle.
double Normalize()
Normlizes a Vettore.
int pChain(int p)
Return the chain.
Geometrical operations on vectors.
int BfDefChain()
Definition of the chain.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
int pType(int p)
Return the type.
double pCm(int d)
Center of mass of the system.
int CLat2
lateral coordinate
void Mult(Matrice &A, Matrice &B)
Multiplication between two matrices.
double Pos[3]
xyz Position of the particle
double PerpTo3(Vettore *Pos, Vettore *Axis)
The vector perpendicolar in three dimension (faster)
double Val(int N)
Value of the N column.
double * x
Where the data are stored.
void ConvoluteMatrix(double *Plot, int NGrid, int NDim, int IfMinImConv)
Convolute with a matrix.
int InitIdx
Initial particle position.
void RadDistrF(int NBin, int How, int nNano)
3d (rad,norma,dens) density profile with respect to a initial position radNano radCm radCmN ...
int Angle(int NBin)
Calculation of the contact angle angle Boh?
double pNanoPos(int n, int d)
Return back folded nano position.
double pEdge(int d)
xyzr edges of the simulation box
void BondDistr(int NSample)
Distribution of the bond lengths.
int pNPCh()
Number of particle per chain.
double PorePos()
Find the position of the pore.
void SlabAngleProfs(int NBin, int NAngle, int Coord)
Radial profiles of the slab density between 0⁰ and 90⁰ subdivided in NAngle angles.
int CoreF(int NBin, int How)
Sampling of the three dimentional space.
int pNBlock()
Number of blocks.
double pchiN()
Incompatibility.
double ProjOnAxis(Vettore *a)
Projects along the axis.
int DensProf(int NBin, int NSample, int Coord)
Calculate the density profile dens.
void RadDens2Thick(int NBin)
Calculate the thickness from the radial density profile.
int pNNano()
Number of nanoparticles.
void CartDens(int NBin, int nNano)
3d (rad,norma,dens) density profile in cartesian coordinates
double VetV(const Vettore *u, const Vettore *v)
Vectorial product between two Vettore returns the area.
void FillGaussian(double Sigma, double CutOff)
Fill the entries for the Gauss blur.
int NBackFold
Type of backfold.
void PrintDens(FILE *FileToWrite, double **Plot, double *LatDim, int NBin)
Print the density profile in the surfaces representation.
int NPCh
particles per chain
Matrice computes the algebric operations on matrices.
char * ChooseDraw(int ExtWhat2Draw)
Convert the internal definition for the menu of ElPoly in string.
Matematica * Mat
Implementation of all usefull algorythms.
int EndIdx
End particle position.
double pPos(int p, int d)
Return back folded position.
int pNChain()
Number of chain.
int NFile[2]
First and last file of the list.
double Angle(Vettore *u, Vettore *v)
Computes the angle between two Vetttore.
int CLat1
lateral coordinate
void DensProfNormalSlab(int NBin, int NSample, int Coord)
Calculate the density profile projecting the particles on the normal density.
void SplayDistr(int NSample)
Distribution of end to end distances.
double Axis[3]
Rotation axis.
int SetNNano(int Val)
Set NNano.
PART * Pm
Particle information of all particle.
void SlabProf(int NBin, int nNano, int Coord1)
Thickness and density profile along Coord1.
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.
double pkappaN()
Incompressibility.
void PerpTo(Vettore *o)
The vector perpendicolar.
int CNorm
Normal coordinate.
int pNPart()
Number of particle.
RETTA InterRett(double *Px, double *Py, int NMass)
Linear interpolation.
void LoadDensFile(double **Plot, int NBin)
Load in the array Plot the density of the system.