Visualization¶
In [1]:
from eminus import Atoms, read, SCF
from eminus.extras import view, view_atoms, view_contour, view_file
In [2]:
# View the initial xyz file
mol = view_file("CH4.xyz")
mol
In [3]:
# Render the view as an image, e.g., to download it
# See the options here: https://nglviewer.org/nglview/latest/api.html#nglview.NGLWidget.render_image
mol_img = mol.render_image()
mol_img.width = "400px"
mol_img
Out[3]:
In [4]:
# Create the Atoms object
atoms = Atoms(*read("CH4.xyz"), center=True)
atoms.s = 50
In [5]:
# The calculations and writing steps have already been done, uncomment them if you want to do them for yourself
# from eminus import USCF, write_cube, write_xyz
# from eminus.extras import get_fods
# Do the DFT calculation
# scf = USCF(atoms)
# scf.run()
# Calculate FODs and write them to a xyz file
# fods = get_fods(scf.atoms)
# write_xyz(scf.atoms, "CH4_fods.xyz", fods)
# Write the density to a cube file
# write_cube(scf, "CH4_density.cube", scf.n)
# One can even display FODs or the density without writing them to files
# view_atoms(scf, fods, plot_n=True)
In [6]:
# View molecule with FODs with the GUI enabled
view_file("CH4_fods.xyz", gui=True)
In [7]:
# Display the cube file
view_file("CH4_density.cube")
In [8]:
# Use a smaller grid and display it along with the atom positions
atoms.s = [10] * 3
atoms.build()
view_atoms(atoms, atoms.r)
In [9]:
# Similar to the `write` method we can also use the `view` method of some classes
atoms.view()
In [10]:
# The view_file function can also handle lists of files
# One can use the view function to call the respective function automatically
view(["CH4_fods.xyz", "CH4_density.cube"]);
In [11]:
# Do two identical calculations for different pseudopotentials
atoms1 = Atoms("Li2", [[0, 0, 0], [0, 0, 5]], ecut=5, center=True)
atoms1.Z = 1
scf1 = SCF(atoms1)
scf1.run()
atoms3 = Atoms("Li2", [[0, 0, 0], [0, 0, 5]], ecut=5, center=True)
atoms3.Z = 3
scf3 = SCF(atoms3)
scf3.run();
In [12]:
# Display the contour lines of the density
# One can see the missing density around the atoms
view_contour(scf1, scf1.n)
In [13]:
# Here one can see the density around the atoms
view_contour(scf3, scf3.n)
In [14]:
# Adjusting the limits of the density gives a more comparable result
view_contour(scf3, scf3.n, limits=(0, 0.02))