From 55d034d62eaf9974c43436757d364ae7ec98d1a6 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 9 May 2008 09:32:51 +0200 Subject: [PATCH] displace stage type added --- mdrun.c | 39 ++++++++++++++++++++++++++++++++++++--- mdrun.h | 6 ++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/mdrun.c b/mdrun.c index b2e67f3..bd045fe 100644 --- 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 ad5c0c2..3b24946 100644 --- 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; -- 2.39.2