posic: $(OBJS) moldyn.o
        $(CC) $(CFLAGS) -lm -o $@ $(OBJS) $(LIBS) posic.c
 
+.PHONY:clean
 clean:
        rm -f *.o posic */*.o
 
        params=moldyn->pot_params;
        atom=moldyn->atom;
        count=moldyn->count;
-       eps=params->epsilon;
+       eps=params->epsilon4;
        sig6=params->sigma6;
        sig12=params->sigma12;
 
                        help=d*d;                               /* 1/r^4 */
                        help*=d;                                /* 1/r^6 */
                        d=help*help;                            /* 1/r^12 */
-                       u+=eps*(sig12*d-sig6*help);
+                       u+=eps*(sig6*help-sig12*d);
                }
        }
        
        atom=moldyn->atom;      
        count=moldyn->count;
        params=moldyn->pot_params;
-       eps=params->epsilon;
+       eps=params->epsilon4;
        sig6=params->sigma6;
        sig12=params->sigma12;
 
                                h1*=h2;                         /* 1/r^14 */
                                h1*=sig12;
                                h2*=sig6;
-                               d=12.0*h1-6.0*h2;
+                               /* actually there would be a '-',       *
+                                * but f=-d/dr potential                */
+                               d=-12.0*h1+6.0*h2;
                                d*=eps;
                                v3_scale(&force,&distance,d);
-                               v3_add(&(atom[j].f),&(atom[j].f),&force);
-                               v3_sub(&(atom[i].f),&(atom[i].f),&force);
+                               v3_add(&(atom[i].f),&(atom[i].f),&force);
+                               v3_sub(&(atom[j].f),&(atom[j].f),&force);
                        }
                }
        }
 
        //t_list vicinity       /* verlet neighbour list */
 } t_atom;
 
+#include "visual/visual.h"
+
 typedef struct s_moldyn {
        /* atoms, amount, dimensions */
        int count;
 typedef struct s_lj_params {
        double sigma6;
        double sigma12;
-       double epsilon;
+       double epsilon4;
 } t_lj_params;
 
 /*
 
        vis.dim.y=b*LC_SI;
        vis.dim.z=c*LC_SI;
 
-       /* init lattice
+       /* init lattice */
        printf("placing silicon atoms ... ");
        count=create_lattice(DIAMOND,SI,M_SI,LC_SI,a,b,c,&si);
-       printf("(%d) ok!\n",count); */
-       /* testing purpose */
+       printf("(%d) ok!\n",count);
+       /* testing purpose
        count=2;
        si=malloc(2*sizeof(t_atom));
-       si[0].r.x=0.35*sqrt(3.0)*LC_SI/2.0;
+       si[0].r.x=0.23*sqrt(3.0)*LC_SI/2.0;
        si[0].r.y=0;
        si[0].r.z=0;
        si[0].element=SI;
        si[1].r.z=0;
        si[1].element=SI;
        si[1].mass=M_SI;
-       /* */
+       */
 
        /* moldyn init (now si is a valid address) */
        md.count=count;
        md.visual=&vis;
 
        printf("setting thermal fluctuations (T=%f K)\n",md.t);
-       //thermal_init(&md,&random,count);
-       for(a=0;a<count;a++) v3_zero(&(si[0].v));
-       //v3_zero(&(si[0].v));
-       //v3_zero(&(si[1].v));
+       thermal_init(&md,&random,count);
+       //for(a=0;a<count;a++) v3_zero(&(si[0].v));
 
        /* check kinetic energy */
 
        help=lj.sigma6*lj.sigma6;
        lj.sigma6*=help;
        lj.sigma12=lj.sigma6*lj.sigma6;
-       lj.epsilon=LJ_EPSILON_SI;
+       lj.epsilon4=4.0*LJ_EPSILON_SI;
 
        ho.equilibrium_distance=0.25*sqrt(3.0)*LC_SI;
-       ho.spring_constant=LJ_EPSILON_SI;
+       ho.spring_constant=4.0*LJ_EPSILON_SI;
 
        u=get_e_pot(&md);
 
 
--- /dev/null
+./clean
+./posic $@
+if [ "$?" == "0" ]; then
+       ./perms
+       argv="`echo $@ | grep -- '-V'`"
+       if [ "$argv" ] ; then
+               base=`echo $argv | awk -F'-V' '{ print $2 }' | \
+                       awk '{ print $2 }'`
+               rasmol -nodisplay < ${base}.scr
+               ./ppm2avi
+       fi
+fi
 
 #include "../moldyn.h"
 #include "../math/math.h"
 
+/* the pse, only needed here */
+static char *pse[]={
+       "*",
+       "H",
+       "He",
+       "Li",
+       "Be",
+       "B",
+       "C",
+       "N",
+       "O",
+       "F",
+       "Ne",
+       "Na",
+       "Mg",
+       "Al",
+       "Si",
+       "P",
+       "S",
+       "Cl",
+       "Ar",
+};
+
 int visual_init(t_visual *v,char *filebase) {
 
        char file[128+8];
                perror("open visual fd");
                return -1;
        }
+       dprintf(v->fd,"set write on\n");
 
        memset(&(v->dim),0,sizeof(t_3dvec));
 
 
 int visual_tini(t_visual *v) {
 
-       if(v->fd) close(v->fd);
+       if(v->fd) {
+               dprintf(v->fd,"quit\n");
+               close(v->fd);
+       }
 
        return 0;
 }
        dim.y=10e9*v->dim.y;
        dim.z=10e9*v->dim.z;
 
-       char pse[19][4]={
-               "*",
-               "H",
-               "He",
-               "Li",
-               "Be",
-               "B",
-               "C",
-               "N",
-               "O",
-               "F",
-               "Ne",
-               "Na",
-               "Mg",
-               "Al",
-               "Si",
-               "P",
-               "S",
-               "Cl",
-               "Ar",
-       };
-
        sprintf(file,"%s-%.15f.xyz",v->fb,time);
        fd=open(file,O_WRONLY|O_CREAT|O_TRUNC);
        if(fd<0) {
 
        /* script file update */
        dprintf(v->fd,"load xyz %s\n",file);
-       dprintf(v->fd,"spacefill 300\n");
+       dprintf(v->fd,"spacefill 270\n");
        dprintf(v->fd,"rotate x 100\n");
        dprintf(v->fd,"rotate y 10\n");
        dprintf(v->fd,"set ambient 20\n");
 
 #include "../moldyn.h"
 #include "../math/math.h"
 
+/* datatypes */
+
 typedef struct s_visual {
        int fd;                 /* rasmol script file descriptor */
        char fb[128];           /* basename of the save files */
        t_3dvec dim;            /* dimensions of the simulation cell */
 } t_visual;
 
-
 /* function prototypes */
 
 int visual_init(t_visual *v,char *filebase);
 int visual_atoms(t_visual *v,double time,t_atom *atom,int n);
 
 #endif
+
+