コード例 #1
0
def initialize(job):
    "Initialize the simulation configuration."
    from pkg_resources import resource_filename

    from mbuild.lib.atoms import H

    from atools.fileio import write_monolayer_ndx
    from atools.lib.chains import Alkylsilane
    from atools.recipes import DualSurface, SilicaInterface, SurfaceMonolayer
    from atools.structure import identify_rigid_groups

    with job:
        chainlength = job.statepoint()['chainlength']
        n_chains = job.statepoint()['n']
        seed = job.statepoint()['seed']
        terminal_group = job.statepoint()['terminal_group']

        surface = SilicaInterface(thickness=1.2, seed=seed)
        chain_proto = Alkylsilane(chain_length=chainlength,
                                  terminal_group=terminal_group)
        monolayer = SurfaceMonolayer(surface=surface,
                                     chains=chain_proto,
                                     n_chains=n_chains,
                                     seed=seed,
                                     backfill=H())
        dual_monolayer = DualSurface(monolayer)
        box = dual_monolayer.boundingbox
        dual_monolayer.periodicity += np.array([0, 0, 5. * box.lengths[2]])

        forcefield_dir = resource_filename('atools', 'forcefields')
        dual_monolayer.save('init.gro',
                            forcefield_files=os.path.join(
                                forcefield_dir, 'oplsaa-silica.xml'),
                            overwrite=True)
        dual_monolayer.save('init.top',
                            forcefield_files=os.path.join(
                                forcefield_dir, 'oplsaa-silica.xml'),
                            overwrite=True)
        rigid_groups = identify_rigid_groups(monolayer=dual_monolayer,
                                             terminal_group=terminal_group,
                                             freeze_thickness=0.5)
        write_monolayer_ndx(rigid_groups=rigid_groups, filename='init.ndx')
コード例 #2
0
def initialize(job):
    "Initialize the simulation configuration."
    '''
    ---------------------------
    Read statepoint information
    ---------------------------
    '''
    chainlength = job.statepoint()['chainlength']
    n_chains = job.statepoint()['n']
    seed = job.statepoint()['seed']
    terminal_group = job.statepoint()['terminal_group']
    '''
    -----------------------------------
    Generate amorphous silica interface
    -----------------------------------
    '''
    surface = SilicaInterface(thickness=1.2, seed=seed)
    '''
    ------------------------------------------------------
    Generate prototype of functionalized alkylsilane chain
    ------------------------------------------------------
    '''
    chain_prototype = Alkylsilane(chain_length=chainlength,
                                  terminal_group=terminal_group)
    '''
    ----------------------------------------------------------
    Create monolayer on surface, backfilled with hydrogen caps
    ----------------------------------------------------------
    '''
    monolayer = SurfaceMonolayer(surface=surface,
                                 chains=chain_prototype,
                                 n_chains=n_chains,
                                 seed=seed,
                                 backfill=H(),
                                 rotate=False)
    '''
    ------------------------------------------
    Duplicate to yield two opposing monolayers
    ------------------------------------------
    '''
    dual_monolayer = DualSurface(monolayer, separation=2.0)
    '''
    --------------------------------------------------------
    Make sure box is elongated in z to be pseudo-2D periodic
    --------------------------------------------------------
    '''
    box = dual_monolayer.boundingbox
    dual_monolayer.periodicity += np.array([0, 0, 5. * box.lengths[2]])
    '''
    -------------------------------------------------------------------
    - Save to .GRO, .TOP, and .LAMMPS formats
    - Atom-type the system using Foyer, with parameters from the OPLS
      force field obtained from GROMACS. Parameters are located in a
      Foyer XML file in the `atools` git repo, with references provided
      as well as notes where parameters have been added or altered to
      reflect the literature.
    -------------------------------------------------------------------
    '''
    forcefield_dir = resource_filename('atools', 'forcefields')
    dual_monolayer.save('init.gro', overwrite=True)
    dual_monolayer.save('init.top',
                        forcefield_files=os.path.join(forcefield_dir,
                                                      'oplsaa.xml'),
                        combining_rule='geometric',
                        overwrite=True)
    dual_monolayer.save('init.lammps',
                        forcefield_files=os.path.join(forcefield_dir,
                                                      'oplsaa.xml'),
                        combining_rule='geometric',
                        overwrite=True)
    '''
    --------------------------------------
    Specify index groups and write to file
    --------------------------------------
    '''
    index_groups = generate_index_groups(system=dual_monolayer,
                                         terminal_group=terminal_group,
                                         freeze_thickness=0.5)
    write_monolayer_ndx(rigid_groups=index_groups, filename='init.ndx')
