コード例 #1
0
def failsSpeciesConstraints(species):
    """
    Pass in either a `Species` or `Molecule` object and checks whether it passes 
    the speciesConstraints set by the user.  If not, returns `True` for failing speciesConstraints.
    """

    from rmgpy.rmg.input import getInput

    try:
        speciesConstraints = getInput('speciesConstraints')
    except Exception, e:
        logging.debug('Species constraints could not be found.')
        speciesConstraints = {}
コード例 #2
0
ファイル: constraints.py プロジェクト: Alborzi/RMG-Py
def failsSpeciesConstraints(species):
    """
    Pass in either a `Species` or `Molecule` object and checks whether it passes 
    the speciesConstraints set by the user.  If not, returns `True` for failing speciesConstraints.
    """
    
    from rmgpy.rmg.input import getInput

    try:
        speciesConstraints = getInput('speciesConstraints')
    except Exception, e:
        logging.debug('Species constraints could not be found.')
        speciesConstraints = {}
コード例 #3
0
ファイル: thermoengine.py プロジェクト: shenghuiqin/RMG-Py
def generateThermoData(spc, thermoClass=NASA, solventName=''):
    """
    Generates thermo data, first checking Libraries, then using either QM or Database.
    
    The database generates the thermo data for each structure (resonance isomer),
    picks that with lowest H298 value.
    
    It then calls :meth:`processThermoData`, to convert (via Wilhoit) to NASA
    and set the E0.
    
    Result stored in `spc.thermo` and returned.
    """

    try:
        thermodb = getDB('thermo')
        if not thermodb: raise Exception
    except Exception:
        logging.debug(
            'Could not obtain the thermo database. Not generating thermo...')
        return None

    thermo0 = thermodb.getThermoData(spc)

    # 1. maybe only submit cyclic core
    # 2. to help radical prediction, HBI should also
    #    look up centrailThermoDB for its saturated version
    #    currently it only looks up libraries or estimates via GAV
    from rmgpy.rmg.input import getInput

    try:
        thermoCentralDatabase = getInput('thermoCentralDatabase')
    except Exception:
        logging.debug('thermoCentralDatabase could not be found.')
        thermoCentralDatabase = None

    if thermoCentralDatabase and thermoCentralDatabase.client \
        and thermoCentralDatabase.satisfyRegistrationRequirements(spc, thermo0, thermodb):

        thermoCentralDatabase.registerInCentralThermoDB(spc)

    return processThermoData(spc, thermo0, thermoClass, solventName)
コード例 #4
0
def generateThermoData(spc, thermoClass=NASA, solventName=''):
    """
    Generates thermo data, first checking Libraries, then using either QM or Database.
    
    The database generates the thermo data for each structure (resonance isomer),
    picks that with lowest H298 value.
    
    It then calls :meth:`processThermoData`, to convert (via Wilhoit) to NASA
    and set the E0.
    
    Result stored in `spc.thermo` and returned.
    """
    
    try:
        thermodb = getDB('thermo')
        if not thermodb: raise Exception
    except Exception:
        logging.debug('Could not obtain the thermo database. Not generating thermo...')
        return None
    
    thermo0 = thermodb.getThermoData(spc) 

    # 1. maybe only submit cyclic core
    # 2. to help radical prediction, HBI should also
    #    look up centrailThermoDB for its saturated version
    #    currently it only looks up libraries or estimates via GAV 
    from rmgpy.rmg.input import getInput
    
    try:
        thermoCentralDatabase = getInput('thermoCentralDatabase')
    except Exception:
        logging.debug('thermoCentralDatabase could not be found.')
        thermoCentralDatabase = None
    
    if thermoCentralDatabase and thermoCentralDatabase.client \
        and thermoCentralDatabase.satisfyRegistrationRequirements(spc, thermo0, thermodb):
        
        thermoCentralDatabase.registerInCentralThermoDB(spc)
        
    return processThermoData(spc, thermo0, thermoClass, solventName)
