From: hackbard Date: Tue, 13 May 2008 09:54:41 +0000 (+0200) Subject: implemented continue featue + skipped d calc in bond_analyze function X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1c8623aedde670da01eb2e85cf36d0b2a7c340f;p=physik%2Fposic.git implemented continue featue + skipped d calc in bond_analyze function --- diff --git a/mdrun.c b/mdrun.c index bd045fe..d99bd7a 100644 --- a/mdrun.c +++ b/mdrun.c @@ -141,7 +141,7 @@ 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; @@ -189,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; } @@ -203,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)) @@ -876,9 +878,16 @@ int main(int argc,char **argv) { /* sanity check! */ /* prepare simulation */ + moldyn_init(&moldyn,argc,argv); + + if(mdrun.continue_file) + moldyn_read_save_file(&moldyn,mdrun.continue_file); + 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; @@ -904,6 +913,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) { + 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) { @@ -933,10 +950,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) diff --git a/mdrun.h b/mdrun.h index 3b24946..d065d57 100644 --- a/mdrun.h +++ b/mdrun.h @@ -51,6 +51,8 @@ typedef struct s_stage { typedef struct s_mdrun { char cfile[128]; // config file + char continue_file[128]; // moldyn save file to continue + u8 intalgo; // integration algorithm double timestep; // timestep diff --git a/moldyn.c b/moldyn.c index caafc4c..a4fef49 100644 --- a/moldyn.c +++ b/moldyn.c @@ -1579,8 +1579,9 @@ int moldyn_integrate(t_moldyn *moldyn) { printf("[moldyn] WARNING: forces too high / tau too small!\n"); /* zero absolute time */ - moldyn->time=0.0; - moldyn->total_steps=0; + // should have right values! + //moldyn->time=0.0; + //moldyn->total_steps=0; /* debugging, ignore */ moldyn->debug=0; @@ -2586,8 +2587,6 @@ int bond_analyze_process(t_moldyn *moldyn,t_atom *itom,t_atom *jtom, if(moldyn->check_2b_bond(moldyn,itom,jtom,bc)==FALSE) return 0; - d=sqrt(d); - /* now count this bonding ... */ ba=data;