Running MultiPsi, input/code structure#
There are two main ways to run MultiPsi. The first one is using a traditional way using an input file, and the second one is as a python script. For advanced users familiar with python programming, running a python script is the most flexible and powerful option while the input format is more adapted for new users as it is simple and has more failsafes.
Running with an input file#
To run multipsi, you can simply run in a terminal
multipsi file.inp
which will print the output to the screen, or redirect the input
multipsi file.inp file.out
You can find example inputs in the examples directory. The general input structure is composed of blocks delimited by @. There is one block for each module (e.g. mcscf, ci, response, etc…) as well as a couple of blocks to define the molecule, active space and method (resp. @molecule, @orbitals and @method settings). The order of the blocks is irrelevant. Within each block are a number of options written as keyword:value, and the value can be multiple lines.
The lines before the first block in the input are called “keylines” and can be used to provide a short-hand input which can be enough for most basic calculations. Thus, a complete input to run a CASSCF with an active space containing 12 electrons in 9 orbitals (full valence) with the def2-svp basis set, followed by a linear response calculation (time-dependent or TD) of the first 5 excited states is simply:
casscf(12,9) def2-svp td:5 # This is the keyline
@molecule
xyz:
O 0.0000 0.0000 0.0000
O 0.0000 1.0885 0.6697
O 0.0000 -1.0885 0.6697
@end
which is fully identical to the long-form input:
@molecule
xyz:
O 0.0000 0.0000 0.0000
O 0.0000 1.0885 0.6697
O 0.0000 -1.0885 0.6697
@end
@orbitals
cas: 12, 9
@end
@method settings
basis: def2-svp
wavefunction: mcscf
@end
@response
n_states:5
@end
Running with a python script#
MultiPsi is a python module and can thus be run natively as a python script. For this, you first need to import multipsi and veloxchem:
import veloxchem as vlx
import multipsi as mtp
Then the input above can be run by the following script:
# Define molecule and basis
mol_str = """
O 0.0000 0.0000 0.0000
O 0.0000 1.0885 0.6697
O 0.0000 -1.0885 0.6697
"""
molecule = vlx.Molecule.read_str(mol_str)
molecule.set_charge(0) # default
molecule.set_multiplicity(1) # default
basis = vlx.MolecularBasis.read(molecule,"def2-svp")
# Generate guess
orbguess = mtp.OrbitalGuess()
guessorb = orbguess.compute(molecule, basis)
# Define the active space (full valence = 9 2p orbitals, 12 electrons)
orb_space = mtp.OrbSpace(molecule, guessorb)
orb_space.cas(12, 9)
# MCSCF energy
mcscf_drv = mtp.McscfDriver()
mcscf_dict = mcscf_drv.compute(molecule, basis, orb_space)
# Linear response calculation
mcrpa = mtp.Mclr_EigenSolver()
mcrpa.max_vector_per_equation = 15
response_dict = mcrpa.compute(molecule, basis, mcscf_drv, n_states = 5)
Multi-Configurational Self-Consistent Field Driver
====================================================
Active space definition:
------------------------
Number of inactive (occupied) orbitals: 6
Number of active orbitals: 9
Number of virtual orbitals: 27
This is a CASSCF wavefunction: CAS(12,9)
CI expansion:
-------------
Number of determinants: 7056
╭────────────────────────────────────╮
│ Driver settings │
╰────────────────────────────────────╯
Number of states : 1
State-specific calculation
- State of interest : 1
Max. iterations : 50
BFGS window : 5
Convergence thresholds:
- Energy change : 1e-08
- Gradient sq. norm : 1e-08
MCSCF Iterations
-------------------
Iter. | Average Energy | E. Change | Grad. Norm | CI Iter. | Trust rad. | Time
---------------------------------------------------------------------------------
1 -223.990804437 0.0e+00 1.3e+00 16 0.40 0:00:00
2 -224.232908972 -2.4e-01 1.4e-01 13 0.40 0:00:00
3 -224.282221229 -4.9e-02 1.0e-02 3 0.48 0:00:00
4 -224.288065932 -5.8e-03 1.3e-03 4 0.48 0:00:00
5 -224.288712397 -6.5e-04 1.7e-04 4 0.58 0:00:00
6 -224.288830390 -1.2e-04 3.0e-05 4 0.69 0:00:00
7 -224.288852010 -2.2e-05 7.9e-06 4 0.80 0:00:00
8 -224.288856464 -4.5e-06 8.4e-07 3 0.80 0:00:00
9 -224.288856934 -4.7e-07 9.7e-08 5 0.80 0:00:00
10 -224.288857006 -7.3e-08 1.5e-08 4 0.80 0:00:00
11 -224.288857022 -1.6e-08 5.3e-09 4 0.80 0:00:00
12 -224.288857026 -4.3e-09 1.9e-09 4 0.80 0:00:00
** Convergence reached in 12 iterations
13 -224.288857028 -1.3e-09 5.7e-10 14 0.80 0:00:00
Final results
-------------
* State 1
- S^2 : 0.00 (multiplicity = 1.0 )
- Energy : -224.288857027729
- Natural orbitals
1.99224 1.99029 1.96397 1.95643 1.94794 1.76948 0.26738 0.06074 0.05154
Spin Restricted Orbitals
------------------------
Molecular Orbital No. 5:
--------------------------
Occupation: 2.000 Energy: -1.26698 a.u.
( 2 O 1s : 0.22) ( 2 O 2s : 0.45) ( 2 O 3s : 0.34)
( 3 O 1s : -0.22) ( 3 O 2s : -0.45) ( 3 O 3s : -0.34)
Molecular Orbital No. 6:
--------------------------
Occupation: 2.000 Energy: -1.01012 a.u.
( 1 O 1s : -0.18) ( 1 O 2s : -0.41) ( 1 O 3s : -0.31)
( 1 O 1p0 : 0.25) ( 2 O 2s : 0.27) ( 2 O 3s : 0.23)
( 2 O 1p0 : 0.20) ( 3 O 2s : 0.27) ( 3 O 3s : 0.23)
( 3 O 1p0 : 0.20)
Molecular Orbital No. 7:
--------------------------
Occupation: 1.992 Energy: -0.60885 a.u.
( 2 O 1p-1: 0.23) ( 2 O 1p0 : -0.41) ( 2 O 2p-1: 0.19)
( 2 O 2p0 : -0.27) ( 3 O 1p-1: 0.23) ( 3 O 1p0 : 0.41)
( 3 O 2p-1: 0.19) ( 3 O 2p0 : 0.27)
Molecular Orbital No. 8:
--------------------------
Occupation: 1.990 Energy: -0.74350 a.u.
( 1 O 2s : -0.32) ( 1 O 3s : -0.33) ( 2 O 3s : 0.16)
( 2 O 1p-1: 0.23) ( 2 O 1p0 : -0.33) ( 2 O 2p0 : -0.26)
( 3 O 3s : 0.16) ( 3 O 1p-1: -0.23) ( 3 O 1p0 : -0.33)
( 3 O 2p0 : -0.26)
Molecular Orbital No. 9:
--------------------------
Occupation: 1.964 Energy: -0.76348 a.u.
( 1 O 1p+1: 0.55) ( 1 O 2p+1: 0.34) ( 2 O 1p+1: 0.23)
( 3 O 1p+1: 0.23)
Molecular Orbital No. 10:
--------------------------
Occupation: 1.956 Energy: -0.84371 a.u.
( 1 O 1p0 : -0.54) ( 1 O 2p0 : -0.33) ( 2 O 1p-1: 0.19)
( 2 O 1p0 : 0.25) ( 2 O 2p0 : 0.17) ( 3 O 1p-1: -0.19)
( 3 O 1p0 : 0.25) ( 3 O 2p0 : 0.17)
Molecular Orbital No. 11:
--------------------------
Occupation: 1.948 Energy: -0.83932 a.u.
( 1 O 1p-1: -0.48) ( 1 O 2p-1: -0.20) ( 2 O 1p-1: 0.35)
( 2 O 2p-1: 0.20) ( 3 O 1p-1: 0.35) ( 3 O 2p-1: 0.20)
Molecular Orbital No. 12:
--------------------------
Occupation: 1.769 Energy: -0.43543 a.u.
( 2 O 1p+1: 0.48) ( 2 O 2p+1: 0.35) ( 3 O 1p+1: -0.48)
( 3 O 2p+1: -0.35)
Molecular Orbital No. 13:
--------------------------
Occupation: 0.267 Energy: -0.05109 a.u.
( 1 O 1p+1: 0.46) ( 1 O 2p+1: 0.28) ( 2 O 1p+1: -0.50)
( 2 O 2p+1: -0.24) ( 3 O 1p+1: -0.50) ( 3 O 2p+1: -0.24)
Molecular Orbital No. 14:
--------------------------
Occupation: 0.061 Energy: 0.41592 a.u.
( 1 O 1s : 0.16) ( 1 O 2s : 0.48) ( 1 O 3s : 0.30)
( 1 O 1p0 : 0.57) ( 2 O 2s : -0.17) ( 2 O 1p-1: 0.51)
( 2 O 1p0 : 0.15) ( 2 O 2p-1: 0.18) ( 3 O 2s : -0.17)
( 3 O 1p-1: -0.51) ( 3 O 1p0 : 0.15) ( 3 O 2p-1: -0.18)
Molecular Orbital No. 15:
--------------------------
Occupation: 0.052 Energy: 0.51207 a.u.
( 1 O 1p-1: 0.76) ( 1 O 2p-1: 0.34) ( 2 O 2s : -0.19)
( 2 O 3s : -0.22) ( 2 O 1p-1: 0.34) ( 2 O 1p0 : 0.36)
( 2 O 2p-1: 0.21) ( 3 O 2s : 0.19) ( 3 O 3s : 0.22)
( 3 O 1p-1: 0.34) ( 3 O 1p0 : -0.36) ( 3 O 2p-1: 0.21)
Molecular Orbital No. 16:
--------------------------
Occupation: 0.000 Energy: 0.90478 a.u.
( 1 O 1s : 0.16) ( 1 O 2s : 0.73) ( 1 O 3s : 0.65)
( 1 O 1p0 : -0.29) ( 1 O 2p0 : 0.95) ( 2 O 2s : 0.78)
( 2 O 3s : -1.26) ( 2 O 1p-1: -0.16) ( 2 O 2p-1: 0.69)
( 3 O 2s : 0.78) ( 3 O 3s : -1.26) ( 3 O 1p-1: 0.16)
( 3 O 2p-1: -0.69)
Molecular Orbital No. 17:
--------------------------
Occupation: 0.000 Energy: 1.02202 a.u.
( 1 O 1p-1: -0.31) ( 1 O 2p-1: 1.30) ( 2 O 1s : -0.15)
( 2 O 2s : -0.72) ( 2 O 1p-1: -0.34) ( 2 O 2p-1: 0.73)
( 2 O 2p0 : 0.46) ( 3 O 1s : 0.15) ( 3 O 2s : 0.72)
( 3 O 1p-1: -0.34) ( 3 O 2p-1: 0.73) ( 3 O 2p0 : -0.46)
Dipole moment for state 1
---------------------------
X : 0.000003 a.u. 0.000007 Debye
Y : -0.000001 a.u. -0.000003 Debye
Z : -0.200660 a.u. -0.510027 Debye
Total : 0.200660 a.u. 0.510027 Debye
Total MCSCF time: 00:00:02
Multi-Configurational Linear response Eigenvalue Solver
=========================================================
╭────────────────────────────────────╮
│ Driver settings │
╰────────────────────────────────────╯
Number of states : 5
Tamm-Damcoff approximation
Max. iterations : 50
Residual sq. norm threshold : 1e-08
Trial vector settings:
- Lin. dep. threshold : 1e-10
- Min. trial vectors : 15
- Max. trial vectors : 75
Number of parameters:
- CI : 7055
- Orbital : 459
* Initialization time: 00:00:00
MC-TDA Iterations
-----------------
Iter. | Average Energy | Grad. Norm | Converged | CI+Orb vec. | Time
-----------------------------------------------------------------------
1 0.221894240 3.0e-01 0/ 5 6 + 5 0:00:00
2 0.118905971 1.1e-01 0/ 5 11 + 5 0:00:00
3 0.104328105 3.1e-02 0/ 5 14 + 7 0:00:00
4 0.098001882 1.0e-02 0/ 5 19 + 7 0:00:00
5 0.096767956 5.6e-03 0/ 5 23 + 8 0:00:00
6 0.095904944 2.2e-03 0/ 5 28 + 8 0:00:00
7 0.095605132 1.3e-03 0/ 5 32 + 9 0:00:00
8 0.095473998 7.7e-04 0/ 5 37 + 9 0:00:00
9 0.095413884 2.2e-04 0/ 5 41 + 10 0:00:00
10 0.095396714 1.1e-04 0/ 5 45 + 11 0:00:00
11 0.095390906 3.2e-05 0/ 5 49 + 12 0:00:00
12 0.095386816 1.3e-05 2/ 5 54 + 12 0:00:00
13 0.095385903 8.7e-06 3/ 5 56 + 13 0:00:00
14 0.095385484 1.9e-06 3/ 5 57 + 14 0:00:00
15 0.095385274 5.3e-07 3/ 5 59 + 14 0:00:00
16 0.095385241 3.2e-07 3/ 5 61 + 14 0:00:00
17 0.095385225 9.1e-08 3/ 5 61 + 16 0:00:00
18 0.095385208 6.4e-08 3/ 5 63 + 16 0:00:00
19 0.095385203 3.6e-08 3/ 5 65 + 16 0:00:00
20 0.095385201 2.1e-08 4/ 5 65 + 18 0:00:00
21 0.095385200 8.7e-09 5/ 5 66 + 18 0:00:00
** Convergence reached in 21 iterations
Oscillator strength
Transition Energy (Ha) Energy (eV) Length gauge Velocity gauge
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1 0.0758269 2.06336 0.0000000 0.0000000
2 0.0838256 2.28101 0.0017223 0.1821877
3 0.0853400 2.32222 0.0014504 0.0193201
4 0.1062426 2.89101 0.0000000 0.0000000
5 0.1256908 3.42022 0.0000000 0.0000000
Rotatory strength (cgs)
Transition Energy (Ha) Energy (eV) Length gauge Velocity gauge
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1 0.0758269 2.06336 -0.0000000 0.0000000
2 0.0838256 2.28101 -1.2815729 16.2164151
3 0.0853400 2.32222 2.1945185 -16.9199162
4 0.1062426 2.89101 0.0000000 0.0000000
5 0.1256908 3.42022 -0.0000000 0.0000000
The script version also provides useful tools to visualize the results, check the orbitals, etc…
You can also use the built-in help functions of python to know the available functions and keywords of modules:
help(mtp.McscfDriver)
Help on class McscfDriver in module multipsi.mcscf_driver:
class McscfDriver(builtins.object)
| McscfDriver(comm=<mpi4py.MPI.Intracomm object at 0x1075b7af0>, ostream=None)
|
| Converge a general MCSCF wavefunction
|
| :param comm:
| The MPI communicator (default world).
| :param ostream:
| The output stream (default stdout).
|
| Methods defined here:
|
| __init__(self, comm=<mpi4py.MPI.Intracomm object at 0x1075b7af0>, ostream=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| compute(self, molecule, basis, orbital_space, n_states=1)
| Performs a MCSCF calculation
|
| :param molecule:
| The molecule.
| :param basis:
| The AO basis set.
| :param orbital_space:
| The Orbital Spaces.
| :param n_states:
| The number of states (default 1) for equal-weights state-averaged calculation
| or a list of weights.
|
| :return:
| A dictionary with the main results.
|
| get_non_separable_2body_density(self, istate=0)
| Return the non-separable part of the active
| 2-body density matrix of a state in MO.
|
| :param istate:
| The index of the state of interest (default: the first state).
|
| :return:
| non-separable part of the 2-body density matrix in MO.
|
| get_total_density(self, istate=0)
| Return the total AO density matrix of a state.
|
| :param istate:
| The index of the state of interest (default: the first state).
| :return:
| 1-body density matrix in AO.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object