示例#1
0
def run(test=False):
    # we'll make a vinyl-type polynorbornene monomer from the pysimm models database
    A = NbTMS(isomer="exo_exo")

    setattr(A.particles[1], 'rnd_wlk_tag', 'tail_cap')
    setattr(A.particles[49], 'rnd_wlk_tag', 'head_cap')

    # we'll instantiate a Dreiding forcefield object for use later
    f = forcefield.Dreiding()

    # the monomers do not have any charges, so we will derive partial charges using the gasteiger algorithm
    A.apply_charges(f, charges='gasteiger')

    # the buckingham potential isn't great at small distances, and therefore we use the LJ potential while growing the polymer
    A.pair_style = 'lj/cut'

    # run the polymer random walk tacticity method with 10 total repeat units, all isotactic insertions, no minimizations
    polymer = random_walk_tacticity(A,
                                    10,
                                    forcefield=f,
                                    capped=True,
                                    tacticity='isotactic',
                                    sim='no',
                                    rotation=180)
    write_file_formats(polymer, "isotactic_PNB_nosim10")

    # run the polymer random walk tacticity method with 10 total repeat units, all syndiotactic insertions, no minimizations
    polymer = random_walk_tacticity(A,
                                    10,
                                    forcefield=f,
                                    capped=True,
                                    tacticity='syndiotactic',
                                    sim='no',
                                    rotation=180)
    write_file_formats(polymer, "syndiotactic_PNB_nosim10")

    # run the polymer random walk tacticity method with 50 total repeat units with minimizations and error
    # checking (when a hardcore overlap is found, the last inserted monomer shrunken and gradually re-expanded)
    polymer = random_walk_tacticity(A,
                                    50,
                                    forcefield=f,
                                    capped=True,
                                    tacticity='syndiotactic',
                                    error_check=True,
                                    rotation=180,
                                    md_spacing=1)
    write_file_formats(polymer, "syndiotactic_PNB_sim50")

    # pack and equilibrate eight 20mers of exo_exo and exo_endo isomers to compare densities
    pack_and_equil(A, 20, 8, f, "exo")
    A = NbTMS(isomer="exo_endo")
    A.apply_charges(f, charges='gasteiger')
    A.pair_style = 'lj/cut'
    pack_and_equil(A, 20, 8, f, "endo")
示例#2
0
def run(test=False):
    # we'll take a polystyrene monomer from the pysimm models database
    monomer = ps(is_capped=True)

    # we'll decorate atoms of PS monomer with tags that are needed for more elaborate polymerisation
    # procedure that takes into account tacticity
    setattr(monomer.particles[9], 'linker', 'mirror')
    setattr(monomer.particles[9], 'rnd_wlk_tag', 'head_cap')
    setattr(monomer.particles[13], 'rnd_wlk_tag', 'tail_cap')

    # we'll instantiate a Dreiding forcefield object for use later
    f = forcefield.Dreiding()
    
    # the monomers do not have any charges, so we will derive partial charges using the gasteiger algorithm
    monomer.apply_charges(f, charges='gasteiger')
    
    # the buckingham potential isn't great at small distances, and therefore we use the LJ potential while growing the polymer
    monomer.pair_style = 'lj/cut'
    
    # run the polymer random walk tacticity method with 10 total repeat units
    polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity='isotactic', sim='no')

    # write a few different file formats
    polymer.write_xyz('isotactic.xyz')
    polymer.write_yaml('isotactic.yaml')
    polymer.write_lammps('isotactic.lmps')
    polymer.write_chemdoodle_json('isotactic.json')

    # run the polymer random walk tacticity method with 10 total repeat units
    polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity='syndiotactic', sim='no')

    # write a few different file formats
    polymer.write_xyz('syndiotactic.xyz')
    polymer.write_yaml('syndiotactic.yaml')
    polymer.write_lammps('syndiotactic.lmps')
    polymer.write_chemdoodle_json('syndiotactic.json')
    
    # run the polymer random walk tacticity method with 10 total repeat units
    polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity=0.2, sim='no')

    # write a few different file formats
    polymer.write_xyz('iso_20_syndio_80.xyz')
    polymer.write_yaml('iso_20_syndio_80.yaml')
    polymer.write_lammps('iso_20_syndio_80.lmps')
    polymer.write_chemdoodle_json('iso_20_syndio_80.json')
