X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=mdrun.c;h=dd8679eb806f6af6ec433d5a646a055f71b55be5;hb=21a29b60a222f81c311d0a3b85ccafa92c8b1279;hp=1368880b7c62cde2eb66761bf726c962751f6cce;hpb=11fafa5d1eefeebd32e0996d2544adc39b16d8d1;p=physik%2Fposic.git diff --git a/mdrun.c b/mdrun.c index 1368880..dd8679e 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]" /* @@ -111,6 +116,12 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) { case STAGE_CHSATTR: psize=sizeof(t_chsattr_params); break; + case STAGE_SET_TEMP: + psize=sizeof(t_set_temp_params); + break; + case STAGE_SET_TIMESTEP: + psize=sizeof(t_set_timestep_params); + break; default: printf("%s unknown stage type: %02x\n",ME,type); return -1; @@ -155,6 +166,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { t_anneal_params ap; t_chaattr_params cap; t_chsattr_params csp; + t_set_temp_params stp; + t_set_timestep_params stsp; /* open config file */ fd=open(mdrun->cfile,O_RDONLY); @@ -184,6 +197,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { memset(&ap,0,sizeof(t_anneal_params)); memset(&cap,0,sizeof(t_chaattr_params)); memset(&csp,0,sizeof(t_chsattr_params)); + memset(&stp,0,sizeof(t_set_temp_params)); + memset(&stsp,0,sizeof(t_set_timestep_params)); // get command + args wcnt=0; @@ -507,8 +522,24 @@ 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)) { + if(word[2][0]=='c') { + stp.type=SET_TEMP_CURRENT; + stp.val=0.0; + } + else { + stp.type=SET_TEMP_VALUE; + stp.val=atof(word[2]); + } + add_stage(mdrun,STAGE_SET_TEMP,&stp); + } + else if(!strncmp(word[1],"set_timestep",12)) { + stsp.tau=atof(word[2]); + add_stage(mdrun,STAGE_SET_TIMESTEP,&stsp); + } else { printf("%s unknown stage type: %s\n", ME,word[1]); @@ -897,13 +928,14 @@ int mdrun_hook(void *ptr1,void *ptr2) { t_stage *stage; t_list *sl; int steps; - double tau; u8 change_stage; t_insert_atoms_params *iap; t_insert_mixed_atoms_params *imp; t_continue_params *cp; t_anneal_params *ap; + t_set_temp_params *stp; + t_set_timestep_params *stsp; moldyn=ptr1; mdrun=ptr2; @@ -919,9 +951,8 @@ int mdrun_hook(void *ptr1,void *ptr2) { /* get stage description */ stage=sl->current->data; - /* default steps and tau values */ + /* steps in next schedule */ steps=mdrun->relax_steps; - tau=mdrun->timestep; /* check whether relaxation steps are necessary */ if((check_pressure(moldyn,mdrun)==TRUE)&\ @@ -981,17 +1012,35 @@ 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(" -> chaattr\n\n"); + stage_print(" -> change atom attributes\n\n"); chaatr(moldyn,mdrun); change_stage=TRUE; break; case STAGE_CHSATTR: - stage_print(" -> chsattr\n\n"); + stage_print(" -> change sys attributes\n\n"); chsattr(moldyn,mdrun); change_stage=TRUE; break; + case STAGE_SET_TEMP: + stage_print(" -> set temperature\n\n"); + stp=stage->params; + if(stp->type&SET_TEMP_CURRENT) { + set_temperature(moldyn,moldyn->t_avg); + } + else { + set_temperature(moldyn,stp->val); + } + change_stage=TRUE; + break; + case STAGE_SET_TIMESTEP: + stage_print(" -> set timestep\n\n"); + stsp=stage->params; + mdrun->timestep=stsp->tau; + change_stage=TRUE; + break; default: printf("%s unknwon stage type\n",ME); break; @@ -1008,7 +1057,6 @@ int mdrun_hook(void *ptr1,void *ptr2) { return 0; } steps=0; - tau=mdrun->timestep; } } @@ -1021,7 +1069,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { } /* continue simulation */ - moldyn_add_schedule(moldyn,steps,tau); + moldyn_add_schedule(moldyn,steps,mdrun->timestep); return 0; } @@ -1127,6 +1175,7 @@ int main(int argc,char **argv) { mdrun.ly,mdrun.lz,&o); break; case NONE: + set_nn_dist(&moldyn,mdrun.nnd); break; default: printf("%s unknown lattice type: %02x\n",