コード例 #3
0
def initialize_system(job):
    """ Generate the monolayer surfaces, parametrize, save LAMMPS, GRO, TOP.
    """
    """
    ---------------------------
    Read statepoint information
    ---------------------------
    """
    chainlength_a = job.statepoint()["chainlength_a"]
    chainlength_b = job.statepoint()["chainlength_b"]
    chainlength_c = job.statepoint()["chainlength_c"]
    chainlength_d = job.statepoint()["chainlength_d"]
    seed = job.statepoint()["seed"]
    pattern_type = job.statepoint()["pattern_type"]
    terminal_groups = job.statepoint()["terminal_groups"]
    a_fraction = job.statepoint()["fraction_a"]
    c_fraction = job.statepoint()["fraction_c"]
    num_chains = job.statepoint()["n"]
    backbone_1 = job.statepoint()["backbone_1"]
    backbone_2 = job.statepoint()["backbone_2"]
    locations = job.statepoint()["locations"]
    """
    -----------------------------------
    Generate amorphous silica interface
    -----------------------------------
    """
    surface_a = SilicaInterface(thickness=1.2, seed=seed)
    surface_b = SilicaInterface(thickness=1.2, seed=seed)

    """
    ------------------------------------------------------
    Generate prototype of functionalized alkylsilane chain
    ------------------------------------------------------
    """
    chain_prototype_a = AlkylsilaneInternalplus(
        chain_length=chainlength_a, internal_group=backbone_1, locations=locations, terminal_group=terminal_groups[0]
    )
    chain_prototype_b = AlkylsilaneInternalplus(
        chain_length=chainlength_b, internal_group=backbone_2, locations=locations, terminal_group=terminal_groups[1]
    )
    chain_prototype_c = AlkylsilaneInternalplus(
        chain_length=chainlength_c, internal_group=backbone_1, locations=locations, terminal_group=terminal_groups[2]
    )
    chain_prototype_d = AlkylsilaneInternalplus(
	chain_length=chainlength_d, internal_group=backbone_2, locations=locations, terminal_group=terminal_groups[3]
    )
    """
    ----------------------------------------------------------
    Create monolayer on surface, backfilled with hydrogen caps
    ----------------------------------------------------------
    """
    # bottom monolayer is backfilled with the other terminal group
    # num_chains = num_chains * a_fraction
    monolayer_a = SurfaceMonolayer(
        surface=surface_a,
        chains=[chain_prototype_a, chain_prototype_b],
        n_chains=num_chains,
        seed=seed,
        backfill=H(),
        rotate=False,
        fractions=[a_fraction, 1.0 - a_fraction],
    )
    monolayer_a.name = "Bottom"
    monolayer_b = SurfaceMonolayer(
        surface=surface_b,
        chains=[chain_prototype_c, chain_prototype_d],
        n_chains=num_chains,
        seed=seed,
        backfill=H(),
        rotate=False,
	fractions=[c_fraction, 1.0 - c_fraction],
    )
    monolayer_b.name = "Top"

    """
    ------------------------------------------
    Duplicate to yield two opposing monolayers
    ------------------------------------------
    """
    dual_monolayer = DualSurface(
        bottom=monolayer_a, top=monolayer_b, separation=2.0
    )

    """
    --------------------------------------------------------
    Make sure box is elongated in z to be pseudo-2D periodic
    --------------------------------------------------------
    """
    box = dual_monolayer.boundingbox
    dual_monolayer.periodicity += np.array([0, 0, 5.0 * box.lengths[2]])

    """
    -------------------------------------------------------------------
    - Save to .GRO, .TOP, and .LAMMPS formats
    - Atom-type the system using Foyer, with parameters from the OPLS
    force field obtained from GROMACS. Parameters are located in a
    Foyer XML file in the `atools` git repo, with references provided
    as well as notes where parameters have been added or altered to
    reflect the literature.
    -------------------------------------------------------------------
    """
    # path for project root dir
    proj = signac.get_project()
    forcefield_filepath = pathlib.Path(
        proj.root_directory() + "/src/util/forcefield/oplsaa.xml"
    )
    # change into job directoryA
    _switch_dir(job)
    logging.info("at dir: {}".format(job.ws))
    for p in dual_monolayer.particles():
        if p.name == "OS":
            p.name = "O"
    dual_monolayer.save("init.gro", residues=["Top", "Bottom"], overwrite=True)

    
            
            
    if not (
        job.isfile("init.top")
        and job.isfile("init.lammps")
        and job.isfile("init.gro")
    ):

        structure = dual_monolayer.to_parmed(
            box=None, residues=["Top", "Bottom"]
        )
        ff = Forcefield(forcefield_files=forcefield_filepath.as_posix())
        structure = ff.apply(structure)
        structure.combining_rule = "geometric"

        structure.save("init.top", overwrite=True)
        write_lammpsdata(filename="init.lammps", structure=structure, detect_forcefield_style=False)

        """
        --------------------------------------
        Specify index groups and write to file
        --------------------------------------
        """
    index_groups = generate_index_groups(
        system=dual_monolayer,
        terminal_groups=terminal_groups,
        freeze_thickness=0.5,
    )
    write_monolayer_ndx(rigid_groups=index_groups, filename="init.ndx")