示例#3
0
        tmp = 1.54 * tmp / numpy.linalg.norm(tmp)
        # add new capping particle along the defined direction
        new_p = new_monomer.add_particle_bonded_to(system.Particle(x=p.x + tmp[0], y=p.y + tmp[1],
                                                                   z=p.z + tmp[2], type=captype), p, f=ff)
        # decorate particle with '****_cap' tag
        new_p.rnd_wlk_tag = p.linker + '_cap'
        if p.linker == 'head':
            setattr(new_p, 'linker', 'mirror')

new_monomer.objectified = False
new_monomer.objectify()

new_monomer.write_pdb('2.monomer_to_rndwlk-tacticity.pdb')

# first random walk **without** simulations
polymer = random_walk_tacticity(new_monomer, chain_len + 1, forcefield=ff, tacticity='syndiotactic', sim='no')
polymer.write_pdb('3.polymer_rndwlk-tacticity.no-sim.pdb')

tacticity_stat = check_tacticity(polymer, tacticity_order, len(monomer.particles))
print('\t Polymer chain built without MD contains {:}/{:} meso- and {:}/{:} racemo- diads'.format(
                            tacticity_stat[1].count(True), chain_len, tacticity_stat[1].count(False), chain_len))


# second, random walk **with** simulations
polymer = random_walk_tacticity(new_monomer, chain_len + 1, forcefield=ff, tacticity='syndiotactic')
polymer.write_pdb('4.polymer_rndwlk-tacticity.pdb')

tacticity_stat = check_tacticity(polymer, tacticity_order, len(monomer.particles))
print('\t Polymer chain built using MD contains {:}/{:} meso- and {:}/{:} racemo- diads'.format(
                            tacticity_stat[1].count(True), chain_len, tacticity_stat[1].count(False), chain_len))
示例#4
0
def pack_and_equil(A, n, x, f, prefix):
    # A: monomer
    # n: number of monomers
    # x: number of chains
    # f: forcefield
    # prefix: prefix for output files

    # run the polymer random walk tacticity method with n total repeat units
    polymer = random_walk_tacticity(A,
                                    n,
                                    forcefield=f,
                                    capped=True,
                                    tacticity='syndiotactic',
                                    rotation=180,
                                    error_check=False,
                                    sim=0)
    write_file_formats(polymer, prefix + "_1", unwrap=True)

    # quick opt of polymer
    lmps.quick_min(polymer, min_style='fire', etol=1.0e-4, maxiter=100000)

    # write a few different file formats
    polymer.unwrap()
    write_file_formats(polymer, prefix + "_1_fire")

    # pack x copies of polymer
    polymers = system.replicate(polymer, x, density=0.005)
    # polymers = polymer
    write_file_formats(polymers, prefix + "_" + str(x))
    lmps.quick_min(polymers, min_style='fire', etol=1.0e-4, maxiter=100000)
    write_file_formats(polymers, prefix + "_" + str(x) + "_fire")

    # quickmd
    nvt_settings = {
        'name': 'nvt_md',
        'print_to_screen': True,
        'ensemble': 'nvt',
        'temperature': {
            'start': 100,
            'stop': 300
        },
        'new_v': True,
        'length': 10000
    }
    npt_settings = {
        'name': 'npt_md',
        'print_to_screen': True,
        'ensemble': 'npt',
        'temperature': 300,
        'new_v': True,
        'pressure': {
            'start': 1000,
            'stop': 1
        },
        'length': 100000,
        'thermo_style': 'custom step temp press density'
    }
    # npt calcs need "add neigh_modify" command to reneighbor more often during compression of npt step
    sim = lmps.Simulation(polymers, name='npt_reneighbor', debug=True)
    sim.add_custom('neigh_modify delay 0')
    sim.add(lmps.Velocity(temperature=1000))
    sim.add_md(length=10000, ensemble='npt', temperature=1000, pressure=5000)
    sim.run()
    write_file_formats(polymers, prefix + "_" + str(x) + "_npt")
    write_file_formats(polymers,
                       prefix + "_" + str(x) + "_npt_unwrapped",
                       unwrap=True)

    # 21-step equilibration
    equil(polymers, np=1, pmax=50000)
    write_file_formats(polymers, prefix + "_" + str(x) + "_equil")
    write_file_formats(polymers,
                       prefix + "_" + str(x) + "_equil_unwrapped",
                       unwrap=True)
