Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added examples for vibrational Hamiltonian functions #6717

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pennylane/bose/bosonic_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@ def christiansen_mapping(

Returns:
Union[PauliSentence, Operator]: A linear combination of qubit operators.

**Example**

>>> w = qml.bose.BoseWord({(0,0):"+", (1,1): "-"})
>>> qml.christiansen_mapping(w)
0.25 * (X(0) @ X(1))
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved
+ 0.25j * (X(0) @ Y(1))
+ -0.25j * (Y(0) @ X(1))
+ (0.25+0j) * (Y(0) @ Y(1))
"""

qubit_operator = _christiansen_mapping_dispatch(bose_operator, tol)
Expand Down
16 changes: 16 additions & 0 deletions pennylane/qchem/vibrational/localize_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ def localize_normal_modes(freqs, vecs, bins=[2600]):
- TensorLike[float] : localization matrix describing the relationship between
original and localized modes.

**Example**
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved

>>> freqs = [1326.66001461, 2297.26736859, 2299.65032901]]
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved
>>> vectors = [[[ 5.71518696e-18, -4.55642350e-01, 5.20920552e-01],
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved
[ 1.13167924e-17, 4.55642350e-01, 5.20920552e-01],
[-1.23163569e-17, 5.09494945e-12, -3.27565762e-02]],
[[-4.53008817e-17, 4.90364125e-01, 4.90363894e-01],
[-1.98591028e-16, 4.90361513e-01, -4.90361744e-01],
[-2.78235498e-18, -3.08350419e-02, -6.75886679e-08]],
[[ 5.75393451e-17, 5.37047963e-01, 4.41957355e-01],
[ 6.53049347e-17, -5.37050348e-01, 4.41959740e-01],
[-5.49709883e-17, 7.49851221e-08, -2.77912798e-02]]]
>>> freqs_loc, vecs_loc, uloc = qml.qchem.localize_normal_modes(freqs, vectors)
>>> freqs_loc
[1332.62021421, 2296.73451756, 2296.73457617]
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved

"""
if not bins:
raise ValueError("The `bins` list cannot be empty.")
Expand Down
33 changes: 33 additions & 0 deletions pennylane/qchem/vibrational/vibrational_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ class VibrationalPES:
1, 2, or 3 for upto one-mode dipole, two-mode dipole and three-mode dipole, respectively. Default
value is 1.

**Example**

>>> freqs = np.array([0.01885397])
>>> grid, weights = np.polynomial.hermite.hermgauss(9)
>>> pes_onebody = [[0.05235573, 0.03093067, 0.01501878, 0.00420778, 0.0,
0.00584504, 0.02881817, 0.08483433, 0.22025702]]
>>> pes_twobody = None
>>> dipole_onebody = [[[-1.92201700e-16, 1.45397041e-16, -1.40451549e-01],
[-1.51005108e-16, 9.53185441e-17, -1.03377032e-01],
[-1.22793018e-16, 7.22781963e-17, -6.92825934e-02],
[-1.96537436e-16, -5.86686504e-19, -3.52245369e-02],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[ 5.24758835e-17, -1.40650833e-16, 3.69955543e-02],
[-4.52407941e-17, 1.38406311e-16, 7.60888733e-02],
[-4.63820104e-16, 5.42928787e-17, 1.17726042e-01],
[ 1.19224372e-16, 9.12491386e-17, 1.64013197e-01]]]
>>> vib_obj = qml.qchem.VibrationalPES(freqs=freqs, grid=grid, gauss_weights=weights,
uloc = None, pes_data=[pes_onebody, pes_twobody],
dipole_data=[dipole_onebody], localized=False)
>>> vib_obj.freqs
[0.01885397]
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved

"""

def __init__(
Expand Down Expand Up @@ -150,6 +172,17 @@ def optimize_geometry(molecule, method="rhf"):
Returns:
array[array[float]]: optimized atomic positions in Cartesian coordinates

**Example**

>>> symbols = ['H', 'F']
>>> geometry = np.array([[0.0, 0.0, 0.0],
[0.0, 0.0, 1.0]])
>>> mol = qml.qchem.Molecule(symbols, geometry)
>>> eq_geom = qml.qchem.optimize_geometry(mol)
>>> eq_geom
[[0.0, 0.0, -0.40277116],
[0.0, 0.0, 1.40277116]]
ddhawan11 marked this conversation as resolved.
Show resolved Hide resolved

"""
pyscf = _import_pyscf()
geometric = _import_geometric()
Expand Down
Loading