X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mdrun.c;h=6effe1aff6c56f33b635da11e332e27a4252b65e;hb=d843bfcc38ac4ad1ceffbb82a1aba8096f791b41;hp=b5abe87ed61b6a8a8e782e07f565e1c20e735a05;hpb=55cd4d049604f2cf1d0fff095e6bcd13ec25780f;p=physik%2Fposic.git diff --git a/mdrun.c b/mdrun.c index b5abe87..6effe1a 100644 --- a/mdrun.c +++ b/mdrun.c @@ -17,6 +17,11 @@ #include "potentials/tersoff.h" #endif +/* pse */ +#define PSE_MASS +#include "pse.h" +#undef PSE_MASS + #define ME "[mdrun]" /* @@ -117,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; @@ -163,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); @@ -194,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; @@ -274,11 +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]); + 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 { + 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 @@ -517,6 +579,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { ap.count=0; ap.runs=atoi(word[2]); ap.dt=atof(word[3]); + ap.interval=atoi(word[4]); add_stage(mdrun,STAGE_ANNEAL,&ap); } else if(!strncmp(word[1],"set_temp",8)) { @@ -923,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; @@ -930,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; @@ -1006,6 +1071,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { set_temperature(moldyn, moldyn->t_ref+ap->dt); ap->count+=1; + steps=ap->interval; break; case STAGE_CHAATTR: stage_print(" -> change atom attributes\n\n"); @@ -1034,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; @@ -1071,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)); @@ -1146,26 +1257,30 @@ 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.element1, - mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, - mdrun.ly,mdrun.lz,NULL); + create_lattice(&moldyn,FCC,mdrun.lc,mdrun.fill_element, + mdrun.m1,DEFAULT_ATOM_ATTR, + mdrun.fill_brand,mdrun.lx, + mdrun.ly,mdrun.lz,NULL,0,NULL); break; case DIAMOND: - create_lattice(&moldyn,DIAMOND,mdrun.lc,mdrun.element1, - mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, - mdrun.ly,mdrun.lz,NULL); + create_lattice(&moldyn,DIAMOND,mdrun.lc, + mdrun.fill_element, + mdrun.m1,DEFAULT_ATOM_ATTR, + mdrun.fill_brand,mdrun.lx, + mdrun.ly,mdrun.lz,NULL,0,NULL); break; case ZINCBLENDE: o.x=0.5*0.25*mdrun.lc; o.y=o.x; o.z=o.x; create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1, mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, - mdrun.ly,mdrun.lz,&o); + mdrun.ly,mdrun.lz,&o,0,NULL); o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x; create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2, mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx, - mdrun.ly,mdrun.lz,&o); + mdrun.ly,mdrun.lz,&o,0,NULL); break; case NONE: set_nn_dist(&moldyn,mdrun.nnd); @@ -1176,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 */