18. tools

18.1. FCIDUMP

pyscf.tools.fcidump.from_chkfile(filename, chkfile, tol=1e-15, float_format=' %.16g')[source]

Read SCF results from PySCF chkfile and transform 1-electron, 2-electron integrals using the SCF orbitals. The transformed integrals is written to FCIDUMP

pyscf.tools.fcidump.from_integrals(filename, h1e, h2e, nmo, nelec, nuc=0, ms=0, orbsym=None, tol=1e-15, float_format=' %.16g')[source]

Convert the given 1-electron and 2-electron integrals to FCIDUMP format

pyscf.tools.fcidump.from_mo(mol, filename, mo_coeff, orbsym=None, tol=1e-15, float_format=' %.16g')[source]

Use the given MOs to transfrom the 1-electron and 2-electron integrals then dump them to FCIDUMP.

pyscf.tools.fcidump.from_scf(mf, filename, tol=1e-15, float_format=' %.16g')[source]

Use the given SCF object to transfrom the 1-electron and 2-electron integrals then dump them to FCIDUMP.

pyscf.tools.fcidump.read(filename)[source]

Parse FCIDUMP. Return a dictionary to hold the integrals and parameters with keys: H1, H2, ECORE, NORB, NELEC, MS, ORBSYM, ISYM

18.2. Molden

pyscf.tools.molden.from_mo(mol, filename, mo_coeff, spin='Alpha', symm=None, ene=None, occ=None, ignore_h=True)[source]

Dump the given MOs in Molden format

pyscf.tools.molden.from_scf(mf, filename, ignore_h=True)[source]

Dump the given SCF object in Molden format

pyscf.tools.molden.load(moldenfile, verbose=0)[source]

Extract mol and orbitals from molden file

pyscf.tools.molden.parse(moldenfile, verbose=0)

Extract mol and orbitals from molden file

pyscf.tools.molden.read(moldenfile, verbose=0)

Extract mol and orbitals from molden file

pyscf.tools.molden.remove_high_l(mol, mo_coeff=None)[source]

Remove high angular momentum (l >= 5) functions before dumping molden file. If molden function raised error message RuntimeError l=5 is not supported, you can use this function to format orbitals.

Note the formated orbitals may have normalization problem. Some visualization tool will complain about the orbital normalization error.

Examples:

>>> mol1, orb1 = remove_high_l(mol, mf.mo_coeff)
>>> molden.from_mo(mol1, outputfile, orb1)

18.3. GAMESS WFN

GAMESS WFN File format

18.4. Cubegen

Gaussian cube file format. Reference: http://paulbourke.net/dataformats/cube/ http://gaussian.com/cubegen/

The output cube file has the following format

Comment line Comment line N_atom Ox Oy Oz # number of atoms, followed by the coordinates of the origin N1 vx1 vy1 vz1 # number of grids along each axis, followed by the step size in x/y/z direction. N2 vx2 vy2 vz2 # ... N3 vx3 vy3 vz3 # ... Atom1 Z1 x y z # Atomic number, charge, and coordinates of the atom ... # ... AtomN ZN x y z # ... Data on grids # (N1*N2) lines of records, each line has N3 elements

class pyscf.tools.cubegen.Cube(mol, nx=80, ny=80, nz=80, resolution=None, margin=3.0)[source]

Read-write of the Gaussian CUBE files

get_coords()[source]

Result: set of coordinates to compute a field which is to be stored in the file.

write(field, fname, comment=None)[source]

Result: .cube file with the field in the file fname.

pyscf.tools.cubegen.density(mol, outfile, dm, nx=80, ny=80, nz=80, resolution=None)[source]

Calculates electron density and write out in cube format.

Args:
mol
: Mole
Molecule to calculate the electron density for.
outfile
: str
Name of Cube file to be written.
dm
: ndarray
Density matrix of molecule.
Kwargs:
nx
: int
Number of grid point divisions in x direction. Note this is function of the molecule’s size; a larger molecule will have a coarser representation than a smaller one for the same value.
ny
: int
Number of grid point divisions in y direction.
nz
: int
Number of grid point divisions in z direction.
pyscf.tools.cubegen.mep(mol, outfile, dm, nx=80, ny=80, nz=80, resolution=None)[source]

Calculates the molecular electrostatic potential (MEP) and write out in cube format.

Args:
mol
: Mole
Molecule to calculate the electron density for.
outfile
: str
Name of Cube file to be written.
dm
: ndarray
Density matrix of molecule.
Kwargs:
nx
: int
Number of grid point divisions in x direction. Note this is function of the molecule’s size; a larger molecule will have a coarser representation than a smaller one for the same value.
ny
: int
Number of grid point divisions in y direction.
nz
: int
Number of grid point divisions in z direction.
pyscf.tools.cubegen.orbital(mol, outfile, coeff, nx=80, ny=80, nz=80, resolution=None)[source]

Calculate orbital value on real space grid and write out in cube format.

