First-order properties quantify expectation values of one-electron operators in individual electronic states. For the electronic ground state, quantities such as the permanent electric dipole moment are evaluated directly from the converged Kohn–Sham density, requiring no response treatment. In contrast, expectation values for electronically excited states—most notably excited-state dipole moments—are obtained from the double residue of the quadratic response function, which provides the transition-specific way to construct expectation values in the excited-state manifold. Together, these formulations provide a consistent route to state-specific first-order properties across both ground and excited electronic states. See Norman et al. (2018) for further details.
Electric dipole moment¶
Ground state¶
Simple translation test¶
import veloxchem as vlx
h2o_xyz = """3
O 10.000000000000 0.000000000000 0.000000000000
H 10.000000000000 0.740848095288 0.582094932012
H 10.000000000000 -0.740848095288 0.582094932012
"""
molecule = vlx.Molecule.read_xyz_string(h2o_xyz)
basis = vlx.MolecularBasis.read(molecule, "def2-svp")
scf_drv = vlx.ScfRestrictedDriver()
scf_drv.xcfun = "b3lyp"
scf_results = scf_drv.compute(molecule, basis)
prop_drv = vlx.FirstOrderPropertyDriver()
prop_drv.property = "electric dipole moment"
prop_results = prop_drv.compute(molecule, basis, scf_results)
Self Consistent Field Driver Setup
====================================
Wave Function Model : Spin-Restricted Kohn-Sham
Initial Guess Model : Superposition of Atomic Densities
Convergence Accelerator : Two Level Direct Inversion of Iterative Subspace
Max. Number of Iterations : 50
Max. Number of Error Vectors : 10
Convergence Threshold : 1.0e-06
ERI Screening Threshold : 1.0e-12
Linear Dependence Threshold : 1.0e-06
Exchange-Correlation Functional : B3LYP
Molecular Grid Level : 4
* Info * Using the B3LYP functional.
P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch., J. Phys. Chem. 98, 11623 (1994)
* Info * Using the Libxc library (v7.0.0).
S. Lehtola, C. Steigemann, M. J.T. Oliveira, and M. A.L. Marques., SoftwareX 7, 1–5 (2018)
* Info * Using the following algorithm for XC numerical integration.
J. Kussmann, H. Laqua and C. Ochsenfeld, J. Chem. Theory Comput. 2021, 17, 1512-1521
* Info * Starting Reduced Basis SCF calculation...
* Info * ...done. SCF energy in reduced basis set: -75.914346039554 a.u. Time: 0.04 sec.
Iter. | Kohn-Sham Energy | Energy Change | Gradient Norm | Max. Gradient | Density Change
--------------------------------------------------------------------------------------------
1 -76.354264472856 0.0000000000 0.18342045 0.02544783 0.00000000
2 -76.356811155654 -0.0025466828 0.06217418 0.00894104 0.04565484
3 -76.357023496002 -0.0002123403 0.03728747 0.00448074 0.01969830
4 -76.357144773667 -0.0001212777 0.00037828 0.00006416 0.00816896
5 -76.357144788061 -0.0000000144 0.00001141 0.00000139 0.00009033
6 -76.357144788075 -0.0000000000 0.00000118 0.00000016 0.00000477
7 -76.357144788075 -0.0000000000 0.00000009 0.00000001 0.00000057
*** SCF converged in 7 iterations. Time: 0.55 sec.
Spin-Restricted Kohn-Sham:
--------------------------
Total Energy : -76.3571447881 a.u.
Electronic Energy : -85.7007829457 a.u.
Nuclear Repulsion Energy : 9.3436381577 a.u.
------------------------------------
Gradient Norm : 0.0000000866 a.u.
Ground State Information
------------------------
Charge of Molecule : 0.0
Multiplicity (2S+1) : 1
Magnetic Quantum Number (M_S) : 0.0
print(prop_results){'electric dipole moment': {'total': array([ 1.95657334e-14, -9.36750677e-17, 7.80569421e-01]), 'nuclear': array([0., 0., 0.]), 'electronic': array([ 1.95657334e-14, -9.36750677e-17, 7.80569421e-01]), 'origin': array([18.89726125, 0. , 0.22 ]), 'units': 'a.u.'}, 'electric_dipole_moment': {'total': array([ 1.95657334e-14, -9.36750677e-17, 7.80569421e-01]), 'nuclear': array([0., 0., 0.]), 'electronic': array([ 1.95657334e-14, -9.36750677e-17, 7.80569421e-01]), 'origin': array([18.89726125, 0. , 0.22 ]), 'units': 'a.u.'}}
It appears that results for key ‘electric dipole moment’ are entered twice into the dictionary.
The origin is reported to be
(18.89726125, 0, 0.22). What does that mean?I am not getting any nuclear dipole moment although I have translated the water molecule in the x-direction
Python script
import veloxchem as vlx
molecule = vlx.Molecule.read_name("para-nitroaniline")
basis = vlx.MolecularBasis.read(molecule, "def2-svp")
scf_drv = vlx.ScfRestrictedDriver()
scf_drv.xcfun = "b3lyp"
scf_results = scf_drv.compute(molecule, basis)
prop_drv = vlx.FirstOrderPropertyDriver()
prop_drv.property = "electric dipole moment"
prop_results = prop_drv.compute(molecule, basis, scf_results)Reading para-nitroaniline from PubChem...
Reference: S. Kim, J. Chen, T. Cheng, A. Gindulyte, J. He, S. He, Q. Li, B. A. Shoemaker, P. A. Thiessen, B. Yu, L. Zaslavsky, J. Zhang, E. E. Bolton, Nucleic Acids Res., 2025, 53, D1516-D1525.
Please double-check the compound since names may refer to more than one record.
Self Consistent Field Driver Setup
====================================
Wave Function Model : Spin-Restricted Kohn-Sham
Initial Guess Model : Superposition of Atomic Densities
Convergence Accelerator : Two Level Direct Inversion of Iterative Subspace
Max. Number of Iterations : 50
Max. Number of Error Vectors : 10
Convergence Threshold : 1.0e-06
ERI Screening Threshold : 1.0e-12
Linear Dependence Threshold : 1.0e-06
Exchange-Correlation Functional : B3LYP
Molecular Grid Level : 4
* Info * Using the B3LYP functional.
P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch., J. Phys. Chem. 98, 11623 (1994)
* Info * Using the Libxc library (v7.0.0).
S. Lehtola, C. Steigemann, M. J.T. Oliveira, and M. A.L. Marques., SoftwareX 7, 1–5 (2018)
* Info * Using the following algorithm for XC numerical integration.
J. Kussmann, H. Laqua and C. Ochsenfeld, J. Chem. Theory Comput. 2021, 17, 1512-1521
* Info * Starting Reduced Basis SCF calculation...
* Info * ...done. SCF energy in reduced basis set: -488.569243894987 a.u. Time: 6.12 sec.
Iter. | Kohn-Sham Energy | Energy Change | Gradient Norm | Max. Gradient | Density Change
--------------------------------------------------------------------------------------------
1 -491.681780507900 0.0000000000 0.63469359 0.04175980 0.00000000
2 -491.650181895461 0.0315986124 0.85119541 0.05488424 0.44187219
3 -491.717823656538 -0.0676417611 0.27218846 0.02210935 0.28411576
4 -491.723104665501 -0.0052810090 0.15543178 0.01309787 0.11615164
5 -491.725519764291 -0.0024150988 0.02520276 0.00153084 0.04830520
6 -491.725576528687 -0.0000567644 0.00956608 0.00070402 0.01091138
7 -491.725587408946 -0.0000108803 0.00359215 0.00029798 0.00483020
8 -491.725589022155 -0.0000016132 0.00130112 0.00006834 0.00180917
9 -491.725589217524 -0.0000001954 0.00025255 0.00001664 0.00042547
10 -491.725589222634 -0.0000000051 0.00012765 0.00000898 0.00010429
11 -491.725589224662 -0.0000000020 0.00001709 0.00000078 0.00004806
12 -491.725589224696 -0.0000000000 0.00000267 0.00000017 0.00000725
13 -491.725589224696 -0.0000000000 0.00000128 0.00000007 0.00000136
14 -491.725589224696 -0.0000000000 0.00000064 0.00000004 0.00000067
*** SCF converged in 14 iterations. Time: 91.76 sec.
Spin-Restricted Kohn-Sham:
--------------------------
Total Energy : -491.7255892247 a.u.
Electronic Energy : -977.7263959634 a.u.
Nuclear Repulsion Energy : 486.0008067387 a.u.
------------------------------------
Gradient Norm : 0.0000006417 a.u.
Ground State Information
------------------------
Charge of Molecule : 0.0
Multiplicity (2S+1) : 1
Magnetic Quantum Number (M_S) : 0.0
import numpy as np
results = prop_results["electric dipole moment"]
print("Electric dipole moment (a.u.):")
print(f"{"x":>17s} {"y":>8s} {"z":>8s}")
print(
f" nuclear: {results["nuclear"][0]:>8.4f} {results["nuclear"][1]:>8.4f} {results["nuclear"][2]:>8.4f}"
)
print(
f"electronic: {results["electronic"][0]:>8.4f} {results["electronic"][1]:>8.4f} {results["electronic"][2]:>8.4f}"
)
print(
f" total: {results["total"][0]:>8.4f} {results["total"][1]:>8.4f} {results["total"][2]:>8.4f}"
)
dipmom = np.linalg.norm(results["total"])
au2debye = 2.5417464
print(f"\nMagnitude: {dipmom * au2debye: .4f} Debye")Electric dipole moment (a.u.):
x y z
nuclear: -0.0000 0.0000 0.0000
electronic: -0.6933 -2.2896 -2.2007
total: -0.6933 -2.2896 -2.2007
Magnitude: 8.2621 Debye
molecule.show()Excited state¶
Python script
import veloxchem as vlx
molecule = vlx.Molecule.read_name("water")
basis = vlx.MolecularBasis.read(molecule, "def2-svp")
scf_drv = vlx.ScfRestrictedDriver()
scf_drv.xcfun = "cam-b3lyp"
scf_results = scf_drv.compute(molecule, basis)from veloxchem.doubleresbeta import DoubleResBetaDriverexcmom_drv = DoubleResBetaDriver()
excmom_drv.initial_state = 3
excmom_drv.final_state = 3
excmom_results = excmom_drv.compute(molecule, basis, scf_results)
Quadratic Response Driver Setup
=================================
ERI Screening Threshold : 1.0e-12
Convergance Threshold : 1.0e-04
Max. Number of Iterations : 150
Max. Number of Iterations : 150
Linear Response EigenSolver Setup
===================================
Number of States : 3
Max. Number of Iterations : 150
Convergence Threshold : 1.0e-04
ERI Screening Threshold : 1.0e-12
Exchange-Correlation Functional : B3LYP
Molecular Grid Level : 4
* Info * Using the B3LYP functional.
P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch., J. Phys. Chem. 98, 11623 (1994)
* Info * Using the Libxc library (v7.0.0).
S. Lehtola, C. Steigemann, M. J.T. Oliveira, and M. A.L. Marques., SoftwareX 7, 1–5 (2018)
* Info * Using the following algorithm for XC numerical integration.
J. Kussmann, H. Laqua and C. Ochsenfeld, J. Chem. Theory Comput. 2021, 17, 1512-1521
* Info * 9 gerade trial vectors in reduced space
* Info * 9 ungerade trial vectors in reduced space
*** Iteration: 1 * Residuals (Max,Min): 3.27e-01 and 7.48e-02
* Info * 12 gerade trial vectors in reduced space
* Info * 12 ungerade trial vectors in reduced space
*** Iteration: 2 * Residuals (Max,Min): 9.08e-02 and 1.35e-02
* Info * 15 gerade trial vectors in reduced space
* Info * 15 ungerade trial vectors in reduced space
*** Iteration: 3 * Residuals (Max,Min): 3.58e-02 and 3.19e-03
* Info * 18 gerade trial vectors in reduced space
* Info * 18 ungerade trial vectors in reduced space
*** Iteration: 4 * Residuals (Max,Min): 1.37e-02 and 3.36e-04
* Info * 21 gerade trial vectors in reduced space
* Info * 21 ungerade trial vectors in reduced space
*** Iteration: 5 * Residuals (Max,Min): 4.42e-03 and 6.25e-05
* Info * 23 gerade trial vectors in reduced space
* Info * 23 ungerade trial vectors in reduced space
*** Iteration: 6 * Residuals (Max,Min): 1.88e-03 and 5.07e-05
* Info * 24 gerade trial vectors in reduced space
* Info * 24 ungerade trial vectors in reduced space
*** Iteration: 7 * Residuals (Max,Min): 6.32e-04 and 5.06e-05
* Info * 25 gerade trial vectors in reduced space
* Info * 25 ungerade trial vectors in reduced space
*** Iteration: 8 * Residuals (Max,Min): 2.00e-04 and 5.06e-05
* Info * 26 gerade trial vectors in reduced space
* Info * 26 ungerade trial vectors in reduced space
*** Iteration: 9 * Residuals (Max,Min): 5.60e-05 and 4.83e-05
*** Linear response converged in 9 iterations. Time: 166.51 sec
Complex Response Solver Setup
===============================
Number of Frequencies : 1
Max. Number of Iterations : 150
Convergence Threshold : 1.0e-04
ERI Screening Threshold : 1.0e-12
Exchange-Correlation Functional : B3LYP
Molecular Grid Level : 4
* Info * Using the B3LYP functional.
P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch., J. Phys. Chem. 98, 11623 (1994)
* Info * Using the Libxc library (v7.0.0).
S. Lehtola, C. Steigemann, M. J.T. Oliveira, and M. A.L. Marques., SoftwareX 7, 1–5 (2018)
* Info * Using the following algorithm for XC numerical integration.
J. Kussmann, H. Laqua and C. Ochsenfeld, J. Chem. Theory Comput. 2021, 17, 1512-1521
* Info * 0 gerade trial vectors in reduced space
* Info * 3 ungerade trial vectors in reduced space
*** Iteration: 1 * Residuals (Max,Min): 1.33e+00 and 7.59e-01
* Info * 0 gerade trial vectors in reduced space
* Info * 6 ungerade trial vectors in reduced space
*** Iteration: 2 * Residuals (Max,Min): 3.22e-01 and 1.44e-01
* Info * 0 gerade trial vectors in reduced space
* Info * 9 ungerade trial vectors in reduced space
*** Iteration: 3 * Residuals (Max,Min): 1.08e-01 and 5.24e-02
* Info * 0 gerade trial vectors in reduced space
* Info * 12 ungerade trial vectors in reduced space
*** Iteration: 4 * Residuals (Max,Min): 2.22e-02 and 1.81e-02
* Info * 0 gerade trial vectors in reduced space
* Info * 15 ungerade trial vectors in reduced space
*** Iteration: 5 * Residuals (Max,Min): 7.30e-03 and 5.18e-03
* Info * 0 gerade trial vectors in reduced space
* Info * 18 ungerade trial vectors in reduced space
*** Iteration: 6 * Residuals (Max,Min): 1.76e-03 and 1.35e-03
* Info * 0 gerade trial vectors in reduced space
* Info * 21 ungerade trial vectors in reduced space
*** Iteration: 7 * Residuals (Max,Min): 5.41e-04 and 3.56e-04
* Info * 0 gerade trial vectors in reduced space
* Info * 24 ungerade trial vectors in reduced space
*** Iteration: 8 * Residuals (Max,Min): 1.46e-04 and 1.02e-04
* Info * 0 gerade trial vectors in reduced space
* Info * 27 ungerade trial vectors in reduced space
*** Iteration: 9 * Residuals (Max,Min): 2.95e-05 and 2.14e-05
*** Complex response converged in 9 iterations. Time: 156.78 sec
Fock Matrix Computation
=========================
* Info * Processing 2 Fock builds...
* Info * Time spent in Fock matrices: 12.91 sec
Summary of Double residue of Quadratic Response Function
==========================================================
Excited state dipole moments
----------------------------
X Y Z
<3|mu|3> : -0.423354 -1.009679 -1.020739
*** Time spent in double residue of quadratic response calculation: 342.00 sec ***
excmom_resultsmu_g = np.array(excmom_results['ground_state_dipole_moments'])
print(f"\nmu_g: {np.linalg.norm(mu_g) * au2debye: .4f} Debye")
mu = []
for key, value in excmom_results['excited_state_dipole_moments'].items():
mu.append(value)
mu = np.array(mu)
print(f"\nmu: {np.linalg.norm(mu) * au2debye: .4f} Debye")
mu_e = -(mu - 2 * mu_g)
print(f"\nmu_e: {np.linalg.norm(mu_e) * au2debye: .4f} Debye")
print(mu_e)
mu_g: 8.2621 Debye
mu: 3.8046 Debye
mu_e: 12.7337 Debye
[-0.96317215 -3.56948309 -3.38073115]
It appears that what is calculated is −(μe−μg) so we need to change sign before adding μg
What is computed is also the difference in electronic dipole moment so we need to add the nuclear part.
polish: let us remove the plural “s” in the keys of the result dictionary
Text file
jobs
task: response
@end
@method settings
xcfun: cam-b3lyp
basis: def2-svpd
@end
@response
property: transition dipole moment
initial_state: 1
final_state: 1
@end
@molecule
charge: 0
multiplicity: 1
xyz:
...
@end- Norman, P., Ruud, K., & Saue, T. (2018). Principles and practices of molecular properties. John Wiley & Sons, Ltd.