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

ND Hindered Rotor Improvements #1849

Merged
merged 6 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions arkane/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from rmgpy.thermo.nasa import NASAPolynomial, NASA
from rmgpy.thermo.thermodata import ThermoData
from rmgpy.thermo.wilhoit import Wilhoit
from rmgpy.kinetics.uncertainties import RateUncertainty
from rmgpy.transport import TransportData
from rmgpy.util import as_list

Expand Down Expand Up @@ -567,6 +568,7 @@ def load_input_file(path):
'SingleExponentialDown': SingleExponentialDown,
# Kinetics
'Arrhenius': Arrhenius,
'RateUncertainty' : RateUncertainty,
# Statistical mechanics
'IdealGasTranslation': IdealGasTranslation,
'LinearRotor': LinearRotor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
bonds = {
'C-C': 4,
'C-H': 8,
'C=C': 3,
}

externalSymmetry = 1

spinMultiplicity = 1

opticalIsomers = 1

energy = {
'CBS-QB3': Log('TolueneEnergy.log')
Expand Down
3 changes: 2 additions & 1 deletion rmgpy/statmech/conformer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ cdef class Conformer(RMGObject):
elif pivots[0] in top1 and pivots[1] in top1:
raise ValueError('Both pivot atoms included in top; you must specify only one pivot atom that belongs'
' with the specified top.')

elif 0 in top1:
alongd marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError('Top must be one indexed, top1: {}'.format(top1))
# Enumerate atoms in other top
top2 = [i + 1 for i in range(n_atoms) if i + 1 not in top1]

Expand Down
23 changes: 15 additions & 8 deletions rmgpy/statmech/ndTorsions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import os
import os.path
import subprocess
import itertools

import numdifftools as nd
import numpy as np
Expand Down Expand Up @@ -576,12 +577,9 @@ def fit(self):
generate splines for the first and second derivatives of the partition function
"""
N = len(self.pivots)
if N > 2:
if N > 1:
self.V = interpolate.LinearNDInterpolator(self.phis, self.Es)
self.rootD = interpolate.LinearNDInterpolator(self.phis, self.rootDs)
elif N == 2:
self.V = interpolate.SmoothBivariateSpline(self.phis[:, 0], self.phis[:, 1], self.Es)
self.rootD = interpolate.SmoothBivariateSpline(self.phis[:, 0], self.phis[:, 1], self.rootDs)
else:
self.V = interpolate.CubicSpline(self.phis, self.Es)
self.rootD = interpolate.CubicSpline(self.phis, self.rootDs)
Expand All @@ -600,12 +598,22 @@ def calc_partition_function(self, T):
"""
calculate the classical/semiclassical partition function at a given temperature
"""
rngs = [(0.0, 2.0 * np.pi) for x in range(len(self.pivots))]

def f(*phis):
return self.rootD(*phis) * np.exp(-self.V(*phis) / (constants.R * T))

intg = inte.nquad(f, ranges=rngs)[0]

rphis = np.linspace(0, 2.0*np.pi, 30)
alongd marked this conversation as resolved.
Show resolved Hide resolved
Imat = np.zeros([len(rphis) for i in range(len(self.pivots))])
it = itertools.product(*[list(range(len(rphis))) for i in range(len(self.pivots))])

for coords in it:
Imat[coords] = f(*rphis[np.array(coords)])

for i in range(len(self.pivots)):
Imat = inte.simps(Imat, rphis)

intg = Imat

Q = intg * (2.0 * np.pi * constants.kB * T / constants.h**2) ** (len(self.pivots) / 2.0) / np.prod(self.sigmas)

if self.semiclassical:
Expand All @@ -615,7 +623,6 @@ def f(*phis):
x = constants.h * freqs / (constants.kB * T)
out = x / (1.0 - np.exp(-x))
Q *= np.prod(out)

return Q

def get_partition_function(self, T):
Expand Down
2 changes: 1 addition & 1 deletion rmgpy/statmech/ndTorsionsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_hindered_rotor_nd(self):
self.hdnd.read_scan()
self.assertAlmostEqual(self.hdnd.Es[0], 20.048316823666962, 4)
self.hdnd.fit()
self.assertAlmostEqual(self.hdnd.calc_partition_function(300.0), 2.85254214434672, 5)
self.assertAlmostEqual(self.hdnd.calc_partition_function(300.0), 2.8524691948593133, 5)


if __name__ == '__main__':
Expand Down