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 */
42 int countn; /* amount of neighbours */
45 #include "visual/visual.h"
49 typedef struct s_moldyn {
51 int count; /* total amount of atoms */
52 t_atom *atom; /* pointer to the atoms */
54 t_3dvec dim; /* dimensions of the simulation volume */
56 /* potential force function pointer and parameters */
57 int (*pf_func1b)(struct s_moldyn *,t_atom *);
58 int (*pf_func2b)(struct s_moldyn *,t_atom *,t_atom *);
59 int (*pf_func3b)(struct s_moldyn *,t_atom *,t_atom *,t_atom *);
60 //int (*potential_force_function)(struct s_moldyn *moldyn);
61 void *pot_params; /* parameters describing the potential */
63 double cutoff; /* cutoff radius */
64 double cutoff_square; /* square of the cutoff radius */
66 t_linkcell lc; /* linked cell method */
68 double t; /* temperature */
70 /* integration function pointer */
71 int (*integrate)(struct s_moldyn *moldyn);
72 int time_steps; /* amount of iterations */
73 double tau; /* delta t */
74 double tau_square; /* delta t squared */
76 double energy; /* energy */
78 t_visual vis; /* visualization/log/save interface structure */
79 unsigned char lvstat; /* log & vis properties */
80 unsigned int ewrite; /* how often to log energy */
81 char efb[64]; /* energy log filename */
82 int efd; /* fd for energy log */
83 unsigned int mwrite; /* how often to log momentum */
84 char mfb[64]; /* momentum log filename */
85 int mfd; /* fd for momentum log */
86 unsigned int vwrite; /* how often to visualize atom information */
87 char vfb[64]; /* visualization file name base */
88 void *visual; /* pointer (hack!) */
89 unsigned int swrite; /* how often to create a save file */
91 unsigned char status; /* general moldyn properties */
93 t_random random; /* random interface */
96 #define MOLDYN_LVSTAT_TOTAL_E 0x01
97 #define MOLDYN_LVSTAT_TOTAL_M 0x02
98 #define MOLDYN_LVSTAT_SAVE 0x04
99 #define MOLDYN_LVSTAT_VISUAL 0x08
100 #define MOLDYN_LVSTAT_INITIALIZED 0x10
102 #define MOLDYN_STAT_1BP 0x01
103 #define MOLDYN_STAT_2BP 0x02 /* define for pair potentials */
104 #define MOLDYN_STAT_3BP 0x04 /* define for 3 body pot */
105 #define MOLDYN_STAT_PBX 0x08 /* periodic boudaries in x */
106 #define MOLDYN_STAT_PBY 0x10 /* y */
107 #define MOLDYN_STAT_PBZ 0x20 /* and z direction */
109 typedef struct s_ho_params {
110 double spring_constant;
111 double equilibrium_distance;
114 typedef struct s_lj_params {
120 typedef struct s_tersoff_params {
133 /* general defines */
135 #define MOLDYN_TEMP 273.0
136 #define MOLDYN_TAU 1.0e-15
137 #define MOLDYN_CUTOFF 10.0e-9
138 #define MOLDYN_RUNS 1000000
140 #define MOLDYN_INTEGRATE_VERLET 0x00
141 #define MOLDYN_INTEGRATE_DEFAULT MOLDYN_INTEGRATE_VERLET
143 #define MOLDYN_POTENTIAL_HO 0x00
144 #define MOLDYN_POTENTIAL_LJ 0x01
145 #define MOLDYN_POTENTIAL_DEFAULT MOLDYN_POTENTIAL_LJ
149 #define K_BOLTZMANN 1.3807e-27 /* Nm/K */
150 #define AMU 1.660540e-27 /* kg */
156 #define M_C (12.011*AMU)
159 #define LC_SI 0.543105e-9 /* m */
160 #define M_SI (28.085*AMU) /* kg */
161 #define LJ_SIGMA_SI ((0.25*sqrt(3.0)*LC_SI)/1.122462) /* m */
162 #define LJ_EPSILON_SI (2.1678*1.60e-19) /* Nm */
164 /* function prototypes */
166 int moldyn_usage(char **argv);
167 int moldyn_parse_argv(t_moldyn *moldyn,int argc,char **argv);
168 int moldyn_log_init(t_moldyn *moldyn);
169 int moldyn_init(t_moldyn *moldyn,int argc,char **argv);
170 int moldyn_shutdown(t_moldyn *moldyn);
172 int create_lattice(unsigned char type,int element,double mass,double lc,
173 int a,int b,int c,t_atom **atom);
174 int destroy_lattice(t_atom *atom);
175 int thermal_init(t_moldyn *moldyn);
176 int scale_velocity(t_moldyn *moldyn);
177 double get_e_kin(t_atom *atom,int count);
178 double get_e_pot(t_moldyn *moldyn);
179 double get_total_energy(t_moldyn *moldyn);
180 t_3dvec get_total_p(t_atom *atom,int count);
182 double estimate_time_step(t_moldyn *moldyn,double nn_dist,double t);
184 int link_cell_init(t_moldyn *moldyn);
185 int link_cell_update(t_moldyn *moldyn);
186 int link_cell_neighbour_index(t_moldyn *moldyn,int i,int j,int k,t_list *cell);
187 int link_cell_shutdown(t_moldyn *moldyn);
189 int moldyn_integrate(t_moldyn *moldyn);
190 int velocity_verlet(t_moldyn *moldyn);
192 int harmonic_oscillator(t_moldyn *moldyn);
193 int lennard_jones(t_moldyn *moldyn);