X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=mdrun.c;h=dd8679eb806f6af6ec433d5a646a055f71b55be5;hb=21a29b60a222f81c311d0a3b85ccafa92c8b1279;hp=29d3160acdc9375864ff56788a293704e8c3ccee;hpb=98f5c05d17d1077aaca379e755bf36f5d8f61776;p=physik%2Fposic.git diff --git a/mdrun.c b/mdrun.c index 29d3160..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]" /* @@ -96,6 +101,9 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) { case STAGE_INSERT_ATOMS: psize=sizeof(t_insert_atoms_params); break; + case STAGE_INSERT_MIXED_ATOMS: + psize=sizeof(t_insert_mixed_atoms_params); + break; case STAGE_CONTINUE: psize=sizeof(t_continue_params); break; @@ -108,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; @@ -147,10 +161,13 @@ int mdrun_parse_config(t_mdrun *mdrun) { t_displace_atom_params dap; t_insert_atoms_params iap; + t_insert_mixed_atoms_params imp; t_continue_params cp; 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); @@ -175,10 +192,13 @@ int mdrun_parse_config(t_mdrun *mdrun) { // reset memset(&iap,0,sizeof(t_insert_atoms_params)); + memset(&imp,0,sizeof(t_insert_mixed_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)); + memset(&stp,0,sizeof(t_set_temp_params)); + memset(&stsp,0,sizeof(t_set_timestep_params)); // get command + args wcnt=0; @@ -247,6 +267,8 @@ int mdrun_parse_config(t_mdrun *mdrun) { mdrun->lattice=FCC; if(!strncmp(word[1],"diamond",7)) mdrun->lattice=DIAMOND; + if(!strncmp(word[1],"none",4)) + mdrun->lattice=NONE; } else if(!strncmp(word[0],"element1",8)) { mdrun->element1=atoi(word[1]); @@ -441,6 +463,57 @@ int mdrun_parse_config(t_mdrun *mdrun) { } add_stage(mdrun,STAGE_INSERT_ATOMS,&iap); } + + + // HERE WE GO ... + + else if(!strncmp(word[1],"ins_m_atoms",11)) { + imp.element1=atoi(word[2]); + imp.element2=atoi(word[3]); + imp.amount1=atoi(word[4]); + imp.amount2=atoi(word[5]); + imp.brand1=atoi(word[6]); + imp.brand2=atoi(word[7]); + imp.crmin=atof(word[8]); + imp.crmax=atof(word[9]); + /* do this later ... + for(i=0;istage.current->data; + imp=stage->params; + + x=moldyn->dim.x; + x0=-x/2.0; + y=moldyn->dim.y; + y0=-y/2.0; + z=moldyn->dim.z; + z0=-z/2.0; + + v.x=0.0; + v.y=0.0; + v.z=0.0; + + cmin=imp->crmin*imp->crmin; + cmax=imp->crmax*imp->crmax; + + while(imp->amount1|imp->amount2) { + if(imp->amount1) { + retry=1; + while(retry) { + retry=0; + r.x=rand_get_double(&(moldyn->random))*x; + r.y=rand_get_double(&(moldyn->random))*y; + r.z=rand_get_double(&(moldyn->random))*z; + r.x+=x0; + r.y+=y0; + r.z+=z0; + dmin=1000.0; // for sure too high! + for(i=0;icount;i++) { + atom=&(moldyn->atom[i]); + v3_sub(&dist,&(atom->r),&r); + check_per_bound(moldyn,&dist); + d=v3_absolute_square(&dist); + if(dcmax) + retry=1; + } + add_atom(moldyn,imp->element1,pse_mass[imp->element1], + imp->brand1,imp->attr1,&r,&v); + printf("%s (mixed) atom inserted (%d): %f %f %f\n", + ME,imp->amount1,r.x,r.y,r.z); + printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax); + imp->amount1-=1; + } + if(imp->amount2) { + retry=1; + while(retry) { + retry=0; + r.x=rand_get_double(&(moldyn->random))*x; + r.y=rand_get_double(&(moldyn->random))*y; + r.z=rand_get_double(&(moldyn->random))*z; + r.x+=x0; + r.y+=y0; + r.z+=z0; + dmin=1000.0; // for sure too high! + for(i=0;icount;i++) { + atom=&(moldyn->atom[i]); + v3_sub(&dist,&(atom->r),&r); + check_per_bound(moldyn,&dist); + d=v3_absolute_square(&dist); + if(dcmax) + retry=1; + } + add_atom(moldyn,imp->element2,pse_mass[imp->element2], + imp->brand2,imp->attr2,&r,&v); + printf("%s (mixed) atom inserted (%d): %f %f %f\n", + ME,imp->amount2,r.x,r.y,r.z); + printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax); + imp->amount2-=1; + } + } + + return 0; +} + int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) { t_stage *stage; @@ -736,12 +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; @@ -757,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)&\ @@ -787,6 +980,18 @@ int mdrun_hook(void *ptr1,void *ptr2) { insert_atoms(moldyn,mdrun); iap->cnt_steps+=1; break; + + + + case STAGE_INSERT_MIXED_ATOMS: + stage_print(" -> insert mixed atoms\n\n"); + imp=stage->params; + insert_mixed_atoms(moldyn,mdrun); + change_stage=TRUE; + break; + + + case STAGE_CONTINUE: stage_print(" -> continue\n\n"); if(stage->executed==TRUE) { @@ -807,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; @@ -834,7 +1057,6 @@ int mdrun_hook(void *ptr1,void *ptr2) { return 0; } steps=0; - tau=mdrun->timestep; } } @@ -847,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; } @@ -952,6 +1174,9 @@ int main(int argc,char **argv) { mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx, mdrun.ly,mdrun.lz,&o); break; + case NONE: + set_nn_dist(&moldyn,mdrun.nnd); + break; default: printf("%s unknown lattice type: %02x\n", ME,mdrun.lattice);