Grid and geometry viewer: GV

Grid/Geometry Viewer/Editor (GV) is an OpenGL based code for visualization of molecular orbitals and densities, density differences and spin-densities, and visualization of molecular structures (with the possibility to manipulate them on the screen), and visualization of some properties.
The name should not be confused with gv (aka ghostview).

GV is built from source with a standard C compiler (GCC or Clang) and requires OpenGL, GLU, and freeglut development libraries. Three STB single-header libraries (stb_image_write.h, stb_truetype.h, stb_easy_font.h) are downloaded automatically by make if not present (curl or wget required).

Linux (Debian / Ubuntu):

sudo apt install freeglut3-dev libglu1-mesa-dev fonts-dejavu
make

macOS (Homebrew):

brew install freeglut
make

Windows (MSYS2 / MinGW64):

pacman -S mingw-w64-x86_64-freeglut
make

Cross-compile Linux → Windows:

sudo apt install gcc-mingw-w64-x86-64
make windows     (set FREEGLUT_PREFIX if freeglut is not in the default MinGW sysroot)

For headless / server-side rendering without a display see the OSMesa build section below. For in-browser use see the WebAssembly build section below.

GV can operate with different kinds of files:

If a file name is specified in a command line, GV will determine the type of the file, and switch to the appropriate mode. If no file is specified, GV will search the current directory for files with a known type.

Command line parameters for GV

Command

Purpose

filename

: name of a grid file, XYZ file, molden file, CIF file, or MOLCAS SEWARD/GATEWAY input file. If this parameter is omitted program will try to find a first relevant file in the current directory.

-h

display help information

-n filename

create an empty XYZ file

-d real

set an initial size for the molecule

-f filename

set the basename of output files (.xyz, .tga, .eps, .pov). By default the basename is taken from the filename.

-s integer

Set initial size for the screen.

-z

Force coordinate-editing mode (is_coord=2), even if the file has no unit cell. Useful for XYZ files where auto-detection picks the wrong mode.

-m

Start in animation mode (same as pressing m key on startup).

-w

Draw isosurface as wireframe instead of solid.

-v

Load saved viewpoint from .ViewPoint file on startup; or compute an automatic best viewpoint if no file exists.

-q

Batch/headless mode: render and save PNG image(s), then exit. No window is opened. Typically used with the OSMesa build and the -o flag. Example: gv -q -o all molecule.lus

-S

Reset all saved settings: delete the .molcasgv configuration directory and restart with defaults.

--record filename

Record all keyboard, mouse and menu events to filename for later playback. See the Record/Playback section below.

--play filename

Play back a previously recorded session from filename. The file may also contain script commands (speed, wait, open, status, echo). See the Record/Playback section below.




The rest of command line parameters have meaning only for displaying grid files:

Command

Purpose

-l real

: set initial isolevel value

-i real

: set increment value for changing isovalue

-t real

: set transparency level (between 0.0 and 1.0) for isosurfaces

-b color

: set initial background color ( white|gray|black)

-o integer

: set the number of initial orbitals (by default: display density)

filename2

: name of a second grid file to display a density difference

-a real

: a weight of second grid. The default is -1 (to calculate density difference).

--minus

: shorthand for -a -1 (density difference, grid1 − grid2).

--plus

: shorthand for -a 1 (sum of two grids).

--same-space

: allow combining two grids that share the same coordinate space but have different mesh resolutions. Grid1 is trilinearly resampled onto grid2’s mesh before the linear combination. Without this flag the program aborts if grid sizes differ.

--align

: combine two grids whose atoms are in the same order but at slightly different positions (e.g. two steps of a geometry optimisation or IRC path). A Kabsch rigid-body alignment (optimal rotation + translation) is computed from the matched atom pairs and used to resample grid2 onto grid1’s coordinate frame before forming the linear combination. The output grid is on grid1’s mesh and carries grid1’s atom positions. The program aborts if any atom displacement exceeds the tolerance (default 2 Å; see --align-tol). The alignment RMSD is printed to stderr.

--align-tol real

