X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=mdrun.c;h=29d3160acdc9375864ff56788a293704e8c3ccee;hb=959801961cfdd51e080e6500f51647b3397d336c;hp=b2e67f371810946b5c4b67b82e6a03caab311dfe;hpb=d1ceb8d3fc8e7a2e067f7576b3e787928d556277;p=physik%2Fposic.git diff --git a/mdrun.c b/mdrun.c index b2e67f3..29d3160 100644 --- a/mdrun.c +++ b/mdrun.c @@ -90,6 +90,9 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) { t_stage *stage; switch(type) { + case STAGE_DISPLACE_ATOM: + psize=sizeof(t_displace_atom_params); + break; case STAGE_INSERT_ATOMS: psize=sizeof(t_insert_atoms_params); break; @@ -138,10 +141,11 @@ int mdrun_parse_config(t_mdrun *mdrun) { char error[128]; char line[128]; char *wptr; - char word[16][32]; + char word[16][64]; int wcnt; int i,o; + t_displace_atom_params dap; t_insert_atoms_params iap; t_continue_params cp; t_anneal_params ap; @@ -185,7 +189,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { wptr=strtok(line," \t"); if(wptr==NULL) break; - strncpy(word[wcnt],wptr,32); + strncpy(word[wcnt],wptr,64); wcnt+=1; } @@ -199,6 +203,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { if(!strncmp(word[1],"lj",2)) mdrun->potential=MOLDYN_POTENTIAL_LJ; } + else if(!strncmp(word[0],"continue",8)) + strncpy(mdrun->continue_file,word[1],128); else if(!strncmp(word[0],"cutoff",6)) mdrun->cutoff=atof(word[1]); else if(!strncmp(word[0],"nnd",3)) @@ -368,7 +374,14 @@ int mdrun_parse_config(t_mdrun *mdrun) { mdrun->visualize=atoi(word[1]); else if(!strncmp(word[0],"stage",5)) { // for every stage line, add a stage - if(!strncmp(word[1],"ins_atoms",9)) { + if(!strncmp(word[1],"displace",8)) { + dap.nr=atoi(word[2]); + dap.dx=atof(word[3]); + dap.dy=atof(word[4]); + dap.dz=atof(word[5]); + add_stage(mdrun,STAGE_DISPLACE_ATOM,&dap); + } + else if(!strncmp(word[1],"ins_atoms",9)) { iap.ins_steps=atoi(word[2]); iap.ins_atoms=atoi(word[3]); iap.element=atoi(word[4]); @@ -494,6 +507,23 @@ int check_temperature(t_moldyn *moldyn,t_mdrun *mdrun) { return TRUE; } +int displace_atom(t_moldyn *moldyn,t_mdrun *mdrun) { + + t_displace_atom_params *dap; + t_stage *stage; + t_atom *atom; + + stage=mdrun->stage.current->data; + dap=stage->params; + + atom=&(moldyn->atom[dap->nr]); + atom->r.x+=dap->dx; + atom->r.y+=dap->dy; + atom->r.z+=dap->dz; + + return 0; +} + int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { t_insert_atoms_params *iap; @@ -742,6 +772,11 @@ int mdrun_hook(void *ptr1,void *ptr2) { /* stage specific stuff */ switch(stage->type) { + case STAGE_DISPLACE_ATOM: + stage_print(" -> displace atom\n\n"); + displace_atom(moldyn,mdrun); + change_stage=TRUE; + break; case STAGE_INSERT_ATOMS: stage_print(" -> insert atoms\n\n"); iap=stage->params; @@ -751,7 +786,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { } insert_atoms(moldyn,mdrun); iap->cnt_steps+=1; - break; + break; case STAGE_CONTINUE: stage_print(" -> continue\n\n"); if(stage->executed==TRUE) { @@ -760,7 +795,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { } cp=stage->params; steps=cp->runs; - break; + break; case STAGE_ANNEAL: stage_print(" -> anneal\n\n"); ap=stage->params; @@ -843,9 +878,24 @@ int main(int argc,char **argv) { /* sanity check! */ /* prepare simulation */ - moldyn_init(&moldyn,argc,argv); + + if(mdrun.continue_file[0]) { + // read the save file + moldyn_read_save_file(&moldyn,mdrun.continue_file); + // manualaadjusting some stuff + moldyn.argc=argc; + moldyn.args=argv; + rand_init(&(moldyn.random),NULL,1); + moldyn.random.status|=RAND_STAT_VERBOSE; + } + else { + moldyn_init(&moldyn,argc,argv); + } + if(set_int_alg(&moldyn,mdrun.intalgo)<0) return -1; + + /* potential */ set_cutoff(&moldyn,mdrun.cutoff); if(set_potential(&moldyn,mdrun.potential)<0) return -1; @@ -871,6 +921,14 @@ int main(int argc,char **argv) { ME,mdrun.potential); return -1; } + + /* if it is a continue run, reset schedule and skip lattice init */ + if(mdrun.continue_file[0]) { + memset(&(moldyn.schedule),0,sizeof(t_moldyn_schedule)); + goto addsched; + } + + /* 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); switch(mdrun.lattice) { @@ -900,10 +958,17 @@ int main(int argc,char **argv) { return -1; } moldyn_bc_check(&moldyn); + + /* temperature and pressure */ set_temperature(&moldyn,mdrun.temperature); set_pressure(&moldyn,mdrun.pressure); thermal_init(&moldyn,TRUE); + +addsched: + /* first schedule */ moldyn_add_schedule(&moldyn,mdrun.prerun,mdrun.timestep); + + /* log */ moldyn_set_log_dir(&moldyn,mdrun.sdir); moldyn_set_report(&moldyn,"CHANGE ME","CHANGE ME TOO"); if(mdrun.elog)