cbfc17302fb04806d21d4b68085b27bb9309a79c
[physik/posic.git] / moldyn.h
1 /*
2  * moldyn.h - molecular dynamics library header file
3  *
4  * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
5  *
6  */
7
8 #ifndef MOLDYN_H
9 #define MOLDYN_H
10
11 #include "math/math.h"
12 #include "random/random.h"
13 //#include "visual/visual.h"
14
15 /* datatypes */
16
17 typedef struct s_atom {
18         t_3dvec r;      /* positions */
19         t_3dvec v;      /* velocities */
20         t_3dvec f;      /* forces */
21         int element;    /* number of element in pse */
22         double mass;    /* atom mass */
23         //t_list vicinity       /* verlet neighbour list */
24 } t_atom;
25
26 typedef struct s_moldyn {
27         /* atoms, amount, dimensions */
28         int count;
29         t_atom *atom;
30         t_3dvec dim;
31         /* potential, force & parameters */
32         double (*potential)(struct s_moldyn *moldyn);
33         int (*force)(struct s_moldyn *moldyn);
34         void *pot_params;
35         double cutoff;
36         double cutoff_square;
37         /* temperature */
38         double t;
39         /* integration of newtons equations */
40         int (*integrate)(struct s_moldyn *moldyn);
41         int time_steps;
42         double tau;
43         /* logging & visualization */
44         unsigned char lvstat;
45         unsigned int ewrite;
46         char efb[64];
47         int efd;
48         unsigned int mwrite;
49         char mfb[64];
50         int mfd;
51         unsigned int swrite;
52         char sfb[64];
53         int sfd;
54         unsigned int dwrite;
55         char dfb[64];
56         int dfd;
57         unsigned int vwrite;
58         void *visual;
59         /* moldyn general status */
60         unsigned char status;
61 } t_moldyn;
62
63 typedef struct s_ho_params {
64         double spring_constant;
65         double equilibrium_distance;
66 } t_ho_params;
67
68 typedef struct s_lj_params {
69         double sigma6;
70         double sigma12;
71         double epsilon;
72 } t_lj_params;
73
74 /*
75  *  defines
76  */
77
78 /* general defines */
79
80 #define MOLDYN_LVSTAT_TOTAL_E           0x01
81 #define MOLDYN_LVSTAT_TOTAL_M           0x02
82 #define MOLDYN_LVSTAT_SAVE              0x04
83 #define MOLDYN_LVSTAT_DUMP              0x08
84 #define MOLDYN_LVSTAT_VISUAL            0x10
85 #define MOLDYN_LVSTAT_INITIALIZED       0x80
86
87 #define MOLDYN_STAT_POTENTIAL           0x01
88 #define MOLDYN_STAT_FORCE               0x02
89
90 #define MOLDYN_TEMP                     273.0
91 #define MOLDYN_TAU                      1.0e-15
92 #define MOLDYN_RUNS                     1000000
93
94 /* phsical values */
95
96 #define K_BOLTZMANN             1.3807e-27                      /* Nm/K */
97 #define AMU                     1.660540e-27                    /* kg */
98
99 #define FCC                     0x01
100 #define DIAMOND                 0x02
101
102 #define C                       0x06
103 #define M_C                     (12.011*AMU)
104
105 #define SI                      0x0e
106 #define LC_SI                   0.543105e-9                             /* m */
107 #define M_SI                    (28.085*AMU)                            /* kg */
108 #define LJ_SIGMA_SI             ((0.25*sqrt(3.0)*LC_SI)/1.122462)       /* m */
109 #define LJ_EPSILON_SI           (2.1678*1.60e-19)                       /* Nm */
110
111 /* function prototypes */
112
113 int moldyn_usage(char **argv);
114 int moldyn_parse_argv(t_moldyn *moldyn,int argc,char **argv);
115 int moldyn_log_init(t_moldyn *moldyn);
116
117 int create_lattice(unsigned char type,int element,double mass,double lc,
118                    int a,int b,int c,t_atom **atom);
119 int destroy_lattice(t_atom *atom);
120 int thermal_init(t_moldyn *moldyn,t_random *random,int count);
121 int scale_velocity(t_moldyn *moldyn,int count);
122 double get_e_kin(t_atom *atom,int count);
123 double get_e_pot(t_moldyn *moldyn);
124 double get_total_energy(t_moldyn *moldyn);
125 t_3dvec get_total_p(t_atom *atom,int count);
126
127 double estimate_time_step(t_moldyn *moldyn,double nn_dist,double t);
128
129 int moldyn_integrate(t_moldyn *moldyn);
130 int velocity_verlet(t_moldyn *moldyn);
131
132 double potential_harmonic_oscillator(t_moldyn *moldyn);
133 int force_harmonic_oscillator(t_moldyn *moldyn);
134 double potential_lennard_jones(t_moldyn *moldyn);
135 int force_lennard_jones(t_moldyn *moldyn);
136
137 #endif