introduced lowmem lists
[physik/posic.git] / potentials / albe_fast.c
index 3b5f681..45ebff9 100644 (file)
@@ -45,7 +45,9 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
        int *neighbour_i[27];
        int p,q;
-       t_atom *atom;
+#elif LOWMEM_LISTS
+       int neighbour_i[27];
+       int p,q;
 #else
        t_list neighbour_i[27];
        t_list neighbour_i2[27];
@@ -90,13 +92,18 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
        t_3dvec dcosdrj,dcosdrk;
        t_3dvec tmp;
 
+       // even more ...
+       double gamma_i;
+       double c_i;
+       double d_i;
+       double h_i;
+       double ci2;
+       double di2;
+       double ci2di2;
 
        count=moldyn->count;
        itom=moldyn->atom;
        lc=&(moldyn->lc);
-#ifdef STATIC_LISTS
-       atom=moldyn->atom;
-#endif
 
        // optimized
        params=moldyn->pot_params;
@@ -149,7 +156,9 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
                dnlc=lc->dnlc;
 
                /* copy the neighbour lists */
-#ifndef STATIC_LISTS
+#ifdef STATIC_LISTS
+#elif LOWMEM_LISTS
+#else
                memcpy(neighbour_i2,neighbour_i,27*sizeof(t_list));
 #endif
 
@@ -163,10 +172,17 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                        p=0;
 
-                       while(neighbour_i[j][p]!=0) {
+                       while(neighbour_i[j][p]!=-1) {
 
-                               jtom=&(atom[neighbour_i[j][p]]);
+                               jtom=&(itom[neighbour_i[j][p]]);
                                p++;
+#elif LOWMEM_LISTS
+                       p=neighbour_i[j];
+
+                       while(p!=-1) {
+
+                               jtom=&(itom[p]);
+                               p=lc->subcell->list[p];
 #else
                        this=&(neighbour_i[j]);
                        list_reset_f(this);
@@ -228,10 +244,17 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
-                                               ktom=&(atom[neighbour_i[k][q]]);
+                                               ktom=&(itom[neighbour_i[k][q]]);
                                                q++;
+#elif LOWMEM_LISTS
+                                       q=neighbour_i[k];
+
+                                       while(q!=-1) {
+
+                                               ktom=&(itom[q]);
+                                               q=lc->subcell->list[q];
 #else
                                        that=&(neighbour_i2[k]);
                                        list_reset_f(that);
@@ -267,24 +290,27 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
                Sk=params->S[brand_i];
                Sk2=params->S2[brand_i];
                /* albe needs i,k depending c,d,h and gamma values */
-               exchange->gamma_i=&(params->gamma[brand_i]);
-               exchange->c_i=&(params->c[brand_i]);
-               exchange->d_i=&(params->d[brand_i]);
-               exchange->h_i=&(params->h[brand_i]);
+               gamma_i=params->gamma[brand_i];
+               c_i=params->c[brand_i];
+               d_i=params->d[brand_i];
+               h_i=params->h[brand_i];
+               ci2=params->c2[brand_i];
+               di2=params->d2[brand_i];
+               ci2di2=params->c2d2[brand_i];
        }
        else {
                Rk=params->Rmixed;
                Sk=params->Smixed;
                Sk2=params->S2mixed;
                /* albe needs i,k depending c,d,h and gamma values */
-               exchange->gamma_i=&(params->gamma_m);
-               exchange->c_i=&(params->c_mixed);
-               exchange->d_i=&(params->d_mixed);
-               exchange->h_i=&(params->h_mixed);
+               gamma_i=params->gamma_m;
+               c_i=params->c_mixed;
+               d_i=params->d_mixed;
+               h_i=params->h_mixed;
+               ci2=params->c2_mixed;
+               di2=params->d2_mixed;
+               ci2di2=params->c2d2_m;
        }
-       exchange->ci2=*(exchange->c_i)**(exchange->c_i);
-       exchange->di2=*(exchange->d_i)**(exchange->d_i);
-       exchange->ci2di2=exchange->ci2/exchange->di2;
 
        /* dist_ik, d_ik2 */
        v3_sub(&dist_ik,&(ktom->r),&(ai->r));
@@ -307,12 +333,19 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
        /* cos theta */
        cos_theta=v3_scalar_product(&dist_ij,&dist_ik)/(d_ij*d_ik);
 
-       /* g_ijk */
+       /* g_ijk 
        h_cos=*(exchange->h_i)+cos_theta; // + in albe formalism
        d2_h_cos2=exchange->di2+(h_cos*h_cos);
        frac=exchange->ci2/d2_h_cos2;
        g=*(exchange->gamma_i)*(1.0+exchange->ci2di2-frac);
        dg=2.0*frac**(exchange->gamma_i)*h_cos/d2_h_cos2; // + in albe f..
+       */
+
+       h_cos=h_i+cos_theta; // + in albe formalism
+       d2_h_cos2=di2+(h_cos*h_cos);
+       frac=ci2/d2_h_cos2;
+       g=gamma_i*(1.0+ci2di2-frac);
+       dg=2.0*frac*gamma_i*h_cos/d2_h_cos2; // + in albe f..
 
        /* zeta sum += f_c_ik * g_ijk */
        if(d_ik<=Rk) {
@@ -341,6 +374,8 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 
 #ifdef STATIC_LISTS
                                        }
+#elif LOWMEM_LISTS
+                                       }
 #else
                                        } while(list_next_f(that)!=\
                                                L_NO_NEXT_ELEMENT);
@@ -448,10 +483,17 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
-                                               ktom=&(atom[neighbour_i[k][q]]);
+                                               ktom=&(itom[neighbour_i[k][q]]);
                                                q++;
+#elif LOWMEM_LISTS
+                                       q=neighbour_i[k];
+
+                                       while(q!=-1) {
+
+                                               ktom=&(itom[q]);
+                                               q=lc->subcell->list[q];
 #else
                                        that=&(neighbour_i2[k]);
                                        list_reset_f(that);
@@ -579,6 +621,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 
 #ifdef STATIC_LISTS
                                        }
+#elif LOWMEM_LISTS
+                                       }
 #else
                                        } while(list_next_f(that)!=\
                                                L_NO_NEXT_ELEMENT);
@@ -588,6 +632,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
                                
 #ifdef STATIC_LISTS
                        }
+#elif LOWMEM_LISTS
+                       }
 #else
                        } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
 #endif