Iso-surfaces from data in a cube-file or a gpw-file can be visualized using
Mayavi from the command line like shown
It’s a good idea to create a short alias like this:
$ alias iso="python3 -m ase.visualize.mlab -C gpaw"
so that you can simply do:
$ iso CO.cube # plot cube file $ iso slab-4.gpw # plot electron density from gpw-file $ iso slab-4.gpw -n 15 # plot wave function from gpw-file $ iso -h # help!
If you want to plot an x-y plot from data in a csv-file (comma separated values), you can use gnuplot:
$ gnuplot gnuplot> plot "abc.csv" using 1:2
Alternatively, use this little
import sys import numpy as np import matplotlib.pyplot as plt for filename in sys.argv[1:]: a = np.loadtxt(filename, delimiter=',').T x = a for y in a[1:]: plt.plot(x, y, '-') plt.show()
$ python3 <path-to-script>/xy.py abc.csv
This can be done from Python using the
from ase.io import write write('abc.cube', atoms, data=data)
Square roots are calculated like this:
sqrt function must first be imported:
from math import sqrt or
from numpy import sqrt).
/ is used for both integer- and float
divisions. Integer division is only performed if both sides of the
operator are integers (you can always force an integer division by
>>> 1 / 3 0 >>> 1 / 3.0 0.33333333333333331
The = operator in Python is not and assignment operator, it is a naming operator: It makes a new name for (reference to) the object:
a = [1, 2, 3, 4, 5] # Create a list b = a # New name for list a = 42 print(b) # [1, 2, 42, 4, 5] c = 7 d = c c += 42 # d is still 7, we just did # c = c + 42 # creating a new object 49 and # giving it the name c
You can save plots made with matplotlib by pressing the floppy-disk icon in the bottom of the plot, and save as a .png file.
You can save a picture of the atoms from ASE’s GUI by choosing Save, and then specify a .png file.
You can view .png files in the databar with the command