add another way of calculating tersoff + small moldyn mods
[physik/posic.git] / moldyn.h
index 1300998..5b12048 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -85,11 +85,15 @@ typedef struct s_moldyn {
        /* 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 (*func2b_post)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
-       int (*func3b)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,t_atom *ak,
-                     u8 bck);
+       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;
-       //int (*potential_force_function)(struct s_moldyn *moldyn);
+       unsigned char run3bp;
 
        double cutoff;          /* cutoff radius */
        double cutoff_square;   /* square of the cutoff radius */
@@ -99,9 +103,18 @@ typedef struct s_moldyn {
 
        double t_ref;           /* reference temperature */
        double t;               /* actual temperature */
+       double t_sum;           /* sum over all t */
+       double mean_t;          /* mean value of t */
+
+       t_virial virial;        /* global virial (absolute coordinates) */
+       double gp;              /* pressure computed from global virial */
+       double gp_sum;          /* sum over all gp */
+       double mean_gp;         /* mean value of gp */
 
        double p_ref;           /* reference pressure */
        double p;               /* actual pressure (computed by virial) */
+       double p_sum;           /* sum over all p */
+       double mean_p;          /* mean value of p */
        t_3dvec tp;             /* thermodynamic pressure dU/dV */
        double dv;              /* dV for thermodynamic pressure calc */
 
@@ -121,7 +134,7 @@ typedef struct s_moldyn {
        double tau;             /* delta t */
        double time;            /* absolute time */
        double tau_square;      /* delta t squared */
-       double elapsed;         /* total elapsed time */
+       int total_steps;        /* total steps */
 
        double energy;          /* potential energy */
        double ekin;            /* kinetic energy */
@@ -133,12 +146,18 @@ typedef struct s_moldyn {
        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 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 pfd;                /* gnuplot script file descriptor */
+       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 */
 
@@ -169,7 +188,7 @@ typedef struct s_moldyn {
 #define P_SCALE_DIRECT                 0x08    /* direct p control */
 
 /*
- * default values
+ * default values & units
  *
  * - length unit: 1 A (1 A = 1e-10 m)
  * - time unit: 1 fs (1 fs = 1e-15 s)
@@ -185,7 +204,9 @@ typedef struct s_moldyn {
 #define KILOGRAM                       (1.0/AMU)               /* amu */
 #define NEWTON (METER*KILOGRAM/(SECOND*SECOND))        /* A amu / fs^2 */
 #define PASCAL (NEWTON/(METER*METER))                  /* N / A^2 */
-#define ATM    ((1.0133e5*PASCAL))                     /* N / A^2 */
+#define BAR    ((1.0e5*PASCAL))                        /* N / A^2 */
+#define K_BOLTZMANN    (1.380650524e-23*METER*NEWTON)  /* NA/K */
+#define EV             (1.6021765314e-19*METER*NEWTON) /* NA */
 
 #define MOLDYN_TEMP                    273.0
 #define MOLDYN_TAU                     1.0
@@ -201,9 +222,11 @@ typedef struct s_moldyn {
 
 #define LOG_TOTAL_ENERGY               0x01
 #define LOG_TOTAL_MOMENTUM             0x02
-#define SAVE_STEP                      0x04
-#define VISUAL_STEP                    0x08
-#define CREATE_REPORT                  0x10
+#define LOG_PRESSURE                   0x04
+#define LOG_TEMPERATURE                        0x08
+#define SAVE_STEP                      0x10
+#define VISUAL_STEP                    0x20
+#define CREATE_REPORT                  0x40
 
 #define TRUE                           1
 #define FALSE                          0
@@ -212,17 +235,12 @@ typedef struct s_moldyn {
 #define QUIET                          0
 
 /*
- *
- * phsical values / constants
- *
+ * potential related phsical values / constants
  *
  */
 
 #define ONE_THIRD              (1.0/3.0)
 
-#define K_BOLTZMANN            (1.380650524e-23*METER*NEWTON)  /* NA/K */
-#define EV                     (1.6021765314e-19*METER*NEWTON) /* NA */
-
 #define C                      0x06
 #define M_C                    12.011                          /* amu */
 
@@ -230,9 +248,9 @@ typedef struct s_moldyn {
 #define LC_SI                  (0.543105e-9*METER)             /* A */
 #define M_SI                   28.08553                        /* amu */
 
-//#define LJ_SIGMA_SI          ((0.25*sqrt(3.0)*LC_SI)/1.122462)       /* A */
+#define LJ_SIGMA_SI            ((0.25*sqrt(3.0)*LC_SI)/1.122462)       /* A */
 //#define LJ_SIGMA_SI          (LC_SI/1.122462)                        /* A */
-#define LJ_SIGMA_SI            (0.5*sqrt(2.0)*LC_SI/1.122462)                  /* A */
+//#define LJ_SIGMA_SI          (0.5*sqrt(2.0)*LC_SI/1.122462)                  /* A */
 #define LJ_EPSILON_SI          (2.1678*EV)                             /* NA */
 
 #define TM_R_SI                        (2.7e-10*METER)                 /* A */
@@ -276,10 +294,9 @@ typedef struct s_moldyn {
  *
  */
 
-typedef int (*pf_func1b)(t_moldyn *,t_atom *ai);
-typedef int (*pf_func2b)(t_moldyn *,t_atom *,t_atom *,u8 bc);
-typedef int (*pf_func2b_post)(t_moldyn *,t_atom *,t_atom *,u8 bc);
-typedef int (*pf_func3b)(t_moldyn *,t_atom *,t_atom *,t_atom *,u8 bc);
+typedef int (*pf_func1b)(t_moldyn *,t_atom *);
+typedef int (*pf_func2b)(t_moldyn *,t_atom *,t_atom *,u8);
+typedef int (*pf_func3b)(t_moldyn *,t_atom *,t_atom *,t_atom *,u8);
 
 int moldyn_init(t_moldyn *moldyn,int argc,char **argv);
 int moldyn_shutdown(t_moldyn *moldyn);
@@ -292,10 +309,14 @@ int set_pt_scale(t_moldyn *moldyn,u8 ptype,double ptc,u8 ttype,double ttc);
 int set_dim(t_moldyn *moldyn,double x,double y,double z,u8 visualize);
 int set_nn_dist(t_moldyn *moldyn,double dist);
 int set_pbc(t_moldyn *moldyn,u8 x,u8 y,u8 z);
-int set_potential1b(t_moldyn *moldyn,pf_func1b func,void *params);
-int set_potential2b(t_moldyn *moldyn,pf_func2b func,void *params);
-int set_potential2b_post(t_moldyn *moldyn,pf_func2b_post func,void *params);
-int set_potential3b(t_moldyn *moldyn,pf_func3b func,void *params);
+int set_potential1b(t_moldyn *moldyn,pf_func1b func);
+int set_potential2b(t_moldyn *moldyn,pf_func2b func);
+int set_potential3b_j1(t_moldyn *moldyn,pf_func2b func);
+int set_potential3b_j2(t_moldyn *moldyn,pf_func2b func);
+int set_potential3b_j3(t_moldyn *moldyn,pf_func2b func);
+int set_potential3b_k1(t_moldyn *moldyn,pf_func3b func);
+int set_potential3b_k2(t_moldyn *moldyn,pf_func3b func);
+int set_potential_params(t_moldyn *moldyn,void *params);
 
 int moldyn_set_log_dir(t_moldyn *moldyn,char *dir);
 int moldyn_set_report(t_moldyn *moldyn,char *author,char *title);
@@ -322,8 +343,7 @@ int scale_volume(t_moldyn *moldyn);
 int scale_dim(t_moldyn *moldyn,double scale,u8 x,u8 y,u8 z);
 int scale_atoms(t_moldyn *moldyn,double scale,u8 x,u8 y,u8 z);
 
-double get_e_kin(t_moldyn *moldyn);
-double update_e_kin(t_moldyn *moldyn);
+double e_kin_calc(t_moldyn *moldyn);
 double get_total_energy(t_moldyn *moldyn);
 t_3dvec get_total_p(t_moldyn *moldyn);