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