X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fposic.git;a=blobdiff_plain;f=mdrun.c;fp=mdrun.c;h=6effe1aff6c56f33b635da11e332e27a4252b65e;hp=83f501ce2074cb568b7637bc0f8f2c4d2a00146e;hb=d843bfcc38ac4ad1ceffbb82a1aba8096f791b41;hpb=787848dc9bf3daa2ccb76296de904688cc504a45 diff --git a/mdrun.c b/mdrun.c index 83f501c..6effe1a 100644 --- a/mdrun.c +++ b/mdrun.c @@ -122,6 +122,12 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) { case STAGE_SET_TIMESTEP: psize=sizeof(t_set_timestep_params); break; + case STAGE_FILL: + psize=sizeof(t_fill_params); + break; + case STAGE_THERMAL_INIT: + psize=0; + break; default: printf("%s unknown stage type: %02x\n",ME,type); return -1; @@ -168,6 +174,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { t_chsattr_params csp; t_set_temp_params stp; t_set_timestep_params stsp; + t_fill_params fp; /* open config file */ fd=open(mdrun->cfile,O_RDONLY); @@ -199,6 +206,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { memset(&csp,0,sizeof(t_chsattr_params)); memset(&stp,0,sizeof(t_set_temp_params)); memset(&stsp,0,sizeof(t_set_timestep_params)); + memset(&fp,0,sizeof(t_fill_params)); // get command + args wcnt=0; @@ -279,19 +287,60 @@ int mdrun_parse_config(t_mdrun *mdrun) { mdrun->m2=pse_mass[mdrun->element2]; } else if(!strncmp(word[0],"fill",6)) { - // only lc mode by now - mdrun->lx=atoi(word[2]); - mdrun->ly=atoi(word[3]); - mdrun->lz=atoi(word[4]); - mdrun->lc=atof(word[5]); - if(wcnt==8) { - mdrun->fill_element=atoi(word[6]); - mdrun->fill_brand=atoi(word[7]); + fp.lx=atoi(word[2]); + fp.ly=atoi(word[3]); + fp.lz=atoi(word[4]); + fp.lc=atof(word[5]); + mdrun->lc=fp.lc; + if(!strncmp(word[1],"lc",2)) { + if(wcnt==8) { + fp.fill_element=atoi(word[6]); + fp.fill_brand=atoi(word[7]); + } + else { + fp.fill_element=mdrun->element1; + fp.fill_brand=0; + } } else { - mdrun->fill_element=mdrun->element1; - mdrun->fill_brand=0; + switch(word[6][0]) { + case 'i': + if(word[6][1]=='r') + fp.p_type=PART_INSIDE_R; + else + fp.p_type=PART_INSIDE_D; + break; + case 'o': + if(word[6][1]=='r') + fp.p_type=PART_OUTSIDE_R; + else + fp.p_type=PART_OUTSIDE_D; + break; + default: + break; + } + } + if((fp.p_type==PART_INSIDE_R)|| + (fp.p_type==PART_OUTSIDE_R)) { + fp.p_vals.r=atof(word[7]); + fp.p_vals.p.x=atof(word[8]); + fp.p_vals.p.y=atof(word[9]); + fp.p_vals.p.z=atof(word[10]); } + if((fp.p_type==PART_INSIDE_D)|| + (fp.p_type==PART_OUTSIDE_D)) { + fp.p_vals.p.x=atof(word[7]); + fp.p_vals.p.y=atof(word[8]); + fp.p_vals.p.z=atof(word[9]); + fp.p_vals.d.x=atof(word[10]); + fp.p_vals.d.y=atof(word[11]); + fp.p_vals.d.z=atof(word[12]); + } + fp.lattice=mdrun->lattice; + add_stage(mdrun,STAGE_FILL,&fp); + } + else if(!strncmp(word[0],"thermal_init",12)) { + add_stage(mdrun,STAGE_THERMAL_INIT,NULL); } else if(!strncmp(word[0],"aattr",5)) { // for aatrib line we need a special stage @@ -937,6 +986,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { t_list *sl; int steps; u8 change_stage; + t_3dvec o; t_insert_atoms_params *iap; t_insert_mixed_atoms_params *imp; @@ -944,6 +994,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { t_anneal_params *ap; t_set_temp_params *stp; t_set_timestep_params *stsp; + t_fill_params *fp; moldyn=ptr1; mdrun=ptr2; @@ -1049,6 +1100,51 @@ int mdrun_hook(void *ptr1,void *ptr2) { mdrun->timestep=stsp->tau; change_stage=TRUE; break; + case STAGE_FILL: + stage_print(" -> fill lattice\n\n"); + fp=stage->params; + if(fp->lattice!=ZINCBLENDE) { + create_lattice(moldyn, + fp->lattice,fp->lc, + mdrun->element1, + mdrun->m1, + DEFAULT_ATOM_ATTR,0, + fp->lx,fp->ly,fp->lz, + NULL,fp->p_type, + &(fp->p_vals)); + } + else { + o.x=0.5*0.25*fp->lc; + o.y=o.x; + o.z=o.x; + create_lattice(moldyn, + FCC,fp->lc, + mdrun->element1, + mdrun->m1, + DEFAULT_ATOM_ATTR,0, + fp->lx,fp->ly,fp->lz, + &o,fp->p_type, + &(fp->p_vals)); + o.x+=0.25*fp->lc; + o.y=o.x; + o.z=o.x; + create_lattice(moldyn, + FCC,fp->lc, + mdrun->element2, + mdrun->m2, + DEFAULT_ATOM_ATTR,1, + fp->lx,fp->ly,fp->lz, + &o,fp->p_type, + &(fp->p_vals)); + } + moldyn_bc_check(moldyn); + change_stage=TRUE; + break; + case STAGE_THERMAL_INIT: + stage_print(" -> thermal init\n\n"); + thermal_init(moldyn,TRUE); + change_stage=TRUE; + break; default: printf("%s unknwon stage type\n",ME); break; @@ -1086,7 +1182,7 @@ int main(int argc,char **argv) { t_mdrun mdrun; t_moldyn moldyn; - t_3dvec o; + //t_3dvec o; /* clear structs */ memset(&mdrun,0,sizeof(t_mdrun)); @@ -1161,6 +1257,7 @@ int main(int argc,char **argv) { /* initial lattice and dimensions */ set_dim(&moldyn,mdrun.dim.x,mdrun.dim.y,mdrun.dim.z,mdrun.vis); set_pbc(&moldyn,mdrun.pbcx,mdrun.pbcy,mdrun.pbcz); + /* replaced by fill stage !! switch(mdrun.lattice) { case FCC: create_lattice(&moldyn,FCC,mdrun.lc,mdrun.fill_element, @@ -1194,11 +1291,14 @@ int main(int argc,char **argv) { return -1; } moldyn_bc_check(&moldyn); + replaced by fill stage !! */ /* temperature and pressure */ set_temperature(&moldyn,mdrun.temperature); set_pressure(&moldyn,mdrun.pressure); + /* replaced thermal_init stage thermal_init(&moldyn,TRUE); + */ addsched: /* first schedule */