示例#5
0
def run(test=False):
    # we'll make a polystyrene monomer from the pysimm models database
    A = NbTMS(isomer="exoexo")
    # we'll instantiate a Dreiding forcefield object for use later
    f = forcefield.Dreiding()

    # the monomers do not have any charges, so we will derive partial charges using the gasteiger algorithm
    A.apply_charges(f, charges='gasteiger')

    # the buckingham potential isn't great at small distances, and therefore we use the LJ potential while growing the polymer
    A.pair_style = 'lj/cut'

    # run the polymer random walk tacticity method with 10 total repeat units
    polymer = random_walk_tacticity(A,
                                    20,
                                    forcefield=f,
                                    capped=True,
                                    tacticity='syndiotactic',
                                    rotation=180,
                                    errorCheck=False,
                                    sim=0)
    writeFileFormats(polymer, "polymer", unwrap=True)

    #quick opt of polymer
    lmps.quick_min(polymer, min_style='fire', etol=1.0e-4, maxiter=100000)

    # write a few different file formats
    polymer.unwrap()
    writeFileFormats(polymer, "polymer_fired")

    #pack multiple copies of polymer
    polymers = system.replicate(polymer, 8, density=0.005)
    #polymers = polymer
    writeFileFormats(polymers, "polymers")
    lmps.quick_min(polymers, min_style='fire', etol=1.0e-4, maxiter=100000)
    writeFileFormats(polymers, "polymers_fired")

    #quickmd
    nvt_settings = {
        'name': 'nvt_md',
        'print_to_screen': True,
        'ensemble': 'nvt',
        'temperature': {
            'start': 100,
            'stop': 300
        },
        'new_v': True,
        'length': 10000
    }
    npt_settings = {
        'name': 'npt_md',
        'print_to_screen': True,
        'ensemble': 'npt',
        'temperature': 300,
        'new_v': True,
        'pressure': {
            'start': 1000,
            'stop': 1
        },
        'length': 100000,
        'thermo_style': 'custom step temp press density'
    }
    #nvt runs okay, but npt fails...need to add neigh_modify command to reneighbor more often during compression of npt step
    #lmps.quick_md(polymers, debug=True, **nvt_settings)
    #writeFileFormats(polymers,"polymers_nvt")
    #lmps.quick_md(polymers, debug=True, **npt_settings)
    #lmps.quick_md(polymers)
    #writeFileFormats(polymers,"polymers_npt")
    sim = lmps.Simulation(polymers, name='nptAndReneighbor', debug=True)
    sim.add_custom('neigh_modify delay 0')
    sim.add(lmps.Velocity(temperature=1000))
    sim.add_md(length=10000, ensemble='npt', temperature=1000, pressure=5000)
    sim.run()
    writeFileFormats(polymers, "polymers_npt")
    writeFileFormats(polymers, "polymers_npt_unwrapped", unwrap=True)

    #21-step equilibration
    equil(polymers, np=1, pmax=50000)
    writeFileFormats(polymers, "polymers_equil")
    polymers.unwrap()
    writeFileFormats(polymers, "polymers_equil_unwrap")