# molden

`psi4.driver.``molden`(wfn, filename=None, density_a=None, density_b=None, dovirtual=None)

  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 (string) – 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 for DFT calculation
      >>> E, wfn = energy('b3lyp', return_wfn=True)
      >>> molden(wfn, 'mycalc.molden')

      >>> # [2] Molden file for CI/MCSCF computation using NO roots
      >>> E, wfn = energy('ci', return_wfn=True)
      >>> molden(wfn, 'no_root1.molden', density_a=wfn.opdm(0, 0, "A", True))

      >>> # [3] The following does NOT work, please see below
      >>> E, wfn = energy('ccsd', return_wfn=True)
      >>> molden(wfn, 'ccsd_no.molden', density_a=wfn.Da())

      >>> # [4] This WILL work, note the transformation of Da (SO->MO)
      >>> E, wfn = properties('ccsd', properties=['dipole'], 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)