Пример #1
0
def main(args=None):
    """The CLI main entry point function.

    The optional argument args, can be used to
    directly supply command line argument like

    $ catmap <args>

    otherwise args will be taken from STDIN.

    """
    from glob import glob

    options, args, parser = get_options(args, get_parser=True)

    if not args[0] in usage.keys():
        args[0] = match_keys(args[0], usage, parser)

    elif args[0] == 'import':
        if len(args) < 2:
            parser.error('mkm filename expected.')

        from catmap import ReactionModel
        mkm_file = args[1]
        global model
        model = ReactionModel(setup_file=mkm_file)
        sh(banner=
           'Note: model = catmap.ReactionModel(setup_file=\'%s\')\n# do model.run()\nfor a fully initialized model.'
           % args[1])
Пример #2
0
def main(args=None):
    """The CLI main entry point function.

    The optional argument args, can be used to
    directly supply command line argument like

    $ catmap <args>

    otherwise args will be taken from STDIN.

    """
    from glob import glob

    options, args, parser = get_options(args, get_parser=True)

    if not args[0] in usage.keys():
        args[0] = match_keys(args[0], usage, parser)

    elif args[0] == 'import':
        if len(args) < 2:
            parser.error('mkm filename expected.')

        from catmap import ReactionModel
        mkm_file = args[1]
        global model
        model = ReactionModel(setup_file=mkm_file)
        sh(banner=
           'Note: model = catmap.ReactionModel(setup_file=\'%s\')\n# do model.run()\nfor a fully initialized model.'
           % args[1])

    elif args[0] == 'graphviz':
        import catmap.analyze.mechanism
        import catmap.model
        if len(args) < 2:
            parser.error('mkm filename expected.')
        mkm_file = args[1]
        seed = mkm_file.split('.')[0]
        model = catmap.model.ReactionModel(setup_file=mkm_file)
        mechanism = catmap.analyze.mechanism.MechanismAnalysis(model)
        graph = mechanism.create_graph()
        graph.render(seed)
Пример #3
0
from catmap import ReactionModel

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
scaler_variables = ['rxn_parameter', 'frequency', 'electronic_energy',
                    'free_energy', 'zero_point_energy', 'enthalpy', 'entropy']
# Warning: adding 'rate_control' or 'selectivity_control' to
# output_variables increases calculation time significantly
solver_variables = ['production_rate', 'rate_control', 'coverage', 'rate',
                    'consumption_rate', 'selectivity', 'rxn_direction',
                    'rate_constant', 'equilibrium_constant', 'carbon_selectivity',
                    'selectivity_control', 'rxn_order', 'apparent_activation_energy',
                    'interacting_energy', 'directional_rates', 'forward_rate', 'reverse_rate',
                    'forward_rate_constant', 'reverse_rate_constant']
two_dim_variables = ['rate_control', 'selectivity_control', 'rxn_order', 'frequency']
one_dim_variables = list(set(scaler_variables + solver_variables) - set(two_dim_variables))
model.output_variables += solver_variables + scaler_variables

model.run()

from catmap import analyze
vm = analyze.VectorMap(model)
vm.log_scale = True  # not necessarily the right choice of parameters for all output_variables
vm.min = 1e-25
vm.max = 1e3
vm.threshold = 1e-25
vm.unique_only = False
for out_var in one_dim_variables:
    vm.plot_variable = out_var
    fig = vm.plot(save=out_var + '.pdf')
    fig.clf()
Пример #4
0
import pylab as plt
from catmap import ReactionModel

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables += [
    'production_rate', 'interaction_matrix', 'free_energy'
]
model.create_standalone = True
model.run()

from catmap import analyze
vm = analyze.VectorMap(model)
vm.plot_variable = 'production_rate'  # tell the model which output to plot
vm.log_scale = True  # rates should be plotted on a log-scale
vm.min = 1e-25  # minimum rate to plot
vm.max = 1e8  # maximum rate to plot
vm.threshold = 1e-25  # anything below this is considered to be 0
vm.subplots_adjust_kwargs = {'left': 0.2, 'right': 0.8, 'bottom': 0.15}
vm.plot(save='production_rate.pdf')

vm.plot_variable = 'coverage'  # tell the model which output to plot
vm.log_scale = False  # coverage should not be plotted on a log-scale
vm.min = 0  # minimum coverage
vm.max = 1  # maximum coverage
vm.subplots_adjust_kwargs = {
    'left': 0.1,
    'right': 0.85,
    'wspace': 0.6,
    'bottom': 0.15
}
Пример #5
0
#SBATCH --time=1:00:00                                 #default is 20 hours
#SBATCH --nodes=1
##SBATCH --mem-per-cpu=4000
#SBATCH --mail-type=END,FAIL                            #get emailed about job BEGIN, END, or FAIL
#SBATCH [email protected]
##SBATCH --ntasks-per-node=16                            #task to run per node; each node has 16 cores

import catmap
import numpy as np
import os
from catmap import ReactionModel
from catmap import analyze
from matplotlib import pyplot as plt

