+#define ATOM_ATTR_FP 0x01 /* fixed position (bulk material) */
+#define ATOM_ATTR_HB 0x02 /* coupled to heat bath (velocity scaling) */
+#define ATOM_ATTR_VA 0x04 /* visualize this atom */ // TODO
+#define ATOM_ATTR_VB 0x08 /* visualize the bond of this atom */
+
+#define ATOM_ATTR_1BP 0x10 /* single paricle potential */
+#define ATOM_ATTR_2BP 0x20 /* pair potential */
+#define ATOM_ATTR_3BP 0x40 /* 3 body potential */
+
+#define DEFAULT_ATOM_ATTR 0x74 // 1,2,3 body interaction + visualize
+
+/* special list structure for low mem approach */
+typedef struct s_lowmem_list {
+ int *head;
+ int *list;
+} t_lowmem_list;
+
+/* cell lists */
+typedef struct s_linkcell {
+ int nx,ny,nz; /* amount of cells in x, y and z direction */
+ int cells; /* total amount of cells */
+ double len; /* prefered cell edge length */
+ double x,y,z; /* the actual cell lengthes */
+#ifdef STATIC_LISTS
+ int **subcell; /* pointer to the cell lists */
+#elif LOWMEM_LISTS
+ t_lowmem_list *subcell; /* low mem approach list */
+#else
+ t_list *subcell; /* pointer to the cell lists */
+#endif
+ int dnlc; /* direct neighbour lists counter */
+} t_linkcell;
+
+#define MAX_ATOMS_PER_LIST 20
+
+/* moldyn schedule structure */
+typedef struct s_moldyn_schedule {
+ int count;
+ int total_sched;
+ int *runs;
+ double *tau;
+ int (*hook)(void *moldyn,void *hook_params);
+ void *hook_params;
+} t_moldyn_schedule;
+
+/* visualization structure */
+typedef struct s_visual {
+ int fd; /* rasmol script file descriptor */
+ char fb[128]; /* basename of the save files */
+ t_3dvec dim; /* dimensions of the simulation cell */
+} t_visual;
+
+/* moldyn main structure */
+typedef struct s_moldyn {
+ int argc; /* number of arguments */
+ char **args; /* pointer to arguments */
+
+ int count; /* total amount of atoms */
+ double mass; /* total system mass */
+ t_atom *atom; /* pointer to the atoms */
+
+ t_3dvec dim; /* dimensions of the simulation volume */
+ double volume; /* volume of sim cell (dim.x*dim.y*dim.z) */
+
+ /* potential force function and parameter pointers */
+ int (*func1b)(struct s_moldyn *moldyn,t_atom *ai);
+ int (*func2b)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+ int (*func3b_j1)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+ int (*func3b_j2)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+ int (*func3b_j3)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+ int (*func3b_k1)(struct s_moldyn *moldyn,
+ t_atom *ai,t_atom *aj,t_atom *ak,u8 bck);
+ int (*func3b_k2)(struct s_moldyn *moldyn,
+ t_atom *ai,t_atom *aj,t_atom *ak,u8 bck);
+ void *pot_params;
+ unsigned char run3bp;
+
+ double cutoff; /* cutoff radius */
+ double cutoff_square; /* square of the cutoff radius */
+ double nnd; /* nearest neighbour distance (optional) */
+
+ t_linkcell lc; /* linked cell list interface */
+
+ int avg_skip; /* amount of steps without average calc */
+
+ double t_ref; /* reference temperature */
+ double t; /* actual temperature */
+ double t_sum; /* sum over all t */
+ double t_avg; /* average value of t */
+
+ /* for sale! */
+ t_virial gvir; /* global virial (absolute coordinates) */
+ //double gv;
+ //double gv_sum;
+ //double gv_avg;
+ double sale1;
+ double sale2;
+ double sale3;
+
+ // gp stuff exchanged by kinetic energies
+ //double gp; /* pressure computed from global virial */
+ //double gp_sum; /* sum over all gp */
+ //double gp_avg; /* average value of gp */
+ double ekinx;
+ double ekiny;
+ double ekinz;
+
+ t_virial vir; /* actual virial */
+ double virial;
+ double virial_sum; /* sum over all calculated virials */
+ double virial_avg; /* average of virial */
+
+ double p_ref; /* reference pressure */
+ double p; /* actual pressure (computed by virial) */
+ double px,py,pz; /* components of pressure */
+ double p_sum; /* sum over all p */
+ double p_avg; /* average value of p */
+
+ double tp; /* thermodynamic pressure dU/dV */
+ double tp_sum; /* sum over dU/dV pressure */
+ double tp_avg; /* average value of dU/dV pressure */
+ int tp_cnt; /* how often to do thermodynamic p calc */
+
+ /* pressure and temperature control (velocity/volume scaling) */
+ /* (t_tc in units of tau, p_tc in units of tau * isoth. compressib.) */
+ unsigned char pt_scale; /* type of p and t scaling */
+ double t_tc; /* t berendsen control time constant */
+ double p_tc; /* p berendsen control time constant */
+
+ /* simulation schedule */
+ t_moldyn_schedule schedule;
+ int current; /* current position in schedule */
+
+ /* integration function pointer */
+ int (*integrate)(struct s_moldyn *moldyn);
+ int time_steps; /* amount of iterations */
+ double tau; /* delta t */
+ double time; /* absolute time */
+ double tau_square; /* delta t squared */
+ int total_steps; /* total steps */
+
+ /* energy */
+ double energy; /* potential energy */
+ double ekin; /* kinetic energy */
+
+ /* energy averages & fluctuations */
+ double k_sum; /* sum of kinetic energy */
+ double v_sum; /* sum of potential energy */
+ double k_avg; /* average of kinetic energy */
+ double v_avg; /* average of potential energy */
+ double k2_sum; /* sum of kinetic energy squared */
+ double v2_sum; /* sum of potential energy squared */
+ double k2_avg; /* average of kinetic energy squared */
+ double v2_avg; /* average of potential energy squared */
+ double dk2_avg; /* mean square kinetic energy fluctuations */
+ double dv2_avg; /* mean square potential energy fluctuations */
+
+ /* response functions */
+ double c_v_nve; /* constant volume heat capacity (nve) */
+ double c_v_nvt; /* constant volume heat capacity (nvt) */
+
+ char vlsdir[128]; /* visualization/log/save directory */
+ t_visual vis; /* visualization interface structure */
+ u8 vlsprop; /* log/vis/save properties */
+ unsigned int ewrite; /* how often to log energy */
+ int efd; /* fd for energy log */
+ unsigned int mwrite; /* how often to log momentum */
+ int mfd; /* fd for momentum log */
+ unsigned int pwrite; /* how often to log pressure */
+ int pfd; /* fd for pressure log */
+ unsigned int twrite; /* how often to log temperature */
+ int tfd; /* fd for temperature log */
+ unsigned int vwrite; /* how often to log volume */
+ int vfd; /* fd for volume log */
+ unsigned int awrite; /* how often to visualize atom information */
+ unsigned int swrite; /* how often to create a save file */
+ int rfd; /* report file descriptor */
+ char rtitle[64]; /* report title */
+ char rauthor[64]; /* report author */
+ int epfd; /* energy gnuplot script file descriptor */
+ int ppfd; /* pressure gnuplot script file descriptor */
+ int tpfd; /* temperature gnuplot script file descriptor */
+
+ u8 status; /* general moldyn properties */
+
+ t_random random; /* random interface */
+
+ double debug; /* debugging stuff, ignore */
+
+ /* potential 2 body check function */
+ int (*check_2b_bond)(struct s_moldyn *moldyn,
+ t_atom *itom,t_atom *jtom,u8 bc);
+} t_moldyn;
+
+typedef struct s_pcc {
+ int o1;
+ int o2;
+ double dr;
+ double *stat;
+} t_pcc;
+
+typedef struct s_ba {
+ int *acnt;
+ int *bcnt;
+ int tcnt;
+} t_ba;
+
+typedef struct s_vb {
+ int fd;
+} t_vb;
+
+typedef struct s_part_params {
+ u8 type;
+ double r;
+ t_3dvec p;
+ t_3dvec d;
+} t_part_params;
+
+#define PART_INSIDE_R 1
+#define PART_OUTSIDE_R 2
+#define PART_INSIDE_D 3
+#define PART_OUTSIDE_D 4
+
+typedef struct s_defect_params {
+ u8 type;
+ u8 stype;
+ double od;
+ double dd;
+ int element;
+ u8 brand;
+ u8 attr;
+} t_defect_params;
+
+#define DEFECT_TYPE_0D 1
+#define DEFECT_TYPE_1D 2
+#define DEFECT_TYPE_2D 3
+#define DEFECT_TYPE_3D 4
+
+#define DEFECT_STYPE_DB_X 1
+#define DEFECT_STYPE_DB_Y 2
+#define DEFECT_STYPE_DB_Z 3
+#define DEFECT_STYPE_DB_R 4
+
+typedef struct s_offset_params {
+ t_3dvec o;
+ u8 use;
+} t_offset_params;
+
+/*
+ *
+ * defines
+ *
+ */
+
+#define MOLDYN_STAT_PBX 0x01 /* periodic boudaries in x */
+#define MOLDYN_STAT_PBY 0x02 /* y */
+#define MOLDYN_STAT_PBZ 0x04 /* and z direction */
+
+#define MOLDYN_PSCALE 0x08 /* size controlled by piston */
+
+#define MOLDYN_1BP 0x10 /* care about single */
+#define MOLDYN_2BP 0x20 /* 2 body */
+#define MOLDYN_3BP 0x40 /* and 3 body particle pots */
+
+#define T_SCALE_NONE 0x00
+#define T_SCALE_BERENDSEN 0x01 /* berendsen t control */
+#define T_SCALE_DIRECT 0x02 /* direct t control */
+#define T_SCALE_MASK 0x03