22 #include "../include/VarData.h" 28 double *Density = (
double *)calloc(NPartition*NPartition*NType*NBin,
sizeof(
double));
31 for(
int b=0;b<Gen->
NBlock;b++){
32 if(!strncmp(
Block[b].Name,
"PEP",3) )
continue;
33 if(!strcmp(
Block[b].Name,
"WATER") )
continue;
37 Pos[d] =
Pm[p].Pos[d];
39 if(vx < 0 || vx >= NBin)
continue;
41 if(vy < 0 || vy >= NBin)
continue;
43 if(vz < 0 || vz >= NBin)
continue;
44 if(CHAIN_IF_TYPE(
Ch[
Pm[p].CId].Type,CHAIN_ADDED))
46 Density[((vz*NType+t)*NPartition+vy)*NPartition+vx] += 1.;
49 for(
int vx=0;vx<NPartition;vx++){
50 for(
int vy=0;vy<NPartition;vy++){
53 for(
int v=0;v<NBin;v++){
54 Weight += Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
55 Media += v*Density[((v*NType+0)*NPartition+vy)*NPartition+vx];
57 int vMedia = Weight > 0 ? (int)(Media/Weight) : NBin/2;
58 int vOffset = vMedia - NBin/2;
59 for(
int t=0;t<NType;t++){
60 for(
int v=0;v<NBin;v++){
61 int vOther = v + vOffset;
63 vOther = NBin - vOther;
65 vOther = vOther - NBin;
66 DensityAv[v*NType+t] += Density[((vOther*NType+t)*NPartition+vy)*NPartition+vx];
76 if(
pEdge(3) <= 0.){printf(
"Lateral radius not defined\n");};
79 double RapCorner = LenMin/LenMax*NBin;
80 double RapMin = LenMin/Gen->
Edge[3]*NBin;
82 for(
int v=0;v<NBin;v++){
84 double Volume1 = PI*QUAD(Rad2);
86 double Pro2 = sqrt(QUAD(v+1)-QUAD(RapMin));
87 double Angle2 = atan(RapMin/Pro2);
88 Volume1 = 2.*QUAD(Rad2)*Angle2 + 2.*Pro2*RapMin;
90 double theta = acos(RapCorner/Rad2);
91 double b = Rad2*sin(theta);
93 Volume1 -= 4.*(Rad2*Rad2*theta - b*RapCorner);
97 double Volume = (Volume1 - Volume2)*Gen->
Edge[
CNorm]*SQR(Gen->
Edge[3])/(double)CUB(NBin);
107 r1 = (
RETTA *)calloc(Partition,
sizeof(
RETTA));
108 Cm = (
double *)calloc(3*Partition,
sizeof(
double));
109 double* Dis0 = (
double *)calloc(Gen->
NPart,
sizeof(
double));
110 double* Dis1 = (
double *)calloc(Gen->
NPart,
sizeof(
double));
111 for(
int pa = 0,cc=0;pa<Partition;pa++){
112 for(
int c=0;c<Gen->
NChain;c++){
113 int v = (int)(
Ch[c].Pos[cLong]*Partition/Gen->
Edge[cLong]);
114 if(v != pa)
continue;
115 *(Dis0 + cc) =
Ch[c].Pos[cLat];
116 *(Dis1 + cc) =
Ch[c].Pos[cLong];
119 *(Cm + 3*v + d) +=
Ch[c].
Pos[d];
124 *(Cm + 3*pa + d) /= cc;
135 for(
int pa=0;pa<Partition;pa++){
137 for(
int p=0;p<Gen->
NPart;p++){
138 int v = (int) (
Pm[p].Pos[cLong]*Partition/Gen->
Edge[cLong]);
139 if(v != pa)
continue;
140 qcm = *(Cm + 3*pa + cLat) + *(Cm + 3*pa + cLong)/r1[pa].
m;
141 qpoint =
Pm[p].
Pos[cLat] - r1[pa].
m*
Pm[p].
Pos[cLong];
142 pos0 = (qcm-qpoint)*r1[pa].m/(QUAD(r1[pa].m) + 1.);
143 pos1 = pos0*r1[pa].
m + qpoint;
144 dist = QUAD((pos0-Cm[3*pa+cLong])) + QUAD((pos1-Cm[3*pa+cLat]));
146 Dis0[pp0] = pow(dist,.5);
147 if(
Pm[p].Pos[cLat] < *(Cm+3*pa+cLat))
152 else if(
Pm[p].Typ == 1){
153 Dis1[pp1] = pow(dist,.5);
154 if(
Pm[p].Pos[cLat] < *(Cm+3*pa+cLat))
163 for(
int v=0;v<NBin;v++)
165 for(
int i=0;i<pp0;i++){
166 int v = (int) ((Dis0[i]-Border[0])/(Border[1] - Border[0])*NBin);
167 if(v>= NBin)
continue;
170 for(
int v=0;v<NBin;v++){
171 dPoint[v*2] *= (NBin*Partition)/(Gen->
Edge[0]*Gen->
Edge[1]*Gen->
Edge[2]);
173 for(
int v=0;v<NBin;v++)
175 for(
int i=0;i<pp1;i++){
176 int v = (int) ((Dis1[i]-Border[0])/(Border[1] - Border[0])*NBin);
177 if(v>= NBin)
continue;
180 for(
int v=0;v<NBin;v++){
181 dPoint[v*2+1] /= (double) (NBin*Partition)/(Gen->
Edge[0]*Gen->
Edge[1]*Gen->
Edge[2]);
187 for(
int v=0;v<NBin;v++){
188 dPoint[v*2] /= (double) NBin;
189 dPoint[v*2+1] /= (double)NBin;
193 void VarData::Stalk(
int NBin,
int NLevel,
double **Plot,
double Threshold){
194 double **Norma = (
double **)calloc(NLevel,
sizeof(
double));
195 for(
int l=0;l<NLevel;l++)
196 Norma[l] = (
double *)calloc(NBin*NBin,
sizeof(
double));
197 for(
int b=0;b<Gen->
NBlock;b++){
199 for(
int v=0;v<NBin;v++){
203 if( v < 0 || v >= NBin)
continue;
205 if( vv < 0 || vv >= NBin)
continue;
207 Norma[b][v*NBin + vv] += 1.;
212 for(
int v=0;v<NBin;v++)
213 for(
int vv=0;vv<NBin;vv++)
214 for(
int l=0;l<NLevel;l++){
215 if(Norma[l][v*NBin+vv] > Threshold)
216 Plot[l][v*NBin+vv] /= Norma[l][v*NBin+vv];
218 Plot[l][v*NBin+vv] = 0.;
220 for(
int l=0;l<NLevel;l++)
CHAIN * Ch
Information on all chains.
BLOCK * Block
Information for every block.
double Edge[4]
xyzr edges of the simulation box
int BfDefChain()
Definition of the chain.
int CLat2
lateral coordinate
double Pos[3]
xyz Position of the particle
int DensityProfile(int coord, int NSample, int NType, double *dDensity)
Calculate the density profile for the x, y, z, r coordinate.
double pEdge(int d)
xyzr edges of the simulation box
int NChain
Number of chain.
int Worm(int Partition, int NSample, double *Border, double *dPoint)
Density profile along a worm like micelle.
void Stalk(int NSample, int NLevel, double **Plot, double Threshold)
Following the contour of a stalk.
double Pos[4]
xyzr Postion of the chain
Matematica * Mat
Implementation of all usefull algorythms.
int EndIdx
End particle position.
int CLat1
lateral coordinate
int NPart
Number of particle.
PART * Pm
Particle information of all particle.
int NBlock
Number of blocks.
void VolumeCircSlab(double *VolContr, int NSample)
Fill an array of.
int CNorm
Normal coordinate.
RETTA InterRett(double *Px, double *Py, int NMass)
Linear interpolation.