: maximum allowed atom displacement in Ångström when using --align. Default is 2.0. Set to 0 to skip the check entirely.

--out filename

: specify output file name for a grid constructed with -a option.

--version

: print the version number

-o N | all | list

: select which orbital(s) to display or export in batch mode. -o 3 selects orbital 3 (1-based), -o all selects all orbitals, -o 1,3,5 selects a comma-separated list. In interactive mode this sets the initial orbital. In batch mode (-q) each orbital is saved as a separate PNG.

--findsym

: run the built-in findsym symmetry utility and exit. Only available in builds compiled with USE_FINDSYM.



For an advanced configuration of GV one can save the current configuration (F9 key), and edit the ASCII formatted configuration files. The configuration files are located in the subdirectory .molcasgv in the user home directory:

The main control of GV can be done by the mouse: the left mouse button is used to rotate the grid or the molecule, right mouse button is used for the on-screen menu. The major operations from menus can also be performed by hot-keys. Note, that behavior of GV, e.g. on-screen menus and hot-keys is different for the different types of visualized files.

Some keys like PageUp/PageDown, plus/minus have different meaning in different modes, with a general rule - plus/minus changes a value, PageUp/PageDown changes a property of selected item.

Note for Mac users. To press functional keys (F1-F10) you have to use 'fn' button. Insert button (missing on Mac keyboard) can be emulated by 'I' key. For more control, set up key remapping table.

General HotKeys.

Command

Purpose

Ctrl-Q

Quit

F10

Exit (exit implies possible back up of edited files).

Escape

unset different editing modes

F1

Display context-dependent help screen (with a list of hot-keys for the current mode: orbital/grid, coordinate, or molden). Press F1 again to scroll to additional pages.

q/Q

decrease/increase quality of drawing

F2

save INPORB file (lus/grid mode) or XYZ coordinates (all other modes); in lus/grid mode Shift-F2 saves atoms as a new XYZ file

F9

Save current settings

Shift+F9

Edit colors for background, labels, orbitals and extra planes.

r/R/g/G/b/B

Interactively change RGB code for the background, labels, and orbitals (selected by Shift-F9 key)

F5

Print screen in tga format. The output files will be named as filename000.tga

Shift+F5

Print screen in PostScript format. The output files will be named as filename000.eps

P

Print screen in PostScript (level 2) format.

p

Save povray file.

z/Z

Zoom the grid or the molecule

x

Maximize the screen

v/V

Create/restore .ViewPoint file (viewing conditions)

Home

Move the molecule to the center of the screen

Up/Down/Left/Right

Move the position of the picture on screen (with shift - make bigger steps)

l

Switch to/from the mode: move the light position with the mouse.

w

Switch between grey-scale and colored picture

m

Start/stop animation

W

Switch to Tee time mode

F

Cycle font rendering mode: GLUT bitmap → stb_easy_font → TrueType. Affects all on-screen text labels and status line. (Not available in the WebAssembly build.)

Ctrl-A

Toggle alternate modifier flag. Use this if Shift or Ctrl appears to be “stuck” after a modifier key was not released properly.

Hot keys in Grid Mode.

Command

Purpose

+/-

increase/decrease the isosurface value (the step and initial value can be modified by command line parameters)

PageUp/PageDown

display next/previous orbital. In multiview mode (F3 has been pressed), use magnify glass.

t/T

change transparency level

f/i/1/2(a)/3/s/d

change the type of the current orbital to frozen, inactive, RAS1, RAS2, RAS3, secondary, deleted.

Space/middle mouse

change the type of the current orbital (by loop)

F2

save INPORB file (file will be saved as filename.GvOrb); Shift-F2 saves the atom coordinates as a new XYZ file

F3

Switch to/from multiview mode. In multiview mode the orbital type is shown by different backgrounds (rainbow colors). User can modify the type of orbitals, by pressing middle mouse button (or Space).

F4

