From: hackbard Date: Mon, 18 Aug 2008 15:02:44 +0000 (+0200) Subject: insert mixed atoms feature added (will be renamed an cleand up later) X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=67df6b3a722a44e36fd56f3f040c3c9726b3fc3f;p=physik%2Fposic.git insert mixed atoms feature added (will be renamed an cleand up later) still problematic! --- diff --git a/mdrun.c b/mdrun.c index 29d3160..31943ef 100644 --- a/mdrun.c +++ b/mdrun.c @@ -96,6 +96,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; @@ -147,6 +150,7 @@ 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; @@ -175,6 +179,7 @@ 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)); @@ -247,6 +252,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 +448,56 @@ 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.cr=atof(word[8]); + /* 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; + + c=imp->cr*imp->cr; + + 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(delement1,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\n",dmin,c); + 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(delement2,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\n",dmin,c); + imp->amount2-=1; + } + } + + return 0; +} + int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) { t_stage *stage; @@ -740,6 +895,7 @@ int mdrun_hook(void *ptr1,void *ptr2) { u8 change_stage; t_insert_atoms_params *iap; + t_insert_mixed_atoms_params *imp; t_continue_params *cp; t_anneal_params *ap; @@ -787,6 +943,17 @@ 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); + break; + + + case STAGE_CONTINUE: stage_print(" -> continue\n\n"); if(stage->executed==TRUE) { @@ -952,6 +1119,8 @@ int main(int argc,char **argv) { mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx, mdrun.ly,mdrun.lz,&o); break; + case NONE: + break; default: printf("%s unknown lattice type: %02x\n", ME,mdrun.lattice); diff --git a/mdrun.h b/mdrun.h index d065d57..b1c2e06 100644 --- a/mdrun.h +++ b/mdrun.h @@ -43,10 +43,11 @@ typedef struct s_stage { #define STAGE_DISPLACE_ATOM 0x00 #define STAGE_INSERT_ATOMS 0x01 -#define STAGE_CONTINUE 0x02 -#define STAGE_ANNEAL 0x03 -#define STAGE_CHAATTR 0x04 -#define STAGE_CHSATTR 0x05 +#define STAGE_INSERT_MIXED_ATOMS 0x02 +#define STAGE_CONTINUE 0x03 +#define STAGE_ANNEAL 0x04 +#define STAGE_CHAATTR 0x05 +#define STAGE_CHSATTR 0x06 typedef struct s_mdrun { char cfile[128]; // config file @@ -119,6 +120,18 @@ typedef struct s_insert_atoms_params { u8 attr; } t_insert_atoms_params; +typedef struct s_insert_mixed_atoms_params { + int element1; + int element2; + int amount1; + int amount2; + u8 brand1; + u8 brand2; + u8 attr1; + u8 attr2; + double cr; +} t_insert_mixed_atoms_params; + #define INS_TOTAL 0x01 #define INS_REGION 0x02 #define INS_POS 0x03 diff --git a/moldyn.c b/moldyn.c index b79dea6..eb3c4b0 100644 --- a/moldyn.c +++ b/moldyn.c @@ -485,6 +485,10 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, count=moldyn->count; /* how many atoms do we expect */ + if(type==NONE) { + new*=1; + printf("[moldyn] WARNING: create 'none' lattice called"); + } if(type==CUBIC) new*=1; if(type==FCC) new*=4; if(type==DIAMOND) new*=8; @@ -1574,9 +1578,11 @@ int moldyn_integrate(t_moldyn *moldyn) { printf("[moldyn] WARNING: cutoff > 0.5 x dim.y\n"); if(moldyn->cutoff>0.5*moldyn->dim.z) printf("[moldyn] WARNING: cutoff > 0.5 x dim.z\n"); - ds=0.5*atom[0].f.x*moldyn->tau_square/atom[0].mass; - if(ds>0.05*moldyn->nnd) + if(moldyn->count) { + ds=0.5*atom[0].f.x*moldyn->tau_square/atom[0].mass; + if(ds>0.05*moldyn->nnd) printf("[moldyn] WARNING: forces too high / tau too small!\n"); + } /* zero absolute time */ // should have right values! diff --git a/moldyn.h b/moldyn.h index ca40103..11fdf6b 100644 --- a/moldyn.h +++ b/moldyn.h @@ -352,6 +352,7 @@ typedef struct s_vb { #define FCC 0x02 #define DIAMOND 0x04 #define ZINCBLENDE 0x08 +#define NONE 0x80 /* * more includes