+/* potential */
+#include "potentials/harmonic_oscillator.h"
+#include "potentials/lennard_jones.h"
+#include "potentials/albe.h"
+#ifdef TERSOFF_ORIG
+#include "potentials/tersoff_orig.h"
+#else
+#include "potentials/tersoff.h"
+#endif
+
+typedef struct s_hp {
+ int prerun_count; /* prerun count */
+ int insert_count; /* insert count */
+ int postrun_count; /* post run count */
+ unsigned char state; /* current state */
+ int argc; /* arg count */
+ char **argv; /* args */
+} t_hp;
+
+#define STATE_PRERUN 0x00
+#define STATE_INSERT 0x01
+#define STATE_POSTRUN 0x02
+
+/* include the config file */
+#include "config.h"
+
+int insert_atoms(t_moldyn *moldyn) {
+
+ int i,j;
+ u8 run;
+ t_3dvec r,v,dist;
+ double d,dmin;
+
+ t_atom *atom;
+
+ atom=moldyn->atom;
+
+ v.x=0; v.y=0; v.z=0;
+
+ for(j=0;j<INS_ATOMS;j++) {
+ run=1;
+ while(run) {
+#ifdef INS_TETRA
+ // tetrahedral
+ r.x=0.0;
+ r.y=0.0;
+ r.z=0.0;
+#endif
+#ifdef INS_HEXA
+ // hexagonal
+ r.x=-1.0/8.0*ALBE_LC_SI;
+ r.y=-1.0/8.0*ALBE_LC_SI;
+ r.z=1.0/8.0*ALBE_LC_SI;
+#endif
+#ifdef INS_110DB
+ // 110 dumbbell
+ r.x=(-0.5+0.25+0.125)*ALBE_LC_SI;
+ r.y=(-0.5+0.25+0.125)*ALBE_LC_SI;
+ r.z=(-0.5+0.25)*ALBE_LC_SI;
+ moldyn->atom[4372].r.x=(-0.5+0.125+0.125)*ALBE_LC_SI;
+ moldyn->atom[4372].r.y=(-0.5+0.125+0.125)*ALBE_LC_SI;
+#endif
+#ifdef INS_001DB
+ // 001 dumbbell
+ r.x=(-0.5+0.25)*ALBE_LC_SI;
+ r.y=(-0.5+0.25)*ALBE_LC_SI;
+ r.z=(-0.1)*ALBE_LC_SI;
+ moldyn->atom[4372].r.z=(-0.4)*ALBE_LC_SI;
+#endif
+#ifdef INS_USER
+ // 001 dumbbell
+ r.x=INS_UX*ALBE_LC_SI;
+ r.y=INS_UY*ALBE_LC_SI;
+ r.z=INS_UZ*ALBE_LC_SI;
+#endif
+#ifdef INS_RAND
+ // random
+#ifdef INS_DYNAMIC_LEN
+ r.x=(rand_get_double(&(moldyn->random))-0.5)*\
+ moldyn->dim.x;
+ r.y=(rand_get_double(&(moldyn->random))-0.5)*\
+ moldyn->dim.y;
+ r.z=(rand_get_double(&(moldyn->random))-0.5)*\
+ moldyn->dim.z;
+#else
+ r.x=(rand_get_double(&(moldyn->random))-0.5)*INS_LENX;
+ r.y=(rand_get_double(&(moldyn->random))-0.5)*INS_LENY;
+ r.z=(rand_get_double(&(moldyn->random))-0.5)*INS_LENZ;
+#endif
+#endif
+ // offset
+ r.x+=INS_OFFSET;
+ r.y+=INS_OFFSET;
+ r.z+=INS_OFFSET;
+ /* assume valid coordinates */
+ run=0;
+ dmin=10000000000.0; // for sure too high!
+ for(i=0;i<moldyn->count;i++) {
+ atom=&(moldyn->atom[i]);
+ v3_sub(&dist,&(atom->r),&r);
+ check_per_bound(moldyn,&dist);
+ d=v3_absolute_square(&dist);
+ /* reject coordinates */
+ if(d<INS_R_C) {
+ //printf("atom %d - %f\n",i,d);
+ run=1;
+ break;
+ }
+ if(d<dmin)
+ dmin=d;
+ }
+ }
+ add_atom(moldyn,INS_TYPE,INS_MASS,INS_BRAND,
+ ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|\
+ INS_ATTR,
+ &r,&v);
+ printf(" %02d: atom %d | %f %f %f | %f\n",
+ j,moldyn->count-1,r.x,r.y,r.z,dmin);
+ }