X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mdrun.c;h=b2e67f371810946b5c4b67b82e6a03caab311dfe;hb=4f7a62883e5e47be44856c9767c9255c1d68190d;hp=8c5cf71c974f8816c58ee97805a9189d69ea7daa;hpb=0d1dfb1e5027d215fced8ca306dd658f692a2a44;p=physik%2Fposic.git diff --git a/mdrun.c b/mdrun.c index 8c5cf71..b2e67f3 100644 --- a/mdrun.c +++ b/mdrun.c @@ -332,7 +332,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { csp.type|=CHSATTR_TCTRL; } if(!strncmp(word[i],"prelax",6)) { - csp.dp=atof(word[++i]); + csp.dp=atof(word[++i])*BAR; csp.type|=CHSATTR_PRELAX; } if(!strncmp(word[i],"trelax",6)) { @@ -372,7 +372,6 @@ int mdrun_parse_config(t_mdrun *mdrun) { iap.ins_steps=atoi(word[2]); iap.ins_atoms=atoi(word[3]); iap.element=atoi(word[4]); - iap.element=atoi(word[4]); iap.brand=atoi(word[5]); for(i=0;isattr&SATTR_PRELAX)) + if(!(mdrun->sattr&SATTR_PRELAX)) { return TRUE; + } delta=moldyn->p_avg-moldyn->p_ref; @@ -486,7 +500,7 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { t_stage *stage; t_atom *atom; t_3dvec r,v,dist; - double d,dmin; + double d,dmin,o; int cnt,i; double x,y,z; double x0,y0,z0; @@ -498,15 +512,32 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { cr_check=FALSE; v.x=0.0; v.y=0.0; v.z=0.0; + x=0; y=0; z=0; + o=0; dmin=0; + + switch(mdrun->lattice) { + case CUBIC: + o=0.5*mdrun->lc; + break; + case FCC: + o=0.25*mdrun->lc; + break; + case DIAMOND: + case ZINCBLENDE: + o=0.125*mdrun->lc; + break; + default: + break; + } switch(iap->type) { case INS_TOTAL: x=moldyn->dim.x; - x0=0.0; + x0=-x/2.0; y=moldyn->dim.y; - y0=0.0; + y0=-y/2.0; z=moldyn->dim.z; - z0=0.0; + z0=-z/2.0; cr_check=TRUE; break; case INS_REGION: @@ -518,6 +549,12 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { z0=iap->z0; cr_check=TRUE; break; + case INS_POS: + x0=iap->x0; + y0=iap->y0; + z0=iap->z0; + cr_check=FALSE; + break; default: printf("%s unknown insertion mode: %02x\n", ME,iap->type); @@ -528,9 +565,25 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { while(cntins_atoms) { run=1; while(run) { - r.x=(rand_get_double(&(moldyn->random))-0.5)*x+x0; - r.y=(rand_get_double(&(moldyn->random))-0.5)*y+y0; - r.z=(rand_get_double(&(moldyn->random))-0.5)*z+z0; + if(iap->type!=INS_POS) { + r.x=rand_get_double(&(moldyn->random))*x; + r.y=rand_get_double(&(moldyn->random))*y; + r.z=rand_get_double(&(moldyn->random))*z; + } + else { + r.x=0.0; + r.y=0.0; + r.z=0.0; + } + r.x+=x0; + r.y+=y0; + r.z+=z0; + // offset + if(iap->type!=INS_TOTAL) { + r.x+=o; + r.y+=o; + r.z+=o; + } run=0; if(cr_check==TRUE) { dmin=1000; // for sure too high! @@ -550,8 +603,10 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { } add_atom(moldyn,iap->element,pse_mass[iap->element], iap->brand,iap->attr,&r,&v); - printf("%s atom inserted: %f %f %f | d squared = %f\n", - ME,r.x,r.y,r.z,dmin); + printf("%s atom inserted (%d/%d): %f %f %f\n", + ME,(iap->cnt_steps+1)*iap->ins_atoms, + iap->ins_steps*iap->ins_atoms,r.x,r.y,r.z); + printf(" -> d2 = %f/%f\n",dmin,iap->cr*iap->cr); cnt+=1; } @@ -630,9 +685,9 @@ int chsattr(t_moldyn *moldyn,t_mdrun *mdrun) { } if(csp->type&CHSATTR_AVGRST) { if(csp->avgrst) - mdrun->sattr|=CHSATTR_AVGRST; + mdrun->sattr|=SATTR_AVGRST; else - mdrun->sattr&=(~(CHSATTR_AVGRST)); + mdrun->sattr&=(~(SATTR_AVGRST)); } if(csp->type&CHSATTR_RSTEPS) { mdrun->relax_steps=csp->rsteps; @@ -677,8 +732,8 @@ int mdrun_hook(void *ptr1,void *ptr2) { tau=mdrun->timestep; /* check whether relaxation steps are necessary */ - if(!((check_pressure(moldyn,mdrun)==FALSE)|\ - (check_temperature(moldyn,mdrun)==FALSE))) { + if((check_pressure(moldyn,mdrun)==TRUE)&\ + (check_temperature(moldyn,mdrun)==TRUE)) { /* be verbose */ stage_print("\n###########################\n"); @@ -713,7 +768,9 @@ int mdrun_hook(void *ptr1,void *ptr2) { change_stage=TRUE; break; } - set_temperature(moldyn,moldyn->t_ref+ap->dt); + if(moldyn->t_ref+ap->dt>=0.0) + set_temperature(moldyn, + moldyn->t_ref+ap->dt); ap->count+=1; break; case STAGE_CHAATTR: