void UpdateAI(const uint32 diff) { if (uiRenew_timer <= diff) { Shout(); DoCast(me, SPELL_RENEW); uiRenew_timer = 1000 + rand()%5000; } else uiRenew_timer -= diff; if (uiInquisitor_Penance_timer <= diff) { Shout(); DoCast(me->getVictim(), SPELL_INQUISITOR_PENANCE); uiInquisitor_Penance_timer = 2000 + rand()%5000; } else uiInquisitor_Penance_timer -= diff; if (uiValroth_Smite_timer <= diff) { Shout(); DoCast(me->getVictim(), SPELL_VALROTH_SMITE); uiValroth_Smite_timer = 1000 + rand()%5000; } else uiValroth_Smite_timer -= diff; DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 diff) { if (Renew_timer <= diff) { Shout(); DoCast(me, SPELL_RENEW); Renew_timer = urand(1000, 6000); } else Renew_timer -= diff; if (Inquisitor_Penance_timer <= diff) { Shout(); DoCast(me->getVictim(), SPELL_INQUISITOR_PENANCE); Inquisitor_Penance_timer = urand(2000, 7000); } else Inquisitor_Penance_timer -= diff; if (Valroth_Smite_timer <= diff) { Shout(); DoCast(me->getVictim(), SPELL_VALROTH_SMITE); Valroth_Smite_timer = urand(1000, 6000); } else Valroth_Smite_timer -= diff; DoMeleeAttackIfReady(); }
void UpdateAI(uint32 diff) override { if (uiRenew_timer <= diff) { Shout(); DoCast(me, SPELL_RENEW); uiRenew_timer = urand(1000, 6000); } else uiRenew_timer -= diff; if (uiInquisitor_Penance_timer <= diff) { Shout(); DoCastVictim(SPELL_INQUISITOR_PENANCE); uiInquisitor_Penance_timer = urand(2000, 7000); } else uiInquisitor_Penance_timer -= diff; if (uiValroth_Smite_timer <= diff) { Shout(); DoCastVictim(SPELL_VALROTH_SMITE); uiValroth_Smite_timer = urand(1000, 6000); } else uiValroth_Smite_timer -= diff; DoMeleeAttackIfReady(); }
Forces::~Forces(){ Shout("Freeing"); fclose(StatFile1); fclose(StatFile2); Shout("Freeing/md: forces domain decomposition"); if(VAR_IF_TYPE(SysAlloc,ALL_FORCES)){ delete [] Fm; } if(VAR_IF_TYPE(SysAlloc,ALL_MD)){ delete Pc; } if(VAR_IF_TYPE(SysAlloc,ALL_MC)){ delete Pc; delete [] OldNrgBead; delete [] OldNrgCh; for(int p=0;p<pNPCh();p++){ delete [] OldPos[p]; } delete [] OldPos; } if(VAR_IF_TYPE(SysAlloc,ALL_BIAS)){ for(int t=0;t<NTrialBias;t++){ delete [] BondPosBias[t]; } delete [] BondPosBias; delete [] CumProbBias; } if(VAR_IF_TYPE(SysAlloc,ALL_SPLINE)){ free(Pl); } if(VAR_IF_TYPE(SysAlloc,ALL_DENS)){ free(LocDens2); free(LocDens3); free(Dens2); free(Dens3); } if(VAR_IF_TYPE(SysShape,SYS_ROD)){ delete IntMatrix; } if(VAR_IF_TYPE(SysShape,SYS_2D)){ delete IntMatrix; } if(VAR_IF_TYPE(SysShape,SYS_LEAVES)){ delete IntMatrix; } #ifdef __glut_h__ free(Cylinder); #endif }
void Forces::InitConst(){ Shout("Init constants"); NEdge = 80+1;//NInEdge; Dx = 1./(double)(NEdge-1); Kf.El[0] = 11.;//2.*NEdge/10.;//Elastic coupling Kf.El[1] = 11.;//Elastic coupling Kf.El[2] = 11.;//Elastic coupling Kf.Lap = 20.*pow(Dx,2.);//bending rigidity Kf.SLap = 0.;//.015*pow(Dx,2.);//Surface tension Kf.Ext = 1.; Kf.LJ = 1.; Kf.LJMin = .5; Kf.CutOff2 = 1.; Kf.Cont = 0.;//.001; Kf.Elong[0] = 0.1; Kf.Elong[1] = 0.1; Kf.Elong[2] = 0.1; Kf.ForThr = 100.; IntMax = 100; IncrDist = 0.01; IfInterp=FIT_FORTH; IfFillMatrix=1; Nano->Rad = .05; Nano->Height = .3; ChemPotId = 0.; ChemPotEx = 0.; Nano->Pos[0] = 0.; Nano->Pos[1] = 0.; Nano->Pos[2] = .5; BoundCond[0] = 1;BoundCond[1] = 1; BoundCond[2] = 1;BoundCond[3] = 1; BoundCond[4] = 1;BoundCond[5] = 1; PeriodicImage[0] = 1;PeriodicImage[1] = 1;PeriodicImage[2] = 1; Time = 0.; NUpdate = 100; NWrite = 1000; NBin = 100; NTrialBias = 10; // GaussVar = sqrt(1./pkSpr()); ThermMode = THERM_LANG; CalcMode = CALC_LJ39; // Part2Move = NEdge/2+NEdge; #ifdef __glut_h__ NSpline = 100; IfSphere = 0; IfLine = 1; IfSpline = 0; NShow = 1; IfMovie=0; Frame = 0; IfExt = 0; IfRot = 0; BeadType = 0; #endif IfExit = 0; IfNano = 0; DynFlag = 0; SetNBlock(1); }
void Forces::PrepareParallel(int argc,char **argv){ #ifdef OMPI_MPI_H Shout("Preparing parallelisation"); MPI_Init(&argc,&argv); int Rank=0,Size=0; MPI_Comm_rank(MPI_COMM_WORLD, &Rank); MPI_Comm_size(MPI_COMM_WORLD, &Size); int Partition = (int)(argc/(double)Size); NFile[0] = Partition*Rank; NFile[1] = Partition*(Rank+1); if(Rank==Size-1) NFile[1] += argc%Size; Proc = new SingProc(Size,Rank); #endif }
Forces::Forces(int argc,char **argv,char *ConfF,char *Snapshot){ Shout("constructor with intial configuration"); InitConst(); if(ReadConfDinamica(ConfF)){ Dx = 1./(double)(NEdge-1); } Open(Snapshot,BF_PART); if(VAR_IF_TYPE(SysShape,SYS_LEAVES)) IfNano = 2; if(VAR_IF_TYPE(SysShape,SYS_PORE)) IfNano = 2; AllocMethod(); PrepareParallel(argc,argv); PrepareSys(); //Interp(); }
void Forces::AllocMethod(){ Shout("Allocation"); StatFile1 = fopen("StatDyn1.dat","w"); StatFile2 = fopen("StatDyn2.dat","w"); ChooseCalcMode(CalcMode); ChoosePot(CalcMode); ChooseThermostat(ThermMode); double Edge[3] = {pEdge(0),pEdge(1),pEdge(2)}; double Pos[3]; //Pc->PrintCells(); //CheckPairList(); SetDeltat(Deltat); if(VAR_IF_TYPE(SysShape,SYS_MD)){ Shout("Allocating/md: forces, domain decomposition"); Fm = (FORCES *)calloc(pNAllocP(),sizeof(FORCES)); VAR_ADD_TYPE(SysAlloc,ALL_MD); VAR_ADD_TYPE(SysAlloc,ALL_FORCES); Pc = new DomDec(Edge,pNPart(),sqrt(Kf.CutOff2)); for(int p=0;p<pNPart();p++){pPos(p,Pos);Pc->AddPart(p,Pos);} } if(VAR_IF_TYPE(SysShape,SYS_ROD)){ Shout("Allocating/rod: forces"); Fm = (FORCES *)calloc(pNAllocP(),sizeof(FORCES)); VAR_ADD_TYPE(SysAlloc,ALL_FORCES); } else if(VAR_IF_TYPE(SysShape,SYS_MC)){ Shout("Allocating/mc: domain decomposition old chain positions, old energies for particles and chains, first bead distribution, bias (cumulative probabilities and bead positions)"); Pc = new DomDec(Edge,pNPart(),sqrt(Kf.CutOff2)); double Pos[3]; for(int p=0;p<pNPart();p++){pPos(p,Pos);Pc->AddPart(p,Pos);} //Pc->PrintCells(); if(VAR_IF_TYPE(CalcMode,CALC_NVT)){ OldNrgBead = new double[3*pNAllocP()]; if(!OldNrgBead){ printf("Could not allocate OldNrgPm \n"); exit(1); } } OldNrgCh = new double[3*pNAllocC()]; FirstBeadDistr = new double[NBin]; if(!OldNrgCh){ printf("Could not allocate OldNrgCh\n"); exit(1); } OldPos = (double **)calloc(pNPCh(),sizeof(double)); if( !OldPos){ printf("Could not allocate OldPos\n"); exit(1); } for(int p=0;p<pNPCh();p++){ OldPos[p] = (double *)calloc(3,sizeof(double)); } CumProbBias = new double[NTrialBias]; BondPosBias = new double*[NTrialBias]; for(int t=0;t<NTrialBias;t++){ BondPosBias[t] = new double[3]; } VAR_ADD_TYPE(SysAlloc,ALL_MC); VAR_ADD_TYPE(SysAlloc,ALL_BIAS); GaussVar = sqrt(pReOverCutOff()/(3.*(pNPCh()-1)))/2.; GaussVar = sqrt(1./pkSpr()); } else if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){ Shout("Allocating/mc: domain decomposition old chain positions, old energies for particles and chains, first bead distribution, bias (cumulative probabilities and bead positions)"); Pc = new DomDec(Edge,pNPart(),sqrt(Kf.CutOff2)); double Pos[3]; for(int p=0;p<pNPart();p++){pPos(p,Pos);Pc->AddPart(p,Pos);} //Pc->PrintCells(); if(VAR_IF_TYPE(CalcMode,CALC_NVT)){ OldNrgBead = new double[3*pNAllocP()]; if(!OldNrgBead){ printf("Could not allocate OldNrgPm \n"); exit(1); } } OldNrgCh = new double[3*pNAllocC()]; FirstBeadDistr = new double[NBin]; if(!OldNrgCh){ printf("Could not allocate OldNrgCh\n"); exit(1); } OldPos = (double **)calloc(pNPCh(),sizeof(double)); if( !OldPos){ printf("Could not allocate OldPos\n"); exit(1); } for(int p=0;p<pNPCh();p++){ OldPos[p] = (double *)calloc(3,sizeof(double)); } CumProbBias = new double[NTrialBias]; BondPosBias = new double*[NTrialBias]; for(int t=0;t<NTrialBias;t++){ BondPosBias[t] = new double[3]; } VAR_ADD_TYPE(SysAlloc,ALL_MC); VAR_ADD_TYPE(SysAlloc,ALL_BIAS); } if(VAR_IF_TYPE(SysShape,SYS_1D) || VAR_IF_TYPE(SysShape,SYS_TRIAL)){ Shout("Allocating/splines"); Pl = (PART *)calloc(NSpline,sizeof(PART)); VAR_ADD_TYPE(SysAlloc,ALL_SPLINE); } if(VAR_IF_TYPE(CalcMode,CALC_DENS)){ Shout("Allocating/particle densities, sum of local densities"); LocDens2 = (double *)calloc(pNPCh()*pNType(),sizeof(double)); LocDens3 = (double *)calloc(pNPCh()*pNType(),sizeof(double)); Dens2 = (double *)calloc(pNAllocP()*pNType(),sizeof(double)); Dens3 = (double *)calloc(pNAllocP()*pNType(),sizeof(double)); if( !Dens2 || !Dens3){ printf("Could not allocate Dens2 Dens3\n"); exit(1); } VAR_ADD_TYPE(SysAlloc,ALL_DENS); } #ifdef __glut_h__ Cylinder = (GLuint *)calloc(pNNano(),sizeof(GLuint)); #endif ChemPotId = log(NChemPotId/pVol()); }
void Forces::PrepareSys(){ Shout("Preparing system"); OldNrgSys = 0.; DefNanoForceParam(); /*calculate the energies per chain or per particle for the calculation of the MC. */ if(VAR_IF_TYPE(SysShape,SYS_MC)){ if(VAR_IF_TYPE(SysAlloc,ALL_DENS)){ Shout("Preparing system/adding densities\n"); OldNrgSys = DensFuncNrgSys(); ChemPotEx += NrgPBead; if(VAR_IF_TYPE(CalcMode,CALC_NcVT)){ //CalcTotNrgCh(); } if(VAR_IF_TYPE(CalcMode,CALC_NVT)){ ;//CalcTotNrgBead(); } if(VAR_IF_TYPE(CalcMode,CALC_mcVT)){ if(!VAR_IF_TYPE(CalcMode,CALC_CONF_BIAS)) ;//CalcTotNrgCh(); } } //defining all the allocated chains for(int p=0;p<pNAllocP();p++){ int c = (int)(p/(double)pNPCh()); Pm[p].CId = c; Pm[p].Typ = 0; if( p%pNPCh() >= Block[0].Asym ) Pm[p].Typ = 1; if( p%pNPCh() == pNPCh() - 1) continue; Ln[p].NLink = 1; Ln[p].Link[0] = p+1; } } if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){ for(int p=0;p<NEdge;p++){ Pm[p].Typ = 2; Pm[p].Idx = p; Pm[p].CId = p; Ln[p].NLink = 0; SetBkf(p); } for(int p=NEdge;p<NEdge+NSpline;p++){ Pm[p].Typ = 0; Pm[p].Idx = p; Pm[p].CId = NEdge; Ln[p].NLink = 1; Ln[p].Link[0] = p+1; if(p==NEdge+NSpline-1) Ln[p].NLink = 0; SetBkf(p); } } if(VAR_IF_TYPE(SysShape,SYS_MD)){ Shout("Preparing system/calculating forces\n"); OldNrgSys = SumForcesMD(); } else if(VAR_IF_TYPE(SysShape,SYS_ROD)){ IntMatrix = new Matrice(pNPart(),pNPart()); } else if(VAR_IF_TYPE(SysShape,SYS_LEAVES)){ IntMatrix = new Matrice(pNPCh(),pNPCh()); } else if(VAR_IF_TYPE(SysShape,SYS_2D)){ IntMatrix = new Matrice(pNPart(),pNPart()); } /*for the chemical potential, to avoid the calculation of large exponential */ NrgPBead = 0.;//2.*OldNrgSys/(double)pNPart(); Shout("Prepared"); }
Forces::Forces(int argc,char **argv,int NInEdge,char *ConfFileExt){ Shout("Constructor/no starting configuration"); InitConst(); sprintf(ConfFile,"%s",ConfFileExt); char ConfF[40]; sprintf(ConfF,ConfFile); if(ReadConfDinamica(ConfF)){ Dx = 1./(double)(NEdge-1); } if(VAR_IF_TYPE(SysShape,SYS_2D)){ nEdge[0] = NEdge; double Ratio = pEdge(1)*pInvEdge(0); nEdge[1] = (int)(nEdge[0]*Ratio + 0.0001); for(int i=0;;i++){ if((int)(nEdge[1]/Ratio) == nEdge[0]) break; nEdge[0]++; nEdge[1] = (int)(nEdge[0]*Ratio + 0.0001); printf("using: nEdge[0] %d nEdge[1] %d\n",nEdge[0],nEdge[1]); if(i>=10){ printf("Could not find the appropriate border partition %d %d\n",nEdge[0],nEdge[1]); exit(0); } } SetNLink(4); ReSetNPart(nEdge[0]*nEdge[1]); ReSetNChain(nEdge[1]); SetNPCh(nEdge[0]); } else if(VAR_IF_TYPE(SysShape,SYS_3D)){ SetNLink(6); ReSetNChain(NEdge*NEdge); ReSetNPart(NEdge*NEdge*NEdge); } else if(VAR_IF_TYPE(SysShape,SYS_ROD)){ SetNLink(1); ReSetNChain(1); ReSetNPart(NEdge); } else if(VAR_IF_TYPE(SysShape,SYS_STALK)){ SetNLink(3); ReSetNPart(4*NEdge); ReSetNChain(4); // Kf.El[0] *= Gen->NPart; } else if(VAR_IF_TYPE(SysShape,SYS_LEAVES)){ SetNLink(3); ReSetNPart(NEdge); ReSetNChain(1); // Kf.El[0] *= Gen->NPart; } else if(VAR_IF_TYPE(SysShape,SYS_PORE)){ SetNLink(3); ReSetNPart(NEdge); ReSetNChain(1); } else if(VAR_IF_TYPE(SysShape,SYS_1D)){ SetNLink(2); ReSetNPart(NEdge); ReSetNChain(1); } else if(VAR_IF_TYPE(SysShape,SYS_RIGID)){ ReSetNPart(0); SetNLink(0); } else if(VAR_IF_TYPE(SysShape,SYS_TRIAL)){ ReSetNPart(3*3*3); SetNLink(0); ReSetNChain(1); } else if(VAR_IF_TYPE(SysShape,SYS_MD)){ SetNLink(0); ReSetNPart(NEdge); ReSetNChain(1); } else if(VAR_IF_TYPE(SysShape,SYS_MC)){ SetNLink(0); ReSetNPart(NEdge); ReSetNChain(1); } else if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){ SetNLink(4); ReSetNPart(NEdge+NSpline); ReSetNChain(1); } ReSetNPCh(pNPart()/pNChain()); //SetNPCh(NEdge); SetDeltat(Deltat); SetStep(0); SetNType(2); CreateInitial(); { MInt = new MatInt(3,3); MInt->SetCoeff(-24.33,0,0); MInt->SetCoeff(-7.22,0,1); MInt->SetCoeff(-24.33,0,2); MInt->SetCoeff(-0.1,1,1); MInt->SetCoeff(-7.22,1,2); MInt->SetCoeff(0.,2,2); MInt->SetCoeff(3.,0,0,0); MInt->SetCoeff(3.,0,0,1); MInt->SetCoeff(3.,0,0,2); MInt->SetCoeff(3.,0,1,1); MInt->SetCoeff(3.,0,1,2); MInt->SetCoeff(3.,0,2,2); MInt->SetCoeff(0.,1,1,1); MInt->SetCoeff(3.,1,1,2); MInt->SetCoeff(3.,1,2,2); MInt->SetCoeff(0.,2,2,2); } AllocMethod(); PrepareSys(); PrepareParallel(argc,argv); if(VAR_IF_TYPE(SysShape,SYS_LEAVES)) IfNano = 2; if(VAR_IF_TYPE(SysShape,SYS_PORE)) IfNano = 2; if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){ Pm[NEdge].Typ = 2; Pm[NEdge+1].Typ = 2; } //Pc->PrintCells(); //for(int p=0;p<pNPart();p++) CheckDomDec(p); //Interp(); }