]> hackdaworld.org Git - physik/posic.git/commitdiff
implemented sphere insertion
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 8 Jan 2009 16:50:44 +0000 (17:50 +0100)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 8 Jan 2009 16:50:44 +0000 (17:50 +0100)
mdrun.c
mdrun.h

diff --git a/mdrun.c b/mdrun.c
index 07333ab99dde79c183acddc926e04b4f1b0f5863..34807e76bd76f646f5d587705d09ce0e05840614 100644 (file)
--- a/mdrun.c
+++ b/mdrun.c
@@ -550,19 +550,32 @@ int mdrun_parse_config(t_mdrun *mdrun) {
                                                iap.z0=atof(word[10]);
                                                break;
                                        case 'r':
-                                               if(word[8][0]=='t') {
+                                               switch(word[8][0]) {
+
+                                               case 't':
                                                        iap.type=INS_TOTAL;
                                                        iap.cr=atof(word[9]);
-                                               }
-                                               else {
-                                                       iap.type=INS_REGION;
-                                                       iap.x0=atof(word[8]);
-                                                       iap.y0=atof(word[9]);
-                                                       iap.z0=atof(word[10]);
-                                                       iap.x1=atof(word[11]);
-                                                       iap.y1=atof(word[12]);
-                                                       iap.z1=atof(word[13]);
-                                                       iap.cr=atof(word[14]);
+                                                       break;
+                                               case 'r':
+                                                       iap.type=INS_RECT;
+                                                       iap.x0=atof(word[9]);
+                                                       iap.y0=atof(word[10]);
+                                                       iap.z0=atof(word[11]);
+                                                       iap.x1=atof(word[12]);
+                                                       iap.y1=atof(word[13]);
+                                                       iap.z1=atof(word[14]);
+                                                       iap.cr=atof(word[15]);
+                                                       break;
+                                               case 's':
+                                                       iap.type=INS_SPHERE;
+                                                       iap.x0=atof(word[9]);
+                                                       iap.y0=atof(word[10]);
+                                                       iap.z0=atof(word[11]);
+                                                       iap.x1=atof(word[12]);
+                                                       iap.cr=atof(word[13]);
+                                                       break;
+                                               default:
+                                                       break;
                                                }
                                        default:
                                                break;
@@ -765,7 +778,7 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
                        z0=-z/2.0;
                        cr_check=TRUE;
                        break;
-               case INS_REGION:
+               case INS_RECT:
                        x=iap->x1-iap->x0;
                        x0=iap->x0;
                        y=iap->y1-iap->y0;
@@ -774,6 +787,15 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
                        z0=iap->z0;
                        cr_check=TRUE;
                        break;
+               case INS_SPHERE:
+                       x=2.0*iap->x1;
+                       x0=iap->x0-iap->x1;
+                       y=x;
+                       y0=iap->y0-iap->x1;
+                       z=x;
+                       z0=iap->z0-iap->x1;
+                       cr_check=TRUE;
+                       break;
                case INS_POS:
                        x0=iap->x0;
                        y0=iap->y0;
@@ -825,6 +847,14 @@ int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
                                                dmin=d;
                                }
                        }
+                       if(iap->type==INS_SPHERE) {
+                               if((r.x-iap->x0)*(r.x-iap->x0)+
+                                  (r.y-iap->y0)*(r.y-iap->y0)+
+                                  (r.z-iap->z0)*(r.z-iap->z0)>
+                                  (iap->x1*iap->x1)) {
+                                       run=1;
+                               }
+                       }
                }
                add_atom(moldyn,iap->element,
                         iap->brand,iap->attr,&r,&v);
diff --git a/mdrun.h b/mdrun.h
index fad1f62952d8a188327e7a6869eb19a82dc5add2..3f2c6ecb0665794304cf89009f95e26d2a3ea0aa 100644 (file)
--- a/mdrun.h
+++ b/mdrun.h
@@ -134,8 +134,9 @@ typedef struct s_insert_mixed_atoms_params {
 } t_insert_mixed_atoms_params;
 
 #define INS_TOTAL                              0x01
-#define INS_REGION                             0x02
-#define INS_POS                                        0x03
+#define INS_RECT                               0x02
+#define INS_SPHERE                             0x03
+#define INS_POS                                        0x04
 
 typedef struct s_continue_params {
        int runs;