0
$\begingroup$

I am trying to visualize some electronic flux data for a quantum mechanical system. I have a file containing electronic flux values and coordinates for different timesteps in a quantum mechanical scattering process. The coordinates are constant and fixed on a sphere for all timesteps (columns 4,5,6), whereas the electronic flux values changes for each column corresponding to the next timestep: column 7 = timestep 2, column 8 = timestep 40 etc.

I whish to visualize every timestep as a spherical colormap. For this I found a way on another thread: Smooth 4D (3D + color) plot from discrete points

Now my troubles have been to generalize this into a function exporting this image for a running number of columns, which I could call using Map[F[j]] to save an image for each timestep.

My code is as follows:

`(*Import document columns 4,5,6 for coordinates x, y, z and columns 7 \
and further for flux data for timestep 20, 4, 60 etc*)
SetDirectory[NotebookDirectory[]];
list1 = Import["fluxmpnew.dat" , {"Data", All, {4, 5, 6}}];
list2 := Import["fluxmpnew.dat" , {"Data", All, {7, 8, 9}}];
listxyz2 = Take[list1, {1, -1}];

listxyz = ToExpression[listxyz2];
Nelements = Length[listxyz];
xList = listxyz[[All, 1]];
yList = listxyz[[All, 2]];
zList = listxyz[[All, 3]];

(*Function plotting and exporting a 3d surface plot of the fluxdata \
running for all timesteps*)

f[j_] := (  
Ncols := Length[list2[[1, All]]];
listflux2 := Take[list2[[All, j]], {1, -1}];
listflux := ToExpression[listflux2];


data := 
Table[{xList[[i]], yList[[i]], zList[[i]], listflux[[i]]}, {i, 1, 
 Nelements}];
(*datat=Table[data[[i,4]],{i,1,Length[data]}];*)

nf := Nearest[data[[All, {1, 2, 3}]] -> Rescale[data[[All, 4]]]];

colfun := ColorData["Rainbow"]@First@nf[{#1, #2, #3}] & ;


s1 := ListSurfacePlot3D[data[[All, {1, 2, 3}]], 
MaxPlotPoints -> 200, BoxRatios -> Automatic, 
ColorFunction -> colfun, ColorFunctionScaling -> False, 
ViewPoint -> {0, -2, -2}];
Export["td." <> ToString[j*20 - 120] <> ".png", s1]

)
Map[f[j], {j, 1, 2, 3, 4}]`

link to data file: https://www.dropbox.com/s/rjrtvqrb0efz2sg/fluxmpnew.dat?dl=0

I hope that you can help me.

$\endgroup$
  • $\begingroup$ For a start, that last Map expression is not how Map works. You are confusing it with the syntax for Table. I suppose you want either Table[f[j], {j, 1, 4}] or Map[f, Range[4]]. We cannot really evaluate the rest because you didn’t provide the data you are using. $\endgroup$ – MarcoB May 25 '18 at 11:48
  • $\begingroup$ I couldn't find a way to attach data files so I have made a link to the files location in dropbox: dropbox.com/s/rjrtvqrb0efz2sg/fluxmpnew.dat?dl=0 $\endgroup$ – Andreas Alberg Foldrup May 27 '18 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.