23 #include "Matematica.h" 28 #include <boost/iostreams/filtering_stream.hpp> 29 #include <boost/iostreams/filter/bzip2.hpp> 30 using namespace boost::iostreams;
34 #define CHAIN_IF_TYPE(c,t) ( ((c)&(t))==(t) ) 35 #define VAR_IF_TYPE(c,t) ( ((c)&(t))==(t) ) 36 #define VAR_ADD_TYPE(c,t) ( (c)|=(t) ) 37 #define VAR_REM_TYPE(c,t) ( (c)&=(~t) ) 96 CHAIN_STRETCH =0x00200,
98 CHAIN_FLABBY =0x00400,
100 CHAIN_TILTED =0x00800,
105 VAR_SYS_XVT = 0x0001,
107 VAR_SYS_TXVL = 0x0002,
109 VAR_SYS_XYZ = 0x0004,
111 VAR_SYS_XYZT = 0x0008,
118 VAR_PART_ALLOCATED = 0x0002,
120 VAR_CH_ALLOCATED = 0x0004,
122 VAR_MEMBRANE = 0x0008,
124 VAR_OPEN_TRUST = 0x0010,
126 VAR_LINK_ALLOCATED = 0x0020,
128 VAR_CHAIN_DEF = 0x0040,
130 VAR_NBLOCK_ALL = 0x0080,
135 VAR_ABSORBING = 0x0001,
137 VAR_REFLECTING = 0x0002,
141 VAR_DISTRIBUTED= 0x0008,
143 VAR_SOLVENT = 0x0010,
147 VAR_PLANAR_PE = 0x0040,
151 VAR_VESICLE = 0x0100,
153 VAR_COATING = 0x0200,
155 VAR_TWOTAILS = 0x0400,
157 VAR_OBSTACLE = 0x0800,
159 VAR_OPPOSED = 0x0f00,
164 ARCH_POINTS = 0x0001,
168 ARCH_TWOTAILS = 0x0004,
170 ARCH_CLUSTER = 0x0008,
175 SHAPE_NONE = 0x00001,
183 SHAPE_TILT = 0x00010,
185 SHAPE_PILL = 0x00020,
187 SHAPE_WALL = 0x00040,
189 SHAPE_PORE = 0x00080,
191 SHAPE_SMOOTH = 0x00100,
193 SHAPE_CLUSTER = 0x00200,
197 SHAPE_JANUS = 0x00800,
199 SHAPE_CLINKS = 0x01000,
201 SHAPE_STALK = 0x02000,
205 SHAPE_TORUS = 0x08000,
207 SHAPE_HARM = 0x10000,
209 SHAPE_UMBR = 0x20000,
211 SHAPE_BOUND = 0x40000,
367 Properties(){RePhob=0.;RePhil=0.;VolPhob=0.;VolPhil=0.;FactPhob=0.;FactPhil=0.;GyrPhob=0.;GyrPhil=0.;ChDiff=0.;};
369 void Print(){printf(
"RePhob %lf RePhil %lf\n",RePhob,RePhil);
370 printf(
"RadGyrPhob %lf RadGyrPhil %lf\n",GyrPhob,GyrPhil);
371 printf(
"StructFactPhob %lf StructFactPhil %lf\n",FactPhob,FactPhil);
372 printf(
"VolPhob %lf VolPhil %lf\n",VolPhob,VolPhil);
373 printf(
"ChainDiff %lf\n",ChDiff);};
400 MatInt(
int NType,
int NOrd);
402 void FillEntries(
double *Matr,
int Ord);
404 int IntType(
int t1,
int t2);
406 int IntType(
int t1,
int t2,
int t3);
408 double Coeff(
int t1,
int t2);
410 double Coeff(
int t1,
int t2,
int t3);
412 void SetCoeff(
double Co,
int t1,
int t2);
414 void SetCoeff(
double Co,
int t1,
int t2,
int t3);
420 void Rescale(
double SFactor,
int Order);
536 void VarMessage(
const char * s, ...);
538 bool Open(
char *InFile,
int BF);
540 bool OpenRisk(
char *InFile,
int BF);
542 bool OpenTrust(
char *InFile,
int BF);
550 void SysInfo(
char *cSystem);
552 void SysDef(
char *cSystem);
558 void SetCoeff(
double *v2,
double *v3);
560 double TwoPartDist(
int p1,
int p2,
double *RelDist);
562 double TwoPartDist(
double *Pos,
int p2,
double *RelDist);
564 double TwoPartDist2(
int p1,
int p2,
double *RelDist);
566 double TwoPartDist2(
double *Pos,
int p2,
double *RelDist);
568 int TwoPartDist(
int p1,
int p2,
double *RelDist,
double CutOff);
570 int TwoPartDist(
double *Pos,
int p2,
double *RelDist,
double CutOff);
573 bool Write(
char *OutFile);
575 bool WriteTxvl(
char *OutFile);
577 bool WriteXvt(
char *OutFile);
579 bool WriteXyz(
char *OutFile);
581 void HeaderInteraction(FILE *FileToWrite);
583 void StringNano(
char *NString,
int n);
585 int HeaderNano(FILE *FileToWrite);
587 int HeaderSoft(
char *Line);
589 void WriteLinkedSurf(FILE *FWrite,
double *Plot,
int NSample,
int NType,
double *Bound,
int *PId);
591 void WriteSurf(FILE *F2Write,
double **Plot,
int NSample,
int OffSet);
593 void ShapeId(
int iShape,
char *Shape);
595 void OpenComprWrite(
char *FName,filtering_ostream ZipFile);
598 void OpenComprRead(
char *FName,filtering_istream ZipFile);
600 void CloseCompr(filtering_istream ZipFile);
602 void CloseCompr(filtering_ostream ZipFile);
606 bool BackFold(
int How);
614 void ShiftRef(
int BackFold);
616 int StalkPos(
double *OldPos);
620 void BackBone(
double *Line,
int NBin);
622 void StalkLineProf(
double *Line,
int NBin);
624 void StalkPos2(
double *OldPos,
double *CmStalk);
626 void StalkPos3(
double *OldPos,
double *CmStalk);
628 int StalkPos4(
double *OldPos,
double *CmStalk);
630 double NormalWeight(
VAR_TRIANGLE *Triang,
double *Weight,
int NGrid,
int NTri);
632 void ConnectLineChain(
VAR_LINE *Triang,
int NGrid,
int NTri);
634 void ConnectLineChain2(
VAR_LINE *Triang,
int NGrid,
int NTri);
636 void ConnectLineChain3(
VAR_LINE *Triang,
int NGrid,
int NTri);
641 int Fetch(
char *str,
char *mask,
char *fmt, ... );
643 int BraketPos(
char *str,
char *mask,
int *sPos,
int *sLen);
645 int Fetch(
char *str,
char *mask,
int NArg,
double *Val);
647 bool ReadString(
const char *String,
char *cLine,
double *Value);
649 bool ReadString(
const char *String,
double *Value,
char *line);
651 bool ReadString(
const char *String,
char *cLine,
int *Value);
653 int ReadVal(
char *pLine,
double *Value);
656 int ReadLineXvt(
char *cLine,
double *Pos,
int *Type);
658 bool ReadConf(
char *InFile);
660 void ReadHeader(FILE *FileToRead);
662 void ReadHeaderTxvl(FILE *FileToRead);
664 void ReadHeaderXvt(FILE *FileToRead);
666 int ReadPart(FILE *FileToRead);
668 int ReadPartTxvl(FILE *FileToRead);
670 int ReadPartXvt(FILE *FileToRead);
672 int ReadPartXyz(FILE *FileToRead);
674 int ReadPartXyzt(FILE *FileToRead);
676 int ReadPassThru(FILE *FileToRead);
678 int ReadSoft(FILE *ConfFile);
680 void ReadNano(FILE *ConfFile,
int NCircle,
int NHeight);
682 int NanoString(
char *cLine,
int n);
684 void SubNanoHeader(
char *cFile);
686 int ShapeId(
char *Shape);
689 int DefSoft(
char *nome2,
char *ConfF);
693 bool CreateSoft(
int *arch,
double Thickness,
int s);
695 void CreateTube(
int *arch,
double Thickness,
int s);
697 void CreatePlanar(
int *arch,
double Thickness,
int s);
699 void CreateVesicle(
int *arch,
double Thickness,
int s);
701 void CreateCoating(
int *arch,
double Thickness,
int s);
703 void CreateObstacle(
int *arch,
double Thickness,
int s);
705 int CheckNano(
double *Pos,
int s);
707 void AddProtein(
int NCircle,
int NHeight,
int nNano,
char *filename);
709 void CreateProtein(
int nNano,
int nStart);
711 void AddStuffing(
char *filename,
int nStuffing,
int nNano);
713 void AddSolvent(
char *filename,
int nWater);
715 void AddChains(
char *filename,
double Thickness);
717 void AddCholesterol(
char *filename,
double Thickness,
int s);
719 void DefBlock(
int *NChStep,
int How);
721 void DefRest(
int *arch,
int s);
723 int PutPart(
int j,
int p,
int HalfLim,
double sigma);
725 void FindNeighbours(
char *FileName);
728 void SwapChain(
int c1,
int c2,
int b);
730 void SwapChain(
int c1,
int c2);
732 void SwapPart(
int p1,
int p2);
734 void ChangeNChain(
int NChain,
int b);
736 bool ShiftSys(
int How);
738 void SampleSurface(
double *Plot,
int NSample,
int Type);
740 MOMENTI SampleSurfacePart(
double *Plot,
int NSample,
int Type);
744 MOMENTI SampleSurfaceMem(
int NSample);
746 void LoadDensFile(
double **Plot,
int NBin);
750 void ShiftBlock(
Vettore *Shift,
int b);
756 void Transform(
int block);
758 void Point2Shape(
int iShape);
760 typedef double(
VarData::*NANO_DIST)(
double *Pos,
int n);
764 double NanoDist2(
double *Pos,
int n){
return (*this.*Nano_Dist)(Pos,n);}
766 double NanoDist2(
double x,
double y,
double z,
int n);
768 double FieldNo(
double *Pos,
int n);
770 double FieldSphere(
double *Pos,
int n);
772 double FieldElips(
double *Pos,
int n);
774 double FieldParab(
double *Pos,
int n);
776 double FieldCyl(
double *Pos,
int n);
778 double FieldTransMem(
double *Pos,
int n);
780 double FieldJanus(
double *Pos,
int n);
782 double FieldTorus(
double *Pos,
int n);
784 double FieldTilt(
double *Pos,
int n);
786 double FieldBound(
double *Pos,
int n);
788 double FieldTiltWall(
double *Pos,
int n);
791 int PairCorrelation(
double *Point,
int NSample,
int How,
int Type);
793 int PairCorrelationRound(
double **Point,
int NSample,
int Type);
795 int PairCorrelationSquare(
double **Point,
int NSample,
int Type);
797 int PairCorrelationPep(
double **Point,
int NSample,
int Type);
799 int Scattering2d(
double **Point,
int NSample,
int Type);
801 int Scattering2D(
double **Point,
int NSample,
int Type);
803 void Spettro2d(
double *Points,
int NSample,
int Type);
805 void Spettro2d(
double *Plot,
int NSample);
808 int DensityProfile(
int coord,
int NSample,
int NType,
double *dDensity);
810 int Core(
double ***Plot,
int NSample,
double Border[3][2]);
812 int RadDistr(
int NSample,
double *Plot,
double Border[2],
int How);
814 int Worm(
int Partition,
int NSample,
double *Border,
double *dPoint);
817 void VolumeCircSlab(
double *VolContr,
int NSample);
819 void Stalk(
int NSample,
int NLevel,
double **Plot,
double Threshold);
822 int Arrange(
int **Triangle,
int Vertex);
828 int CalcnPos(
double *Pos);
830 int Neighbour(
double *Pos);
832 int NChainPSquare(
double *Plot);
834 int LateralFluctuation(
double *Plot,
int LatValue);
838 int PosVectInt(
double *Pos);
841 int InterParab(
PART *PmIn,
PART *PmOut,
int NIn,
int nOut);
843 int InterParab2(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
845 int InterCubica(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
847 int InterForth(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
849 int InterSpline3(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
851 int InterSpline4(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
853 int InterBSpline(
PART *PmIn,
PART *PmOut,
int NIn,
int NOut);
855 int InterBSpline2D(
double **PlIn,
double **PmOut,
int NIn,
int NOut);
857 int InterBSpline2D(
double *PlIn,
double *PmOut,
int NIn,
int NOut);
859 int InterBSpline1D(
double *PlIn,
double *PmOut,
int NIn,
int NOut);
861 int InterPoly(
PART *PmIn,
PART *PmOut,
int NIn,
int nOut);
863 int InterDerMatrix(
PART *Pm,
int NMass,
SPLINE Weight,
double Offset);
865 void SmoothGrid(
int NSample,
char *FWrite);
867 void SmoothGrid(
int NSample);
869 void ConvoluteMatrix(
double *Plot,
int NGrid,
Matrice *Mask,
int NDim);
871 void ConvoluteMatrix1(
double *Plot,
int NGrid,
Matrice *Mask);
873 void ConvoluteMatrix2(
double *Plot,
int NGrid,
Matrice *Mask);
875 void ConvoluteMatrix3(
double *Plot,
int NGrid,
Matrice *Mask);
878 int SetNPart(
int NewNPart);
880 int SetNChain(
int NewNCh);
882 int SetNLink(
int NewNCh);
884 void SetNPCh(
int NewNCh);
886 void SetNType(
int NewNType);
888 int AllocLinks(
int NewNCh);
890 int SetNBlock(
int Val);
892 int SetNNano(
int Val);
894 void Copy(
PART *P1,
PART *P2,
int NPartOld);
899 VAR_TRIANGLE *MarchingCubes(
double *Plot,
int NSample,
double IsoLevel,
int *NTri);
901 VAR_LINE *MarchingSquares(
double *Plot,
int NSample,
double IsoLevel,
int *NTri);
905 void AreaDistr(
double *Distr,
double *RadDistr,
int NSample);
924 double pCm(
int d){
return Gen->
Cm[d];};
979 if(d<0 || d > 2)
return;
986 for(
int d=0;d<3;d++){
987 ScaleF[d] = Scale[d];
992 for(
int d=0;d<3;d++){
993 ShiftPos[d] = RefPos[d];
996 void SetIfNormalize(
int If){
1010 double pPos(
int p,
int d);
1012 double pChPos(
int p,
int d);
1014 void pPos(
int p,
double *Pos);
1016 double *pPos(
int p);
1018 double pPosNoBkf(
int p,
int d);
1020 double pVel(
int p,
int d);
1022 void SetPos(
int p,
double *Pos);
1024 void SetPos(
int p,
int d,
double Pos);
1026 void SetVel(
int p,
double *Vel);
1028 void SetType(
int p,
int t);
1034 double pNanoPos(
int n,
int d);
1038 void SetNanoBkf(
int n);
1040 void pPos(
double *Pos);
1042 char cWhat2Draw[STRSIZE];
1096 #endif //VARIABILI_H CHAIN * Ch
Information on all chains.
void SetScaleF(double *Scale)
Set scale factor.
double pTime()
Total time.
double pkBen()
Bending coupling.
Information about the nanoparticle.
int NLink
How many links per particle.
double kappaN
Incompressibility.
General information of the system.
double NanoDist2(double *Pos, int n)
Pointer to a generic function.
int Type
Type of the chain (see list CHAIN_)
double prho()
Density coexistence.
BLOCK * Block
Information for every block.
int NAddChol
Additional cholesterol chains into the membrane.
LINKS * Ln
Array of linking between the particles.
double Viscosity
Viscosity.
NANO * Nano
Extra particle.
double chiN
Incompatibility.
Energy contribution from the density functional hamiltonian.
double Gamma
Friction term.
double Hamaker
Strength of the interaction.
double DistThr
Minimum distance threshold.
Geometrical operations on vectors.
double Edge[4]
xyzr edges of the simulation box
Properties()
Set the values to zero.
double WFuncStraight2
Weighting function straight length.
int Asym
Diblock limit of the chain.
void SetTime(double Val)
Set Time.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
int Arch
Architecture type.
double Height
Height of the cylinder.
Information for every soft object.
int NChType
Type of chain selected.
double pCm(int d)
Center of mass of the system.
int CLat2
lateral coordinate
Information for every block.
int IfPlotMem
If PlotMem is allocated and filled.
int InitIdx
Initial Position.
int NLink
Maximum number of bonds.
double pkSpr()
Spring coupling.
double pSprRest()
Rest distance of the harmonic potential.
NANO_DIST Nano_Dist
Pointer to a distance/field function.
double * PlotMem
Particle position/density on the square lattice.
int NAllocP
Number of allocated particles.
Some calculated properties of the system.
Structure with the links of the particles.
int InitBead
Initial bead.
int NAddChain
Additional homopolymer chains into the membrane.
int pNType()
Print n type.
Information of every chain.
double Area
Area of a pore or a stalk.
void SetShiftPos(double *RefPos)
Set reference pos.
double pVol()
xyzr edges of the simulation box
int InitIdx
Initial particle position.
int SysCreate
Contains the information for the creation.
double Vel[4]
Velocity of the system.
int Shape
0 none, 1 spherical, 2 cylindrical 3 wall
double SpringRest
Rest length of the harmonic potential.
void SetDeltat(double Val)
Set DeltaT.
int nBlock
In which block is the peptide written.
int NStuffing
Stuffing for the cylinder.
double pEdge(int d)
xyzr edges of the simulation box
int Idx
Particle identifier.
Moments of a distribution.
double vBB
Chemical potential of the water.
int NPType
Type of particle selected.
double pWei3Par()
Parameter of the third order weighting function.
int NPartNearSphere
Number of particle to be considered in the radial density profile.
double pEnergy(int d)
Pot, kinetik, free.
double pchiN()
Incompatibility.
double BaseLine
Baseline of the potential.
MatInt * MInt
Matrix of the prefactor of the interactions.
int NChain
Number of chain.
int * Link
with whom is bonded
int NEdge
Number of particles per edge.
int NLink
Number of links connecting the constituent monomers.
double kappaSpring
Prefactor of the bond spring.
double InvEdge[4]
Inverted xyzr edges of the simulation box.
int NCircle
Number of monomers per circle.
void SetkSpr(double Val)
Spring coupling.
double Zeta
Stochastic term.
double ForThr
Maximum value of the force.
void SetTemp(double Val)
Set Temperature.
int NPCh
Number of particle per chain.
int SysType
Contains the definition of the system.
double pWei2Par()
Parameter of the second order weighting function.
double Coating
Thickness of the LJ well.
double Cm[3]
Center of mass of the system.
double pBeta()
Beta factor 1/kTB.
void IncrStep()
Increment Step.
double Energy[3]
Pot, kinetik, free.
int NPCh
particles per chain
Matrice computes the algebric operations on matrices.
double PotThr
Maximum value of the potential.
All the vertex in a cell.
void SetStep(int Val)
Set Step.
void SetCNorm(int d)
Set Edge.
int SysFormat
Contains the definition of the file format.
int NSolvent
Solvent molecules.
double OffSet
Reference potential.
double pReOverCutOff()
Re/CutOff.
Matematica * Mat
Implementation of all usefull algorythms.
void SetSprRest(double Val)
Rest distance of the harmonic potential.
double WFuncStraight3
Weighting function straight length.
double pVelMax(int d)
Maximum velocity.
int EndIdx
End particle position.
int NType
of types of the particle
unsigned long Step
Courrent step.
double RePhob
End2End distance of the.
double CutOff
Cut off of the potential.
double pTemp()
Temperature.
Implementation of useful algorythms.
int IfNormalize
If normalize the lateral dimensions to one.
int CLat1
lateral coordinate
Information of every particle.
int NAllocC
Number of allocated chains.
Reads and elaborates a system of chains.
int NSoft
Number of soft bodies.
void Print()
Print the current values.
int NPart
Number of particle.
PART * Pm
Particle information of all particle.
double ReOverCutOff
Convertion unit R_e over CutOff.
int NPCh
Number of particles per chain.
int NBlock
Number of blocks.
double SurfTens
Surface tension.
double rho
Density coexistence.
void SetEdge(double Val, int d)
Set Edge.
double pkappaN()
Incompressibility.
int CNorm
Normal coordinate.
int NHeight
Number of monomers per side.
void SetkBen(double Val)
Bending coupling.
double kappaBend
Prefactor of the bending potential.