3 if(Gen->
NPart == NewNPart)
return 1;
6 if( !VAR_IF_TYPE(
SysType,VAR_PART_ALLOCATED) ){
13 printf(
"Couldn't alloc the particles\n");
16 VAR_ADD_TYPE(
SysType,VAR_PART_ALLOCATED);
29 printf(
"Couldn't realloc the particles\n");
42 if(Gen->
NLink == NewNLink)
return 1;
43 Gen->
NLink = NewNLink;
47 if( !VAR_IF_TYPE(
SysType,VAR_LINK_ALLOCATED) ){
50 printf(
"Couldn't alloc the links\n");
53 for(
int p=0;p<Gen->
NAllocP;p++){
55 if(
Ln[p].Link == NULL){
56 printf(
"Couldn't alloc the links\n");
60 VAR_ADD_TYPE(
SysType,VAR_LINK_ALLOCATED);
62 else if(Gen->
NAllocP < NewNPart){
65 printf(
"Couldn't realloc the links\n");
68 for(
int p=0;p<Gen->
NAllocP;p++){
69 Ln[p].
Link = (
int *)realloc(
Ln[p].Link,Gen->
NLink*
sizeof(
int));
70 if(
Ln[p].Link == NULL){
71 printf(
"Couldn't realloc the links\n");
81 if( !VAR_IF_TYPE(
SysType,VAR_CH_ALLOCATED) ){
84 VAR_ADD_TYPE(
SysType,VAR_CH_ALLOCATED);
92 printf(
"Couldn't realloc the chains\n");
104 printf(
"No particles or no particle tag: {} \n");
107 if( !VAR_IF_TYPE(
SysType,VAR_PART_ALLOCATED) ){
112 if(
Ln == NULL ||
Pm == NULL){
115 for(
int p=0;p<Gen->
NAllocP;p++){
116 Ln[p].
Link = (
int *)calloc(Gen->
NLink,
sizeof(
int));
119 VAR_ADD_TYPE(
SysType,VAR_PART_ALLOCATED);
120 VAR_ADD_TYPE(
SysType,VAR_CH_ALLOCATED);
136 if(!
Pm){ printf(
"Non alloca Pm\n");return ;}
137 if(!
Ch){ printf(
"Non alloca Ch\n");return ;}
140 for(
int p=0;p<
pNPart();p++){
141 if(p >= NPartOld)
break;
142 for(
int d=0;d<3;d++){
143 P1[p].
Pos[d] = P2[p].
Pos[d];
144 P1[p].
Vel[d] = P2[p].
Vel[d];
151 if(c >= NChainOld)
break;
152 for(
int d=0;d<3;d++){
153 C1[c].
Pos[d] = C2[c].
Pos[d];
154 C1[c].
Vel[d] = C2[c].
Vel[d];
164 if(Val == Gen->
NBlock)
return 1;
165 if(!VAR_IF_TYPE(
SysType,VAR_NBLOCK_ALL)){
168 VAR_ADD_TYPE(
SysType,VAR_NBLOCK_ALL);
177 if(Val == Gen->NNano)
return 1;
181 if(Val == 0) Val = 1;
187 Gen->
NType = NewNType;
197 Pos[d] =
Pm[p].Pos[d] +
Pm[p].Bkf[d];
207 Pm[p].Pos[d] = Pos[d];
214 Pm[p].Vel[d] = Vel[d];
243 printf(
"%lf %lf %lf\n",Pos[0],Pos[1],Pos[2]);
int SetNLink(int NewNCh)
Set and reallocate the number of links.
void SetNPCh(int NewNCh)
Set and reallocate the number of particles per chains.
CHAIN * Ch
Information on all chains.
int pNLink()
Maximum number of bonds.
Information about the nanoparticle.
int Type
Type of the chain (see list CHAIN_)
double pPosNoBkf(int p, int d)
Return the velocity.
double pVel(int p, int d)
Return the velocity.
double pChPos(int p, int d)
Return back folded position.
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 Bkf[3]
xyz Backfold distance
int SetNChain(int NewNCh)
Set and reallocate the number of chains.
int pChain(int p)
Return the chain.
double Vel[3]
Chain velocity.
int pNAllocC()
Allocated number of chains.
void AllocPart()
Alloc the structures.
void SetPos(int p, double *Pos)
Set the particle position.
int SetNBlock(int Val)
Set NBlock.
void SetNanoBkf(int n)
Set the back folded array for the nano n.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
int pType(int p)
Return the type.
Information for every block.
double Pos[3]
xyz Position of the particle
int NLink
Maximum number of bonds.
int NAllocP
Number of allocated particles.
void SetBkf(int p)
Set the back folded array for the particle p.
Structure with the links of the particles.
Information of every chain.
int pNAllocP()
Allocated number of particles.
double pNanoPos(int n, int d)
Return back folded nano position.
int SetNPart(int NewNPart)
Set and reallocate the number of particles.
double pEdge(int d)
xyzr edges of the simulation box
int pNPCh()
Number of particle per chain.
int pNBlock()
Number of blocks.
int NChain
Number of chain.
int * Link
with whom is bonded
int AllocLinks(int NewNCh)
(re)allocate the links
int NPCh
Number of particle per chain.
void SetType(int p, int t)
Set the particle type.
void Copy(PART *P1, PART *P2, int NPartOld)
Copy the part P2 on part P1.
double Bkf[3]
Backfolded position.
int SysType
Contains the definition of the system.
int pNNano()
Number of nanoparticles.
double Pos[4]
xyzr Postion of the chain
int NPCh
particles per chain
void SetNType(int NewNType)
Set the number of species.
int pNType()
of types of the particle
int NType
of types of the particle
double pPos(int p, int d)
Return back folded position.
unsigned long Step
Courrent step.
int pNChain()
Number of chain.
Information of every particle.
int NAllocC
Number of allocated chains.
int SetNNano(int Val)
Set NNano.
int NPart
Number of particle.
PART * Pm
Particle information of all particle.
int NBlock
Number of blocks.
void SetVel(int p, double *Vel)
Set the particle velocity.
int pStep()
Number of steps.
int pNPart()
Number of particle.