Visualizing Files

Visualizing Files

Structure

There is no GUI on the cluster itself. To view the outputs below, either run the copy the necessary files to your local machine and run the commands there or follow the Princeton Research Computing  instructions  for using GUI applications on the cluster.

Trajectory

To view an optimization trajectory (structure, energy, and forces vs. geometry step) using ASE:
from ase.io import read
from ase.visualize import view

atoms = read("OUTCAR", index=":")
view(atoms)
Alternatively, from the command-line on your local machine or a visualization node:
ase gui OUTCAR

Final Structure

The easiest option is to simply click-and-drag the structure into VESTA!
To view the final structure via Python using ASE:
from ase.io import read
from ase.visualize import view

atoms = read("CONTCAR")
view(atoms)
Alternatively, from the command-line:
ase gui CONTCAR

Charge Density

Click-and-drag the CHGCAR into VESTA. That's it!

Density of States

Using  sumo , run sumo-dosplot in a folder containing the vasprun.xml.
Alternatively, in Pymatgen, do the following:
import matplotlib.pyplot as plt
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.plotter import DosPlotter

sigma = 0.1 # smooth out the DOS
vr = Vasprun("vasprun.xml")

dos = vr.complete_dos
dos.densities = dos.get_smeared_densities(0.1)

x = dos.energies - dos.efermi
y = dos.get_densities()
plt.plot(x, y, color="k")
plt.xlabel("E - Ef (eV)")
plt.ylabel("DOS (a.u.)")
plt.show()
or a slightly more stylized version: Sparkles
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.core import Spin
import matplotlib.pyplot as plt
from pymatgen.electronic_structure.plotter import DosPlotter
from matplotlib.ticker import AutoMinorLocator
import numpy as np

vasprun = Vasprun("vasprun.xml")
dos = vasprun.complete_dos
energies = dos.energies - dos.efermi
element_dos = dos.get_element_dos() # {Element: Dos}

# --- Colors per element: customize as needed ---
element_colors = {
"Na": "#6667ff",
"C": "#ff6666",
"H": "#66cc66",
"O": "#face48"
}
fig, ax = plt.subplots(figsize=(7, 6))

# --- Total DOS (background, spin-polarized, gray) ---
# sigma is a smearing parameter, adjust based on desired smoothness
total_up = gaussian_filter1d(dos.densities[Spin.up], sigma=50)
total_down = -gaussian_filter1d(dos.densities[Spin.down], sigma=50)

ax.plot(energies, total_up, color="black", linewidth=1.5, zorder=1, label="Total")
ax.plot(energies, total_down, color="black", linewidth=1.5, zorder=1)
ax.fill_between(energies, total_up, 0, alpha=0.1, color="gray", zorder=1)
ax.fill_between(energies, total_down, 0, alpha=0.1, color="gray", zorder=1)

# --- Elemental PDOS (foreground) ---
#math sigmas for realistic plots, otherwise split yaxis
for element, dos_obj in element_dos.items():
el = str(element)
color = element_colors.get(el, "gray")

y_up = gaussian_filter1d(dos_obj.densities[Spin.up], sigma=50)
y_down = -gaussian_filter1d(dos_obj.densities[Spin.down], sigma=50)

ax.plot(energies, y_up, color=color, linewidth=1.5, label=el, zorder=3)
ax.plot(energies, y_down, color=color, linewidth=1.5, zorder=3)
ax.fill_between(energies, y_up, 0, alpha=0.15, color=color, zorder=3)
ax.fill_between(energies, y_down, 0, alpha=0.15, color=color, zorder=3)

ax.axvline(x=0, color="black", linewidth=1.5, zorder=2)
ax.axhline(y=0, color="black", linewidth=1.0, zorder=1)

ax.set_xlabel(r"$E - E_{\mathrm{f}}$ (eV)", fontsize=24)
ax.set_ylabel(r"DOS (arb. units)", fontsize=24)



# center on zero
lim = max(abs(np.min([total_up, total_down])), np.max([total_up, total_down]))
ax.set_ylim(-lim, lim)

ax.text(0.02, 0.97, r"spin $\uparrow
quot;
, transform=ax.transAxes, va="top", fontsize=16)
ax.text(0.02, 0.03, r"spin $\downarrow
quot;
, transform=ax.transAxes, va="bottom", fontsize=16)

ax.tick_params(axis="both", which="major", labelsize=16, length=8, width=1.5, direction="inout")
ax.tick_params(axis="both", which="minor", length=4, width=1, direction="inout")
ax.xaxis.set_minor_locator(AutoMinorLocator())
ax.yaxis.set_minor_locator(AutoMinorLocator())

for spine in ax.spines.values():
spine.set_linewidth(2)

ax.legend(fontsize=16, framealpha=0.8, edgecolor="gray", bbox_to_anchor=(0.735, .999), loc="upper left")
#adjust based on your DOS plot what area you want to focus on
ax.set_xlim([-8, 3])
ax.set_ylim([-20, 20])
plt.tight_layout()
plt.show()