Interface to Molden — molden()

Code author: Justin M. Turney

Section author: C. David Sherrill

PSI4 contains an interface to the Molden program. Molden is a visualization program for electronic structure developed by Gijs Schaftenaar at the University of of Nijmegen, Netherlands. It is available at https://www3.cmbi.umcn.nl/molden/ . Molden can plot atomic orbitals, densities, electrostatic potentials (ESPs), etc. PSI4 can create a file containing atomic coordinates, basis set, and SCF orbital coefficients in the so-called Molden format. This file is written by the SCF module (see Section SCF) if the user sets the MOLDEN_WRITE keyword to true. This Molden file is also used to pass information between PSI4 and WebMO, if PSI4 computations are invoked using the WebMO GUI. The filename of the Molden file ends in “.molden”, and the prefix is determined by WRITER_FILE_LABEL (if set), or else by the name of the output file plus the name of the current molecule. If MOLDEN_WITH_VIRTUAL is set to false, the unoccupied orbitals are not written to the Molden file.

psi4.molden(wfn, filename)[source]

Function to write wavefunction information in wfn to filename in molden format. Will write natural orbitals from density (MO basis) if supplied. Warning! Most post-SCF Wavefunctions do not build the density as this is often much more costly than the energy. In addition, the Wavefunction density attributes (Da and Db) return the SO density and must be transformed to the MO basis to use with this function.

New in version 0.5: wfn parameter passed explicitly

Returns:

None

Parameters:
  • wfn (Wavefunction) – set of molecule, basis, orbitals from which to generate cube files

  • filename (str) – destination file name for MOLDEN file (optional)

  • density_a (Matrix) – density in the MO basis to build alpha NO’s from (optional)

  • density_b (Matrix) – density in the MO basis to build beta NO’s from, assumes restricted if not supplied (optional)

  • dovirtual (bool) – do write all the MOs to the MOLDEN file (true) or discard the unoccupied MOs, not valid for NO’s (false) (optional)

Examples:

  1. Molden file with the Kohn-Sham orbitals of a DFT calculation.

    >>> E, wfn = energy('b3lyp', return_wfn=True)
    >>> molden(wfn, 'mycalc.molden')
    
  2. Molden file for CI/MCSCF computation using NO roots. Any method returning a CIWavefunction object will work: detci, fci, casscf, etc. The first two arguments of get_opdm can be set to n, n where n => 0 selects the root to write out, provided these roots were computed, see NUM_ROOTS. The third argument controls the spin ("A", "B" or "SUM") and the final boolean option determines whether inactive orbitals are included.

    >>> E, wfn = energy('detci', return_wfn=True)
    >>> molden(wfn, 'no_root1.molden', density_a=wfn.get_opdm(0, 0, "A", True))
    
  3. The following produces an INCORRECT Molden file, because the molden function needs orbitals in the MO basis (which are internally converted and written to the Molden file in the AO basis). The correct usage is given in the next point.

    >>> E, wfn = energy('ccsd', return_wfn=True)
    >>> molden(wfn, 'ccsd_no.molden', density_a=wfn.Da())
    
  4. Molden file with the natural orbitals of the ground-state 1RDM of a Post-HF calculation. Note the required transformation of Da (SO->MO).

    >>> E, wfn = properties('ccsd', return_wfn=True)
    >>> Da_so = wfn.Da()
    >>> SCa = core.doublet(wfn.S(), wfn.Ca(), False, False)
    >>> Da_mo = core.triplet(SCa, Da_so, SCa, True, False, False)
    >>> molden(wfn, 'ccsd_no.molden', density_a=Da_mo)
    

Options

MOLDEN_WRITE

Do write a MOLDEN output file? If so, the filename will end in .molden, and the prefix is determined by WRITER_FILE_LABEL (if set), or else by the name of the output file plus the name of the current molecule.

WRITER_FILE_LABEL

Base filename for text files written by PSI, such as the MOLDEN output file, the Hessian file, the internal coordinate file, etc. Use the add_str_i function to make this string case sensitive.

  • Type: string

  • Default: No Default

MOLDEN_WITH_VIRTUAL

Write all the MOs to the MOLDEN file (true) or discard the unoccupied MOs (false).