22 #include "../include/VarData.h" 29 Info = (
char *)malloc(256*
sizeof(
char));
36 for(
int p=0;p<Gen->
NPart;p++){
38 Gen->
Pre[d] += SQUARE(
Pm[p].Vel[d]);
46 sprintf(Info,
"Pre0\tPre1\tPre2\tSurfTens\tTemp\n%.4g\t%.4g\t%.4g\t%.4g\t%.4g\n",Gen->
Pre[0],Gen->
Pre[1],Gen->
Pre[2],Gen->
SurfTens,Gen->
Temp);
54 PlotMem = (
double *) calloc(SQR(NSample),
sizeof(double));
55 double *PlotR = (
double *) calloc(SQR(
NEdge),
sizeof(double));
68 double **Norma = (
double **)calloc(NSample,
sizeof(
double));
69 for(
int v=0;v<NSample;v++){
70 Norma[v] = (
double *)calloc(NSample,
sizeof(
double));
71 for(
int vv=0;vv<NSample;vv++){
72 Plot[v*NSample+vv] = 0.;
76 for(
int c=0;c<Gen->
NChain;c++){
80 if( v < 0 || v >= NSample)
continue;
82 if( vv < 0 || vv >= NSample)
continue;
89 for(
int p=0;p<Gen->
NPart;p++){
92 if( v < 0 || v >= NSample)
continue;
94 if( vv < 0 || vv >= NSample)
continue;
100 Average /= (double)NAverage;
101 for(
int v=0;v<NSample;v++){
102 for(
int vv=0;vv<NSample;vv++){
103 if(Norma[v][vv] > 0.){
104 Plot[v*NSample+vv] /= Norma[v][vv];
106 else Plot[v*NSample+vv] = Average;
109 for(
int v=0;v<NSample;v++)
117 double **Norma = (
double **)calloc(NSample,
sizeof(
double));
118 for(
int v=0;v<NSample;v++){
119 Norma[v] = (
double *)calloc(NSample,
sizeof(
double));
120 for(
int vv=0;vv<NSample;vv++){
124 for(
int c=0;c<Gen->
NChain;c++){
125 if(!CHAIN_IF_TYPE(
Ch[c].Type,
NChType))
continue;
128 if( v < 0 || v >= NSample)
continue;
130 if( vv < 0 || vv >= NSample)
continue;
135 Average /= (double)NAverage;
136 for(
int v=0;v<NSample;v++){
137 for(
int vv=0;vv<NSample;vv++){
138 if(Norma[v][vv] > 0.)
139 Plot->
Set(v,vv,Plot->
Val(v,vv)/Norma[v][vv]);
141 else Plot->
Set(v,vv,Average);
147 m1.
Num = SQR(NSample);
151 double Round = 0.001;
152 double *Count = (
double *)calloc(3*NSample*NSample,
sizeof(
double));
153 for(
int p=0;p<
pNPart();p++){
155 if(sr < 0 || sr >= NSample)
continue;
157 if(sz < 0 || sz >= NSample)
continue;
159 Plot[t][sr*NSample+sz] +=
pPos(p,2);
160 Count[(sr*NSample+sz)*3+t] += 1.;
163 Mask.FillGaussian(.5,3.);
164 for(
int t=0;t<3;t++){
165 for(
int s=0;s<NSample*NSample;s++){
166 if(Count[s*3+t] > 0.)
167 Plot[t][s] /= Count[s*3+t];
172 for(
int t=0;t<3;t++){
173 Mask.ConvoluteMatrix(Plot[t],NSample,NDim,IfMinImConv);
174 Mask.ConvoluteMatrix(Plot[t],NSample,NDim,IfMinImConv);
179 double Round = 0.001;
182 double Min = 10000000.;
183 double Max =-10000000.;
184 double **Norma = (
double **)calloc(NSample,
sizeof(
double));
186 for(
int v=0;v<NSample;v++){
187 Norma[v] = (
double *)calloc(NSample,
sizeof(
double));
188 for(
int vv=0;vv<NSample;vv++){
189 Plot[v*NSample+vv] = 0;
192 for(
int p=0;p<Gen->
NPart;p++){
193 if(
Pm[p].Typ != Type)
continue;
195 if( v < 0 || v >= NSample)
continue;
197 if( vv < 0 || vv >= NSample)
continue;
202 Average /= (double)NAverage;
203 for(
int v=0;v<NSample;v++){
204 for(
int vv=0;vv<NSample;vv++){
205 if(Norma[v][vv] > 0.){
206 Plot[v*NSample+vv] /= Norma[v][vv];
208 else Plot[v*NSample+vv] = Average;
209 if(Plot[v*NSample+vv] < Min) Min = Plot[v*NSample+vv];
210 if(Plot[v*NSample+vv] > Max) Max = Plot[v*NSample+vv];
213 for(
int v=0;v<NSample;v++)
219 m1.
Num = SQR(NSample);
225 for(
int h=0;h<Resp->
Size();h++)
226 for(
int w=0;w<Resp->
Size();w++)
236 double StructPhil = 0.;
237 double StructPhob = 0.;
238 for(
int c=0;c<Gen->
NChain;c++){
239 for(
int cc=0;cc<Gen->
NChain;cc++){
243 double CmPhil[3] = {0.,0.,0.};
244 double CmPhob[3] = {0.,0.,0.};
249 double q=1./Gen->
Edge[3];
250 double Dist[3] = {0.,0.,0.};
252 for(
int d=0;d<3;d++){
253 CmPhob[d] +=
Pm[p].
Pos[d];
256 if(p == pp) StructPhob += 1.;
259 StructPhob += exp(-QUAD(( q*Dist[d] ))/6. );
262 Pr->
RePhob += QUAD((
Pm[p].Pos[d] -
Pm[p+1].Pos[d]));
265 for(
int p=c*Gen->
NPCh+
Block[0].
Asym;p<Gen->NPCh*(c+1)-1;p++){
266 for(
int d=0;d<3;d++){
267 CmPhil[d] +=
Pm[p].
Pos[d];
268 for(
int pp=c*Gen->
NPCh+
Block[0].
Asym;pp<Gen->NPCh*(c+1)-1;pp++){
270 if(p == pp) StructPhil += 1.;
273 StructPhil += exp(-QUAD(( q*Dist[d] ))/6. );
275 if( p == Gen->
NPCh*(c+1)-1)
continue;
276 Pr->RePhil += QUAD((
Pm[p].Pos[d] -
Pm[p+1].Pos[d]));
279 for(
int d=0;d<3;d++){
280 CmPhob[d] /= (double)
Block[0].Asym;
285 RadPhob += QUAD(( CmPhob[d] -
Pm[p].Pos[d]));
289 RadPhil += QUAD(( CmPhil[d] -
Pm[p].Pos[d]));
291 Pr->GyrPhob += RadPhob / (double)(
Block[0].Asym*Gen->
NChain);
295 Pr->RePhil /= Gen->
NChain;
296 Pr->ChDiff /= (double)QUAD((Gen->
NChain));
297 Pr->FactPhob += StructPhob/(double)(Gen->
NChain);
298 Pr->FactPhil += StructPhil/(double)(Gen->
NChain);
303 double *Interp1 = (
double *)calloc(Gen->
NPCh,
sizeof(
double));
304 double *Interp2 = (
double *)calloc(Gen->
NPCh,
sizeof(
double));
305 double *InterpN = (
double *)calloc(Gen->
NPCh,
sizeof(
double));
308 for(
int c=0;c<Gen->
NChain;c++){
309 double Comp[3]={0.,0.,0.};
310 for(
int p= c*Gen->
NPCh,pp=0;p<(c+1)*Gen->
NPCh;p++,pp++){
314 if(p == (c+1)*Gen->
NPCh - 1)
break;
315 double Segm[3]={0.,0.,0.};
317 for(
int d=0;d<3;d++){
319 Rad += QUAD((Segm[d]));
322 for(
int d=0;d<3;d++){
323 Comp[d] += Segm[d] / (Rad*Gen->
NPCh);
326 if( ASS((Comp[
CNorm])) < .7)
327 Ch[c].
Type |= CHAIN_FLABBY;
329 Ch[c].
Type |= CHAIN_STRETCH;
332 if( POS(r1.
m) < .5 || POS(r2.
m) < .5)
333 Ch[c].
Type |= CHAIN_TILTED;
345 for(
int b=1;b<Gen->
NBlock;b++){
360 for(
int d=0;d<3;d++){
361 Temp[d] =
Pm[p+p1].
Pos[d];
363 Pm[p+p2].
Pos[d] = Temp[d];
364 Temp[d] =
Pm[p+p1].
Vel[d];
366 Pm[p+p2].
Vel[d] = Temp[d];
369 for(
int d=0;d<3;d++){
370 Temp[d] =
Ch[c1].
Pos[d];
372 Ch[c2].
Pos[d] = Temp[d];
373 Temp[d] =
Ch[c1].
Vel[d];
375 Ch[c2].
Vel[d] = Temp[d];
380 for(
int d=0;d<3;d++){
381 Temp[d] =
Pm[p1].
Pos[d];
383 Pm[p2].
Pos[d] = Temp[d];
384 Temp[d] =
Pm[p1].
Vel[d];
386 Pm[p2].
Vel[d] = Temp[d];
391 for(
int l=0;l<MAX(
Ln[p1].NLink,
Ln[p2].NLink);l++){
410 for(
int d=0;d<3;d++){
411 DistRel[d] = Pos[d] -
Pm[p2].
Pos[d];
414 return DistRel[3] = (SQR(DistRel[0])+SQR(DistRel[1])+SQR(DistRel[2]));
426 for(
int d=0;d<3;d++){
427 DistRel[d] = Pos[d] -
Pm[p2].
Pos[d];
430 DistRel[3] = (SQR(DistRel[0])+SQR(DistRel[1])+SQR(DistRel[2]));
431 if(DistRel[3] > SQR(CutOff))
return 0;
432 DistRel[3] = sqrt(DistRel[3]);
437 if(!(
Pm[p].CId%2))
continue;
438 for(
int d=0;d<3;d++){
446 if(Norm <= 0.){printf(
"Cannot rotate block, the axis is null\n");
return;};
450 for(
int d=0;d<3;d++){
451 Pos.
Set(
Pm[p].Pos[d]-Origin->
Val(d),d);
456 for(
int d=0;d<3;d++){
457 Pm[p].
Pos[d] = Origin->
Val(d) + Pos[d] + 2.*Proj[d];
466 for(
int d=0;d<3;d++){
467 Pos.
Set(
Pm[p].Pos[d],0);
470 for(
int d=0;d<3;d++){
491 if(VAR_IF_TYPE(iShape,SHAPE_NONE))
493 else if(VAR_IF_TYPE(iShape,SHAPE_SPH))
495 else if(VAR_IF_TYPE(iShape,SHAPE_CYL))
498 else if(VAR_IF_TYPE(iShape,SHAPE_CLUSTER))
500 else if(VAR_IF_TYPE(iShape,SHAPE_PILL))
502 else if(VAR_IF_TYPE(iShape,SHAPE_TILT))
505 else if(VAR_IF_TYPE(iShape,SHAPE_WALL))
507 else if(VAR_IF_TYPE(iShape,SHAPE_PORE))
509 else if(VAR_IF_TYPE(iShape,SHAPE_EXT))
511 else if(VAR_IF_TYPE(iShape,SHAPE_JANUS))
513 else if(VAR_IF_TYPE(iShape,SHAPE_STALK))
515 else if(VAR_IF_TYPE(iShape,SHAPE_TIP))
518 else if(VAR_IF_TYPE(iShape,SHAPE_TORUS))
520 else if(VAR_IF_TYPE(iShape,SHAPE_HARM))
522 else if(VAR_IF_TYPE(iShape,SHAPE_UMBR))
524 else if(VAR_IF_TYPE(iShape,SHAPE_BOUND))
532 double Pos[3] = {x,y,z};
543 for(
int d=0;d<3;d++){
548 double Lat = SQR(PosRel[0])+SQR(PosRel[1]);
549 double Norm = SQR(Ratio*(PosRel[2]));
554 for(
int d=0;d<3;d++){
558 double r2 = SQR(PosRel[0])+SQR(PosRel[1]);
561 double z = Pos[
CNorm];
566 return SQR(a*z + b*r2 + c*r + d);
572 else if(Pos[2] < -
Nano[n].Height*.5+
Nano[n].Pos[2])
578 for(
int d=0;d<3;d++){
608 else if(PosRel[
CNorm] < -
Nano[n].Height*.5){
617 double Dist2 = SQR(PosRel[0]) + SQR(PosRel[1]) + SQR(PosRel[2]);
622 for(
int d=0;d<3;d++){
626 double Radxy = sqrt(SQR(PosRel[
CLat1]) + SQR(PosRel[
CLat2]));
627 double Temp = SQR(
Nano[n].Height - Radxy) - SQR(
Nano[n].Rad) + SQR(PosRel[
CNorm]);
635 for(
int d=0;d<3;d++){
638 double r2 = fabs(Dist.
PerpTo3(&PosRel,&NanoAxis));
639 double HeiOnAxis = PosRel.
ProjOnAxis(&NanoAxis);
640 if(fabs(HeiOnAxis) > .5*
Nano[n].Height){
641 double Sign = HeiOnAxis > 0. ? 1. : -1.;
643 for(
int d=0;d<3;d++){
655 double Dist2 = a*Pos[0]+b*Pos[1]+c*Pos[2]+d;
656 Dist2 = SQR(Dist2)/(SQR(a)+SQR(b)+SQR(c));
660 double dr[3] = {Pos[0],Pos[1],Pos[2]};
666 return SQR(dr[0]) + SQR(dr[1]) + SQR(dr[2]);
673 for(
int d=0;d<3;d++){
676 PosRel.
Set(PosRel.
Val(2)*2.,2);
677 double r2 = fabs(Dist.
PerpTo3(&PosRel,&NanoAxis));
int RadDistr(int NSample, double *Plot, double Border[2], int How)
rzd representation of the system referring to
CHAIN * Ch
Information on all chains.
double FieldParab(double *Pos, int n)
Scalar field of a elipsoid.
int NLink
How many links per particle.
double NanoDist2(double *Pos, int n)
Pointer to a generic function.
int Type
Type of the chain (see list CHAIN_)
void Copy(Vettore *o)
Copy the vector.
BLOCK * Block
Information for every block.
double Vel[4]
xyzr Velocity of the particle
LINKS * Ln
Array of linking between the particles.
NANO * Nano
Extra particle.
double FieldTiltWall(double *Pos, int n)
Scalar field of a tilted cylinder.
double Normalize()
Normlizes a Vettore.
double TwoPartDist2(int p1, int p2, double *RelDist)
Return the relative distance between two particles (wrapped)
Geometrical operations on vectors.
double Edge[4]
xyzr edges of the simulation box
double Vel[3]
Chain velocity.
double FieldJanus(double *Pos, int n)
Scalar field of a janus peptide.
double FieldElips(double *Pos, int n)
Scalar field of a elipsoid.
int Asym
Diblock limit of the chain.
double Pre[3]
Three components of the pressure.
double FieldNo(double *Pos, int n)
No field.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
Properties SysProperties()
Calculate some basis properties.
double Height
Height of the cylinder.
int NChType
Type of chain selected.
MOMENTI SampleSurfaceMem(int NSample)
Allocate and fill PlotMem with the particle average position.
int pType(int p)
Return the type.
void ShiftBlock(Vettore *Shift, int b)
Shift a block wrt to Shift.
int CLat2
lateral coordinate
double Pos[3]
xyz Position of the particle
int IfPlotMem
If PlotMem is allocated and filled.
double FieldTransMem(double *Pos, int n)
Scalar field of a transmembrane protein.
void Print()
Prints the components.
NANO_DIST Nano_Dist
Pointer to a distance/field function.
double PerpTo3(Vettore *Pos, Vettore *Axis)
The vector perpendicolar in three dimension (faster)
double * PlotMem
Particle position/density on the square lattice.
Some calculated properties of the system.
double Val(int N)
Value of the N column.
double FieldCyl(double *Pos, int n)
Scalar field of a cylinder.
void SwapPart(int p1, int p2)
Swap two particle.
int InitIdx
Initial particle position.
double pNanoPos(int n, int d)
Return back folded nano position.
double pEdge(int d)
xyzr edges of the simulation box
int pNPCh()
Number of particle per chain.
int Idx
Particle identifier.
Moments of a distribution.
void Transpose()
Transpose the matrix.
double TwoPartDist(int p1, int p2, double *RelDist)
Return the relative distance between two particles (wrapped)
int pNBlock()
Number of blocks.
void RotateBlock(Vettore *Axis, Vettore *Origin, int b)
Rotate a block wrt to the Axis from the Origin.
void MirrorBlock(Vettore *Px1, Vettore *Px2, Vettore *Px3, int b)
Mirror the position wrt to a plane.
int NChain
Number of chain.
int * Link
with whom is bonded
int NEdge
Number of particles per edge.
double ProjOnAxis(Vettore *a)
Projects along the axis.
double Val(int row)
Returns a value in 1d.
void Point2Shape(int iShape)
Point to the shape function.
void ChangeNChain(int NChain, int b)
Update the new number of chains.
int NPCh
Number of particle per chain.
bool Add(int row, int col, double Val)
Add the value of the coefficient to the previous one.
void SwapChain(int c1, int c2, int b)
Swap two chains.
MOMENTI SampleSurfacePart(double *Plot, int NSample, int Type)
Define a normal coordinate for every patch.
double Pos[4]
xyzr Postion of the chain
int NPCh
particles per chain
Matrice computes the algebric operations on matrices.
bool Set(int row, int column, double Val)
Set a coefficient.
double FieldSphere(double *Pos, int n)
Scalar field of a sphere.
int Size()
Size of Matrice.
Matematica * Mat
Implementation of all usefull algorythms.
int EndIdx
End particle position.
int ApplyFilter(Matrice *Point, Matrice *Res, Matrice *Mask)
Applies the filter.
double pPos(int p, int d)
Return back folded position.
double RePhob
End2End distance of the.
void Transform(int block)
Transform a block.
double FieldTilt(double *Pos, int n)
Scalar field of a tilted cylinder.
int CLat1
lateral coordinate
int SpatialDerivative(Matrice *Surface, Matrice *Resp, SPLINE Weight, int NSample)
Perform a spatial derivative on a surface.
int Num
Number of points considered.
double ProjOnSurf(Vettore *S1, Vettore *S2, Vettore *S3, Vettore *P)
Project a point P on the point PS perpendicular to the surface described by the points S1...
char * SysState()
Calculates fundamental quantities.
double Axis[3]
Rotation axis.
void Print()
Print the current values.
double FieldTorus(double *Pos, int n)
Scalar field of a janus peptide.
int NPart
Number of particle.
PART * Pm
Particle information of all particle.
int InterBSpline2D(double **PlIn, double **PmOut, int NIn, int NOut)
2-d BSpline
int NBlock
Number of blocks.
double FieldBound(double *Pos, int n)
Scalar field of a hard wall at the box edges.
void SampleSurface(double *Plot, int NSample, int Type)
Define a normal coordinate for every patch.
double SurfTens
Surface tension.
void Set(double Val, int Col)
Set the N column.
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.