Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Charge Density Visualization

The Charge Density module allows for the visual analysis of 3D volumetric data generated by ab-initio codes, specifically targeting VASP CHGCAR formats. This tool bridges the gap between raw electronic structure outputs and qualitative chemical bonding analysis.

The window has two pages, chosen at the top: Slice (2D) and 3D Isosurface. Both use the files, difference mode and density channel selected on the right; every change applies immediately to both. The sliders you drag to shape the picture sit in a bar under the view and change with the page: slice position (or hkl offset) and number of isolines for the slice; the |ρ| histogram, isovalue and opacity for 3D.

Core Features

2D Slice Extraction

The Slice page uses a high-precision 2D slice extraction technique coupled with a marching squares algorithm for isoline generation.

Slices can be defined in two ways:

  1. Crystallographic Planes: Fast slicing perpendicular to the primary lattice vectors (XY, XZ, YZ planes) at a specific fractional coordinate.
  2. Miller Planes: General slicing along any $(hkl)$ index. The internal engine interpolates the 3D grid data onto the specified arbitrary plane.

Density Channels

For spin-polarized calculations, CView supports extracting specific electronic components:

  • Total Density: Standard $\rho_{up} + \rho_{down}$.
  • Spin-Up / Spin-Down: Isolated individual spin channels.
  • Magnetization: The difference $\rho_{up} - \rho_{down}$. This channel automatically applies a diverging colormap to clearly delineate positive and negative magnetic moments.

Difference Density Maps

A powerful feature of the module is the Difference Mode. You can load two distinct CHGCAR files (e.g., a combined system and an isolated adatom) to compute and visualize charge transfer.

The software calculates $\Delta\rho(r) = \rho_A(r) - \rho_B(r)$ on the fly, allowing you to visually identify regions of electron accumulation and depletion.

Tip

CView utilizes Cairo for high-fidelity 2D rendering. When a slice is drawn, atoms near the slice plane are geometrically projected onto the 2D canvas, using standard CPK colors for easy chemical identification.

Exporting

Slices can be instantly exported as high-resolution png or pdf images directly from the visualization tab, complete with isolines, heatmaps, and atomic projections.

The Export Data (NumPy .npy) action also saves the raw 2D slice as a float64 NumPy array with a JSON sidecar containing the axis extents and labels.

Export Configuration: Settings (font sizes, colorbar tick labels, line thickness) are read live from the Preferences dialog at the moment you click export — not when the window opens. This ensures your exports always match your current preferences.


3D Isosurfaces

The 3D Isosurface page draws isosurfaces of the density together with the atoms and cell, on the GPU (OpenGL 3.3). In this mode the right-hand pane shows the 3D controls.

Surfaces

  • Isovalue in e/ų: the logarithmic slider for exploring, the box for an exact value, or a click on the |ρ| histogram under the view.
  • Set by enclosed charge: choose the fraction of the electrons the surface should enclose (e.g. 50%) and CView finds the isovalue. This compares across systems in a way an absolute isovalue does not.
  • Lobes: +, − or ± (difference and spin densities are detected and shown as ± automatically), with opacity and a colour for each sign.
  • Ambient occlusion darkens crevices and contacts between lobes and atoms, which makes the shape readable in print.
  • Presets set lobes, colours and an enclosed-charge isovalue for total density, bonding/difference maps and spin density.

Surfaces are watertight (no pinholes) and continue seamlessly across cell faces. They are recomputed in the background as you move the slider.

Section plane and cut-away

Section plane draws the density on any $(hkl)$ plane, coloured on a logarithmic scale (or blue–white–red for difference and spin densities) with a contour at the isovalue. Cut away beyond the plane removes surfaces and atoms on one side, so the section becomes the cut face.

Numbers

The view lists the electrons and volume inside each lobe. Report Enclosed Charge writes them, the isovalue and ∫ρ dV over the cell to Structure Info.

Figures for publication

Export Figure… produces a journal-ready image:

  • Pick a journal width (Nature 89/183 mm, Science, ACS) or any size in mm, and 300–1200 dpi (600 dpi is recommended for figures with text). A red frame on the view shows the exported area; Fit to Frame fills it.
  • Fonts and lines are set in points at final size (Nature asks for 5–7 pt); the dialog warns if a Nature figure is taller than 170 mm.
  • PDF / SVG contain the picture at full resolution with the title, isovalue key, colour bar, axes, scale bar and panel letter as vector text, editable in Illustrator or Inkscape. PNG / TIFF carry the dpi, so they open at print size.
  • Transparency is rendered exactly, edges are supersampled, and the background can be transparent for assembling multi-panel figures.
  • A scene file (.cview.json) is saved next to every figure. Load Scene… restores the view, isovalue and all settings, so a requested change is quick to make.

Export Mesh writes the surfaces as OBJ (with colours) or PLY for Blender or ParaView.

Advanced Features

Picture-in-Picture 3D Preview

When viewing a 2D slice, CView displays a 3D miniature of the full crystal structure in the corner of the canvas. This preview shows:

  • The complete unit cell with atoms rendered
  • The orientation of the current slice plane highlighted
  • Real-time updates as you change the slice position or Miller indices

Purpose: Helps maintain spatial context when inspecting arbitrary $(hkl)$ planes — you always know where the slice is cutting through the structure.

Location: Top-right corner of the charge density window (semi-transparent overlay).

HKL Plane Polygon Clipping

For Miller plane slices (non-orthogonal cuts), CView computes the exact intersection polygon:

Example: In a cubic cell, the $(111)$ plane intersects three edges → triangular slice region

Implementation:

  • Computes plane-cell boundary intersections geometrically
  • Clips the heatmap and isolines to the polygon boundary
  • Renders the polygon outline for clarity

This ensures the 2D visualization accurately reflects the crystallographic geometry, not just a rectangular crop.

Visual cue: The slice boundary polygon is drawn in a contrasting color (e.g., white on dark background).