-/* harmonic oscillator potential and force */
-
-int harmonic_oscillator(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
-
- t_ho_params *params;
- t_3dvec force,distance;
- double d;
- double sc,equi_dist;
-
- params=moldyn->pot2b_params;
- sc=params->spring_constant;
- equi_dist=params->equilibrium_distance;
-
- v3_sub(&distance,&(ai->r),&(aj->r));
-
- if(bc) check_per_bound(moldyn,&distance);
- d=v3_norm(&distance);
- if(d<=moldyn->cutoff) {
- /* energy is 1/2 (d-d0)^2, but we will add this twice ... */
- moldyn->energy+=(0.25*sc*(d-equi_dist)*(d-equi_dist));
- v3_scale(&force,&distance,-sc*(1.0-(equi_dist/d)));
- v3_add(&(ai->f),&(ai->f),&force);
- }
-
- return 0;
-}
-
-/* lennard jones potential & force for one sort of atoms */
-
-int lennard_jones(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
-
- t_lj_params *params;
- t_3dvec force,distance;
- double d,h1,h2;
- double eps,sig6,sig12;
-
- params=moldyn->pot2b_params;
- eps=params->epsilon4;
- sig6=params->sigma6;
- sig12=params->sigma12;
-
- v3_sub(&distance,&(ai->r),&(aj->r));
- if(bc) check_per_bound(moldyn,&distance);
- d=v3_absolute_square(&distance); /* 1/r^2 */
- if(d<=moldyn->cutoff_square) {
- d=1.0/d; /* 1/r^2 */
- h2=d*d; /* 1/r^4 */
- h2*=d; /* 1/r^6 */
- h1=h2*h2; /* 1/r^12 */
- /* energy is eps*..., but we will add this twice ... */
- moldyn->energy+=0.5*eps*(sig12*h1-sig6*h2);
- h2*=d; /* 1/r^8 */
- h1*=d; /* 1/r^14 */
- h2*=6*sig6;
- h1*=12*sig12;
- d=+h1-h2;
- d*=eps;
- v3_scale(&force,&distance,d);
- v3_add(&(ai->f),&(ai->f),&force);
- }
-
- return 0;
-}
-
-/*
- * tersoff potential & force for 2 sorts of atoms
- */
-
-/* tersoff 1 body part */
-int tersoff_mult_1bp(t_moldyn *moldyn,t_atom *ai) {
-
- int num;
- t_tersoff_mult_params *params;
- t_tersoff_exchange *exchange;
-
- num=ai->bnum;
- params=moldyn->pot1b_params;
- exchange=&(params->exchange);
-
- /*
- * simple: point constant parameters only depending on atom i to
- * their right values
- */
-
- exchange->beta=&(params->beta[num]);
- exchange->n=&(params->n[num]);
- exchange->c=&(params->c[num]);
- exchange->d=&(params->d[num]);
- exchange->h=&(params->h[num]);
-
- exchange->betan=pow(*(exchange->beta),*(exchange->n));
- exchange->c2=params->c[num]*params->c[num];
- exchange->d2=params->d[num]*params->d[num];
- exchange->c2d2=exchange->c2/exchange->d2;
-
- return 0;
-}
-
-/* tersoff 2 body part */
-int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
-
- t_tersoff_mult_params *params;
- t_tersoff_exchange *exchange;
- t_3dvec dist_ij,force;
- double d_ij;
- double A,B,R,S,lambda,mu;
- double f_r,df_r;
- double f_c,df_c;
- int num;
- double s_r;
- double arg;
- double scale;
-
- params=moldyn->pot2b_params;
- num=ai->bnum;
- exchange=&(params->exchange);
-
- exchange->run3bp=0;
-
- /*
- * we need: f_c, df_c, f_r, df_r
- *
- * therefore we need: R, S, A, lambda
- */
-
- v3_sub(&dist_ij,&(ai->r),&(aj->r));
-
- if(bc) check_per_bound(moldyn,&dist_ij);
-
- /* save for use in 3bp */ /* REALLY ?!?!?! */
- exchange->dist_ij=dist_ij;
-
- /* constants */
- if(num==aj->bnum) {
- S=params->S[num];
- R=params->R[num];
- A=params->A[num];
- lambda=params->lambda[num];
- /* more constants depending of atoms i and j, needed in 3bp */
- params->exchange.B=&(params->B[num]);
- params->exchange.mu=&(params->mu[num]);
- mu=params->mu[num];
- params->exchange.chi=1.0;
- }
- else {
- S=params->Smixed;
- R=params->Rmixed;
- A=params->Amixed;
- lambda=params->lambda_m;
- /* more constants depending of atoms i and j, needed in 3bp */
- params->exchange.B=&(params->Bmixed);
- params->exchange.mu=&(params->mu_m);
- mu=params->mu_m;
- params->exchange.chi=params->chi;
- }
-
- d_ij=v3_norm(&dist_ij);
-
- /* save for use in 3bp */
- exchange->d_ij=d_ij;
-
- if(d_ij>S)
- return 0;
-
- f_r=A*exp(-lambda*d_ij);
- df_r=-lambda*f_r/d_ij;