本文整理汇总了Python中rmgpy.rmg.model.Species.generateResonanceIsomers方法的典型用法代码示例。如果您正苦于以下问题:Python Species.generateResonanceIsomers方法的具体用法?Python Species.generateResonanceIsomers怎么用?Python Species.generateResonanceIsomers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rmgpy.rmg.model.Species
的用法示例。
在下文中一共展示了Species.generateResonanceIsomers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testNewThermoGeneration
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testNewThermoGeneration(self):
"""
Test that the new ThermoDatabase generates appropriate thermo data.
"""
for smiles, symm, H298, S298, Cp300, Cp400, Cp500, Cp600, Cp800, Cp1000, Cp1500 in self.testCases:
Cplist = [Cp300, Cp400, Cp500, Cp600, Cp800, Cp1000, Cp1500]
molecule=Molecule(SMILES=smiles)
species = Species(molecule=molecule)
species.generateResonanceIsomers()
species.molecule[0]
thermoData = self.database.getThermoDataFromGroups(species)
molecule = species.molecule[0]
for mol in species.molecule[1:]:
thermoData0 = self.database.getAllThermoData(Species(molecule=[mol]))[0][0]
for data in self.database.getAllThermoData(Species(molecule=[mol]))[1:]:
if data.getEnthalpy(298) < thermoData0.getEnthalpy(298):
thermoData0 = data
if thermoData0.getEnthalpy(298) < thermoData.getEnthalpy(298):
thermoData = thermoData0
molecule = mol
self.assertAlmostEqual(H298, thermoData.getEnthalpy(298) / 4184, places=1, msg="H298 error for {0}".format(smiles))
self.assertAlmostEqual(S298, thermoData.getEntropy(298) / 4.184, places=1, msg="S298 error for {0}".format(smiles))
for T, Cp in zip(self.Tlist, Cplist):
self.assertAlmostEqual(Cp, thermoData.getHeatCapacity(T) / 4.184, places=1, msg="Cp{1} error for {0}".format(smiles,T))
示例2: testPolycyclicPicksBestThermo
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testPolycyclicPicksBestThermo(self):
"""
Test that RMG prioritizes thermo correctly and chooses the thermo from the isomer which
has a non generic polycyclic ring correction
"""
spec = Species().fromSMILES('C1=C[C]2CCC=C2C1')
spec.generateResonanceIsomers()
thermoDataList = []
for molecule in spec.molecule:
thermo = self.database.estimateRadicalThermoViaHBI(molecule, self.database.computeGroupAdditivityThermo)
thermoDataList.append(thermo)
thermoDataList.sort(key=lambda x: x.getEnthalpy(298))
most_stable_thermo = thermoDataList[0]
ringGroups, polycyclicGroups = self.database.getRingGroupsFromComments(most_stable_thermo)
selected_thermo = self.database.getThermoDataFromGroups(spec)
self.assertNotEqual(selected_thermo, thermoDataList)
selected_ringGroups, selected_polycyclicGroups = self.database.getRingGroupsFromComments(selected_thermo)
# The group used to estimate the most stable thermo is the generic polycyclic group and
# therefore is not selected. Note that this unit test will have to change if the correction is fixed later.
self.assertEqual(polycyclicGroups[0].label, 'PolycyclicRing')
self.assertEqual(selected_polycyclicGroups[0].label, 'C12CCC=C1CC=C2')
示例3: testSpeciesThermoGenerationHBIGAV
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testSpeciesThermoGenerationHBIGAV(self):
"""Test thermo generation for species objects.
Ensure that molecule list is only reordered, and not changed after group additivity"""
spec = Species().fromSMILES('CCC[CH]c1ccccc1')
spec.generateResonanceIsomers()
initial = list(spec.molecule) # Make a copy of the list
thermo = self.database.getThermoData(spec)
self.assertEqual(len(initial), len(spec.molecule))
self.assertEqual(set(initial), set(spec.molecule))
self.assertTrue('group additivity' in thermo.comment, 'Thermo not found from GAV, test purpose not fulfilled.')
示例4: testAddPolyRingCorrectionThermoDataFromHeuristicUsingPyrene
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testAddPolyRingCorrectionThermoDataFromHeuristicUsingPyrene(self):
# create testing molecule: Pyrene with two ring of aromatic version
# the other two ring of kekulized version
#
# creating it seems not natural in RMG, that's because
# RMG cannot parse the adjacencyList of that isomer correctly
# so here we start with pyrene radical and get the two aromatic ring isomer
# then saturate it.
smiles = '[C]1C=C2C=CC=C3C=CC4=CC=CC=1C4=C23'
spe = Species().fromSMILES(smiles)
spe.generateResonanceIsomers()
mols = []
for mol in spe.molecule:
sssr0 = mol.getSmallestSetOfSmallestRings()
aromaticRingNum = 0
for sr0 in sssr0:
sr0mol = Molecule(atoms=sr0)
if isAromaticRing(sr0mol):
aromaticRingNum += 1
if aromaticRingNum == 2:
mol.saturate()
mols.append(mol)
ringGroupLabels = []
polycyclicGroupLabels = []
for mol in mols:
polyring = mol.getDisparateRings()[1][0]
thermoData = ThermoData(
Tdata = ([300,400,500,600,800,1000,1500],"K"),
Cpdata = ([0.0,0.0,0.0,0.0,0.0,0.0,0.0],"J/(mol*K)"),
H298 = (0.0,"kJ/mol"),
S298 = (0.0,"J/(mol*K)"),
)
self.database._ThermoDatabase__addPolyRingCorrectionThermoDataFromHeuristic(
thermoData, polyring)
ringGroups, polycyclicGroups = self.database.getRingGroupsFromComments(thermoData)
ringGroupLabels += [ringGroup.label for ringGroup in ringGroups]
polycyclicGroupLabels += [polycyclicGroup.label for polycyclicGroup in polycyclicGroups]
self.assertIn('Benzene', ringGroupLabels)
self.assertIn('six-inringtwodouble-12', ringGroupLabels)
self.assertIn('Cyclohexene', ringGroupLabels)
self.assertIn('1,3-Cyclohexadiene', ringGroupLabels)
self.assertIn('s2_6_6_ben_ene_1', polycyclicGroupLabels)
self.assertIn('s2_6_6_ben_ene_2', polycyclicGroupLabels)
self.assertIn('s2_6_6_naphthalene', polycyclicGroupLabels)
示例5: testBicyclicDecompositionForPolyringUsingPyrene
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testBicyclicDecompositionForPolyringUsingPyrene(self):
# create testing molecule: Pyrene with two ring of aromatic version
# the other two ring of kekulized version
#
# creating it seems not natural in RMG, that's because
# RMG cannot parse the adjacencyList of that isomer correctly
# so here we start with pyrene radical and get the two aromatic ring isomer
# then saturate it.
smiles = '[C]1C=C2C=CC=C3C=CC4=CC=CC=1C4=C23'
spe = Species().fromSMILES(smiles)
spe.generateResonanceIsomers()
for mol in spe.molecule:
sssr0 = mol.getSmallestSetOfSmallestRings()
aromaticRingNum = 0
for sr0 in sssr0:
sr0mol = Molecule(atoms=sr0)
if isAromaticRing(sr0mol):
aromaticRingNum += 1
if aromaticRingNum == 2:
break
mol.saturate()
# extract polyring from the molecule
polyring = mol.getDisparateRings()[1][0]
bicyclicList, ringOccurancesDict = bicyclicDecompositionForPolyring(polyring)
# 1st test: number of cores
self.assertEqual(len(bicyclicList), 5)
# 2nd test: ringOccurancesDict
ringInCoreOccurances = sorted(ringOccurancesDict.values())
expectedRingInCoreOccurances = [2, 2, 3, 3]
self.assertEqual(ringInCoreOccurances, expectedRingInCoreOccurances)
# 3rd test: size of each bicyclic core
bicyclicSizes = sorted([len(bicyclic.atoms) for bicyclic in bicyclicList])
expectedBicyclicSizes = [10, 10, 10, 10, 10]
self.assertEqual(bicyclicSizes, expectedBicyclicSizes)
# 4th test: bond info for members of each core
aromaticBondNumInBicyclics = []
for bicyclic in bicyclicList:
aromaticBondNum = len(findAromaticBondsFromSubMolecule(bicyclic))
aromaticBondNumInBicyclics.append(aromaticBondNum)
aromaticBondNumInBicyclics = sorted(aromaticBondNumInBicyclics)
expectedAromaticBondNumInBicyclics = [0, 6, 6, 6, 11]
self.assertEqual(aromaticBondNumInBicyclics, expectedAromaticBondNumInBicyclics)
示例6: testComputeGroupAdditivityThermoForTwoRingMolecule
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testComputeGroupAdditivityThermoForTwoRingMolecule(self):
"""
The molecule being tested has two rings, one is 13cyclohexadiene5methylene
the other is benzene ring. This method is to test thermo estimation will
give two different corrections accordingly.
"""
spec = Species().fromSMILES('CCCCCCCCCCCC(CC=C1C=CC=CC1)c1ccccc1')
spec.generateResonanceIsomers()
thermo = self.database.getThermoDataFromGroups(spec)
ringGroups, polycyclicGroups = self.database.getRingGroupsFromComments(thermo)
self.assertEqual(len(ringGroups),2)
self.assertEqual(len(polycyclicGroups),0)
expected_matchedRingsLabels = ['13cyclohexadiene5methylene', 'Benzene']
expected_matchedRings = [self.database.groups['ring'].entries[label] for label in expected_matchedRingsLabels]
self.assertEqual(set(ringGroups), set(expected_matchedRings))
示例7: testFindAromaticBondsFromSubMolecule
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testFindAromaticBondsFromSubMolecule(self):
smiles = "C1=CC=C2C=CC=CC2=C1"
spe = Species().fromSMILES(smiles)
spe.generateResonanceIsomers()
mol = spe.molecule[1]
# get two SSSRs
SSSR = mol.getSmallestSetOfSmallestRings()
ring1 = SSSR[0]
ring2 = SSSR[1]
# create two testing submols
submol1 = Molecule(atoms=ring1)
submol2 = Molecule(atoms=ring2)
# check with expected results
self.assertEqual(len(findAromaticBondsFromSubMolecule(submol1)), 6)
self.assertEqual(len(findAromaticBondsFromSubMolecule(submol2)), 6)
示例8: testAddPolyRingCorrectionThermoDataFromHeuristicUsingAromaticTricyclic
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testAddPolyRingCorrectionThermoDataFromHeuristicUsingAromaticTricyclic(self):
# create testing molecule
#
# creating it seems not natural in RMG, that's because
# RMG cannot parse the adjacencyList of that isomer correctly
# so here we start with kekulized version and generateResonanceIsomers
# and pick the one with two aromatic rings
smiles = 'C1=CC2C=CC=C3C=CC(=C1)C=23'
spe = Species().fromSMILES(smiles)
spe.generateResonanceIsomers()
for mol in spe.molecule:
sssr0 = mol.getSmallestSetOfSmallestRings()
aromaticRingNum = 0
for sr0 in sssr0:
sr0mol = Molecule(atoms=sr0)
if isAromaticRing(sr0mol):
aromaticRingNum += 1
if aromaticRingNum == 2:
break
# extract polyring from the molecule
polyring = mol.getDisparateRings()[1][0]
thermoData = ThermoData(
Tdata = ([300,400,500,600,800,1000,1500],"K"),
Cpdata = ([0.0,0.0,0.0,0.0,0.0,0.0,0.0],"J/(mol*K)"),
H298 = (0.0,"kJ/mol"),
S298 = (0.0,"J/(mol*K)"),
)
self.database._ThermoDatabase__addPolyRingCorrectionThermoDataFromHeuristic(
thermoData, polyring)
ringGroups, polycyclicGroups = self.database.getRingGroupsFromComments(thermoData)
ringGroupLabels = [ringGroup.label for ringGroup in ringGroups]
polycyclicGroupLabels = [polycyclicGroup.label for polycyclicGroup in polycyclicGroups]
self.assertIn('Benzene', ringGroupLabels)
self.assertIn('Cyclopentene', ringGroupLabels)
self.assertIn('s2_5_6_indene', polycyclicGroupLabels)
self.assertIn('s2_6_6_naphthalene', polycyclicGroupLabels)
示例9: testThermoForMonocyclicAndPolycyclicSameMolecule
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testThermoForMonocyclicAndPolycyclicSameMolecule(self):
"""
Test a molecule that has both a polycyclic and a monocyclic ring in the same molecule
"""
spec = Species().fromSMILES('C(CCC1C2CCC1CC2)CC1CCC1')
spec.generateResonanceIsomers()
thermo = self.database.getThermoDataFromGroups(spec)
ringGroups, polycyclicGroups = self.database.getRingGroupsFromComments(thermo)
self.assertEqual(len(ringGroups),1)
self.assertEqual(len(polycyclicGroups),1)
expected_matchedRingsLabels = ['Cyclobutane']
expected_matchedRings = [self.database.groups['ring'].entries[label] for label in expected_matchedRingsLabels]
self.assertEqual(set(ringGroups), set(expected_matchedRings))
expected_matchedPolyringsLabels = ['s3_5_5_ane']
expected_matchedPolyrings = [self.database.groups['polycyclic'].entries[label] for label in expected_matchedPolyringsLabels]
self.assertEqual(set(polycyclicGroups), set(expected_matchedPolyrings))
示例10: testSymmetryNumberGeneration
# 需要导入模块: from rmgpy.rmg.model import Species [as 别名]
# 或者: from rmgpy.rmg.model.Species import generateResonanceIsomers [as 别名]
def testSymmetryNumberGeneration(self):
"""
Test we generate symmetry numbers correctly.
This uses the new thermo database to generate the H298, used
to select the stablest resonance isomer.
"""
for smiles, symm, H298, S298, Cp300, Cp400, Cp500, Cp600, Cp800, Cp1000, Cp1500 in self.testCases:
molecule=Molecule(SMILES=smiles)
species = Species(molecule=molecule)
species.generateResonanceIsomers()
thermoData = self.database.getThermoDataFromGroups(Species(molecule=[species.molecule[0]]))
# pick the molecule with lowest H298
molecule = species.molecule[0]
for mol in species.molecule[1:]:
thermoData0 = self.database.getAllThermoData(Species(molecule=[mol]))[0][0]
for data in self.database.getAllThermoData(Species(molecule=[mol]))[1:]:
if data.getEnthalpy(298) < thermoData0.getEnthalpy(298):
thermoData0 = data
if thermoData0.getEnthalpy(298) < thermoData.getEnthalpy(298):
thermoData = thermoData0
molecule = mol
self.assertEqual(molecule.calculateSymmetryNumber(), symm, msg="Symmetry number error for {0}".format(smiles))