From 3592f3b0cf641729566674a7cdfd8eff3f61f59a Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 29 Apr 2008 11:23:17 +0200 Subject: [PATCH] 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.39.2