Args:
mol
: Mole
Molecule to calculate the electron density for.
outfile
: str
Name of Cube file to be written.
coeff
: 1D array
coeff coefficient.
Kwargs:
nx
: int
Number of grid point divisions in x direction. Note this is function of the molecule’s size; a larger molecule will have a coarser representation than a smaller one for the same value.
ny
: int
Number of grid point divisions in y direction.
nz
: int
Number of grid point divisions in z direction.

18.5. Print Matrix

pyscf.tools.dump_mat.dump_mo(mol, c, label=None, ncol=5, digits=5, start=0)[source]

Format print for orbitals

Args:
stdout
: file object
eg sys.stdout, or stdout = open(‘/path/to/file’) or mol.stdout if mol is an object initialized from gto.Mole
c
: numpy.ndarray
Orbitals, each column is an orbital
Kwargs:
label
: list of strings
Row labels (default is AO labels)

Examples:

>>> from pyscf import gto
>>> mol = gto.M(atom='C 0 0 0')
>>> mo = numpy.eye(mol.nao_nr())
>>> dump_mo(mol, mo)
            #0     #1     #2     #3     #4     #5     #6     #7     #8   
0  C 1s     1.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 2s     0.00   1.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 3s     0.00   0.00   1.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 2px    0.00   0.00   0.00   1.00   0.00   0.00   0.00   0.00   0.00
0  C 2py    0.00   0.00   0.00   0.00   1.00   0.00   0.00   0.00   0.00
0  C 2pz    0.00   0.00   0.00   0.00   0.00   1.00   0.00   0.00   0.00
0  C 3px    0.00   0.00   0.00   0.00   0.00   0.00   1.00   0.00   0.00
0  C 3py    0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00   0.00
0  C 3pz    0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00
pyscf.tools.dump_mat.dump_rec(stdout, c, label=None, label2=None, ncol=5, digits=5, start=0)[source]

Print an array in rectangular format

Args:
stdout
: file object
eg sys.stdout, or stdout = open(‘/path/to/file’) or mol.stdout if mol is an object initialized from gto.Mole
c
: numpy.ndarray
coefficients
Kwargs:
label
: list of strings
Row labels (default is 1,2,3,4,...)
label2
: list of strings
Col labels (default is 1,2,3,4,...)
ncol
: int
Number of columns in the format output (default 5)
digits
: int
Number of digits of precision for floating point output (default 5)
start
: int
The number to start to count the index (default 0)

Examples:

>>> import sys, numpy
>>> dm = numpy.eye(3)
>>> dump_rec(sys.stdout, dm)
        #0        #1        #2   
0       1.00000   0.00000   0.00000
1       0.00000   1.00000   0.00000
2       0.00000   0.00000   1.00000
>>> from pyscf import gto
>>> mol = gto.M(atom='C 0 0 0')
>>> dm = numpy.eye(mol.nao_nr())
>>> dump_rec(sys.stdout, dm, label=mol.ao_labels(), ncol=9, digits=2)
            #0     #1     #2     #3     #4     #5     #6     #7     #8   
0  C 1s     1.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 2s     0.00   1.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 3s     0.00   0.00   1.00   0.00   0.00   0.00   0.00   0.00   0.00
0  C 2px    0.00   0.00   0.00   1.00   0.00   0.00   0.00   0.00   0.00
0  C 2py    0.00   0.00   0.00   0.00   1.00   0.00   0.00   0.00   0.00
0  C 2pz    0.00   0.00   0.00   0.00   0.00   1.00   0.00   0.00   0.00
0  C 3px    0.00   0.00   0.00   0.00   0.00   0.00   1.00   0.00   0.00
0  C 3py    0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00   0.00
0  C 3pz    0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00
pyscf.tools.dump_mat.dump_tri(stdout, c, label=None, ncol=5, digits=5, start=0)[source]

Format print for the lower triangular part of an array

Args:
stdout
: file object
eg sys.stdout, or stdout = open(‘/path/to/file’) or mol.stdout if mol is an object initialized from gto.Mole
c
: numpy.ndarray
coefficients
Kwargs:
label
: list of strings
Row labels (default is 1,2,3,4,...)
ncol
: int
Number of columns in the format output (default 5)
digits
: int
Number of digits of precision for floating point output (default 5)
start
: int
The number to start to count the index (default 0)

Examples:

>>> import sys, numpy
>>> dm = numpy.eye(3)
>>> dump_tri(sys.stdout, dm)
        #0        #1        #2   
0       1.00000
1       0.00000   1.00000
2       0.00000   0.00000   1.00000
>>> from pyscf import gto
>>> mol = gto.M(atom='C 0 0 0')
>>> dm = numpy.eye(mol.nao_nr())
>>> dump_tri(sys.stdout, dm, label=mol.ao_labels(), ncol=9, digits=2)
            #0     #1     #2     #3     #4     #5     #6     #7     #8   
0  C 1s     1.00
0  C 2s     0.00   1.00
0  C 3s     0.00   0.00   1.00
0  C 2px    0.00   0.00   0.00   1.00
0  C 2py    0.00   0.00   0.00   0.00   1.00
0  C 2pz    0.00   0.00   0.00   0.00   0.00   1.00
0  C 3px    0.00   0.00   0.00   0.00   0.00   0.00   1.00
0  C 3py    0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00
0  C 3pz    0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   1.00