2 * moldyn.h - molecular dynamics library header file
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
11 #include "math/math.h"
12 #include "random/random.h"
13 #include "list/list.h"
19 /* the atom of the md simulation */
21 typedef struct s_atom {
22 t_3dvec r; /* position */
23 t_3dvec v; /* velocity */
24 t_3dvec f; /* force */
25 int element; /* number of element in pse */
26 double mass; /* atom mass */
27 unsigned char attr; /* attributes */
30 #define ATOM_ATTR_FP 0x01 /* fixed position (bulk material) */
31 #define ATOM_ATTR_HB 0x02 /* coupled to heat bath (velocity scaling) */
35 typedef struct s_linkcell {
36 int nx,ny,nz; /* amount of cells in x, y and z direction */
37 int cells; /* total amount of cells */
38 double len; /* prefered cell edge length */
39 double x,y,z; /* the actual cell lengthes */
40 t_list *subcell; /* pointer to the cell lists */
41 int dnlc; /* direct neighbour lists counter */
44 #include "visual/visual.h"
46 # moldyn properties structure */
48 typedef struct s_moldyn {
50 int count; /* total amount of atoms */
51 t_atom *atom; /* pointer to the atoms */
52 t_3dvec dim; /* dimensions of the simulation volume */
53 /* potential, force & parameters */
55 /* potential force funtion created by the user */
56 int (*potential_force_function)(struct s_moldyn *moldyn);
57 void *pot_params; /* parameters describing the potential */
61 /* linked list / cell method */
65 /* integration of newtons equations */
66 int (*integrate)(struct s_moldyn *moldyn);
72 /* logging & visualization */
90 /* moldyn general status */
96 typedef struct s_ho_params {
97 double spring_constant;
98 double equilibrium_distance;
101 typedef struct s_lj_params {
107 typedef struct s_tersoff_params {
120 /* general defines */
122 #define MOLDYN_LVSTAT_TOTAL_E 0x01
123 #define MOLDYN_LVSTAT_TOTAL_M 0x02
124 #define MOLDYN_LVSTAT_SAVE 0x04
125 #define MOLDYN_LVSTAT_DUMP 0x08
126 #define MOLDYN_LVSTAT_VISUAL 0x10
127 #define MOLDYN_LVSTAT_INITIALIZED 0x80
129 #define MOLDYN_STAT_POTENTIAL 0x01
130 #define MOLDYN_STAT_FORCE 0x02
132 #define MOLDYN_TEMP 273.0
133 #define MOLDYN_TAU 1.0e-15
134 #define MOLDYN_CUTOFF 10.0e-9
135 #define MOLDYN_RUNS 1000000
137 #define MOLDYN_INTEGRATE_VERLET 0x00
138 #define MOLDYN_INTEGRATE_DEFAULT MOLDYN_INTEGRATE_VERLET
140 #define MOLDYN_POTENTIAL_HO 0x00
141 #define MOLDYN_POTENTIAL_LJ 0x01
142 #define MOLDYN_POTENTIAL_DEFAULT MOLDYN_POTENTIAL_LJ
146 #define K_BOLTZMANN 1.3807e-27 /* Nm/K */
147 #define AMU 1.660540e-27 /* kg */
153 #define M_C (12.011*AMU)
156 #define LC_SI 0.543105e-9 /* m */
157 #define M_SI (28.085*AMU) /* kg */
158 #define LJ_SIGMA_SI ((0.25*sqrt(3.0)*LC_SI)/1.122462) /* m */
159 #define LJ_EPSILON_SI (2.1678*1.60e-19) /* Nm */
161 /* function prototypes */
163 int moldyn_usage(char **argv);
164 int moldyn_parse_argv(t_moldyn *moldyn,int argc,char **argv);
165 int moldyn_log_init(t_moldyn *moldyn);
166 int moldyn_init(t_moldyn *moldyn,int argc,char **argv);
167 int moldyn_shutdown(t_moldyn *moldyn);
169 int create_lattice(unsigned char type,int element,double mass,double lc,
170 int a,int b,int c,t_atom **atom);
171 int destroy_lattice(t_atom *atom);
172 int thermal_init(t_moldyn *moldyn);
173 int scale_velocity(t_moldyn *moldyn);
174 double get_e_kin(t_atom *atom,int count);
175 double get_e_pot(t_moldyn *moldyn);
176 double get_total_energy(t_moldyn *moldyn);
177 t_3dvec get_total_p(t_atom *atom,int count);
179 double estimate_time_step(t_moldyn *moldyn,double nn_dist,double t);
181 int link_cell_init(t_moldyn *moldyn);
182 int link_cell_update(t_moldyn *moldyn);
183 int link_cell_neighbour_index(t_moldyn *moldyn,int i,int j,int k,t_list *cell);
184 int link_cell_shutdown(t_moldyn *moldyn);
186 int moldyn_integrate(t_moldyn *moldyn);
187 int velocity_verlet(t_moldyn *moldyn);
189 int harmonic_oscillator(t_moldyn *moldyn);
190 int lennard_jones(t_moldyn *moldyn);