Enter an isovalue (if a number was typed), or an orbital number (# n m - to display orbital with symmetry n and number m), or create a filter (for more information check tutorial for GV).

Delete

Hide the orbital from the list

Insert

Restore all hidden orbitals

If GV is used to display a molecule, it is possible to make a selection of an atom, a bond, an angle, or a dihedral angle by clicking (by left mouse button) on the atom. First selected atom will be displayed with a blue colored net, the rest (for bond and angle) with a magenta colored net. Using hot keys it is possible to make modification of the selected part of the structure. In addition to selection (note that only 4 atoms can be selected), it is possible to highlight a group of atoms. Highlighting is made either by mouse (is Shift button is hold), or by keyboard (F7 button). Highlighted atoms can be modified as a single unit - e.g. rotated, moved. To remove current selection - press middle mouse button or space. If user has both selected and highlighted atoms - the first press of space button will unselect 'selected', and the second one - unhighlight atoms.

 GV can understand an extended syntax of XYZ file, and draw additional elements: axises, polygons, etc.

Hot keys available when atoms are loaded (XYZ, Molden atoms, or lus file).

Command

Purpose

F2

Save coordinates (file will be saved as filename000.xyz)

Shift-F2

Save coordinates (overwrite the file)

left mouse

select an atom by clicking on it.

left mouse + shift

highlight an atom

drag left mouse + shift pressed, followed by left click

highlight atoms in the rectangular area

F3

display menu with molecular fragments.


Hot keys in if no atoms are selected

Command

Purpose

+/-

change a size of atoms and bonds

Insert

add an atom, or last inserted fragment

End

add dummy atoms (reference points, symbol Z or Bq) on the direction of axis. Dummy atoms are invisible and excluded from bounding box and center-of-mass.

a

Mark hydrogen atoms in the molecule

F8

analyze the symmetry of the molecule and display symmetry elements.

Delete

delete all dummy atoms (Z or Bq)

Home

Move the molecule to the center of screen

*

Reverse the selection

#

if several atoms are highlighted, sort them, and place into the beginning of xyz file.

C

Generate concentric-shell clusters from a periodic structure (XYZ, Molden, or lus file with unit cell vectors). The selected atom (or the origin if none is selected) is placed at the center. Clusters are written to _clusters.molden, with the largest cluster first. Cell axes are removed after generation.

M

Run MOPAC geometry optimization on the current XYZ file. Requires the $MOPAC environment variable to be set to the MOPAC binary path. The optional $MOPAC_KEYWORDS variable selects the method (default: PM6). Optimized coordinates overwrite the current XYZ file. (Not available in the WebAssembly build.)

Backspace

Undo the last geometry change.

F6

Enable watch mode: automatically reload the current file whenever it changes on disk (useful for following an ongoing calculation). Shift-F6 disables watch mode.

F12

Insert atom (same as the Insert key).

k / K

Dump SLAPAF constraint indices (k) or plain atom indices (K) to the status line. Useful for preparing MOLCAS geometry constraint input.


Hot keys in Selection mode (1 atom is selected)

Command

Purpose

Space/middle mouse

remove selection.

F3

display a menu with fragments, to be inserted close to selected atom

Insert

add an atom (or last selected fragment) near selected atom

Delete

delete selected atom

Home

place the origin to the position of selected atom

PageUp/PageDown

Change selected atom to one from the list (H,C,N,O,F,S,Cl)

F4 or =

invoke an edit box, where you can type an element name for selected atom.

F7

Mark atoms connected to the selected atom.

a

Mark all atoms which are the same elements as selected

F8

apply Inversion symmetry around selected atom

+/-

desaturate the color of the atom


Hot keys in Selection mode for bond (2 atoms are selected)

Command

Purpose

Space/middle mouse

remove selection.

Insert

create a bond between selected atoms

Delete

delete the bond between selected atoms

PageUp/PageDown

change the type of the bond between atoms

+/-

change the distance between atoms. Note that first selected atom (blue) will move.

F4 or =

invoke an edit box, where you can type an interatomic distance

F7

Mark all connected atoms around the first atom in a selected bond into a group.

F8

apply translation by the axis specified by selected atoms.

F6

Watch the value of selected bond

#

Change the order of selected atoms

v

toggle behavior of F8: use C2 symmetry instead of translation


Hot keys in Selection mode for angle (3 atoms are selected)

Command

Purpose

Space/middle mouse

remove selection.

+/-

change the angle between selected atoms. Note that first selected atom (blue) will move.

PageUp/PageDown

change the angle according to 'standard' angle values (by loop)

F4 or =

invoke an edit box, where you can type an angle value (or, you may type the value directly)

F8

apply mirror symmetry around an plain specified by selected atoms.

F6

Watch the value of selected angle

3

draw a triangle between points

4

Draw a plane

Hot keys in Selection mode for dihedral angle (4 atoms are selected)

Command

Purpose

Space/middle mouse

Remove selection.

+/-

Change the dihedral angle between selected atoms. Note that first selected atom (blue) will move.

F4 or =

Invoke an edit box, where you can type a dihedral angle value (or, you may type the value directly)

F6

Watch the value of selected angle

F7

Mark atoms located at other side from the plane defined by selected atoms 2-3-4, in comparison to atom 1

F7+Shift

Use selected atoms as a cell, and highlight atoms outside this cell

6

Draw a cell, using selected atoms as axis definition. First atom indicate the origin.



Hot keys in Molden mode for a orbital file (e.g. scf.molden)

Command

Purpose

PageUp/PageDown

Display charges


Hot keys in Molden mode for a frequency file

Command

Purpose

PageUp/PageDown

Load next/previous vibration mode

F3

Draw graphical information in a separate window.

+/-

Change the speed of vibrations


Hot keys in Molden mode for a geometry file

Command

Purpose

PageUp/PageDown

Load next/previous geometry

F3

Draw graphical information in a separate window.

Home

Show initial structure

End

Show the resulting structure










Tutorial

Editing molecular structures using the GV program.

Program GV is used to manipulate molecular structures, build new molecules, etc. It is also used to show orbitals , densities, etc. Here, we shall exemplify how structures are manipulated.

To open a coordinate file, use command gv Water.xyz, or to create a new file, use flag -n:  gv -n Water.xyz. If a filename is not specified, GV  will open a first coordinate file in the current directory.

Some common hot keys are shown if F1 key is pressed. And extra menu are available via right mouse click.

order to make modifications of coordinates we have to select one, two, three or four atoms. Selection is made by clicking on an atom. The first selected atom is covered by blue-colored net, the following selected atoms are covered by magenta-colored net. The number of selected atoms determines the behavior of GV. If only one atom is selected - any operations will refer to this atom, if two atoms are selected - any operations will be done for the bond, connecting these atoms, if three atoms are selected - operations will be performed for the angle, and finally, four atoms defines the dihedral angle. As a general rule - '+/-' changes the value of selected object, PageUp/PageDown changes the property, = (or F4) allows to set up the value.
To remove selection - use 'space' button, or click middle button on the mouse.Pressing + or - will modify the value, e.g. if a bond is selected, and user pressed '+' key, the bond length will increase, so the first selected atom will move away from the second atom.

Example of selected atom:

pressing F4 (or =) and typing O (note that you do not need to focus into 'edit' window), we change the H atom to O.


It is also possible to use PgUp and change the atom name from the list of of most common elements.

Backspace button can be used to Undo modifications.

If two atoms are selected - the bond length can be modified (using +/- or =/F4)


Note that first atom (blue) is moving during the operation.

Similarly, if three atoms are selected - a value of the angle will be modified, and if four atoms are selected the dihedral angle will be modified.

Pressing PageUp/PageDown will modify the 'property' of selected object. If only one atom is selected - it will change element name, if bond is selected - it will change the type of the bond (single, double, etc.), and for angle selected, it will change the angle to most common values.

F2 key can be used to save the coordinate file. The file name will be generated from the original name, by adding a counter. Shift-F2 will overwrite the original file. These operations work for XYZ, Molden, and lus files.

If one atom is selected it is possible to use Delete or Insert key to delete or insert a new atom. These operations are available for XYZ, Molden, and lus files. Let make H2O2 molecule started from Water.xyz file.