]> hackdaworld.org Git - physik/posic.git/commitdiff
displace stage type added
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Fri, 9 May 2008 07:32:51 +0000 (09:32 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Fri, 9 May 2008 07:32:51 +0000 (09:32 +0200)
mdrun.c
mdrun.h

diff --git a/mdrun.c b/mdrun.c
index b2e67f371810946b5c4b67b82e6a03caab311dfe..bd045feb705b51a2ca0905c7a1aeb42bb19b6a3c 100644 (file)
--- a/mdrun.c
+++ b/mdrun.c
@@ -90,6 +90,9 @@ int add_stage(t_mdrun *mdrun,u8 type,void *params) {
        t_stage *stage;
 
        switch(type) {
+               case STAGE_DISPLACE_ATOM:
+                       psize=sizeof(t_displace_atom_params);
+                       break;
                case STAGE_INSERT_ATOMS:
                        psize=sizeof(t_insert_atoms_params);
                        break;
@@ -142,6 +145,7 @@ int mdrun_parse_config(t_mdrun *mdrun) {
        int wcnt;
        int i,o;
 
+       t_displace_atom_params dap;
        t_insert_atoms_params iap;
        t_continue_params cp;
        t_anneal_params ap;
@@ -368,7 +372,14 @@ int mdrun_parse_config(t_mdrun *mdrun) {
                        mdrun->visualize=atoi(word[1]);
                else if(!strncmp(word[0],"stage",5)) {
                        // for every stage line, add a stage
-                       if(!strncmp(word[1],"ins_atoms",9)) {
+                       if(!strncmp(word[1],"displace",8)) {
+                               dap.nr=atoi(word[2]);   
+                               dap.dx=atof(word[3]);
+                               dap.dy=atof(word[4]);
+                               dap.dz=atof(word[5]);
+                               add_stage(mdrun,STAGE_DISPLACE_ATOM,&dap);
+                       }
+                       else if(!strncmp(word[1],"ins_atoms",9)) {
                                iap.ins_steps=atoi(word[2]);
                                iap.ins_atoms=atoi(word[3]);
                                iap.element=atoi(word[4]);
@@ -494,6 +505,23 @@ int check_temperature(t_moldyn *moldyn,t_mdrun *mdrun) {
        return TRUE;
 }
 
+int displace_atom(t_moldyn *moldyn,t_mdrun *mdrun) {
+
+       t_displace_atom_params *dap;
+       t_stage *stage;
+       t_atom *atom;
+
+       stage=mdrun->stage.current->data;
+       dap=stage->params;
+
+       atom=&(moldyn->atom[dap->nr]);
+       atom->r.x+=dap->dx;
+       atom->r.y+=dap->dy;
+       atom->r.z+=dap->dz;
+
+       return 0;
+}
+
 int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
 
        t_insert_atoms_params *iap;
@@ -742,6 +770,11 @@ int mdrun_hook(void *ptr1,void *ptr2) {
                
                /* stage specific stuff */
                switch(stage->type) {
+                       case STAGE_DISPLACE_ATOM:
+                               stage_print("  -> displace atom\n\n");
+                               displace_atom(moldyn,mdrun);
+                               change_stage=TRUE;
+                               break;
                        case STAGE_INSERT_ATOMS:
                                stage_print("  -> insert atoms\n\n");
                                iap=stage->params;
@@ -751,7 +784,7 @@ int mdrun_hook(void *ptr1,void *ptr2) {
                                }
                                insert_atoms(moldyn,mdrun);
                                iap->cnt_steps+=1;
-                                       break;
+                               break;
                        case STAGE_CONTINUE:
                                stage_print("  -> continue\n\n");
                                if(stage->executed==TRUE) {
@@ -760,7 +793,7 @@ int mdrun_hook(void *ptr1,void *ptr2) {
                                }
                                cp=stage->params;
                                steps=cp->runs;
-                                       break;
+                               break;
                        case STAGE_ANNEAL:
                                stage_print("  -> anneal\n\n");
                                ap=stage->params;
diff --git a/mdrun.h b/mdrun.h
index ad5c0c2405144d7d8a69f3c44c204338e6a5dc90..3b2494602b59b1c32a9b1a65238cfc8a684d6c7e 100644 (file)
--- a/mdrun.h
+++ b/mdrun.h
@@ -41,6 +41,7 @@ typedef struct s_stage {
        u8 executed;
 } t_stage;
 
+#define STAGE_DISPLACE_ATOM                    0x00
 #define STAGE_INSERT_ATOMS                     0x01
 #define STAGE_CONTINUE                         0x02
 #define STAGE_ANNEAL                           0x03
@@ -99,6 +100,11 @@ typedef struct s_mdrun {
 #define SATTR_TRELAX                           0x02
 #define SATTR_AVGRST                           0x04
 
+typedef struct s_displace_atom_params {
+       int nr;
+       double dx,dy,dz;
+} t_displace_atom_params;
+
 typedef struct s_insert_atoms_params {
        u8 type;
        double x0,y0,z0,x1,y1,z1;