#mkm_file = [f for f in os.listdir('.') if f.endswith('.mkm')][0]
model = ReactionModel(setup_file='mechanism.mkm')
model.output_variables.append('production_rate')
model.output_variables.append('free_energy')
#model.output_variables.append('interaction_matrix')
model.run()

vm = analyze.VectorMap(model)
vm.model_name = 'CH3OH'
vm.plot_variable = 'free_energy'
vm.log_scale = False
vm.plot(save=vm.plot_variable + '.pdf')

vm.plot_variable = 'coverage'
vm.min = 0
vm.max = 1
vm.plot(save=vm.plot_variable + '.pdf')
Пример #6
0
from catmap import ReactionModel
from catmap import analyze
import numpy as np
import cPickle as pickle


include_overbinding = False
include_rate_control = False
mkm_file = 'EtOH.mkm'
model = ReactionModel(setup_file=mkm_file)
model.create_standalone = True

# We should probably omit the overbinding correction from the tutorial to simplify things.
if include_overbinding:
    overbinding = 0.25
    CO_energies = model.species_definitions['CO_s']['formation_energy']
    CO_energies = [E + overbinding for E in CO_energies]
    model.species_definitions['CO_s']['formation_energy'] = CO_energies

model.output_variables += ['production_rate', 'selectivity',
                           'zero_point_energy', 'enthalpy', 'entropy', 'free_energy']
model.output_variables += ['interaction_matrix', 'interacting_energy', 'equilibrium_constant']
if include_rate_control:
    model.output_variables += ['rate_control']

model.interaction_strength = 0.1  # Otherwise it won't converge
# Tutorial should consider showing "integration" along interaction_strength (e.g. use the
# ouput of interaction_strength=0.1 as input to interaction_strength=0.2 and so on). It
# is ugly, but its the best option at the moment for stubborn ads-ads interaction models,
# and most ads-ads interaction models are stubborn.
model.run()
Пример #7
0
from catmap import ReactionModel

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables += ['production_rate']  # ,'rate_control']
model.run()

#model = ReactionModel(setup_file=mkm_file.replace('mkm','log'))

from catmap import analyze
vm = analyze.VectorMap(model)
vm.plot_variable = 'production_rate'  # tell the model which output to plot
vm.log_scale = True  # rates should be plotted on a log-scale
vm.min = 1e-25  # minimum rate to plot
vm.max = 1e3  # maximum rate to plot

vm.descriptor_labels = ['O reactivity [eV]', 'CO reactivity [eV]', ]
vm.threshold = 1e-25  # anything below this is considered to be 0
vm.subplots_adjust_kwargs = {'left': 0.2, 'right': 0.8, 'bottom': 0.15}
vm.plot(save='pretty_production_rate.pdf')

#mm = analyze.MatrixMap(model)
#mm.plot_variable = 'rate_control'
#mm.log_scale = False
#mm.min = -2
#mm.max = 2
# mm.plot(save='rate_control.pdf')

ma = analyze.MechanismAnalysis(model)
ma.energy_type = 'free_energy'  # can also be free_energy/potential_energy
ma.include_labels = False  # way too messy with labels
Пример #8
0
"""This mkm_job script generates the same results as the tutorialsoutput_variables/mkm_job.py script
however it demonstrates that values of output_variables do not need to be all hard-coded

FIXME: At this point we still need to hard-code two-dimensional variables, since this is difficult to glean from code inspection only.
FIXME: Output variables 'turnover_frequency' and 'interaction_matrix' currently crash, we should fix them or remove them from the parser.

"""
from catmap import ReactionModel
from catmap import analyze

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables = ['all']  # <==== Here is where the 'all' magic happens
two_dim_variables = [
    'rate_control', 'selectivity_control', 'rxn_order', 'frequency',
    'interaction_matrix'
]
# !!! However we still need to hard-code those variables that are supposed to go through MatrixMap instead of VectorMap
model.run()

vm = analyze.VectorMap(model)
mm = analyze.MatrixMap(model)


def set_defaults(vm, mm):
    vm.log_scale = True
    vm.min = 1e-25
    vm.max = 1e3
    vm.threshold = 1e-25
    vm.unique_only = False
    mm.log_scale = False
Пример #9
0
"""This mkm_job script generates the same results as the tutorialsoutput_variables/mkm_job.py script
however it demonstrates that values of output_variables do not need to be all hard-coded

FIXME: At this point we still need to hard-code two-dimensional variables, since this is difficult to glean from code inspection only.
FIXME: Output variables 'turnover_frequency' and 'interaction_matrix' currently crash, we should fix them or remove them from the parser.

"""
from catmap import ReactionModel
from catmap import analyze

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables = ['all']  # <==== Here is where the 'all' magic happens
two_dim_variables = ['rate_control', 'selectivity_control',
                     'rxn_order', 'frequency', 'interaction_matrix']
# !!! However we still need to hard-code those variables that are supposed to go through MatrixMap instead of VectorMap
model.run()

vm = analyze.VectorMap(model)
mm = analyze.MatrixMap(model)


def set_defaults(vm, mm):
    vm.log_scale = True
    vm.min = 1e-25
    vm.max = 1e3
    vm.threshold = 1e-25
    vm.unique_only = False
    mm.log_scale = False
    mm.min = -2
    mm.max = 2
