added harmonic potntial + bugfixes + boundings
[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         int count;
28         t_atom *atom;
29         double (*potential)(struct s_moldyn *moldyn);
30         void *pot_params;
31         int (*force)(struct s_moldyn *moldyn);
32         double cutoff;
33         double cutoff_square;
34         t_3dvec dim;
35         int (*integrate)(struct s_moldyn *moldyn);
36         int time_steps;
37         double tau;
38         void *visual;
39         int write;
40         unsigned char status;
41 } t_moldyn;
42
43 typedef struct s_ho_params {
44         double spring_constant;
45         double equilibrium_distance;
46 } t_ho_params;
47
48 typedef struct s_lj_params {
49         double sigma6;
50         double sigma12;
51         double epsilon;
52 } t_lj_params;
53
54 /*
55  *  defines
56  */
57
58 /* general defines */
59
60 #define MOLDYN_STAT_POTENTIAL           0x01
61 #define MOLDYN_STAT_FORCE               0x02
62
63 /* phsical values */
64
65 #define K_BOLTZMANN             1.3807e-27                      /* Nm/K */
66 #define AMU                     1.660540e-27                    /* kg */
67
68 #define FCC                     0x01
69 #define DIAMOND                 0x02
70
71 #define C                       0x06
72 #define M_C                     (12.011*AMU)
73
74 #define SI                      0x0e
75 #define LC_SI                   0.543105e-9                             /* m */
76 #define M_SI                    (28.085*AMU)                            /* kg */
77 #define LJ_SIGMA_SI             ((0.25*sqrt(3.0)*LC_SI)/1.122462)       /* m */
78 #define LJ_EPSILON_SI           (2.1678*1.60e-19)                       /* Nm */
79
80 /* function prototypes */
81
82 int create_lattice(unsigned char type,int element,double mass,double lc,
83                    int a,int b,int c,t_atom **atom);
84 int destroy_lattice(t_atom *atom);
85 int thermal_init(t_atom *atom,t_random *random,int count,double t);
86 int scale_velocity(t_atom *atom,int count,double t);
87 double get_e_kin(t_atom *atom,int count);
88 double get_e_pot(t_moldyn *moldyn);
89 double get_total_energy(t_moldyn *moldyn);
90 t_3dvec get_total_p(t_atom *atom,int count);
91
92 double estimate_time_step(t_moldyn *moldyn,double nn_dist,double t);
93
94 int moldyn_integrate(t_moldyn *moldyn);
95 int velocity_verlet(t_moldyn *moldyn);
96
97 double potential_harmonic_oscillator(t_moldyn *moldyn);
98 int force_harmonic_oscillator(t_moldyn *moldyn);
99 double potential_lennard_jones(t_moldyn *moldyn);
100 int force_lennard_jones(t_moldyn *moldyn);
101
102 #endif