]> hackdaworld.org Git - physik/posic.git/commitdiff
added modify atom function (velocity only by now!)
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 28 May 2009 19:11:10 +0000 (21:11 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 28 May 2009 19:11:10 +0000 (21:11 +0200)
mdrun.c
mdrun.h

diff --git a/mdrun.c b/mdrun.c
index f402e40e1566eb198166aaa12effc443a9370310..f0edd0bac7546bed88625c1d7a3242a0a2632650 100644 (file)
--- 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(i<wcnt) {
+                                       if(!strncmp(word[i],"t",1)) {
+                                               map.tag=atoi(word[++i]);
+                                               i+=1;
+                                       }
+                                       if(!strncmp(word[i],"ekin",5)) {
+                                               map.ekin.x=atof(word[++i])*EV;
+                                               map.ekin.y=atof(word[++i])*EV;
+                                               map.ekin.z=atof(word[++i])*EV;
+                                               i+=1;
+                                       }
+                               }
+                               add_stage(mdrun,STAGE_MODIFY_ATOMS,&map);
+                       }
                        else if(!strncmp(word[1],"ins_atoms",9)) {
                                iap.ins_steps=atoi(word[2]);
                                iap.ins_atoms=atoi(word[3]);
@@ -767,7 +788,39 @@ int del_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
        }
 
        return 0;
+}
+
+int modify_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
+
+       t_modify_atoms_params *map;
+       t_stage *stage;
+       t_atom *atom;
+       t_3dvec v;
+       int i;
+
+       atom=moldyn->atom;
+       stage=mdrun->stage.current->data;
+       map=stage->params;
+       v.x=0.0; v.y=0.0; v.z=0.0;
+
+       for(i=0;i<moldyn->count;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 be09d5a80a6296bb597b513776aebb28beae07a7..102d00e73c4e3e51b433deddc39d1e464ee21826 100644 (file)
--- 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;
 
 /*