Exemplo n.º 1
0
    def __init__(self, parent, menubar):
        self.project_data = ObjectTree([Column('name',
                                               use_markup=True,
                                               data_type=str,
                                               sorted=True),
                                        Column('info')])

        self.project_data.connect('row-activated', self.on_row_activated)
        self.model_tree = Project()
        self._set_treeview_hooks()

        self.menubar = menubar

        self.set_parent(parent)


        self.filename = ''

        self.undo_stack = UndoStack(
            self.model_tree.__repr__,
            self.import_xml_file,
            self.project_data.select,
            menubar,
            self.meta,
            'Initialization')

        SlaveDelegate.__init__(self, toplevel=self.project_data)
Exemplo n.º 2
0
    def __init__(self, parent, menubar):
        self.project_data = ObjectTree([
            Column('name', use_markup=True, data_type=str, sorted=True),
            Column('info')
        ])

        self.project_data.connect('row-activated', self.on_row_activated)
        self.model_tree = Project()
        self._set_treeview_hooks()

        self.menubar = menubar

        self.set_parent(parent)

        self.filename = ''

        self.undo_stack = UndoStack(self.model_tree.__repr__,
                                    self.import_xml_file,
                                    self.project_data.select, menubar,
                                    self.meta, 'Initialization')

        SlaveDelegate.__init__(self, toplevel=self.project_data)
Exemplo n.º 3
0
#!/usr/bin/env python

from kmos.types import Project, Condition, Action
import numpy as np


pt = Project()



pt.set_meta(author='StangenMensch',
            email='*****@*****.**',
            model_dimension=1,
            model_name='hopping_model')
pt.add_species(name='empty',
               color='#ffffff',
               )
pt.add_species(name='C',
               representation="Atoms('C',[[0,0,0]])",
               color='#000000')

pt.layer_list.cell = np.diag([1., 1., 1.])
pt.add_layer(name='default',
                     color='#ffffff')
pt.add_site(layer='default',
            pos='0 0 0',
            name='a')

coord = pt.layer_list.generate_coord

