PySOC is a Python and Fortran program for calculating spin-orbit coupling (SOC) between singlet ground or excited states and triplet excited states from linear-response excited-state calculations.
PySOC currently supports excited-state data from:
- Gaussian 09/16 TDDFT and TDA calculations
- DFTB+ TD-DFTB calculations
- ORCA TDDFT/TDA calculations
- Evaluation of SOC matrix elements between singlet and triplet states.
- Text-table and CSV command-line output.
- Gaussian TDDFT/TDA interface using
.log/.rwfdata. - DFTB+ TD-DFTB interface using transition-vector and fitted-basis data.
- ORCA TDDFT/TDA interface using printed orbital data plus full TD vectors from
orca_2json. - One-electron, full Breit-Pauli, and effective-charge (
Zeff) SOC modes. - Cartesian integral backend through MolSOC and
soc_td; ORCA spherical harmonic AO data are reordered and converted internally for the supported shells.
Install the Python dependencies:
$ pip install -r requirements.txtor equivalently:
$ pip install cclib tabulate periodictable scipyPySOC also needs its Fortran backend executables:
pysoc/data/bin/molsocpysoc/data/bin/soc_td
The repository includes these paths. If you recompile either Fortran backend,
copy the newly built executable back into pysoc/data/bin before testing or
running pysoc.
Program-specific external tools:
- Gaussian calculations require Gaussian's
rwfdumpexecutable inPATH. - ORCA calculations should have
orca_2jsoninPATHfor complete TD vectors. - ORCA calculations also need an
.mklfile, ororca_2mklinPATHso PySOC can generate it from the.gbwfile.
Add the repository to PYTHONPATH:
$ export PYTHONPATH="$PYTHONPATH:/path/to/pysoc"Add the bin directory to PATH:
$ export PATH="$PATH:/path/to/pysoc/bin"The bin/pysoc command is a symlink to pysoc/program/main.py.
Before running PySOC, first run the electronic-structure excited-state calculation in Gaussian, DFTB+, or ORCA.
Note
Shells higher than the f shell are not currently supported by the full PySOC workflow. Use basis sets without g or higher angular-momentum shells.
The command-line interface can guess the program from the main file extension:
.log-> Gaussian.xyz-> DFTB+.out-> ORCA
If a file extension is ambiguous, pass --program explicitly. This is important
for Gaussian jobs whose main output file is named .out, because .out is
guessed as ORCA.
Gaussian TDDFT and TDA calculations are supported for Gaussian 09 and 16. Other
Gaussian methods may work if the required .rwf sections are present, but they
are not the tested path.
PySOC requires:
- The Gaussian output file, normally
.log. - The Gaussian read-write file,
.rwf. - Gaussian's
rwfdumpexecutable inPATH. - Cartesian d and f functions in Gaussian output ordering.
- Printed basis-set information in the output file.
Gaussian normally deletes the .rwf file at the end of a job. Keep it by adding
an %rwf line to the Gaussian input:
%rwf=formaldehyde.rwf
Use 6D 10F GFInput so PySOC receives Cartesian d/f functions and the basis set
is printed:
%mem=1GB
%chk=formaldehyde.chk
%rwf=formaldehyde.rwf
# TD(50-50,nstates=5) wB97XD/TZVP 6D 10F GFInput
formaldehyde
0 1
C -0.131829 -0.000001 -0.000286
O 1.065288 0.000001 0.000090
H -0.718439 0.939705 0.000097
H -0.718441 -0.939705 0.000136
Run PySOC with:
$ pysoc formaldehyde.log --rwf_file formaldehyde.rwfIf --rwf_file is omitted, PySOC looks for a file with the same basename as the
Gaussian output and the .rwf suffix.
ORCA support is designed for TDDFT/TDA calculations with singlet and triplet
roots. ORCA uses spherical harmonic AO functions, while MolSOC and soc_td
operate internally with Cartesian Gaussian functions. PySOC handles the
spherical ordering and Cartesian conversion for the supported shells, using the
GTO basis data printed by ORCA.
PySOC requires:
- The ORCA
.outfile. - The ORCA
.gbwfile. - The ORCA
.cisfile for TD-vector export throughorca_2json. - The ORCA
.property.txtfile when produced by ORCA. - The ORCA
.mklfile, ororca_2mklinPATHso PySOC can create it. orca_2jsoninPATHfor complete TD vectors.
Recommended ORCA input options:
! wB97X-D3 TZVP
%tddft
nroots 10
triplets true
end
%output
Print[ P_Basis ] 2
Print[ P_Overlap ] 1
Print[ P_MOs ] 1
end
* xyz 0 1
C -0.131829 -0.000001 -0.000286
O 1.065288 0.000001 0.000090
H -0.718439 0.939705 0.000097
H -0.718441 -0.939705 0.000136
*
Print[ P_Basis ] 2 is strongly recommended because it lets PySOC use ORCA's
raw GTO basis block. If that block is missing, PySOC falls back to basis data in
the .mkl file and prints a warning because the contraction normalization may
not be the same as MolSOC expects.
Run PySOC with:
$ pysoc ch2o_orca.out --program ORCA -s 5 -t 5When ORCA support is working in the full-vector path, PySOC automatically writes
or updates ch2o_orca.json.conf, runs:
$ orca_2json ch2o_orca.gbw -jsonand reads the complete X and Y TD vectors from ch2o_orca.json. For TDA
roots, ORCA does not provide Y; PySOC correctly uses X for both X+Y and
X-Y.
If orca_2json or the JSON TD-vector data is unavailable, PySOC falls back to
the sparse CI amplitudes printed in the .out file and emits a warning. That
fallback is useful for debugging, but it is not recommended for quantitative SOC
values because ORCA usually prints only amplitudes above a threshold.
Request more ORCA roots than you plan to use in PySOC. Root ordering near the highest requested Davidson root can be unstable; PySOC warns when selected roots include the highest root printed by ORCA.
Note
This section is under revision.
DFTB+ TD-DFTB calculations are supported through the original PySOC/TD-DFTB interface.
Note
PySOC's SOC backend uses Gaussian-type orbital data. DFTB+ uses Slater-type
orbitals, so the parameter set used for the DFTB+ calculation must be fitted
to GTOs for use with PySOC. PySOC includes a fitted set for mio-1-1, and an
alternative fitted basis directory can be supplied with --fitted_basis.
An example dftb_in.hsd:
Geometry = GenFormat {
<<< "ch2o.gen"
}
Driver = {}
Hamiltonian = DFTB {
SCC = Yes
SCCTolerance = 1e-10
MaxAngularMomentum = {
H = "s"
C = "p"
O = "p"
}
SlaterKosterFiles = Type2FileNames {
Prefix = "/path/to/mio-1-1/"
Separator = "-"
Suffix = ".skf"
}
LinearResponse {
NrOfExcitations = 10
StateOfInterest = 0
Symmetry = both
HubbardDerivatives {
H = 0.347100 0.491900
C = 0.341975 0.387425
O = 0.467490 0.523300
}
WriteTransitions = Yes
WriteTransitionDipole = Yes
WriteXplusY = Yes
}
}
Options {
WriteEigenvectors = Yes
WriteHS = No
}
ParserOptions {
ParserVersion = 4
}
After the first DFTB+ calculation, set WriteHS = Yes and run the calculation a
second time so the Hamiltonian and overlap data are written.
Run PySOC with the geometry file:
$ pysoc formaldehyde.xyz --program "DFTB+"Basic command:
$ pysoc CALC_FILEExamples:
$ pysoc examples/ch2o_gaussian/gaussian.log -s 5 -t 5
$ pysoc examples/ch2o_orca/ch2o_orca.out --program ORCA -s 5 -t 5
$ pysoc examples/ch2o_tddftb/ch2o.xyz --program "DFTB+" -s 5 -t 5Common options:
| Option | Meaning |
|---|---|
-p, --program |
Input program: Gaussian, DFTB+, or ORCA. |
-s, --singlets |
Number of singlet excited states to include. Defaults to all parsed states. |
-t, --triplets |
Number of triplet excited states to include. Defaults to all parsed states. |
-T, --calculation |
SOC integral mode: auto, one, two, or zeff. |
-S, --SOC_scale |
Scale factor for Zeff mode. |
-n, --no_ground |
Exclude the singlet ground state from the SOC table. |
-C, --CI_threshold |
Threshold for CI coefficients passed to soc_td. |
-c, --CSV |
Print comma-separated output instead of a formatted table. |
-o, --output |
Directory where intermediate files should be kept. |
--rwf_file |
Gaussian .rwf file. |
--fitted_basis |
DFTB+ fitted GTO basis directory. |
At present, -s and -t select the first N singlet and triplet states. They do
not select arbitrary state lists.
--calculation auto is the default. It uses zeff when MolSOC has effective
charges for all atoms in the molecule; otherwise it falls back to one-electron
SOC and prints a warning.
The default output is a table:
$ pysoc examples/ch2o_gaussian/gaussian.log -s 5 -t 5
Singlet Triplet RSS (cm-1) +1 (cm-1) 0 (cm-1) -1 (cm-1)
--------- --------- ------------ ----------- ---------- -----------
S(0) T(1) 60.7419 42.9510 0.0077 42.9510
S(0) T(2) 0.0194 0.0137 0.0000 0.0137
S(0) T(3) 10.6234 0.0133 10.6234 0.0133
S(0) T(4) 59.8873 42.3467 0.0012 42.3467
S(0) T(5) 11.7332 0.0013 11.7332 0.0013Each line is one singlet-triplet pair. +1, 0, and -1 are the triplet
sub-state couplings. RSS is the root-sum-square of those three components.
CSV output:
$ pysoc examples/ch2o_gaussian/gaussian.log -s 5 -t 5 -c
Singlet,Triplet,RSS (cm-1),+1 (cm-1),0 (cm-1),-1 (cm-1)
S(0),T(1),60.7419154885397,42.95102,0.00769,42.95102
S(0),T(2),0.019431296920174937,0.01374,1e-05,0.01374Use shell redirection to write CSV output to a file:
$ pysoc examples/ch2o_gaussian/gaussian.log -s 5 -t 5 -c > SOC.csvBy default, PySOC writes intermediate files to a temporary directory and removes
them at the end of the run. Use -o to keep them:
$ pysoc examples/ch2o_orca/ch2o_orca.out --program ORCA -s 5 -t 5 -o ./pysoc_debugUseful intermediate files include:
molsoc.inpmolsoc_basismolsoc_overlap.datmolsoc_dipole.datsointmo_ene.datmo_coeff.datao_overlap.datci_coeff.datsoc_td_input.datsoc_out.dat
For ORCA, the orca_2json cache files are written next to the ORCA output
files, not into the PySOC intermediate directory:
basename.json.confbasename.jsonbasename.JSON.bibtex
- Shells above f are not supported by the full workflow.
- ORCA quantitative SOC calculations need the
orca_2jsonfull-vector path. Sparse CI amplitudes printed in.outare not complete enough for production SOC values. - ORCA support has been developed and tested primarily for TDDFT/TDA closed-shell examples.
- DFTB+ support requires a fitted GTO basis compatible with the DFTB+ parameter set.
- The command line currently selects the first N singlet/triplet states, not an arbitrary set of roots.
- Short tutorial: doc/pysoc.pdf
- Chinese tutorial by sobereva Lu Tian: http://bbs.keinsci.com/thread-9442-1-1.html
- Gaussian 16 tutorial by ggdh: http://bbs.keinsci.com/thread-19813-1-1.html
Evaluation of Spin-Orbit Couplings with Linear-Response Time-Dependent Density Functional Methods
Xing Gao, Shuming Bai, Daniele Fazzi, Thomas Niehaus, Mario Barbatti, and Walter Thiel
J. Chem. Theory Comput., 2017, 13 (2), pp 515-524
DOI: 10.1021/acs.jctc.6b00915
If you use ORCA-generated data, also cite ORCA and any ORCA methods used in the underlying electronic-structure calculation.
PySOC was originally written by Xing Gao et al. for Python 2.x.
MolSOC is used for the calculation of atomic integrals and was originally written by Sandro Giuseppe Chiodo et al. (Computer Physics Communications 185 (2014) 676-683).
PySOC was rewritten for Python 3.x by Oliver S. Lee.
Support for ORCA was added by Diego J. Alonso de Armiño.