MolecularVibrations
__init__(self, molecule, basis, freqs=None, init=None):
Sets up a vibration for a Molecule object over the CoordinateSystem basis
molecule
:AbstractMolecule
init
:None | CoordinateSet
basis
:MolecularNormalModes
@property
basis(self):
@property
molecule(self):
@property
freqs(self):
@property
coords(self):
:returns
:CoordinateSet
__len__(self):
displace(self, displacements=None, amt=0.1, n=1, which=0):
Displaces along the vibrational mode specified by which
displacements
:Any
amt
:Any
n
:Any
which
:Any
:returns
:_
visualize(self, step_size=5, steps=(2, 2), which=0, anim_opts=None, mode='fast', **plot_args):
step_size
:Any
steps
:Any
which
:Any
anim_opts
:Any
mode
:Any
plot_args
:Any
:returns
:_
to_widget(self):
__getitem__(self, item):
Takes a slice of the modes
item
:Any
:returns
:_
embed(self, frame):
frame
:MolecularTransformation
:returns
:_
rescale(self, scaling):
Multiplies each mode by some scaling factor
phases
:Any
:returns
:_
rotate(self, scaling):
Multiplies each mode by some scaling factor
phases
:Any
:returns
:_
__repr__(self):
Examples
Before we can run our examples we should get a bit of setup out of the way. Since these examples were harvested from the unit tests not all pieces will be necessary for all situations.
All tests are wrapped in a test class
class MolecoolsTests(TestCase):
def setUp(self):
self.test_log_water = TestManager.test_data("water_OH_scan.log")
self.test_log_freq = TestManager.test_data("water_freq.log")
self.test_HOD = TestManager.test_data("HOD_freq.fchk")
self.test_fchk = TestManager.test_data("water_freq.fchk")
self.test_log_h2 = TestManager.test_data("outer_H2_scan_new.log")
VisualizeNormalModes
def test_VisualizeNormalModes(self):
from Psience.Molecools.Vibrations import MolecularVibrations, MolecularNormalModes
from McUtils.Plots import GraphicsGrid, Graphics3D
m = Molecule.from_file(self.test_fchk, bonds = [[0, 1, 1], [0, 2, 1]])
with GaussianFChkReader(self.test_fchk) as reader:
parse = reader.parse(("VibrationalModes", "VibrationalData"))
modes = parse["VibrationalModes"].T
test_freqs = parse["VibrationalData"]["Frequencies"]
nms = m.normal_modes
realvibs = MolecularVibrations(m, basis=MolecularNormalModes(m, modes, freqs=test_freqs))
realvibs.visualize(mode='jupyter') # get no bugs
plot_vibrations = False
if plot_vibrations:
nmodes = 1
mode_start = 0
g = GraphicsGrid(nrows=2, ncols=nmodes,
graphics_class=Graphics3D,
plot_range = [[-2, 2], [-2, 2], [-2, 2]],
fig_kw = dict(figsize = (17, 5)),
tighten = True
)
for i in range(nmodes):
nms.visualize(step_size=.1, figure = g[0, i], which=mode_start + i,
anim_opts= dict(interval = 10)
)
for i in range(nmodes):
realvibs.visualize(step_size=.1, figure = g[1, i], which= mode_start+i,
anim_opts= dict(interval = 10)
)
g.show()
self.assertEquals(
tuple(np.round(UnitsData.convert("Hartrees", "Wavenumbers")*nms.modes.freqs, 4)),
tuple(np.round(test_freqs, 4))
)