Skip to content

Commit 32cb930

Browse files
committed
Prevent RMG from crashing because of missing transport groups
- add function getTransportPropertiesViaLennardJonesParameters(self,species) to transport.py - use this function as a fall back only if the library and the transport groups do not have proper information
1 parent 13297e3 commit 32cb930

1 file changed

Lines changed: 49 additions & 10 deletions

File tree

rmgpy/data/transport.py

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,12 @@ def getTransportProperties(self, species):
274274
transport[0].comment = label
275275
break
276276
else:
277-
#Transport not found in any loaded libraries, so estimate
278-
transport = self.getTransportPropertiesViaGroupEstimates(species)
279-
#data, library, entry = transport
280-
#return data
277+
try:
278+
#Transport not found in any loaded libraries, so estimate
279+
transport = self.getTransportPropertiesViaGroupEstimates(species)
280+
except:
281+
transport = self.getTransportPropertiesViaLennardJonesParameters(species)
282+
281283
return transport
282284

283285
def getAllTransportProperties(self, species):
@@ -368,7 +370,6 @@ def estimateCriticalPropertiesViaGroupAdditivity(self, molecule):
368370
# For transport estimation we need the atoms to already be sorted because we
369371
# iterate over them; if the order changes during the iteration then we
370372
# will probably not visit the right atoms, and so will get the transport wrong
371-
molecule.sortVertices()
372373

373374
if sum([atom.radicalElectrons for atom in molecule.atoms]) > 0: # radical species
374375

@@ -433,12 +434,9 @@ def estimateCriticalPropertiesViaGroupAdditivity(self, molecule):
433434
if molecule.isVertexInCycle(atom):
434435
self.__addCriticalPointContribution(groupData, self.groups['ring'], molecule, {'*':atom})
435436
else:
436-
self.__addCriticalPointContribution(groupData, self.groups['nonring'], molecule, {'*':atom})
437+
self.__addCriticalPointContribution(groupData, self.groups['nonring'], molecule, {'*':atom})
437438
except KeyError:
438-
logging.error("Couldn't find in any transport database:")
439-
logging.error(molecule)
440-
logging.error(molecule.toAdjacencyList())
441-
raise
439+
raise
442440

443441
Tb = 198.18 + groupData.Tb
444442
Vc = 17.5 + groupData.Vc
@@ -493,6 +491,47 @@ def __addCriticalPointContribution(self, groupData, database, molecule, atom):
493491
groupData.structureIndex += data.structureIndex
494492

495493
return groupData
494+
495+
def getTransportPropertiesViaLennardJonesParameters(self,species):
496+
"""
497+
Serves as last resort if every other method to estimate Transport Properties fails.
498+
499+
Generate the Lennard-Jones parameters for the species.
500+
"""
501+
count = sum([1 for atom in species.molecule[0].vertices if atom.isNonHydrogen()])
502+
503+
if count == 1:
504+
sigma = (3.758e-10,"m")
505+
epsilon = (148.6,"K")
506+
elif count == 2:
507+
sigma = (4.443e-10,"m")
508+
epsilon = (110.7,"K")
509+
elif count == 3:
510+
sigma = (5.118e-10,"m")
511+
epsilon = (237.1,"K")
512+
elif count == 4:
513+
sigma = (4.687e-10,"m")
514+
epsilon = (531.4,"K")
515+
elif count == 5:
516+
sigma = (5.784e-10,"m")
517+
epsilon = (341.1,"K")
518+
else:
519+
sigma = (5.949e-10,"m")
520+
epsilon = (399.3,"K")
521+
522+
shapeIndex = 1 if species.molecule[0].isLinear() else 2
523+
524+
transport = TransportData(
525+
shapeIndex = shapeIndex, # 1 if linear, else 2
526+
epsilon = epsilon,
527+
sigma = sigma,
528+
dipoleMoment = (0, 'C*m'),
529+
polarizability = (0, 'angstroms^3'),
530+
rotrelaxcollnum = 0, # rotational relaxation collision number at 298 K
531+
comment = 'Epsilon & sigma estimated with fixed Lennard Jones Parameters. This is the fallback method! Try improving transport databases!'
532+
)
533+
534+
return (transport, None, None)
496535

497536
class CriticalPoint:
498537
"""

0 commit comments

Comments
 (0)