From 3592f3b0cf641729566674a7cdfd8eff3f61f59a Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 11:23:17 +0200 Subject: [PATCH 01/16] fixed compile errors, no testing yet! --- config.default | 34 ++----- mdrun.c | 247 ++++++++++++++++++++++++++++++++++++------------- mdrun.h | 24 +++-- moldyn.c | 20 ++-- 4 files changed, 216 insertions(+), 109 deletions(-) diff --git a/config.default b/config.default index 0bd26d2..e9181be 100644 --- a/config.default +++ b/config.default @@ -22,14 +22,6 @@ pbc 1 1 1 temperature 450.0 pressure 0.0 -## ensemble control ## - -ectrl 100.0 100.0 - -## equi ctrl ## - -equictrl 1.0 1.0 - ## initial lattice ## lattice diamond @@ -38,31 +30,25 @@ element1 silicon #element2 carbon fill lc 9 9 9 -aattr all h +## atom attributes ## + +aattr t h123 ## initial simulation run ## prerun 100 avgskip 0 -## more stages ## +## system attributes, eg ensemble ctrl, equi ctrl, relaxation steps ## -# format: -# stage -# -# actions: -# -# ins_atoms <#insertions> <#atoms> \ -# <#atom-attrib> -# -# continue <#runs> -# -# anneal <#annealing-steps> +sattr pctrl 100.0 tctrl 100.0 prelax 1.0 trelax 1.0 rsteps 100 avgrst 1 + +## more stages ## -stage ins_atoms 10 1 14 v h rand 0 0 0 11 11 11 -stage ins_atoms 1 1 6 v h rand 0 0 0 5.429 5.429 5.429 +stage ins_atoms 10 1 14 0 vh123 rand -5.5 -5.5 -5.5 5.5 5.5 5.5 +stage ins_atoms 1 1 6 1 vh123 rand 0 0 0 5.429 5.429 5.429 stage continue 10000 -stage anneal 723 -1.0 +#stage anneal 723 -1.0 ## report / log / visualization / save files ## diff --git a/mdrun.c b/mdrun.c index 6f7a2f0..c4b6df2 100644 --- a/mdrun.c +++ b/mdrun.c @@ -62,12 +62,12 @@ int mdrun_parse_argv(t_mdrun *mdrun,int argc,char **argv) { return 0; } -del_stages(t_mdrun *mdrun) { +int del_stages(t_mdrun *mdrun) { t_list *sl; t_stage *stage; - sl=mdrun->stage; + sl=&(mdrun->stage); list_reset_f(sl); @@ -83,7 +83,7 @@ del_stages(t_mdrun *mdrun) { return 0; } -add_stage(t_mdrun *mdrun,u8 type,void *params) { +int add_stage(t_mdrun *mdrun,u8 type,void *params) { int psize; @@ -106,7 +106,8 @@ add_stage(t_mdrun *mdrun,u8 type,void *params) { psize=sizeof(t_chsattr_params); break; default: - + printf("%s unknown stage type: %02x\n",ME,type); + return -1; } stage=malloc(sizeof(t_stage)); @@ -126,7 +127,7 @@ add_stage(t_mdrun *mdrun,u8 type,void *params) { memcpy(stage->params,params,psize); - list_add_immediate_f(mdrun->stage,stage); + list_add_immediate_f(&(mdrun->stage),stage); return 0; } @@ -168,6 +169,13 @@ int mdrun_parse_config(t_mdrun *mdrun) { if((line[0]=='#')|(ret==1)) continue; + // reset + memset(&iap,0,sizeof(t_insert_atoms_params)); + memset(&cp,0,sizeof(t_continue_params)); + memset(&ap,0,sizeof(t_anneal_params)); + memset(&cap,0,sizeof(t_chaattr_params)); + memset(&csp,0,sizeof(t_chsattr_params)); + // get command + args wcnt=0; while(1) { @@ -271,13 +279,37 @@ int mdrun_parse_config(t_mdrun *mdrun) { else if(!strncmp(word[0],"aattr",5)) { // for aatrib line we need a special stage // containing one schedule of 0 loops ... - if(!strncmp(word[1],"all",3)) { - cap.type= - - - HIER WEITER + for(i=0;ip_tau=atof(word[1]); - mdrun->t_tau=atof(word[2]); + else if(!strncmp(word[0],"sattr",5)) { + // for satrib line we need a special stage + // containing one schedule of 0 loops ... + for(i=1;iprerun=atoi(word[1]); @@ -328,10 +381,72 @@ 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 - printf("%s stage: %s\n",ME,word[1]); + if(!strncmp(word[1],"ins_atoms",9)) { + 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;istage->current->data; + stage=mdrun->stage.current->data; iap=stage->params; cr_check=FALSE; @@ -417,7 +532,8 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { cr_check=TRUE; break; default: - printf("%s unknown insertion mode\n"); + printf("%s unknown insertion mode: %02x\n", + ME,iap->type); return -1; } @@ -455,14 +571,14 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { return 0; } -int chaatrib(t_moldyn *moldyn,t_mdrun *mdrun) { +int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) { t_stage *stage; t_chaattr_params *cap; t_atom *atom; - u8 assigne; + int i; - stage=mdrun->stage->current->data; + stage=mdrun->stage.current->data; cap=stage->params; for(i=0;icount;i++) { @@ -496,41 +612,51 @@ int chsattr(t_moldyn *moldyn,t_mdrun *mdrun) { t_stage *stage; t_chsattr_params *csp; - stage=mdrun->stage->current->data; + stage=mdrun->stage.current->data; csp=stage->params; - switch(csp->type) { - case CHSATTR_PCTRL: - set_p_scale(moldyn,csp->ctrl_type,csp->tau); - break; - case CHSATTR_TCTRL: - set_t_scale(moldyn,csp->ctrl_type,csp->tau); - break; - case CHSATTR_PRELAX: - mdrun->sattr&=(^(SATTR_PRELAX)); - if(csp->ctrl==TRUE) - mdrun->sattr|=SATTR_PRELAX; - break; - case CHSATTR_TRELAX: - mdrun->sattr&=(^(SATTR_TRELAX)); - if(csp->ctrl==TRUE) - mdrun->sattr|=SATTR_TRELAX; - break; - case CHSATTR_AVGRST: - mdrun->sattr&=(^(SATTR_AVGRST)); - if(csp->ctrl==TRUE) - mdrun->sattr|=SATTR_AVGRST; - break; - default: - printf("%s unknown system attribute change\n",ME); - return -1; + if(csp->type&CHSATTR_PCTRL) { + if(csp->ptau>0) + set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau); + else + set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau); + } + if(csp->type&CHSATTR_TCTRL) { + if(csp->ttau>0) + set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau); + else + set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau); + } + if(csp->type&CHSATTR_PRELAX) { + if(csp->dp<0) + mdrun->sattr&=(~(SATTR_PRELAX)); + else + mdrun->sattr|=SATTR_PRELAX; + mdrun->dp=csp->dp; + } + if(csp->type&CHSATTR_TRELAX) { + if(csp->dt<0) + mdrun->sattr&=(~(SATTR_TRELAX)); + else + mdrun->sattr|=SATTR_TRELAX; + mdrun->dt=csp->dt; + } + if(csp->type&CHSATTR_AVGRST) { + if(csp->avgrst) + mdrun->sattr|=CHSATTR_AVGRST; + else + mdrun->sattr&=(~(CHSATTR_AVGRST)); + } + if(csp->type&CHSATTR_RSTEPS) { + mdrun->relax_steps=csp->rsteps; } return 0; } -int mdrun_hook(t_moldyn *moldyn,void *ptr) { +int mdrun_hook(void *ptr1,void *ptr2) { + t_moldyn *moldyn; t_mdrun *mdrun; t_stage *stage; t_list *sl; @@ -542,8 +668,10 @@ int mdrun_hook(t_moldyn *moldyn,void *ptr) { t_continue_params *cp; t_anneal_params *ap; - mdrun=ptr; - sl=mdrun->stage; + moldyn=ptr1; + mdrun=ptr2; + + sl=&(mdrun->stage); change_stage=FALSE; @@ -552,14 +680,15 @@ int mdrun_hook(t_moldyn *moldyn,void *ptr) { return 0; /* get stage description */ - stage=mdrun->sl->current->data; + stage=sl->current->data; /* default steps and tau values */ steps=mdrun->relax_steps; tau=mdrun->timestep; /* check whether relaxation steps are necessary */ - if(!((check_pressure==FALSE)|(check_temperature==FALSE))) { + if(!((check_pressure(moldyn,mdrun)==FALSE)|\ + (check_temperature(moldyn,mdrun)==FALSE))) { /* stage specific stuff */ switch(stage->type) { @@ -590,11 +719,11 @@ int mdrun_hook(t_moldyn *moldyn,void *ptr) { ap->count+=1; break; case STAGE_CHAATTR: - chaatrib(moldyn,mdrun); + chaatr(moldyn,mdrun); change_stage=TRUE; break; case STAGE_CHSATTR: - chsatrib(moldyn,mdrun); + chsattr(moldyn,mdrun); change_stage=TRUE; break; default: @@ -704,7 +833,7 @@ int main(int argc,char **argv) { mdrun.ly,mdrun.lz,&o); o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x; create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2, - mdrun.m2,0,0,mdrun.lx, + mdrun.m2,0,1,mdrun.lx, mdrun.ly,mdrun.lz,&o); break; default: @@ -734,12 +863,6 @@ int main(int argc,char **argv) { moldyn_set_log(&moldyn,CREATE_REPORT,0); set_avg_skip(&moldyn,mdrun.avgskip); - /* pt scaling */ - if(mdrun.p_tau!=0) - set_p_scale(&moldyn,P_SCALE_BERENDSEN,mdrun.p_tau); - if(mdrun.t_tau!=0) - set_t_scale(&moldyn,T_SCALE_BERENDSEN,mdrun.t_tau); - /* prepare the hook function */ moldyn_set_schedule_hook(&moldyn,&mdrun_hook,&mdrun); diff --git a/mdrun.h b/mdrun.h index be8e2a4..20d68d7 100644 --- a/mdrun.h +++ b/mdrun.h @@ -11,12 +11,16 @@ #include #include #include +#include #include /* main molecular dynamics api */ #include "moldyn.h" +/* elements */ +#include "pse.h" + /* list api */ #include "list/list.h" @@ -73,10 +77,8 @@ typedef struct s_mdrun { u8 sattr; // system attributes double temperature; // temperature double pressure; // pressure - double p_tau; // pressure tau - double t_tau; // temperature tau - double dp; // delta p fpr pctrl - double dt; // delta t for tctrl + double dp; + double dt; int relax_steps; // amount of relaxation steps int prerun; // amount of loops in first run @@ -91,7 +93,7 @@ typedef struct s_mdrun { int avgskip; // average skip char sdir[128]; // save root - t_list *stage; // stages + t_list stage; // stages int s_cnt; // stage counter } t_mdrun; @@ -108,7 +110,7 @@ typedef struct s_insert_atoms_params { int ins_atoms; int element; u8 brand; - u8 aattr; + u8 attr; } t_insert_atoms_params; #define INS_TOTAL 0x01 @@ -138,9 +140,12 @@ typedef struct s_chaattr_params { typedef struct s_chsattr_params { u8 type; - double tau; - u8 ctrl; - double delta; + double ttau; + double ptau; + double dt; + double dp; + int rsteps; + u8 avgrst; } t_chsattr_params; #define CHSATTR_PCTRL 0x01 @@ -148,6 +153,7 @@ typedef struct s_chsattr_params { #define CHSATTR_PRELAX 0x04 #define CHSATTR_TRELAX 0x08 #define CHSATTR_AVGRST 0x10 +#define CHSATTR_RSTEPS 0x20 /* * function prototypes diff --git a/moldyn.c b/moldyn.c index 988b467..832d171 100644 --- a/moldyn.c +++ b/moldyn.c @@ -79,7 +79,8 @@ static char *pse_col[]={ "Ar", }; -static double *pse_mass[]={ +/* +static double pse_mass[]={ 0, 0, 0, @@ -101,7 +102,7 @@ static double *pse_mass[]={ 0, }; -static double *pse_lc[]={ +static double pse_lc[]={ 0, 0, 0, @@ -122,6 +123,7 @@ static double *pse_lc[]={ 0, 0, }; +*/ /* * the moldyn functions @@ -202,7 +204,7 @@ int set_pressure(t_moldyn *moldyn,double p_ref) { int set_p_scale(t_moldyn *moldyn,u8 ptype,double ptc) { - moldyn->pt_scalei&=(^(P_SCALE_MASK)); + moldyn->pt_scale&=(~(P_SCALE_MASK)); moldyn->pt_scale|=ptype; moldyn->p_tc=ptc; @@ -213,27 +215,17 @@ int set_p_scale(t_moldyn *moldyn,u8 ptype,double ptc) { printf(" | type: %02x | factor: %f",ptype,ptc); printf("\n"); - printf(" t: %s",ttype?"yes":"no "); - if(ttype) - printf(" | type: %02x | factor: %f",ttype,ttc); - printf("\n"); - return 0; } int set_t_scale(t_moldyn *moldyn,u8 ttype,double ttc) { - moldyn->pt_scalei&=(^(T_SCALE_MASK)); + moldyn->pt_scale&=(~(T_SCALE_MASK)); moldyn->pt_scale|=ttype; moldyn->t_tc=ttc; printf("[moldyn] p/t scaling:\n"); - printf(" p: %s",ptype?"yes":"no "); - if(ptype) - printf(" | type: %02x | factor: %f",ptype,ptc); - printf("\n"); - printf(" t: %s",ttype?"yes":"no "); if(ttype) printf(" | type: %02x | factor: %f",ttype,ttc); -- 2.20.1 From 2dddad627c54f294c4c5b5d736178c3ef3288159 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 13:44:49 +0200 Subject: [PATCH 02/16] safety checkin before mensa --- config.default | 11 ++++++----- mdrun.c | 52 ++++++++++++++++++++++++++------------------------ mdrun.h | 3 ++- moldyn.c | 3 +++ 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/config.default b/config.default index e9181be..d63e401 100644 --- a/config.default +++ b/config.default @@ -4,8 +4,9 @@ ## potential ## -potential albe +potential albe 14 6 cutoff 2.96 +nnd 2.351 ## integration algorithm ## @@ -14,20 +15,20 @@ timestep 1.0 ## simulation volume ## -volume +volume 48.861 48.861 48.861 pbc 1 1 1 ## temperature / pressure ## -temperature 450.0 +temperature -273.0 pressure 0.0 ## initial lattice ## lattice diamond #lattice zincblende -element1 silicon -#element2 carbon +element1 14 +element2 6 fill lc 9 9 9 ## atom attributes ## diff --git a/mdrun.c b/mdrun.c index c4b6df2..63899a6 100644 --- a/mdrun.c +++ b/mdrun.c @@ -201,6 +201,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { } else if(!strncmp(word[0],"cutoff",6)) mdrun->cutoff=atof(word[1]); + else if(!strncmp(word[0],"nnd",3)) + mdrun->nnd=atof(word[1]); else if(!strncmp(word[0],"intalgo",7)) { if(!strncmp(word[1],"verlet",5)) mdrun->intalgo=MOLDYN_INTEGRATE_VERLET; @@ -242,33 +244,11 @@ int mdrun_parse_config(t_mdrun *mdrun) { } else if(!strncmp(word[0],"element1",8)) { mdrun->element1=atoi(word[1]); - switch(mdrun->element1) { - case SI: - mdrun->m1=M_SI; - break; - case C: - mdrun->m1=M_C; - break; - default: - printf("%s unknown element1: %s|%d\n", - ME,word[1],mdrun->element1); - return -1; - } + mdrun->m1=pse_mass[mdrun->element1]; } else if(!strncmp(word[0],"element2",8)) { mdrun->element2=atoi(word[1]); - switch(mdrun->element2) { - case SI: - mdrun->m2=M_SI; - break; - case C: - mdrun->m2=M_C; - break; - default: - printf("%s unknown element2: %s|%d\n", - ME,word[1],mdrun->element2); - return -1; - } + mdrun->m2=pse_mass[mdrun->element2]; } else if(!strncmp(word[0],"fill",6)) { // only lc mode by now @@ -341,24 +321,31 @@ int mdrun_parse_config(t_mdrun *mdrun) { else if(!strncmp(word[0],"sattr",5)) { // for satrib line we need a special stage // containing one schedule of 0 loops ... + csp.type=0; for(i=1;iexecuted)) \ + printf("%s",m) + int mdrun_hook(void *ptr1,void *ptr2) { t_moldyn *moldyn; @@ -684,15 +674,22 @@ int mdrun_hook(void *ptr1,void *ptr2) { /* default steps and tau values */ steps=mdrun->relax_steps; +printf("-------> %d\n",mdrun->relax_steps); tau=mdrun->timestep; /* check whether relaxation steps are necessary */ if(!((check_pressure(moldyn,mdrun)==FALSE)|\ (check_temperature(moldyn,mdrun)==FALSE))) { + + /* be verbose */ + stage_print("\n###########################\n"); + stage_print("# [mdrun] executing stage #\n"); + stage_print("###########################\n\n"); /* stage specific stuff */ switch(stage->type) { case STAGE_INSERT_ATOMS: + stage_print(" -> insert atoms\n\n"); iap=stage->params; if(iap->cnt_steps==iap->ins_steps) { change_stage=TRUE; @@ -702,6 +699,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { iap->cnt_steps+=1; break; case STAGE_CONTINUE: + stage_print(" -> continue\n\n"); if(stage->executed==TRUE) { change_stage=TRUE; break; @@ -710,6 +708,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { steps=cp->runs; break; case STAGE_ANNEAL: + stage_print(" -> anneal\n\n"); ap=stage->params; if(ap->count==ap->runs) { change_stage=TRUE; @@ -719,10 +718,12 @@ int mdrun_hook(void *ptr1,void *ptr2) { ap->count+=1; break; case STAGE_CHAATTR: + stage_print(" -> chaattr\n\n"); chaatr(moldyn,mdrun); change_stage=TRUE; break; case STAGE_CHSATTR: + stage_print(" -> chsattr\n\n"); chsattr(moldyn,mdrun); change_stage=TRUE; break; @@ -789,6 +790,7 @@ int main(int argc,char **argv) { if(set_int_alg(&moldyn,mdrun.intalgo)<0) return -1; set_cutoff(&moldyn,mdrun.cutoff); + set_nn_dist(&moldyn,mdrun.nnd); if(set_potential(&moldyn,mdrun.potential)<0) return -1; switch(mdrun.potential) { diff --git a/mdrun.h b/mdrun.h index 20d68d7..83a8196 100644 --- a/mdrun.h +++ b/mdrun.h @@ -57,8 +57,9 @@ typedef struct s_mdrun { double timestep; // timestep u8 potential; // potential - double cutoff; // cutoff radius + double nnd; // next neighbour distance + t_3dvec dim; // simulation volume u8 pbcx; // periodic boundary conditions u8 pbcy; diff --git a/moldyn.c b/moldyn.c index 832d171..6fa9df2 100644 --- a/moldyn.c +++ b/moldyn.c @@ -1635,6 +1635,7 @@ int moldyn_integrate(t_moldyn *moldyn) { atom=moldyn->atom; /* initialize linked cell method */ +printf(" hier soll es sein\n"); link_cell_init(moldyn,VERBOSE); /* logging & visualization */ @@ -2415,6 +2416,8 @@ int process_2b_bonds(t_moldyn *moldyn,void *data, lc=&(moldyn->lc); + /* only init link cell if it doesn't exist! */ + HIER WEITER link_cell_init(moldyn,VERBOSE); itom=moldyn->atom; -- 2.20.1 From 0d1dfb1e5027d215fced8ca306dd658f692a2a44 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 17:01:45 +0200 Subject: [PATCH 03/16] unstable but might run ... --- bond_analyze.c | 3 +++ config.default | 4 ++-- mdrun.c | 23 +++++++++++---------- moldyn.c | 18 +++++++++-------- moldyn.h | 2 ++ pair_correlation_calc.c | 3 +++ runmd | 37 ++++++++++++++++++++++++++++++++++ runmd_rx200 | 44 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 112 insertions(+), 22 deletions(-) create mode 100755 runmd create mode 100755 runmd_rx200 diff --git a/bond_analyze.c b/bond_analyze.c index cc1c318..6c46251 100644 --- a/bond_analyze.c +++ b/bond_analyze.c @@ -49,6 +49,9 @@ int main(int argc,char **argv) { set_potential(&moldyn,MOLDYN_POTENTIAL_AM); albe_mult_set_params(&moldyn,SI,C); + /* link cell init */ + link_cell_init(&moldyn,VERBOSE); + /* analyzing ... */ bond_analyze(&moldyn,quality); diff --git a/config.default b/config.default index d63e401..74e4997 100644 --- a/config.default +++ b/config.default @@ -20,7 +20,7 @@ pbc 1 1 1 ## temperature / pressure ## -temperature -273.0 +temperature 0.0 pressure 0.0 ## initial lattice ## @@ -29,7 +29,7 @@ lattice diamond #lattice zincblende element1 14 element2 6 -fill lc 9 9 9 +fill lc 9 9 9 5.429 ## atom attributes ## diff --git a/mdrun.c b/mdrun.c index 63899a6..8c5cf71 100644 --- a/mdrun.c +++ b/mdrun.c @@ -140,7 +140,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { char *wptr; char word[16][32]; int wcnt; - int i; + int i,o; t_insert_atoms_params iap; t_continue_params cp; @@ -255,6 +255,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { mdrun->lx=atoi(word[2]); mdrun->ly=atoi(word[3]); mdrun->lz=atoi(word[4]); + mdrun->lc=atof(word[5]); } else if(!strncmp(word[0],"aattr",5)) { // for aatrib line we need a special stage @@ -274,7 +275,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { break; } } - i=1; + i=2; if(cap.type&CHAATTR_REGION) { cap.x0=atof(word[1]); cap.y0=atof(word[2]); @@ -288,9 +289,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { cap.element=atoi(word[i]); i+=1; } - wptr=word[i]; - for(i=0;irelax_steps; -printf("-------> %d\n",mdrun->relax_steps); tau=mdrun->timestep; /* check whether relaxation steps are necessary */ @@ -767,8 +766,9 @@ int main(int argc,char **argv) { t_moldyn moldyn; t_3dvec o; - /* clear mdrun struct */ + /* clear structs */ memset(&mdrun,0,sizeof(t_mdrun)); + memset(&moldyn,0,sizeof(t_moldyn)); /* parse arguments */ if(mdrun_parse_argv(&mdrun,argc,argv)<0) @@ -790,7 +790,6 @@ int main(int argc,char **argv) { if(set_int_alg(&moldyn,mdrun.intalgo)<0) return -1; set_cutoff(&moldyn,mdrun.cutoff); - set_nn_dist(&moldyn,mdrun.nnd); if(set_potential(&moldyn,mdrun.potential)<0) return -1; switch(mdrun.potential) { @@ -820,22 +819,22 @@ int main(int argc,char **argv) { switch(mdrun.lattice) { case FCC: create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1, - mdrun.m1,0,0,mdrun.lx, + mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, mdrun.ly,mdrun.lz,NULL); break; case DIAMOND: create_lattice(&moldyn,DIAMOND,mdrun.lc,mdrun.element1, - mdrun.m1,0,0,mdrun.lx, + mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, mdrun.ly,mdrun.lz,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,0,0,mdrun.lx, + mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx, mdrun.ly,mdrun.lz,&o); o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x; create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2, - mdrun.m2,0,1,mdrun.lx, + mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx, mdrun.ly,mdrun.lz,&o); break; default: diff --git a/moldyn.c b/moldyn.c index 6fa9df2..82ae543 100644 --- a/moldyn.c +++ b/moldyn.c @@ -574,6 +574,7 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, t_3dvec orig; void *ptr; t_atom *atom; + char name[16]; new=a*b*c; count=moldyn->count; @@ -608,18 +609,21 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, case CUBIC: set_nn_dist(moldyn,lc); ret=cubic_init(a,b,c,lc,atom,&orig); + strcpy(name,"cubic"); break; case FCC: if(!origin) v3_scale(&orig,&orig,0.5); set_nn_dist(moldyn,0.5*sqrt(2.0)*lc); ret=fcc_init(a,b,c,lc,atom,&orig); + strcpy(name,"fcc"); break; case DIAMOND: if(!origin) v3_scale(&orig,&orig,0.25); set_nn_dist(moldyn,0.25*sqrt(3.0)*lc); ret=diamond_init(a,b,c,lc,atom,&orig); + strcpy(name,"diamond"); break; default: printf("unknown lattice type (%02x)\n",type); @@ -636,7 +640,7 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, } moldyn->count+=new; - printf("[moldyn] created lattice with %d atoms\n",new); + printf("[moldyn] created %s lattice with %d atoms\n",name,new); for(ret=0;retatom; /* initialize linked cell method */ -printf(" hier soll es sein\n"); link_cell_init(moldyn,VERBOSE); /* logging & visualization */ @@ -1704,7 +1707,11 @@ printf(" hier soll es sein\n"); temperature_calc(moldyn); virial_sum(moldyn); pressure_calc(moldyn); - //thermodynamic_pressure_calc(moldyn); + /* + thermodynamic_pressure_calc(moldyn); + printf("\n\nDEBUG: numeric pressure calc: %f\n\n", + moldyn->tp/BAR); + */ /* calculate fluctuations + averages */ average_and_fluctuation_calc(moldyn); @@ -2415,11 +2422,6 @@ int process_2b_bonds(t_moldyn *moldyn,void *data, t_list *this; lc=&(moldyn->lc); - - /* only init link cell if it doesn't exist! */ - HIER WEITER - link_cell_init(moldyn,VERBOSE); - itom=moldyn->atom; for(i=0;icount;i++) { diff --git a/moldyn.h b/moldyn.h index 9d49dfa..0f37a35 100644 --- a/moldyn.h +++ b/moldyn.h @@ -56,6 +56,8 @@ typedef struct s_atom { #define ATOM_ATTR_2BP 0x20 /* pair potential */ #define ATOM_ATTR_3BP 0x40 /* 3 body potential */ +#define DEFAULT_ATOM_ATTR 0x74 // 1,2,3 body interaction + visualize + /* cell lists */ typedef struct s_linkcell { int nx,ny,nz; /* amount of cells in x, y and z direction */ diff --git a/pair_correlation_calc.c b/pair_correlation_calc.c index 56369f6..efe81ad 100644 --- a/pair_correlation_calc.c +++ b/pair_correlation_calc.c @@ -64,6 +64,9 @@ int main(int argc,char **argv) { return -1; } + /* link cell init */ + link_cell_init(&moldyn,VERBOSE); + calculate_pair_correlation(&moldyn,dr,stat); fd=open("pair_corr_func.txt", diff --git a/runmd b/runmd new file mode 100755 index 0000000..c09780c --- /dev/null +++ b/runmd @@ -0,0 +1,37 @@ +if [ -z "$1" ]; then + echo "specify a directory for logging and save files" + exit +fi + +if [ ! -f ./config ]; then + echo "no config file found" + exit +fi + +[ ! -d $1 ] && mkdir $1 + +./clean $1 + +./mdrun -c ./config -s $1 + +if [ "$?" == "0" ]; then + #./perms + if [ "$1" ] ; then + # whole simulation cell + #./visualize -w 640 -h 480 -d $1 + + # center unit cell + ./visualize -w 640 -h 480 -d $1 \ + -nll -0.56 -0.56 -0.56 -fur 0.56 0.56 0.56 \ + -b -0.5 -0.5 -0.5 0.5 0.5 0.5 \ + -c -0.2 -2.0 0.6 -L 0 0 -0.1 \ + -r 0.6 -B 0.1 + + # old rasmol + #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1 + ./ppm2avi $1 + + # copy config + cp -v config $1/config + fi +fi diff --git a/runmd_rx200 b/runmd_rx200 new file mode 100755 index 0000000..1bf24f8 --- /dev/null +++ b/runmd_rx200 @@ -0,0 +1,44 @@ +if [ -z "$1" ]; then + exit +fi + +if [ ! -f ./config ]; then + exit +fi + +[ ! -d $1 ] && mkdir $1 +./clean $1 + +# create run file +rf=`basename $1` +cat > run_$rf <<-EOF +#!/bin/bash +#$ -cwd + +./mdrun -c ./config -s $1 + +EOF + +# submit job +qsub run_$rf + +if [ "$?" == "0" ]; then + #./perms + if [ "$1" ] ; then + # whole simulation cell + #./visualize -w 640 -h 480 -d $1 + + # center unit cell + #./visualize -w 640 -h 480 -d $1 \ + # -nll -2.4 -2.4 -2.4 -fur 3.8 3.8 3.8 \ + # -b -2.03 -2.03 -2.03 3.39 3.39 3.39 \ + # -r 0.6 -c 0.5 -11.0 2.5 -B 0.1 + + # old rasmol + #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1 + #./ppm2avi $1 + + # copy config and main prog + cp -v config $1/config + fi +fi -- 2.20.1 From 1bcee27b60522025d3f43ad02347c413f6030698 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 17:24:19 +0200 Subject: [PATCH 04/16] avgrst fix + introduced px,py,pz into moldyn (for future use) --- mdrun.c | 4 ++-- moldyn.h | 1 + runmd | 5 ++--- runmd_rx200 | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mdrun.c b/mdrun.c index 8c5cf71..31abd1c 100644 --- a/mdrun.c +++ b/mdrun.c @@ -630,9 +630,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; diff --git a/moldyn.h b/moldyn.h index 0f37a35..cd7c5d0 100644 --- a/moldyn.h +++ b/moldyn.h @@ -145,6 +145,7 @@ typedef struct s_moldyn { double p_ref; /* reference pressure */ double p; /* actual pressure (computed by virial) */ + double px,py,pz; /* components of pressure */ double p_sum; /* sum over all p */ double p_avg; /* average value of p */ diff --git a/runmd b/runmd index c09780c..5db09fd 100755 --- a/runmd +++ b/runmd @@ -12,6 +12,8 @@ fi ./clean $1 +cp -v config $1/config + ./mdrun -c ./config -s $1 if [ "$?" == "0" ]; then @@ -30,8 +32,5 @@ if [ "$?" == "0" ]; then # old rasmol #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1 ./ppm2avi $1 - - # copy config - cp -v config $1/config fi fi diff --git a/runmd_rx200 b/runmd_rx200 index 1bf24f8..9368141 100755 --- a/runmd_rx200 +++ b/runmd_rx200 @@ -7,8 +7,11 @@ if [ ! -f ./config ]; then fi [ ! -d $1 ] && mkdir $1 + ./clean $1 +cp -v config $1/config + # create run file rf=`basename $1` cat > run_$rf <<-EOF @@ -37,8 +40,5 @@ if [ "$?" == "0" ]; then # old rasmol #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1 #./ppm2avi $1 - - # copy config and main prog - cp -v config $1/config fi fi -- 2.20.1 From fc49c3d16b8d8e3b0dc9b502dd72612c30f5ec57 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 18:08:33 +0200 Subject: [PATCH 05/16] more verbose insertion + d2 fix --- config.default | 6 +++--- mdrun.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.default b/config.default index 74e4997..ecc87fc 100644 --- a/config.default +++ b/config.default @@ -20,7 +20,7 @@ pbc 1 1 1 ## temperature / pressure ## -temperature 0.0 +temperature 723 pressure 0.0 ## initial lattice ## @@ -46,8 +46,8 @@ sattr pctrl 100.0 tctrl 100.0 prelax 1.0 trelax 1.0 rsteps 100 avgrst 1 ## more stages ## -stage ins_atoms 10 1 14 0 vh123 rand -5.5 -5.5 -5.5 5.5 5.5 5.5 -stage ins_atoms 1 1 6 1 vh123 rand 0 0 0 5.429 5.429 5.429 +stage ins_atoms 10 1 14 0 vh123 rand -5.5 -5.5 -5.5 5.5 5.5 5.5 1.5 +stage ins_atoms 1 1 6 1 vh123 rand -2.715 -2.715 -2.715 2.715 2.715 2.715 1.5 stage continue 10000 #stage anneal 723 -1.0 diff --git a/mdrun.c b/mdrun.c index 31abd1c..eff1ee5 100644 --- a/mdrun.c +++ b/mdrun.c @@ -402,8 +402,10 @@ int mdrun_parse_config(t_mdrun *mdrun) { } } // only rand mode by now - if(word[8][0]=='t') + if(word[8][0]=='t') { iap.type=INS_TOTAL; + iap.cr=atof(word[9]); + } else { iap.type=INS_REGION; iap.x0=atof(word[8]); @@ -412,6 +414,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { iap.x1=atof(word[11]); iap.y1=atof(word[12]); iap.z1=atof(word[13]); + iap.cr=atof(word[14]); } add_stage(mdrun,STAGE_INSERT_ATOMS,&iap); } @@ -550,8 +553,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; } -- 2.20.1 From fcff5c32dd93b974117e82c6d3c92087f6a099dd Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 20:55:34 +0200 Subject: [PATCH 06/16] stupid unit mistake prelax dp --- mdrun.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mdrun.c b/mdrun.c index eff1ee5..d875822 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)) { @@ -451,8 +451,10 @@ int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) { double delta; - if(!(mdrun->sattr&SATTR_PRELAX)) + if(!(mdrun->sattr&SATTR_PRELAX)) { +printf("##### gleich raus!\n"); return TRUE; + } delta=moldyn->p_avg-moldyn->p_ref; @@ -462,6 +464,7 @@ int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) { if(delta>mdrun->dp) return FALSE; +printf("##### nach check raus (%f/%f)!\n",delta,mdrun->dp); return TRUE; } @@ -682,8 +685,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"); -- 2.20.1 From b2bc9ad0715e541e4a110894ea9c1ff721407ece Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 30 Apr 2008 11:37:26 +0200 Subject: [PATCH 07/16] deleted printfs --- mdrun.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mdrun.c b/mdrun.c index d875822..e5feda3 100644 --- a/mdrun.c +++ b/mdrun.c @@ -452,7 +452,6 @@ int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) { double delta; if(!(mdrun->sattr&SATTR_PRELAX)) { -printf("##### gleich raus!\n"); return TRUE; } @@ -464,7 +463,6 @@ printf("##### gleich raus!\n"); if(delta>mdrun->dp) return FALSE; -printf("##### nach check raus (%f/%f)!\n",delta,mdrun->dp); return TRUE; } -- 2.20.1 From d7382ea10cd0fc49a5b8b5e3f2b48f5c1c8a2392 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 30 Apr 2008 11:41:47 +0200 Subject: [PATCH 08/16] added pse file --- pse.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pse.h diff --git a/pse.h b/pse.h new file mode 100644 index 0000000..d9aff12 --- /dev/null +++ b/pse.h @@ -0,0 +1,53 @@ +/* + * pse.h - elemnts specific stuff + * + * author: Frank Zirkelbach + * + */ + +#include "moldyn.h" + +static double pse_mass[]={ + 0, + 0, + 0, + 0, + 0, + 0, + M_C, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + M_SI, + 0, + 0, + 0, + 0, +}; + +static double pse_lc[]={ + 0, + 0, + 0, + 0, + 0, + 0, + LC_C, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + LC_SI, + 0, + 0, + 0, + 0, +}; + -- 2.20.1 From d1ceb8d3fc8e7a2e067f7576b3e787928d556277 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 3 May 2008 16:08:14 +0200 Subject: [PATCH 09/16] added position insertion method + fixed positioning --- mdrun.c | 97 +++++++++++++++++++++++++++++++++++++++++++-------------- mdrun.h | 1 + 2 files changed, 75 insertions(+), 23 deletions(-) diff --git a/mdrun.c b/mdrun.c index e5feda3..b2e67f3 100644 --- a/mdrun.c +++ b/mdrun.c @@ -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;ilattice) { + 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: @@ -522,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); @@ -532,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! @@ -719,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: diff --git a/mdrun.h b/mdrun.h index 83a8196..fa16906 100644 --- a/mdrun.h +++ b/mdrun.h @@ -116,6 +116,7 @@ typedef struct s_insert_atoms_params { #define INS_TOTAL 0x01 #define INS_REGION 0x02 +#define INS_POS 0x03 typedef struct s_continue_params { int runs; -- 2.20.1 From 4f7a62883e5e47be44856c9767c9255c1d68190d Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 5 May 2008 08:53:26 +0200 Subject: [PATCH 10/16] tool to search for bonds --- Makefile | 4 +- search_bonds.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 search_bonds.c diff --git a/Makefile b/Makefile index fbe3f59..62a137e 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ DEPS += potentials/lennard_jones.o potentials/harmonic_oscillator.o DEPS += potentials/tersoff.o potentials/albe.o ALL = mdrun sic fluctuation_calc postproc pair_correlation_calc diffusion_calc -ALL += bond_analyze +ALL += bond_analyze search_bonds all: $(ALL) @@ -39,6 +39,8 @@ diffusion_calc: $(DEPS) bond_analyze: $(DEPS) +search_bonds: $(DEPS) + .PHONY:clean clean: rm -vf $(ALL) *.o */*.o diff --git a/search_bonds.c b/search_bonds.c new file mode 100644 index 0000000..d3c1199 --- /dev/null +++ b/search_bonds.c @@ -0,0 +1,127 @@ +/* + * code searching for special types of bonds + * + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#define _GNU_SOURCE +#include +//#include +//#include +//#include +//#include +//#include +//#include + +#include "moldyn.h" +#include "potentials/albe.h" + +int usage(char *prog) { + + printf("\nusage:\n"); + printf(" %s <+->\n",prog); + printf(" type: a - 0-0 bond\n"); + printf(" type: b - 1-1 bond\n"); + printf(" type: c - 0-1 / 1-0 bond\n\n"); + + return -1; +} + +int main(int argc,char **argv) { + + t_moldyn moldyn; + t_atom *itom,*jtom; + int i,j; + int ret; + t_list n[27]; + t_list *this; + t_linkcell *lc; + t_3dvec dist; + double d,bondlen,bondpm; + + if(argc!=5) { + usage(argv[0]); + return -1; + } + + bondlen=atof(argv[3]); + bondpm=atof(argv[4]); + + memset(&moldyn,0,sizeof(t_moldyn)); + + printf("[search bonds] reading save file ...\n"); + ret=moldyn_read_save_file(&moldyn,argv[1]); + if(ret) { + printf("[search bonds] exit!\n"); + return ret; + } + + /* link cell init */ + moldyn.cutoff=bondlen+bondpm; + link_cell_init(&moldyn,VERBOSE); + lc=&(moldyn.lc); + + /* analyzing ... */ + for(i=0;ir.x+moldyn.dim.x/2)/lc->x, + (itom->r.y+moldyn.dim.y/2)/lc->y, + (itom->r.z+moldyn.dim.z/2)/lc->z, + n); + for(j=0;j<27;j++) { + this=&(n[j]); + list_reset_f(this); + + if(this->start==NULL) + continue; + + do { + + jtom=this->current->data; + + if(jtombrand!=0) + continue; + if(jtom->brand!=0) + continue; + break; + case 'b': + if(itom->brand!=1) + continue; + if(jtom->brand!=1) + continue; + break; + default: + if(itom->brand==jtom->brand) + continue; + break; + } + + v3_sub(&dist,&(itom->r),&(jtom->r)); + check_per_bound(&moldyn,&dist); + d=v3_norm(&dist); + + if((d<=bondlen+bondpm)&(d>=bondlen-bondpm)) { + + printf(" # atoms %d/%d %d/%d - %f\n", + itom->tag,itom->brand, + jtom->tag,jtom->brand,d); + + } + + } while(list_next_f(this)!=L_NO_NEXT_ELEMENT); + } + } + + link_cell_shutdown(&moldyn); + + moldyn_free_save_file(&moldyn); + + return 0; +} -- 2.20.1 From a58211f24f237b51e708b9e8b9fd463a709754a6 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 5 May 2008 10:07:01 +0200 Subject: [PATCH 11/16] search bonds using infrastructure now, new visual atoms tool --- Makefile | 4 +- mdrun.h | 3 -- moldyn.c | 95 -------------------------------------- moldyn.h | 6 +++ pse.h | 44 ++++++++++++++++++ search_bonds.c | 122 ++++++++++++++++++++++--------------------------- visual_atoms.c | 113 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 221 insertions(+), 166 deletions(-) create mode 100644 visual_atoms.c diff --git a/Makefile b/Makefile index 62a137e..36c411e 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ DEPS += potentials/lennard_jones.o potentials/harmonic_oscillator.o DEPS += potentials/tersoff.o potentials/albe.o ALL = mdrun sic fluctuation_calc postproc pair_correlation_calc diffusion_calc -ALL += bond_analyze search_bonds +ALL += bond_analyze search_bonds visual_atoms all: $(ALL) @@ -41,6 +41,8 @@ bond_analyze: $(DEPS) search_bonds: $(DEPS) +visual_atoms: $(DEPS) + .PHONY:clean clean: rm -vf $(ALL) *.o */*.o diff --git a/mdrun.h b/mdrun.h index fa16906..ad5c0c2 100644 --- a/mdrun.h +++ b/mdrun.h @@ -18,9 +18,6 @@ /* main molecular dynamics api */ #include "moldyn.h" -/* elements */ -#include "pse.h" - /* list api */ #include "list/list.h" diff --git a/moldyn.c b/moldyn.c index 82ae543..4330396 100644 --- a/moldyn.c +++ b/moldyn.c @@ -30,101 +30,6 @@ #include "potentials/tersoff.h" #endif - -/* - * global variables, pse and atom colors (only needed here) - */ - -static char *pse_name[]={ - "*", - "H", - "He", - "Li", - "Be", - "B", - "C", - "N", - "O", - "F", - "Ne", - "Na", - "Mg", - "Al", - "Si", - "P", - "S", - "Cl", - "Ar", -}; - -static char *pse_col[]={ - "*", - "White", - "He", - "Li", - "Be", - "B", - "Gray", - "N", - "Blue", - "F", - "Ne", - "Na", - "Mg", - "Al", - "Yellow", - "P", - "S", - "Cl", - "Ar", -}; - -/* -static double pse_mass[]={ - 0, - 0, - 0, - 0, - 0, - 0, - M_C, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - M_SI, - 0, - 0, - 0, - 0, -}; - -static double pse_lc[]={ - 0, - 0, - 0, - 0, - 0, - 0, - LC_C, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - LC_SI, - 0, - 0, - 0, - 0, -}; -*/ - /* * the moldyn functions */ diff --git a/moldyn.h b/moldyn.h index cd7c5d0..ca40103 100644 --- a/moldyn.h +++ b/moldyn.h @@ -353,6 +353,12 @@ typedef struct s_vb { #define DIAMOND 0x04 #define ZINCBLENDE 0x08 +/* + * more includes + */ + +#include "pse.h" + /* * * function prototypes diff --git a/pse.h b/pse.h index d9aff12..3391d26 100644 --- a/pse.h +++ b/pse.h @@ -51,3 +51,47 @@ static double pse_lc[]={ 0, }; +static char *pse_name[]={ + "*", + "H", + "He", + "Li", + "Be", + "B", + "C", + "N", + "O", + "F", + "Ne", + "Na", + "Mg", + "Al", + "Si", + "P", + "S", + "Cl", + "Ar", +}; + +static char *pse_col[]={ + "*", + "White", + "He", + "Li", + "Be", + "B", + "Gray", + "N", + "Blue", + "F", + "Ne", + "Na", + "Mg", + "Al", + "Yellow", + "P", + "S", + "Cl", + "Ar", +}; + diff --git a/search_bonds.c b/search_bonds.c index d3c1199..8291109 100644 --- a/search_bonds.c +++ b/search_bonds.c @@ -17,6 +17,11 @@ #include "moldyn.h" #include "potentials/albe.h" +typedef struct s_data { + double pm,len; + u8 type; +} t_data; + int usage(char *prog) { printf("\nusage:\n"); @@ -28,25 +33,63 @@ int usage(char *prog) { return -1; } +int process(t_moldyn *moldyn,t_atom *ai,t_atom *aj,void *ptr,u8 bc) { + + t_3dvec dist; + double d; + t_data *data; + + data=ptr; + + if(ajtype) { + case 'a': + if(ai->brand!=0) + return 0; + if(aj->brand!=0) + return 0; + + break; + case 'b': + if(ai->brand!=1) + return 0; + if(aj->brand!=1) + return 0; + break; + default: + if(ai->brand==aj->brand) + return 0; + break; + } + + v3_sub(&dist,&(ai->r),&(aj->r)); + check_per_bound(moldyn,&dist); + d=v3_norm(&dist); + + if((d<=data->len+data->pm)&(d>=data->len-data->pm)) + printf(" # atoms %d/%d %d/%d - %f\n", + ai->tag,ai->brand, + aj->tag,aj->brand,d); + + return 0; +} + int main(int argc,char **argv) { t_moldyn moldyn; - t_atom *itom,*jtom; - int i,j; int ret; - t_list n[27]; - t_list *this; - t_linkcell *lc; - t_3dvec dist; - double d,bondlen,bondpm; + t_data data; if(argc!=5) { usage(argv[0]); return -1; } - bondlen=atof(argv[3]); - bondpm=atof(argv[4]); + data.type=argv[2][0]; + data.len=atof(argv[3]); + data.pm=atof(argv[4]); memset(&moldyn,0,sizeof(t_moldyn)); @@ -58,67 +101,12 @@ int main(int argc,char **argv) { } /* link cell init */ - moldyn.cutoff=bondlen+bondpm; + moldyn.cutoff=data.len+data.pm; link_cell_init(&moldyn,VERBOSE); - lc=&(moldyn.lc); - /* analyzing ... */ - for(i=0;ir.x+moldyn.dim.x/2)/lc->x, - (itom->r.y+moldyn.dim.y/2)/lc->y, - (itom->r.z+moldyn.dim.z/2)/lc->z, - n); - for(j=0;j<27;j++) { - this=&(n[j]); - list_reset_f(this); - - if(this->start==NULL) - continue; - - do { - - jtom=this->current->data; - - if(jtombrand!=0) - continue; - if(jtom->brand!=0) - continue; - break; - case 'b': - if(itom->brand!=1) - continue; - if(jtom->brand!=1) - continue; - break; - default: - if(itom->brand==jtom->brand) - continue; - break; - } - - v3_sub(&dist,&(itom->r),&(jtom->r)); - check_per_bound(&moldyn,&dist); - d=v3_norm(&dist); - - if((d<=bondlen+bondpm)&(d>=bondlen-bondpm)) { - - printf(" # atoms %d/%d %d/%d - %f\n", - itom->tag,itom->brand, - jtom->tag,jtom->brand,d); - - } - - } while(list_next_f(this)!=L_NO_NEXT_ELEMENT); - } - } + process_2b_bonds(&moldyn,&data,process); + /* analyzing ... */ link_cell_shutdown(&moldyn); moldyn_free_save_file(&moldyn); diff --git a/visual_atoms.c b/visual_atoms.c new file mode 100644 index 0000000..9baa487 --- /dev/null +++ b/visual_atoms.c @@ -0,0 +1,113 @@ +/* + * code visualize atoms + * + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#define _GNU_SOURCE +#include +//#include +//#include +//#include +//#include +//#include +//#include + +#include "moldyn.h" + +int usage(char *prog) { + + printf("\nusage:\n"); + printf(" %s [marked atom]\n\n",prog); + + return -1; +} + +int main(int argc,char **argv) { + + t_moldyn moldyn; + t_atom *itom,*jtom; + int j; + int ret; + t_list n[27]; + t_list *this; + t_linkcell *lc; + t_3dvec dist; + double d,radius; + int ma,ca; + + if(argc<4) { + usage(argv[0]); + return -1; + } + + ca=atoi(argv[2]); + radius=atof(argv[3]); + + ma=-1; + if(argc==5) + ma=atoi(argv[4]); + + memset(&moldyn,0,sizeof(t_moldyn)); + + printf("[visual atoms] reading save file ...\n"); + ret=moldyn_read_save_file(&moldyn,argv[1]); + if(ret) { + printf("[visual atoms] exit!\n"); + return ret; + } + + /* link cell init */ + moldyn.cutoff=radius; + link_cell_init(&moldyn,VERBOSE); + lc=&(moldyn.lc); + + /* serach atoms */ + itom=&(moldyn.atom[ca]); + link_cell_neighbour_index(&moldyn, + (itom->r.x+moldyn.dim.x/2)/lc->x, + (itom->r.y+moldyn.dim.y/2)/lc->y, + (itom->r.z+moldyn.dim.z/2)/lc->z, + n); + + + printf("%s %f %f %f %s %f\n", + pse_name[itom->element],itom->r.x,itom->r.y,itom->r.z, + "Green",itom->ekin); + + for(j=0;j<27;j++) { + this=&(n[j]); + list_reset_f(this); + + if(this->start==NULL) + continue; + + do { + + jtom=this->current->data; + + if(jtom==itom) + continue; + + v3_sub(&dist,&(itom->r),&(jtom->r)); + check_per_bound(&moldyn,&dist); + d=v3_norm(&dist); + + if(d<=radius) { + printf("%s %f %f %f %s %f\n", + pse_name[jtom->element], + jtom->r.x,jtom->r.y,jtom->r.z, + (jtom->tag==ma)?"Red":pse_col[jtom->element], + jtom->ekin); + } + + } while(list_next_f(this)!=L_NO_NEXT_ELEMENT); + } + + link_cell_shutdown(&moldyn); + + moldyn_free_save_file(&moldyn); + + return 0; +} -- 2.20.1 From 506ec06909fab3aa57b6f75712aada8755f464e5 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 5 May 2008 10:36:13 +0200 Subject: [PATCH 12/16] centre atoms for visualization --- visual_atoms.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/visual_atoms.c b/visual_atoms.c index 9baa487..50507db 100644 --- a/visual_atoms.c +++ b/visual_atoms.c @@ -19,7 +19,8 @@ int usage(char *prog) { printf("\nusage:\n"); - printf(" %s [marked atom]\n\n",prog); + printf(" %s [marked atom]\n\n", + prog); return -1; } @@ -35,7 +36,9 @@ int main(int argc,char **argv) { t_linkcell *lc; t_3dvec dist; double d,radius; + double ox,oy,oz; int ma,ca; + double lac; if(argc<4) { usage(argv[0]); @@ -44,10 +47,11 @@ int main(int argc,char **argv) { ca=atoi(argv[2]); radius=atof(argv[3]); + lac=atof(argv[4]); ma=-1; - if(argc==5) - ma=atoi(argv[4]); + if(argc==6) + ma=atoi(argv[5]); memset(&moldyn,0,sizeof(t_moldyn)); @@ -71,9 +75,41 @@ int main(int argc,char **argv) { (itom->r.z+moldyn.dim.z/2)/lc->z, n); - + + /* prepare offset */ + ox=0.0; + if(itom->r.x<0) { + while((itom->r.x+ox)<(-lac/2.0)) + ox+=lac; + } + else { + while((itom->r.x+ox)>(lac/2.0)) + ox-=lac; + } + + oy=0.0; + if(itom->r.y<0) { + while((itom->r.y+oy)<(-lac/2.0)) + oy+=lac; + } + else { + while((itom->r.y+oy)>(lac/2.0)) + oy-=lac; + } + + oz=0.0; + if(itom->r.z<0) { + while((itom->r.z+oz)<(-lac/2.0)) + oz+=lac; + } + else { + while((itom->r.z+oz)>(lac/2.0)) + oz-=lac; + } + + printf("%s %f %f %f %s %f\n", - pse_name[itom->element],itom->r.x,itom->r.y,itom->r.z, + pse_name[itom->element],itom->r.x+ox,itom->r.y+oy,itom->r.z+oz, "Green",itom->ekin); for(j=0;j<27;j++) { @@ -97,7 +133,7 @@ int main(int argc,char **argv) { if(d<=radius) { printf("%s %f %f %f %s %f\n", pse_name[jtom->element], - jtom->r.x,jtom->r.y,jtom->r.z, + jtom->r.x+ox,jtom->r.y+oy,jtom->r.z+oz, (jtom->tag==ma)?"Red":pse_col[jtom->element], jtom->ekin); } -- 2.20.1 From aeadf270bb692bdaa044e8e71cefd707825b44c0 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 7 May 2008 20:50:39 +0200 Subject: [PATCH 13/16] 1-6 --- pair_corr_calc_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pair_corr_calc_script b/pair_corr_calc_script index b005960..67ba32c 100755 --- a/pair_corr_calc_script +++ b/pair_corr_calc_script @@ -48,7 +48,7 @@ set terminal postscript eps enhanced color solid lw 1 'Helvetica' 14 set output '$pdir/pair_corr.eps' EOF -echo -en "plot [1.5:6.0] " >> $pfile +echo -en "plot [1.0:6.0] " >> $pfile komma=0 -- 2.20.1 From 9b7ed8daf887bef7ec61abd021931d2e92226e6a Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 7 May 2008 22:18:49 +0200 Subject: [PATCH 14/16] remeber file .. wichtig --- remember_me.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 remember_me.txt diff --git a/remember_me.txt b/remember_me.txt new file mode 100644 index 0000000..80498f8 --- /dev/null +++ b/remember_me.txt @@ -0,0 +1,13 @@ +pair correlation +################ + +si-si +----- + +2.96: saves/c_in_si_prec_450_01/s-0004000.save 67101 8.0 5.429 186262 + +c-c +--- + +3.1: saves/c_in_si_prec_450_01/s-0566000.save 239458 240660 110 - 100 + 239703 241605 110 - 110 -- 2.20.1 From b1c3e2366702a37786ed057c7b56929258890950 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 9 May 2008 09:31:49 +0200 Subject: [PATCH 15/16] added display atom data tool --- Makefile | 4 ++- display_atom_data.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 display_atom_data.c diff --git a/Makefile b/Makefile index 36c411e..47670a8 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ DEPS += potentials/lennard_jones.o potentials/harmonic_oscillator.o DEPS += potentials/tersoff.o potentials/albe.o ALL = mdrun sic fluctuation_calc postproc pair_correlation_calc diffusion_calc -ALL += bond_analyze search_bonds visual_atoms +ALL += bond_analyze search_bonds visual_atoms display_atom_data all: $(ALL) @@ -43,6 +43,8 @@ search_bonds: $(DEPS) visual_atoms: $(DEPS) +display_atom_data: $(DEPS) + .PHONY:clean clean: rm -vf $(ALL) *.o */*.o diff --git a/display_atom_data.c b/display_atom_data.c new file mode 100644 index 0000000..0872366 --- /dev/null +++ b/display_atom_data.c @@ -0,0 +1,80 @@ +/* + * code to display atom data + * + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#define _GNU_SOURCE +#include +//#include +//#include +//#include +//#include +//#include +//#include + +#include "moldyn.h" +#include "potentials/albe.h" + +int usage(char *prog) { + + printf("\nusage:\n"); + printf(" %s ... \n\n",prog); + + return -1; +} + +int main(int argc,char **argv) { + + t_moldyn moldyn; + int ret; + int i; + int nr; + t_atom *atom; + double off; + double lc; + + if(argc<2) { + usage(argv[0]); + return -1; + } + + memset(&moldyn,0,sizeof(t_moldyn)); + + printf("[search bonds] reading save file ...\n"); + ret=moldyn_read_save_file(&moldyn,argv[1]); + if(ret) { + printf("[search bonds] exit!\n"); + return ret; + } + + /* todo: guessing offset/lc */ + lc=ALBE_LC_SI; + off=0.125*lc-0.5*lc; + + for(i=2;ir.x,atom->r_0.x,atom->r.x-off,atom->r_0.x-off, + atom->r.x-atom->r_0.x,(atom->r.x-off)/lc); + printf(" y: %f %f | %f %f | %f | %f\n", + atom->r.y,atom->r_0.y,atom->r.y-off,atom->r_0.y-off, + atom->r.y-atom->r_0.y,(atom->r.y-off)/lc); + printf(" z: %f %f | %f %f | %f | %f\n", + atom->r.z,atom->r_0.z,atom->r.z-off,atom->r_0.z-off, + atom->r.z-atom->r_0.z,(atom->r.z-off)/lc); + + } + + moldyn_free_save_file(&moldyn); + + return 0; +} -- 2.20.1 From 7cc8f9c36d213de44dd64aed29d0e76a3a0b580d Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 9 May 2008 09:32:23 +0200 Subject: [PATCH 16/16] more precise print for t and p scaling --- moldyn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moldyn.c b/moldyn.c index 4330396..caafc4c 100644 --- a/moldyn.c +++ b/moldyn.c @@ -113,7 +113,7 @@ int set_p_scale(t_moldyn *moldyn,u8 ptype,double ptc) { moldyn->pt_scale|=ptype; moldyn->p_tc=ptc; - printf("[moldyn] p/t scaling:\n"); + printf("[moldyn] p scaling:\n"); printf(" p: %s",ptype?"yes":"no "); if(ptype) @@ -129,7 +129,7 @@ int set_t_scale(t_moldyn *moldyn,u8 ttype,double ttc) { moldyn->pt_scale|=ttype; moldyn->t_tc=ttc; - printf("[moldyn] p/t scaling:\n"); + printf("[moldyn] t scaling:\n"); printf(" t: %s",ttype?"yes":"no "); if(ttype) -- 2.20.1