pt.add_process(name='ads',
Exemplo n.º 4
0
class GTKProject(SlaveDelegate):
    """A facade of kmos.types.Project so that
    pygtk can display in a TreeView.
    """
    def __init__(self, parent, menubar):
        self.project_data = ObjectTree([
            Column('name', use_markup=True, data_type=str, sorted=True),
            Column('info')
        ])

        self.project_data.connect('row-activated', self.on_row_activated)
        self.model_tree = Project()
        self._set_treeview_hooks()

        self.menubar = menubar

        self.set_parent(parent)

        self.filename = ''

        self.undo_stack = UndoStack(self.model_tree.__repr__,
                                    self.import_xml_file,
                                    self.project_data.select, menubar,
                                    self.meta, 'Initialization')

        SlaveDelegate.__init__(self, toplevel=self.project_data)

    def _set_treeview_hooks(self):
        """Fudge function to import to access function to kmos.types.Project
        to kmos.gui.GTKProject.
        """
        self.project_data.clear()
        # Meta
        self.meta = self.project_data.append(None, self.model_tree.meta)
        self.model_tree.meta = self.meta

        # Layer List
        self.model_tree.add_layer = self.add_layer
        self.layer_list = self.project_data.append(None,
                                                   self.model_tree.layer_list)
        self.get_layers = lambda :\
            sorted(self.project_data.get_descendants(self.layer_list),
                   key=lambda x: x.name)
        self.model_tree.get_layers = self.get_layers
        self.lattice = self.layer_list

        # Parameter List
        self.parameter_list = self.project_data.append(
            None, self.model_tree.parameter_list)
        self.add_parameter = lambda parameter :\
            self.project_data.append(self.parameter_list, parameter)
        self.model_tree.add_parameter = self.add_parameter
        self.get_parameters = lambda :\
            sorted(self.project_data.get_descendants(self.parameter_list),
                   key=lambda x: x.name)
        self.model_tree.get_parameters = self.get_parameters

        # Species List
        self.species_list = self.project_data.append(
            None, self.model_tree.species_list)
        self.add_species = lambda species :\
            self.project_data.append(self.species_list, species)
        self.model_tree.add_species = self.add_species
        self.get_speciess = lambda :\
            sorted(self.project_data.get_descendants(self.species_list),
                   key=lambda x: x.name)
        self.model_tree.get_speciess = self.get_speciess

        # Process List
        self.process_list = self.project_data.append(
            None, self.model_tree.process_list)
        self.add_process = lambda process:\
            self.project_data.append(self.process_list, process)
        self.model_tree.add_process = self.add_process
        self.get_processes = lambda :\
            sorted(self.project_data.get_descendants(self.process_list),
                   key=lambda x: x.name)
        self.model_tree.get_processes = self.get_processes

        # Output List
        self.output_list = self.project_data.append(
            None, self.model_tree.output_list)
        self.add_output = lambda output:\
            self.project_data.append(self.output_list, output)
        self.model_tree.add_output = self.add_output
        self.get_outputs = lambda : \
            sorted(self.project_data.get_descendants(self.output_list),
                   key=lambda x: x.name)
        self.model_tree.get_outputs = self.get_outputs

    def add_layer(self, layer):
        self.project_data.append(self.layer_list, layer)
        if len(self.get_layers()) == 1:
            self.set_default_layer(layer.name)
            self.set_substrate_layer(layer.name)

    def set_default_species(self, species):
        self.model_tree.species_list.default_species = species

    def set_substrate_layer(self, layer):
        self.model_tree.layer_list.substrate_layer = layer

    def set_default_layer(self, layer):
        self.model_tree.layer_list.default_layer = layer

    def update(self, model):
        self.project_data.update(model)

    def on_row_activated(self, tree, data):
        if isinstance(data, Layer):
            data.active = not data.active

    def get_name(self):
        if self.filename:
            return os.path.basename(self.filename)
        else:
            return 'Untitled'

    def __repr__(self):
        return str(self.model_tree)

    def import_xml_file(self, filename):
        self.model_tree.import_xml_file(filename)
        self.expand_all()

    def expand_all(self):
        """Expand all list of the project tree
        """
        self.project_data.expand(self.species_list)
        self.project_data.expand(self.layer_list)
        self.project_data.expand(self.parameter_list)
        self.project_data.expand(self.process_list)
        self.project_data.expand(self.output_list)

    def on_key_press(self, _, event):
        """When the user hits the keyboard focusing the treeview
        this event is triggered. Right now the only supported function
        is to deleted the selected item
        """
        selection = self.project_data.get_selected()
        if gtk.gdk.keyval_name(event.keyval) == 'Delete':
            if (isinstance(selection, Species)
                    or isinstance(selection, Process)
                    or isinstance(selection, Parameter)
                    or isinstance(selection, Layer)):
                if kiwi.ui.dialogs.yesno(
                    "Do you really want to delete '%s'?" \
                        % selection.name) == gtk.RESPONSE_YES:
                    self.project_data.remove(selection)

    def on_project_data__selection_changed(self, _, elem):
        """When a new item is selected in the treeview this function
        loads the main area of the window with the corresponding form
        and data.
        """
        slave = self.get_parent().get_slave('workarea')
        if slave:
            self.get_parent().detach_slave('workarea')
        if isinstance(elem, Layer):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Edit Layer %s' % elem.name, elem)
            form = LayerEditor(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Meta):
            self.undo_stack.start_new_action('Edit Meta', elem)
            meta_form = MetaForm(self.meta, self)
            self.get_parent().attach_slave('workarea', meta_form)
            meta_form.focus_toplevel()
            meta_form.focus_topmost()
        elif isinstance(elem, OutputList):
            self.undo_stack.start_new_action('Edit Output', elem)
            form = OutputForm(self.output_list, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Parameter):
            self.undo_stack.start_new_action('Edit Parameter %s' % elem.name,
                                             elem)
            form = ParameterForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Process):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Edit Process %s' % elem.name,
                                             elem)
            form = ProcessForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, ProcessList):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Batch process editing', elem)
            form = BatchProcessForm(self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Species):
            self.undo_stack.start_new_action('Edit species', elem)
            form = SpeciesForm(elem, self.project_data)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, SpeciesList):
            self.undo_stack.start_new_action('Edit default species', elem)
            form = SpeciesListForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, LayerList):
            self.undo_stack.start_new_action('Edit lattice', elem)
            dimension = self.meta.model_dimension
            form = LatticeForm(elem, dimension, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        else:
            self.get_parent().toast('Not implemented, yet(%s).' % type(elem))
Exemplo n.º 5
0
def generate_model():
    import kmos
    from kmos.types import \
        ConditionAction, \
        Coord, \
        Layer, \
        Parameter, \
        Process,\
        Project,\
        Site, \
        Species

    project = Project()

    # set meta information
    model_name = 'test_cli_generated_model'
    project.meta.author = 'Max J. Hoffmann'
    project.meta.email = '*****@*****.**'
    project.meta.model_dimension = '2'
    project.meta.debug = 0
    project.meta.model_name = model_name

    # add layer
    project.add_layer(
        Layer(name='default', sites=[Site(name='cus', pos='0 0.5 0.5')]))

    project.layer_list.default_layer = 'default'

    # add species
    project.add_species(Species(name='oxygen', color='#ff0000'))
    project.add_species(Species(name='CO', color='#000000'))
    project.add_species(Species(name='empty', color='#ffffff'))
    project.species_list.default_species = 'empty'

    # add parameters
    project.add_parameter(Parameter(name='p_CO', value=0.2, scale='log'))
    project.add_parameter(Parameter(name='T', value=500, adjustable=True))
    project.add_parameter(Parameter(name='p_O2', value=1.0, adjustable=True))

    # add processes
    cus = Coord(name='cus', layer='default')
    p = Process(name='CO_adsorption', rate_constant='1000.')
    p.add_condition(ConditionAction(species='empty', coord=cus))
    p.add_action(ConditionAction(species='CO', coord=cus))
    project.add_process(p)

    p = Process(name='CO_desorption', rate_constant='1000.')
    p.add_condition(ConditionAction(species='CO', coord=cus))
    p.add_action(ConditionAction(species='empty', coord=cus))
    project.add_process(p)
    return project
Exemplo n.º 6
0
def generate_model():
    import kmos
    from kmos.types import \
        ConditionAction, \
        Coord, \
        Layer, \
        Parameter, \
        Process,\
        Project,\
        Site, \
        Species

    project = Project()

    # set meta information
    model_name = 'test_cli_generated_model'
    project.meta.author = 'Max J. Hoffmann'
    project.meta.email = '*****@*****.**'
    project.meta.model_dimension = '2'
    project.meta.debug = 0
    project.meta.model_name = model_name

    # add layer
    project.add_layer(Layer(name='default', sites=[
        Site(name='cus', pos='0 0.5 0.5')]))

    project.layer_list.default_layer = 'default'

    # add species
    project.add_species(Species(name='oxygen', color='#ff0000'))
    project.add_species(Species(name='CO', color='#000000'))
    project.add_species(Species(name='empty', color='#ffffff'))
    project.species_list.default_species = 'empty'

    # add parameters
    project.add_parameter(Parameter(name='p_CO', value=0.2, scale='log'))
    project.add_parameter(Parameter(name='T', value=500, adjustable=True))
    project.add_parameter(Parameter(name='p_O2', value=1.0, adjustable=True))

    # add processes
    cus = Coord(name='cus', layer='default')
    p = Process(name='CO_adsorption', rate_constant='1000.')
    p.add_condition(ConditionAction(species='empty', coord=cus))
    p.add_action(ConditionAction(species='CO', coord=cus))
    project.add_process(p)

    p = Process(name='CO_desorption', rate_constant='1000.')
    p.add_condition(ConditionAction(species='CO', coord=cus))
    p.add_action(ConditionAction(species='empty', coord=cus))
    project.add_process(p)
    return project
Exemplo n.º 7
0
#!/usr/bin/env python

from kmos.types import Project, Condition, Action
import numpy as np

pt = Project()

pt.set_meta(author='StangenMensch',
            email='*****@*****.**',
            model_dimension=1,
            model_name='hopping_model')
pt.add_species(
    name='empty',
    color='#ffffff',
)
pt.add_species(name='C',
               representation="Atoms('C',[[0,0,0]])",
               color='#000000')

pt.layer_list.cell = np.diag([1., 1., 1.])
pt.add_layer(name='default', color='#ffffff')
pt.add_site(layer='default', pos='0 0 0', name='a')

coord = pt.layer_list.generate_coord

pt.add_process(name='ads',
               rate_constant='10**6',
               conditions=[Condition(species='empty', coord=coord('a'))],
               actions=[Action(species='C', coord=coord('a'))],
               tof_count={'adsorption': 1})
from itertools import product

from kmos.cli import main as cli_main
from kmos.types import Action, Condition, Layer, Project, Site, Species


# Project
pt = Project()
pt.set_meta(
    author='Michael Seibt',
    email='*****@*****.**',
    model_name='LGD_lateral',
    model_dimension=2
)

# Species
pt.add_species(
    Species(name='empty', color='#d3d3d3'),
    Species(name='ion', color='#0000ff', representation="Atoms('Si')"),
    Species(name='source', color='#00ff00', representation="Atoms('Au')"),
    Species(name='drain', color='#ff0000', representation="Atoms('Ag')")
)
pt.species_list.default_species = 'empty'

# Layer and Coordinates
layer = Layer(name='simple_cubic')
layer.add_site(Site(name='hollow', pos='0.5 0.5 0.5'))
pt.add_layer(layer)

center = pt.lattice.generate_coord('hollow')
bottom = pt.lattice.generate_coord('hollow.(0,-1,0)')
#!/usr/bin/env python


import numpy as np
from kmos.types import Project, Site, Condition, Action

pt = Project()

pt.set_meta(author="LotkaVolterra",
            email='*****@*****.**',
            model_name='lotka_volterra_model',
            model_dimension=2)

pt.add_species(name='empty')
pt.add_species(name='A', representation="Atoms('O')")
pt.add_species(name='B', representation="Atoms('C')")

layer = pt.add_layer(name='sc')

pt.lattice.cell = np.diag([3.5, 3.5, 10])

layer.sites.append(Site(name='site', pos='.5 .5 .5'))


pt.add_parameter(name='k1', value='1000000.', adjustable=True, min=0., max=100.)
pt.add_parameter(name='k2', value=3.65, adjustable=True, min=0., max=100.)
pt.add_parameter(name='k3', value=1.1, adjustable=True, min=0., max=100.)
pt.add_parameter(name='zeta', value='0.06', adjustable=True, min=0., max=1.)


Exemplo n.º 10
0
class GTKProject(SlaveDelegate):
    """A facade of kmos.types.Project so that
    pygtk can display in a TreeView.
    """
    def __init__(self, parent, menubar):
        self.project_data = ObjectTree([Column('name',
                                               use_markup=True,
                                               data_type=str,
                                               sorted=True),
                                        Column('info')])

        self.project_data.connect('row-activated', self.on_row_activated)
        self.model_tree = Project()
        self._set_treeview_hooks()

        self.menubar = menubar

        self.set_parent(parent)


        self.filename = ''

        self.undo_stack = UndoStack(
            self.model_tree.__repr__,
            self.import_xml_file,
            self.project_data.select,
            menubar,
            self.meta,
            'Initialization')

        SlaveDelegate.__init__(self, toplevel=self.project_data)

    def _set_treeview_hooks(self):
        """Fudge function to import to access function to kmos.types.Project
        to kmos.gui.GTKProject.
        """
        self.project_data.clear()
        # Meta
        self.meta = self.project_data.append(None, self.model_tree.meta)
        self.model_tree.meta = self.meta

        # Layer List
        self.model_tree.add_layer = self.add_layer
        self.layer_list = self.project_data.append(None,
                                   self.model_tree.layer_list)
        self.get_layers = lambda :\
            sorted(self.project_data.get_descendants(self.layer_list),
                   key=lambda x: x.name)
        self.model_tree.get_layers = self.get_layers
        self.lattice = self.layer_list

        # Parameter List
        self.parameter_list = self.project_data.append(None,
                                       self.model_tree.parameter_list)
        self.add_parameter = lambda parameter :\
            self.project_data.append(self.parameter_list, parameter)
        self.model_tree.add_parameter = self.add_parameter
        self.get_parameters = lambda :\
            sorted(self.project_data.get_descendants(self.parameter_list),
                   key=lambda x: x.name)
        self.model_tree.get_parameters = self.get_parameters

        # Species List
        self.species_list = self.project_data.append(None,
                                   self.model_tree.species_list)
        self.add_species = lambda species :\
            self.project_data.append(self.species_list, species)
        self.model_tree.add_species = self.add_species
        self.get_speciess = lambda :\
            sorted(self.project_data.get_descendants(self.species_list),
                   key=lambda x: x.name)
        self.model_tree.get_speciess = self.get_speciess


        # Process List
        self.process_list = self.project_data.append(None,
                                     self.model_tree.process_list)
        self.add_process = lambda process:\
            self.project_data.append(self.process_list, process)
        self.model_tree.add_process = self.add_process
        self.get_processes = lambda :\
            sorted(self.project_data.get_descendants(self.process_list),
                   key=lambda x: x.name)
        self.model_tree.get_processes = self.get_processes

        # Output List
        self.output_list = self.project_data.append(None,
                                self.model_tree.output_list)
        self.add_output = lambda output:\
            self.project_data.append(self.output_list, output)
        self.model_tree.add_output = self.add_output
        self.get_outputs = lambda : \
            sorted(self.project_data.get_descendants(self.output_list),
                   key=lambda x: x.name)
        self.model_tree.get_outputs = self.get_outputs

    def add_layer(self, layer):
        self.project_data.append(self.layer_list, layer)
        if len(self.get_layers()) == 1 :
            self.set_default_layer(layer.name)
            self.set_substrate_layer(layer.name)

    def set_default_species(self, species):
        self.model_tree.species_list.default_species = species

    def set_substrate_layer(self, layer):
        self.model_tree.layer_list.substrate_layer = layer

    def set_default_layer(self, layer):
        self.model_tree.layer_list.default_layer = layer

    def update(self, model):
        self.project_data.update(model)

    def on_row_activated(self, tree, data):
        if isinstance(data, Layer):
            data.active = not data.active

    def get_name(self):
        if self.filename:
            return os.path.basename(self.filename)
        else:
            return 'Untitled'

    def __repr__(self):
        return str(self.model_tree)

    def import_xml_file(self, filename):
        self.model_tree.import_xml_file(filename)
        self.expand_all()

    def expand_all(self):
        """Expand all list of the project tree
        """
        self.project_data.expand(self.species_list)
        self.project_data.expand(self.layer_list)
        self.project_data.expand(self.parameter_list)
        self.project_data.expand(self.process_list)
        self.project_data.expand(self.output_list)

    def on_key_press(self, _, event):
        """When the user hits the keyboard focusing the treeview
        this event is triggered. Right now the only supported function
        is to deleted the selected item
        """
        selection = self.project_data.get_selected()
        if gtk.gdk.keyval_name(event.keyval) == 'Delete':
            if(isinstance(selection, Species)
            or isinstance(selection, Process)
            or isinstance(selection, Parameter)
            or isinstance(selection, Layer)):
                if kiwi.ui.dialogs.yesno(
                    "Do you really want to delete '%s'?" \
                        % selection.name) == gtk.RESPONSE_YES:
                    self.project_data.remove(selection)

    def on_project_data__selection_changed(self, _, elem):
        """When a new item is selected in the treeview this function
        loads the main area of the window with the corresponding form
        and data.
        """
        slave = self.get_parent().get_slave('workarea')
        if slave:
            self.get_parent().detach_slave('workarea')
        if isinstance(elem, Layer):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Edit Layer %s' % elem.name,
                                                               elem)
            form = LayerEditor(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Meta):
            self.undo_stack.start_new_action('Edit Meta', elem)
            meta_form = MetaForm(self.meta, self)
            self.get_parent().attach_slave('workarea', meta_form)
            meta_form.focus_toplevel()
            meta_form.focus_topmost()
        elif isinstance(elem, OutputList):
            self.undo_stack.start_new_action('Edit Output', elem)
            form = OutputForm(self.output_list, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Parameter):
            self.undo_stack.start_new_action('Edit Parameter %s' % elem.name,
                                                                   elem)
            form = ParameterForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Process):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Edit Process %s' % elem.name,
                                                                 elem)
            form = ProcessForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, ProcessList):
            if self.meta.model_dimension in [1, 3]:
                self.get_parent().toast('Only 2d supported')
                return
            self.undo_stack.start_new_action('Batch process editing', elem)
            form = BatchProcessForm(self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, Species):
            self.undo_stack.start_new_action('Edit species', elem)
            form = SpeciesForm(elem, self.project_data)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, SpeciesList):
            self.undo_stack.start_new_action('Edit default species', elem)
            form = SpeciesListForm(elem, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        elif isinstance(elem, LayerList):
            self.undo_stack.start_new_action('Edit lattice', elem)
            dimension = self.meta.model_dimension
            form = LatticeForm(elem, dimension, self)
            self.get_parent().attach_slave('workarea', form)
            form.focus_topmost()
        else:
            self.get_parent().toast('Not implemented, yet(%s).' % type(elem))
Exemplo n.º 11
0
#!/usr/bin/env python


import numpy as np
from kmos.types import Project, Site, Condition, Action

pt = Project()

pt.set_meta(author="Ziff,Gulari,Barshad",
            email='*****@*****.**',
            model_name='zgb_model',
            model_dimension=2)

pt.add_species(name='empty', color='#ffffff')
pt.add_species(name='CO', representation="Atoms('C')", color='#000000')
pt.add_species(name='O', representation="Atoms('O')", color='#ff0000')

layer = pt.add_layer(name='sc')

pt.lattice.cell = np.diag([3.5, 3.5, 10])

layer.sites.append(Site(name='site', pos='.5 .5 .5'))

pt.add_parameter(name='yCO', value='0.45', adjustable=True, min=0., max=1.)

pt.parse_and_add_process('CO_adsorption; empty@site -> CO@site; yCO')

pt.parse_and_add_process('O2_adsorption1; empty@site + empty@site.(1, 0, 0) -> O@site + O@site.(1,0,0); (1 - yCO)/2.')
pt.parse_and_add_process('O2_adsorption2; empty@site + empty@site.(0, 1, 0) -> O@site + O@site.(0,1,0); (1 - yCO)/2.')

pt.parse_and_add_process('CO_oxidation1; CO@site + O@site.(1, 0, 0) -> empty@site + empty@site.(1,0,0); 10**10')
Exemplo n.º 12
0
#!/usr/bin/env python

import numpy as np
from kmos.types import Project, Site, Condition, Action

pt = Project()

pt.set_meta(author="Ziff,Gulari,Barshad",
            email='*****@*****.**',
            model_name='zgb_model',
            model_dimension=2)

pt.add_species(name='empty', color='#ffffff')
pt.add_species(name='CO', representation="Atoms('C')", color='#000000')
pt.add_species(name='O', representation="Atoms('O')", color='#ff0000')

layer = pt.add_layer(name='sc')

pt.lattice.cell = np.diag([3.5, 3.5, 10])

layer.sites.append(Site(name='site', pos='.5 .5 .5'))

pt.add_parameter(name='yCO', value='0.45', adjustable=True, min=0., max=1.)

pt.parse_and_add_process('CO_adsorption; empty@site -> CO@site; yCO')

pt.parse_and_add_process(
    'O2_adsorption1; empty@site + empty@site.(1, 0, 0) -> O@site + O@site.(1,0,0); (1 - yCO)/2.'
)
pt.parse_and_add_process(
    'O2_adsorption2; empty@site + empty@site.(0, 1, 0) -> O@site + O@site.(0,1,0); (1 - yCO)/2.'
Exemplo n.º 13
0
#!/usr/bin/env python

import numpy as np
from kmos.types import Project, Site, Condition, Action

pt = Project()

pt.set_meta(author="LotkaVolterra",
            email='*****@*****.**',
            model_name='lotka_volterra_model',
            model_dimension=2)

pt.add_species(name='empty')
pt.add_species(name='A', representation="Atoms('O')")
pt.add_species(name='B', representation="Atoms('C')")

layer = pt.add_layer(name='sc')

pt.lattice.cell = np.diag([3.5, 3.5, 10])

layer.sites.append(Site(name='site', pos='.5 .5 .5'))

pt.add_parameter(name='k1',
                 value='1000000.',
                 adjustable=True,
                 min=0.,
                 max=100.)
pt.add_parameter(name='k2', value=3.65, adjustable=True, min=0., max=100.)
pt.add_parameter(name='k3', value=1.1, adjustable=True, min=0., max=100.)
pt.add_parameter(name='zeta', value='0.06', adjustable=True, min=0., max=1.)
Exemplo n.º 14
0
from itertools import product

from kmos.cli import main as cli_main
from kmos.types import Action, Condition, Layer, Project, Site, Species

# Project
pt = Project()
pt.set_meta(author='Michael Seibt',
            email='*****@*****.**',
            model_name='LGD_lateral',
            model_dimension=2)

# Species
pt.add_species(
    Species(name='empty', color='#d3d3d3'),
    Species(name='ion', color='#0000ff', representation="Atoms('Si')"),
    Species(name='source', color='#00ff00', representation="Atoms('Au')"),
    Species(name='drain', color='#ff0000', representation="Atoms('Ag')"))
pt.species_list.default_species = 'empty'

# Layer and Coordinates
layer = Layer(name='simple_cubic')
layer.add_site(Site(name='hollow', pos='0.5 0.5 0.5'))
pt.add_layer(layer)

center = pt.lattice.generate_coord('hollow')
bottom = pt.lattice.generate_coord('hollow.(0,-1,0)')
top = pt.lattice.generate_coord('hollow.(0,+1,0)')
left = pt.lattice.generate_coord('hollow.(-1,0,0)')
right = pt.lattice.generate_coord('hollow.(+1,0,0)')