From: hackbard Date: Thu, 28 May 2009 19:11:10 +0000 (+0200) Subject: added modify atom function (velocity only by now!) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03dbca0a50d2f2e929c1feac3b145abf5575490b;p=physik%2Fposic.git added modify atom function (velocity only by now!) --- diff --git a/mdrun.c b/mdrun.c index f402e40..f0edd0b 100644 --- a/mdrun.c +++ b/mdrun.c @@ -96,6 +96,9 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) { case STAGE_DEL_ATOMS: psize=sizeof(t_del_atoms_params); break; + case STAGE_MODIFY_ATOMS: + psize=sizeof(t_modify_atoms_params); + break; case STAGE_INSERT_ATOMS: psize=sizeof(t_insert_atoms_params); break; @@ -164,6 +167,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { int i,o; t_displace_atom_params dap; + t_modify_atoms_params map; t_insert_atoms_params iap; t_insert_mixed_atoms_params imp; t_continue_params cp; @@ -198,6 +202,7 @@ int mdrun_parse_config(t_mdrun *mdrun) { // reset memset(&iap,0,sizeof(t_insert_atoms_params)); + memset(&map,0,sizeof(t_modify_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)); @@ -522,6 +527,22 @@ int mdrun_parse_config(t_mdrun *mdrun) { delp.r=atof(word[5]); add_stage(mdrun,STAGE_DEL_ATOMS,&delp); } + else if(!strncmp(word[1],"mod_atoms",8)) { + i=2; + while(iatom; + stage=mdrun->stage.current->data; + map=stage->params; + v.x=0.0; v.y=0.0; v.z=0.0; + + for(i=0;icount;i++) { + if(atom[i].tag==map->tag) { + v.x=sqrt(2.0*fabs(map->ekin.x)/atom[i].mass); + if(map->ekin.x<0.0) + v.x=-v.x; + v.y=sqrt(2.0*fabs(map->ekin.y)/atom[i].mass); + if(map->ekin.y<0.0) + v.y=-v.y; + v.z=sqrt(2.0*fabs(map->ekin.z)/atom[i].mass); + if(map->ekin.z<0.0) + v.z=-v.z; + v3_copy(&(atom[i].v),&v); + printf("%s atom modified: v = (%f %f %f)\n", + ME,v.x,v.y,v.z); + } + } + return 0; } int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { @@ -899,7 +952,23 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) { 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); + printf(" attributes: "); + if(iap->attr&ATOM_ATTR_VB) + printf("b "); + if(iap->attr&ATOM_ATTR_HB) + printf("h "); + if(iap->attr&ATOM_ATTR_VA) + printf("v "); + if(iap->attr&ATOM_ATTR_FP) + printf("f "); + if(iap->attr&ATOM_ATTR_1BP) + printf("1 "); + if(iap->attr&ATOM_ATTR_2BP) + printf("2 "); + if(iap->attr&ATOM_ATTR_3BP) + printf("3 "); + printf("\n"); + printf(" d2 = %f/%f\n",dmin,iap->cr*iap->cr); cnt+=1; } @@ -1151,6 +1220,11 @@ int mdrun_hook(void *ptr1,void *ptr2) { del_atoms(moldyn,mdrun); change_stage=TRUE; break; + case STAGE_MODIFY_ATOMS: + stage_print(" -> modify atoms\n\n"); + modify_atoms(moldyn,mdrun); + change_stage=TRUE; + break; case STAGE_INSERT_ATOMS: stage_print(" -> insert atoms\n\n"); iap=stage->params; diff --git a/mdrun.h b/mdrun.h index be09d5a..102d00e 100644 --- a/mdrun.h +++ b/mdrun.h @@ -53,6 +53,7 @@ typedef struct s_stage { #define STAGE_FILL 0x09 #define STAGE_THERMAL_INIT 0x10 #define STAGE_DEL_ATOMS 0x11 +#define STAGE_MODIFY_ATOMS 0x12 typedef struct s_mdrun { char cfile[128]; // config file @@ -114,6 +115,12 @@ typedef struct s_del_atoms_params { t_3dvec o; } t_del_atoms_params; +typedef struct s_modify_aoms_params { + u8 type; + int tag; + t_3dvec ekin; +} t_modify_atoms_params; + typedef struct s_insert_atoms_params { u8 type; double x0,y0,z0,x1,y1,z1; @@ -206,6 +213,7 @@ typedef struct s_fill_params { u8 fill_brand; t_part_params p_params; t_defect_params d_params; + t_offset_params o_params; } t_fill_params; /*