sualization mods + adabtions
[physik/posic.git] / visual / visual.c
index 3a8f7f8..73b4941 100644 (file)
@@ -18,7 +18,7 @@
 #include "../math/math.h"
 
 /* the pse, only needed here */
-static char *pse[]={
+static char *pse_name[]={
        "*",
        "H",
        "He",
@@ -40,30 +40,56 @@ static char *pse[]={
        "Ar",
 };
 
+static char *pse_col[]={
+       "*",
+       "White",
+       "He",
+       "Li",
+       "Be",
+       "B",
+       "Gray",
+       "N",
+       "Blue",
+       "F",
+       "Ne",
+       "Na",
+       "Mg",
+       "Al",
+       "Yellow",
+       "P",
+       "S",
+       "Cl",
+       "Ar",
+};
+
 int visual_init(t_visual *v,char *filebase) {
 
        char file[128+8];
 
        strncpy(v->fb,filebase,128);
        memset(file,0,128+8);
-       sprintf(file,"%s/visualize.scr",v->fb);
+       //sprintf(file,"%s/visualize.scr",v->fb); // obsolete!
 
+       /* obsolete!
        v->fd=open(file,O_WRONLY|O_CREAT|O_EXCL,S_IRUSR|S_IWUSR);
        if(v->fd<0) {
                perror("open visual fd");
                return -1;
        }
        dprintf(v->fd,"set write on\n");
+       */
 
        return 0;
 }
 
 int visual_tini(t_visual *v) {
 
+       /* obsolete!
        if(v->fd) {
                dprintf(v->fd,"quit\n");
                close(v->fd);
        }
+       */
 
        return 0;
 }
@@ -73,13 +99,15 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        int i,fd;
        char file[128+64];
        t_3dvec dim;
+       double help;
 
        dim.x=v->dim.x;
        dim.y=v->dim.y;
        dim.z=v->dim.z;
 
-       //sprintf(file,"%s/visualize_%07.f.xyz",v->fb,time);
-       sprintf(file,"%s/povray_%07.f.in",v->fb,time);
+       help=(dim.x+dim.y);
+
+       sprintf(file,"%s/atomic_conf_%07.f.xyz",v->fb,time);
        fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
        if(fd<0) {
                perror("open visual save file fd");
@@ -87,6 +115,7 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        }
 
        /* script file update */
+       /* obsolete!
        dprintf(v->fd,"load xyz %s\n",file);
        dprintf(v->fd,"spacefill 200\n");
        dprintf(v->fd,"rotate x 100\n");
@@ -98,17 +127,19 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        sprintf(file,"%s/visualize_%07.f.ppm",v->fb,time);
        dprintf(v->fd,"write ppm %s\n",file);
        dprintf(v->fd,"zap\n");
+       */
 
        /* write the actual data file */
        //dprintf(fd,"%d\n",(dim.x==0)?n:n+8);
-       dprintf(fd,"# [C] %d\n",n);
-       dprintf(fd,"# [T] %07.f\n",time);
-       dprintf(fd,"# [L] <%f,%f,%f>\n",-1.0*dim.x/4.0,
-                                       1.5*dim.y,1.5*dim.z);
+       dprintf(fd,"# [P] %d %07.f <%f,%f,%f>\n",
+               n,time,help/40.0,help/40.0,-0.8*help);
        for(i=0;i<n;i++)
-               dprintf(fd,"0.5 %f %f %f\n",atom[i].r.x,
-                                           atom[i].r.y,
-                                           atom[i].r.z);
+               dprintf(fd,"%s %f %f %f %s %f\n",pse_name[atom[i].element],
+                                                atom[i].r.x,
+                                                atom[i].r.y,
+                                                atom[i].r.z,
+                                                pse_col[atom[i].element],
+                                                atom[i].ekin);
        if(dim.x) {
                dprintf(fd,"# [D] %f %f %f %f %f %f\n",
                        -dim.x/2,-dim.y/2,-dim.z/2,