コード例 #5
0
ファイル: thermoengine.py プロジェクト: yplitw/RMG-Py
        if not thermodb: raise Exception
    except Exception, e:
        logging.debug(
            'Could not obtain the thermo database. Not generating thermo...')
        return None

    thermo0 = thermodb.getThermoData(spc)

    # 1. maybe only submit cyclic core
    # 2. to help radical prediction, HBI should also
    #    look up centrailThermoDB for its saturated version
    #    currently it only looks up libraries or estimates via GAV
    from rmgpy.rmg.input import getInput

    try:
        thermoCentralDatabase = getInput('thermoCentralDatabase')
    except Exception, e:
        logging.debug('thermoCentralDatabase could not be found.')
        thermoCentralDatabase = None

    if thermoCentralDatabase and thermoCentralDatabase.client \
        and thermoCentralDatabase.satisfyRegistrationRequirements(spc, thermo0, thermodb):

        thermoCentralDatabase.registerInCentralThermoDB(spc)

    return processThermoData(spc, thermo0, thermoClass)


def evaluator(spc):
    """
    Module-level function passed to workers.
コード例 #6
0
ファイル: constraints.py プロジェクト: sleepyguyallday/RMG-Py
def failsSpeciesConstraints(species):
    """
    Pass in either a `Species` or `Molecule` object and checks whether it passes 
    the speciesConstraints set by the user.  If not, returns `True` for failing speciesConstraints.
    """

    from rmgpy.rmg.input import getInput

    try:
        speciesConstraints = getInput('speciesConstraints')
    except Exception:
        logging.debug('Species constraints could not be found.')
        speciesConstraints = {}

    if isinstance(species, Species):
        struct = species.molecule[0]
    else:
        # expects a molecule here
        struct = species

    explicitlyAllowedMolecules = speciesConstraints.get(
        'explicitlyAllowedMolecules', [])
    for molecule in explicitlyAllowedMolecules:
        if struct.isIsomorphic(molecule):
            return False

    maxCarbonAtoms = speciesConstraints.get('maximumCarbonAtoms', -1)
    if maxCarbonAtoms != -1:
        if struct.getNumAtoms('C') > maxCarbonAtoms:
            return True

    maxOxygenAtoms = speciesConstraints.get('maximumOxygenAtoms', -1)
    if maxOxygenAtoms != -1:
        if struct.getNumAtoms('O') > maxOxygenAtoms:
            return True

    maxNitrogenAtoms = speciesConstraints.get('maximumNitrogenAtoms', -1)
    if maxNitrogenAtoms != -1:
        if struct.getNumAtoms('N') > maxNitrogenAtoms:
            return True

    maxSiliconAtoms = speciesConstraints.get('maximumSiliconAtoms', -1)
    if maxSiliconAtoms != -1:
        if struct.getNumAtoms('Si') > maxSiliconAtoms:
            return True

    maxSulfurAtoms = speciesConstraints.get('maximumSulfurAtoms', -1)
    if maxSulfurAtoms != -1:
        if struct.getNumAtoms('S') > maxSulfurAtoms:
            return True

    maxHeavyAtoms = speciesConstraints.get('maximumHeavyAtoms', -1)
    if maxHeavyAtoms != -1:
        if struct.getNumAtoms() - struct.getNumAtoms('H') > maxHeavyAtoms:
            return True

    maxRadicals = speciesConstraints.get('maximumRadicalElectrons', -1)
    if maxRadicals != -1:
        if (struct.getRadicalCount() > maxRadicals):
            return True

    maxCarbenes = speciesConstraints.get('maximumSingletCarbenes', 1)
    if maxRadicals != -1:
        if struct.getSingletCarbeneCount() > maxCarbenes:
            return True

    maxCarbeneRadicals = speciesConstraints.get('maximumCarbeneRadicals', 0)
    if maxCarbeneRadicals != -1:
        if struct.getSingletCarbeneCount() > 0 and struct.getRadicalCount(
        ) > maxCarbeneRadicals:
            return True

    return False
コード例 #7
0
ファイル: constraints.py プロジェクト: cainja/RMG-Py
def failsSpeciesConstraints(species):
    """
    Pass in either a `Species` or `Molecule` object and checks whether it passes 
    the speciesConstraints set by the user.  If not, returns `True` for failing speciesConstraints.
    """
    
    from rmgpy.rmg.input import getInput

    try:
        speciesConstraints = getInput('speciesConstraints')
    except Exception:
        logging.debug('Species constraints could not be found.')
        speciesConstraints = {}
    
    if isinstance(species, Species):
        struct = species.molecule[0]
    else:
        # expects a molecule here
        struct = species

    explicitlyAllowedMolecules = speciesConstraints.get('explicitlyAllowedMolecules', [])
    for molecule in explicitlyAllowedMolecules:
        if struct.isIsomorphic(molecule):
            return False  
    
    maxCarbonAtoms = speciesConstraints.get('maximumCarbonAtoms', -1)          
    if maxCarbonAtoms != -1:
        if struct.getNumAtoms('C') > maxCarbonAtoms:
            return True

    maxOxygenAtoms = speciesConstraints.get('maximumOxygenAtoms', -1)
    if maxOxygenAtoms != -1:
        if struct.getNumAtoms('O') > maxOxygenAtoms:
            return True

    maxNitrogenAtoms = speciesConstraints.get('maximumNitrogenAtoms', -1)
    if maxNitrogenAtoms != -1:
        if struct.getNumAtoms('N') > maxNitrogenAtoms:
            return True

    maxSiliconAtoms = speciesConstraints.get('maximumSiliconAtoms', -1)
    if maxSiliconAtoms != -1:
        if struct.getNumAtoms('Si') > maxSiliconAtoms:
            return True

    maxSulfurAtoms = speciesConstraints.get('maximumSulfurAtoms', -1)
    if maxSulfurAtoms != -1:
        if struct.getNumAtoms('S') > maxSulfurAtoms:
            return True

    maxHeavyAtoms = speciesConstraints.get('maximumHeavyAtoms', -1)
    if maxHeavyAtoms != -1:
        if struct.getNumAtoms() - struct.getNumAtoms('H') > maxHeavyAtoms:
            return True

    maxRadicals = speciesConstraints.get('maximumRadicalElectrons', -1)
    if maxRadicals != -1:
        if (struct.getRadicalCount() > maxRadicals):
            return True

    maxCarbenes = speciesConstraints.get('maximumSingletCarbenes', 1)
    if maxRadicals != -1:
        if struct.getSingletCarbeneCount() > maxCarbenes:
            return True

    maxCarbeneRadicals = speciesConstraints.get('maximumCarbeneRadicals', 0)
    if maxCarbeneRadicals != -1:
        if struct.getSingletCarbeneCount() > 0 and struct.getRadicalCount() > maxCarbeneRadicals:
            return True

    maxIsotopes = speciesConstraints.get('maximumIsotopicAtoms', -1)
    if maxIsotopes != -1:
        counter = 0
        for atom in struct.atoms:
            if not isclose(atom.mass, getElement(atom.symbol).mass, atol=1e-04):
                counter += 1
            if counter > maxIsotopes: return True

    return False
コード例 #8
0
ファイル: thermoengine.py プロジェクト: cainja/RMG-Py
        thermodb = getDB('thermo')
        if not thermodb: raise Exception
    except Exception, e:
        logging.debug('Could not obtain the thermo database. Not generating thermo...')
        return None
    
    thermo0 = thermodb.getThermoData(spc) 

    # 1. maybe only submit cyclic core
    # 2. to help radical prediction, HBI should also
    #    look up centrailThermoDB for its saturated version
    #    currently it only looks up libraries or estimates via GAV 
    from rmgpy.rmg.input import getInput
    
    try:
        thermoCentralDatabase = getInput('thermoCentralDatabase')
    except Exception, e:
        logging.debug('thermoCentralDatabase could not be found.')
        thermoCentralDatabase = None
    
    if thermoCentralDatabase and thermoCentralDatabase.client \
        and thermoCentralDatabase.satisfyRegistrationRequirements(spc, thermo0, thermodb):
        
        thermoCentralDatabase.registerInCentralThermoDB(spc)
        
    return processThermoData(spc, thermo0, thermoClass, solventName)


def evaluator(spc, solventName = ''):
    """
    Module-level function passed to workers.