Skip to content

Commit 864fbe4

Browse files
committed
Docstrs in properties API
1 parent 665f836 commit 864fbe4

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

dqc/api/properties.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ def ir_spectrum(qc: BaseQCCalc, freq_unit: Optional[str] = "cm^-1",
9292
Tuple of tensors where the first tensor is the frequency in the given unit
9393
with shape ``(nfreqs,)`` sorted from the largest to smallest, and the second
9494
tensor is the IR intensity with the same order as the frequency.
95+
96+
Example
97+
-------
98+
99+
.. code-block:: python
100+
101+
import torch
102+
import dqc
103+
104+
dtype = torch.float64
105+
moldesc = "O 0 0 0.2156; H 0 1.4749 -0.8625; H 0 -1.4749 -0.8625" # in Bohr
106+
efield = torch.zeros(3, dtype=dtype).requires_grad_() # efield must be specified
107+
mol = dqc.Mol(moldesc=moldesc, basis="3-21G", dtype=dtype, efield=(efield,))
108+
qc = dqc.HF(mol).run()
109+
ir_freq, ir_ints = dqc.ir_spectrum(qc, freq_unit="cm^-1")
110+
95111
"""
96112
freq, ir_ints = _ir_spectrum(qc)
97113
freq = convert_freq(freq, to_unit=freq_unit)
@@ -120,6 +136,22 @@ def raman_spectrum(qc: BaseQCCalc, freq_unit: Optional[str] = "cm^-1",
120136
Tuple of tensors where the first tensor is the frequency in the given unit
121137
with shape ``(nfreqs,)`` sorted from the largest to smallest, and the second
122138
tensor is the IR intensity with the same order as the frequency.
139+
140+
141+
Example
142+
-------
143+
144+
.. code-block:: python
145+
146+
import torch
147+
import dqc
148+
149+
dtype = torch.float64
150+
moldesc = "O 0 0 0.2156; H 0 1.4749 -0.8625; H 0 -1.4749 -0.8625" # in Bohr
151+
efield = torch.zeros(3, dtype=dtype).requires_grad_() # efield must be specified
152+
mol = dqc.Mol(moldesc=moldesc, basis="3-21G", dtype=dtype, efield=(efield,))
153+
qc = dqc.HF(mol).run()
154+
raman_freq, raman_ints = dqc.raman_spectrum(qc, freq_unit="cm^-1", ints_unit="angst^4/amu")
123155
"""
124156
freq, raman_ints = _raman_spectrum(qc)
125157
freq = convert_freq(freq, to_unit=freq_unit)
@@ -143,6 +175,22 @@ def edipole(qc: BaseQCCalc, unit: Optional[str] = "Debye") -> torch.Tensor:
143175
-------
144176
torch.Tensor
145177
Tensor representing the dipole moment in atomic unit with shape ``(ndim,)``
178+
179+
Example
180+
-------
181+
182+
.. code-block:: python
183+
184+
import torch
185+
import dqc
186+
187+
dtype = torch.float64
188+
moldesc = "O 0 0 0.2156; H 0 1.4749 -0.8625; H 0 -1.4749 -0.8625" # in Bohr
189+
efield = torch.zeros(3, dtype=dtype).requires_grad_() # efield must be specified
190+
mol = dqc.Mol(moldesc=moldesc, basis="3-21G", dtype=dtype, efield=(efield,))
191+
qc = dqc.HF(mol).run()
192+
dip_moment = dqc.edipole(qc, unit="debye")
193+
146194
"""
147195
edip = _edipole(qc)
148196
edip = convert_edipole(edip, to_unit=unit)
@@ -164,6 +212,22 @@ def equadrupole(qc: BaseQCCalc, unit: Optional[str] = "Debye*Angst") -> torch.Te
164212
-------
165213
torch.Tensor
166214
Tensor representing the quadrupole moment in atomic unit in ``(ndim, ndim)``
215+
216+
Example
217+
-------
218+
219+
.. code-block:: python
220+
221+
import torch
222+
import dqc
223+
224+
dtype = torch.float64
225+
moldesc = "O 0 0 0.2156; H 0 1.4749 -0.8625; H 0 -1.4749 -0.8625" # in Bohr
226+
efield = torch.zeros(3, dtype=dtype).requires_grad_() # efield must be specified
227+
grad_efield = torch.zeros((3, 3), dtype=dtype).requires_grad_() # grad_efield must be specified
228+
mol = dqc.Mol(moldesc=moldesc, basis="3-21G", dtype=dtype, efield=(efield, grad_efield))
229+
qc = dqc.HF(mol).run()
230+
equad = dqc.equadrupole(qc)
167231
"""
168232
equad = _equadrupole(qc)
169233
equad = convert_equadrupole(equad, to_unit=unit)

0 commit comments

Comments
 (0)