コード例 #4
0
def initialize_system(job):
    """ Generate the monolayer surfaces, parametrize, save LAMMPS, GRO, TOP.
    """
    '''
    ---------------------------
    Read statepoint information
    ---------------------------
    '''
    chainlength = job.statepoint()['chainlength']
    n_chains = job.statepoint()['n']
    seed = job.statepoint()['seed']
    terminal_groups = job.statepoint()['terminal_groups']

    '''
    -----------------------------------
    Generate amorphous silica interface
    -----------------------------------
    '''
    surface_a = SilicaInterface(thickness=1.2, seed=seed)
    surface_b = SilicaInterface(thickness=1.2, seed=seed)

    '''
    ------------------------------------------------------
    Generate prototype of functionalized alkylsilane chain
    ------------------------------------------------------
    '''
    chain_prototype_a = Alkylsilane(chain_length=chainlength,
                                    terminal_group=terminal_groups[0])
    chain_prototype_b = Alkylsilane(chain_length=chainlength,
                                    terminal_group=terminal_groups[1])
    '''
    ----------------------------------------------------------
    Create monolayer on surface, backfilled with hydrogen caps
    ----------------------------------------------------------
    '''
    monolayer_a = SurfaceMonolayer(surface=surface_a, chains=chain_prototype_a,
                                   n_chains=n_chains, seed=seed,
                                   backfill=H(), rotate=False)
    monolayer_a.name = 'Bottom'
    monolayer_b = SurfaceMonolayer(surface=surface_b, chains=chain_prototype_b,
                                   n_chains=n_chains, seed=seed,
                                   backfill=H(), rotate=False)
    monolayer_b.name = 'Top'

    '''
    ------------------------------------------
    Duplicate to yield two opposing monolayers
    ------------------------------------------
    '''
    dual_monolayer = DualSurface(bottom=monolayer_a, top=monolayer_b,
                                 separation=2.0)

    '''
    --------------------------------------------------------
    Make sure box is elongated in z to be pseudo-2D periodic
    --------------------------------------------------------
    '''
    box = dual_monolayer.boundingbox
    dual_monolayer.periodicity += np.array([0, 0, 5. * box.lengths[2]])

    '''
    -------------------------------------------------------------------
    - Save to .GRO, .TOP, and .LAMMPS formats
    - Atom-type the system using Foyer, with parameters from the OPLS
    force field obtained from GROMACS. Parameters are located in a
    Foyer XML file in the `atools` git repo, with references provided
    as well as notes where parameters have been added or altered to
    reflect the literature.
    -------------------------------------------------------------------
    '''
    # path for project root dir
    proj = signac.get_project()
    forcefield_filepath = pathlib.Path(
        proj.root_directory() + "/src/util/forcefield/oplsaa.xml")
    # change into job directoryA
    _switch_dir(job)
    logging.info("at dir: {}".format(job.ws))
    dual_monolayer.save('init.gro', residues=['Top', 'Bottom'],
			    overwrite=True)

    if not (job.isfile('init.top') and job.isfile('init.lammps') and
	    job.isfile('init.gro')):

        structure = dual_monolayer.to_parmed(box=None,
					     residues=['Top', 'Bottom'])
        ff = Forcefield(forcefield_files=forcefield_filepath.as_posix())
        structure = ff.apply(structure)
        structure.combining_rule = 'geometric'

        structure.save('init.top', overwrite=True)
        write_lammpsdata(filename='init.lammps', structure=structure)

        '''
        --------------------------------------
        Specify index groups and write to file
        --------------------------------------
        '''
    index_groups = generate_index_groups(system=dual_monolayer,
					 terminal_groups=terminal_groups,
					 freeze_thickness=0.5)
    write_monolayer_ndx(rigid_groups=index_groups, filename='init.ndx')