Пример #10
0
from catmap import ReactionModel
import sys
from string import Template

model = ReactionModel(setup_file='HER.mkm')
model.output_variables += [
    'production_rate', 'free_energy', 'selectivity', 'directional_rates'
]
model.run()

from catmap import analyze
vm = analyze.VectorMap(model)

vm.plot_variable = 'rate'
vm.log_scale = True
vm.min = 1e-10
vm.max = 1e6
fig = vm.plot(save='rate.png')

vm.plot_variable = 'production_rate'
vm.log_scale = True
vm.min = 1e-10
vm.max = 1e6
fig = vm.plot(save='production_rate.png')

vm.plot_variable = 'coverage'
vm.min = 0
vm.max = 1
vm.log_scale = False
fig = vm.plot(save='coverage.png')
Пример #11
0
from catmap import ReactionModel
from catmap.parsers import TableParser

mkm_file = 'RWGS.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables += ['production_rate', 'rate_control']
model.run()

from catmap import analyze

mm = analyze.MatrixMap(model)
mm.plot_variable = 'rate_control'
mm.log_scale = False
mm.min = -2
mm.max = 2
mm.subplots_adjust_kwargs = {'wspace': 0.6, 'hspace': 0.6}
mm.plot(save='rate_control.pdf')

vm = analyze.VectorMap(model)
vm.plot_variable = 'rate'  #tell the model which output to plot
vm.log_scale = True  #rates should be plotted on a log-scale
vm.min = 1e-8  #minimum rate to plot
vm.max = 1e5  #maximum rate to plot
vm.plot(save='rate.pdf')  #draw the plot and save it as "rate.pdf"

vm.unique_only = False
vm.subplots_adjust_kwargs = {
    'left': 0.1,
    'right': 0.9,
    'bottom': 0.15,
    'wspace': 0.5,
Пример #12
0
import pylab as plt
from catmap import ReactionModel

mkm_file = 'CO_oxidation.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables += ['production_rate','interaction_matrix','free_energy']
model.create_standalone = True
model.run()

from catmap import analyze
vm = analyze.VectorMap(model)
vm.plot_variable = 'production_rate' #tell the model which output to plot
vm.log_scale = True #rates should be plotted on a log-scale
vm.min = 1e-25 #minimum rate to plot
vm.max = 1e8 #maximum rate to plot
vm.threshold = 1e-25 #anything below this is considered to be 0
vm.subplots_adjust_kwargs = {'left':0.2,'right':0.8,'bottom':0.15}
vm.plot(save='production_rate.pdf')

vm.plot_variable = 'coverage' #tell the model which output to plot
vm.log_scale = False #coverage should not be plotted on a log-scale
vm.min = 0 #minimum coverage
vm.max = 1 #maximum coverage
vm.subplots_adjust_kwargs = {'left':0.1,'right':0.85,'wspace':0.6,'bottom':0.15}
vm.plot(save='coverage.pdf')
Пример #13
0
from catmap import ReactionModel
from catmap import analyze
import numpy as np
import cPickle as pickle

include_overbinding = False
include_rate_control = False
mkm_file = 'EtOH.mkm'
model = ReactionModel(setup_file=mkm_file)
model.create_standalone = True

if include_overbinding:
    overbinding = 0.25
    CO_energies = model.species_definitions['CO_s']['formation_energy']
    CO_energies = [E+overbinding for E in CO_energies]
    model.species_definitions['CO_s']['formation_energy'] = CO_energies

model.output_variables += ['production_rate','selectivity','zero_point_energy','enthalpy','entropy','free_energy']
model.output_variables += ['interaction_matrix','interacting_energy','equilibrium_constant']
if include_rate_control:
    model.output_variables += ['rate_control']

model.run()

vm = analyze.VectorMap(model)
vm.log_scale = True #rates should be plotted on a log-scale
vm.min = 1e-15 #minimum rate to plot
vm.max = 1 #maximum rate to plot
vm.threshold = 1e-25 #do not plot rates below this
vm.descriptor_labels = ['Temperature [K]','log$_{10}$(Pressure [bar])']
vm.plot_variable = 'production_rate'
Пример #14
0
from catmap import ReactionModel
from catmap import analyze
import numpy as np
import cPickle as pickle

include_overbinding = False
include_rate_control = False
mkm_file = 'EtOH.mkm'
model = ReactionModel(setup_file=mkm_file)
model.create_standalone = True

if include_overbinding:
    overbinding = 0.25
    CO_energies = model.species_definitions['CO_s']['formation_energy']
    CO_energies = [E + overbinding for E in CO_energies]
    model.species_definitions['CO_s']['formation_energy'] = CO_energies

model.output_variables += [
    'production_rate', 'selectivity', 'zero_point_energy', 'enthalpy',
    'entropy', 'free_energy'
]
model.output_variables += [
    'interaction_matrix', 'interacting_energy', 'equilibrium_constant'
]
if include_rate_control:
    model.output_variables += ['rate_control']

model.run()

vm = analyze.VectorMap(model)
vm.log_scale = True  #rates should be plotted on a log-scale