moldyn->func3b_k2=albe_mult_3bp_k2;
moldyn->check_2b_bond=albe_mult_check_2b_bond;
break;
+ case MOLDYN_POTENTIAL_HO:
+ moldyn->func2b=harmonic_oscillator;
+ moldyn->check_2b_bond=harmonic_oscillator_check_2b_bond;
+ break;
+ case MOLDYN_POTENTIAL_LJ:
+ moldyn->func2b=lennard_jones;
+ moldyn->check_2b_bond=lennard_jones_check_2b_bond;
+ break;
default:
printf("[moldyn] set potential: unknown type %02x\n",
type);
#define ATOM_ATTR_VA 0x04 /* visualize this atom */
#define ATOM_ATTR_VB 0x08 /* visualize the bond of this atom */
-#define ATOM_ATTR_1BP 0x10 /* single paricle potential */
-#define ATOM_ATTR_2BP 0x20 /* pair potential */
-#define ATOM_ATTR_3BP 0x40 /* 3 body potential */
+#define ATOM_ATTR_1BP 0x10 /* single paricle potential */
+#define ATOM_ATTR_2BP 0x20 /* pair potential */
+#define ATOM_ATTR_3BP 0x40 /* 3 body potential */
/* cell lists */
typedef struct s_linkcell {
#define SCALE_DIRECT 'D'
/*
- * potential related phsical values / constants
- *
+ * usefull constants
*/
#define ONE_THIRD (1.0/3.0)
+/*
+ * element specific defines
+ */
+
#define C 0x06
#define LC_C 3.567 /* A */
#define M_C 12.011 /* amu */
#define LC_3C_SIC 4.3596 /* A */
-#define LJ_SIGMA_SI ((0.25*sqrt(3.0)*LC_SI)/1.122462) /* A */
-//#define LJ_SIGMA_SI (LC_SI/1.122462) /* A */
-//#define LJ_SIGMA_SI (0.5*sqrt(2.0)*LC_SI/1.122462) /* A */
-#define LJ_EPSILON_SI (2.1678*EV) /* NA */
-
/*
* lattice types
*/
t_albe_mult_params *p;
+ // set cutoff before parameters (actually only necessary for some pots)
+ if(moldyn->cutoff==0.0) {
+ printf("[albe] WARNING: no cutoff!\n");
+ return -1;
+ }
+
/* alloc mem for potential parameters */
moldyn->pot_params=malloc(sizeof(t_albe_mult_params));
if(moldyn->pot_params==NULL) {
#include "../math/math.h"
#include "harmonic_oscillator.h"
+int harmonic_oscillator_set_params(t_moldyn *moldyn,int element) {
+
+ t_ho_params *p;
+
+ // set cutoff before parameters (actually only necessary for some pots)
+ if(moldyn->cutoff==0.0) {
+ printf("[harmonic oscillator] WARNING: no cutoff!\n");
+ return -1;
+ }
+
+ /* alloc mem for potential parameters */
+ moldyn->pot_params=malloc(sizeof(t_ho_params));
+ if(moldyn->pot_params==NULL) {
+ perror("[harmonic oscillator] pot params alloc");
+ return -1;
+ }
+
+ /* these are now ho parameters */
+ p=moldyn->pot_params;
+
+ switch(element) {
+ case SI:
+ /* type: silicon */
+ p->spring_constant=HO_SC_SI;
+ p->equilibrium_distance=HO_ED_SI;
+ break;
+ case C:
+ /* type: carbon */
+ p->spring_constant=HO_SC_C;
+ p->equilibrium_distance=HO_ED_C;
+ break;
+ default:
+ printf("[harmonic oscillator] WARNING: element\n");
+ return -1;
+ }
+
+
+ return 0;
+}
+
int harmonic_oscillator(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
t_ho_params *params;
return 0;
}
+int harmonic_oscillator_check_2b_bond(t_moldyn *moldyn,
+ t_atom *ai,t_atom *aj,u8 bc) {
+
+ t_3dvec distance;
+ double d;
+
+ v3_sub(&distance,&(aj->r),&(ai->r));
+ if(bc) check_per_bound(moldyn,&distance);
+ d=v3_norm(&distance);
+
+ if(d>moldyn->cutoff)
+ return FALSE;
+
+ return TRUE;
+}
+
} t_ho_params;
/* function prototype */
+int harmonic_oscillator_set_params(t_moldyn *moldyn,int element);
int harmonic_oscillator(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+int harmonic_oscillator_check_2b_bond(t_moldyn *moldyn,
+ t_atom *ai,t_atom *aj,u8 bc);
+
+/* harmonic oscillator potential parameter defines */
+
+// silicon
+#define HO_SC_SI 1
+#define HO_ED_SI (0.25*sqrt(3.0)*LC_SI)
+
+// carbon
+#define HO_SC_C 1
+#define HO_ED_C (0.25*sqrt(3.0)*LC_C)
#endif
#include "../math/math.h"
#include "lennard_jones.h"
+int lennard_jones_set_params(t_moldyn *moldyn,int element) {
+
+ t_lj_params *p;
+ t_atom a,b;
+
+ // set cutoff before parameters (actually only necessary for some pots)
+ if(moldyn->cutoff==0.0) {
+ printf("[lennard jones] WARNING: no cutoff!\n");
+ return -1;
+ }
+
+ /* atoms for correction term */
+ a.r.x=0.0; a.r.y=0.0; a.r.z=0.0;
+ b.r.x=0.0; b.r.y=0.0; b.r.z=moldyn->cutoff;
+
+ /* alloc mem for potential parameters */
+ moldyn->pot_params=malloc(sizeof(t_lj_params));
+ if(moldyn->pot_params==NULL) {
+ perror("[lennard jones] pot params alloc");
+ return -1;
+ }
+
+ /* these are now lennard jones parameters */
+ p=moldyn->pot_params;
+
+ switch(element) {
+ case SI:
+ /* type: silicon */
+ p->sigma6=LJ_SIGMA_SI*LJ_SIGMA_SI*LJ_SIGMA_SI;
+ p->sigma6+=p->sigma6;
+ p->sigma12=p->sigma6*p->sigma6;
+ p->epsilon4=4.0*LJ_EPSILON_SI;
+ p->uc=0.0; // calc it now!
+ lennard_jones(moldyn,&a,&b,0);
+ p->uc=moldyn->energy;
+ moldyn->energy=0.0;
+ break;
+ case C:
+ /* type: carbon */
+ p->sigma6=LJ_SIGMA_C*LJ_SIGMA_C*LJ_SIGMA_C;
+ p->sigma6+=p->sigma6;
+ p->sigma12=p->sigma6*p->sigma6;
+ p->epsilon4=4.0*LJ_EPSILON_C;
+ p->uc=0.0; // calc it now!
+ lennard_jones(moldyn,&a,&b,0);
+ p->uc=moldyn->energy;
+ moldyn->energy=0.0;
+ break;
+ default:
+ printf("[lennard jones] WARNING: element\n");
+ return -1;
+ }
+
+ return 0;
+}
+
int lennard_jones(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
t_lj_params *params;
return 0;
}
+int lennard_jones_check_2b_bond(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
+
+ t_3dvec dist;
+ double d;
+
+ v3_sub(&dist,&(aj->r),&(ai->r));
+ if(bc) check_per_bound(moldyn,&dist);
+ d=v3_absolute_square(&dist);
+
+ if(d>moldyn->cutoff_square)
+ return FALSE;
+
+ return TRUE;
+}
} t_lj_params;
/* function prototype */
+int lennard_jones_set_params(t_moldyn *moldyn,int element);
int lennard_jones(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+int lennard_jones_check_2b_bond(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
+
+/* lennard jones potential parameters */
+
+// silicon
+#define LJ_SIGMA_SI ((0.25*sqrt(3.0)*LC_SI)/1.122462)
+#define LJ_EPSILON_SI (2.1678*EV) // TODO
+
+// carbob
+#define LJ_SIGMA_C ((0.25*sqrt(3.0)*LC_C)/1.122462)
+#define LJ_EPSILON_C (2.1678*EV) // TODO
#endif
t_tersoff_mult_params *p;
+ // set cutoff before parameters (actually only necessary for some pots)
+ if(moldyn->cutoff==0.0) {
+ printf("[tersoff] WARNING: no cutoff!\n");
+ return -1;
+ }
+
/* alloc mem for potential parameters */
moldyn->pot_params=malloc(sizeof(t_tersoff_mult_params));
if(moldyn->pot_params==NULL) {
/* choose potential */
#ifdef ALBE
- set_potential(&md,MOLDYN_POTENTIAL_AM);
+ if(set_potential(&md,MOLDYN_POTENTIAL_AM)<0)
+ return -1;
#else
- set_potential(&md,MOLDYN_POTENTIAL_TM);
+ if(set_potential(&md,MOLDYN_POTENTIAL_TM)<0)
+ return -1;
#endif
/* cutoff radius & bondlen */
* potential parameters
*/
+#ifndef ALBE
/*
* tersoff mult potential parameters for SiC
*/
tersoff_mult_set_params(&md,SI,C);
-
+#else
/*
* albe mult potential parameters for SiC
*/
albe_mult_set_params(&md,SI,C);
+#endif
/* set (initial) dimensions of simulation volume */
#ifdef ALBE