Beispiel #1
0
def run(test=False):
    # we'll create a pmma monomer from the pysimm.models database
    pmma = monomer()
    
    # we'll instantiate a Dreiding forcefield object for use later
    f = forcefield.Dreiding()
    
    pmma.pair_style = 'lj/cut'
    
    # we're going to make 4 chains, each of 5 repeat units
    # the first system we make will be used as the initial system and then replicated to form 4 chains
    # in this case the system.replicate function take a system input(polymer),
    # replicates a defined number of times(4), and inserts the new replication randomly(rand=True) at the specified density(0.022) 
    
    print('Building polymer chain 1...')
    polymer = random_walk(pmma, nmon=5, forcefield=f)
    print('Replicating polymer chain...')
    uniform_polymer = system.replicate(polymer, 4, density=0.022, rand=True)
    
    # next we're going to make 4 chains, with lengths of 2, 4, 6, and 8 monomer units
    # the first system we make will be used as the initial system for the subsequent random walk calls
    
    print('Building polymer chain 1...')
    nonuniform_polymer = random_walk(pmma, nmon=2, forcefield=f, density=0.3/4)
    print('Building polymer chain 2...')
    nonuniform_polymer = random_walk(pmma, nmon=4, s_=nonuniform_polymer, forcefield=f)
    print('Building polymer chain 3...')
    nonuniform_polymer = random_walk(pmma, nmon=6, s_=nonuniform_polymer, forcefield=f)
    print('Building polymer chain 4...')
    nonuniform_polymer = random_walk(pmma, nmon=8, s_=nonuniform_polymer, forcefield=f)
    
    # now that we have our two polymer systems, let's calculate their molecular weight dispersity
    uniform_polymer.set_mm_dist()
    nonuniform_polymer.set_mm_dist()
    
    print('')
    print('Uniform polymer')
    print('---------------')
    print('Number average molecular weight: {}'.format(uniform_polymer.mn))
    print('Weight average molecular weight: {}'.format(uniform_polymer.mw))
    print('Dispersity: {}'.format(uniform_polymer.dispersity))
    print('')
    print('Nonuniform polymer')
    print('------------------')
    print('Number average molecular weight: {}'.format(nonuniform_polymer.mn))
    print('Weight average molecular weight: {}'.format(nonuniform_polymer.mw))
    print('Dispersity: {}'.format(nonuniform_polymer.dispersity))
    
    # write a few different file formats
    uniform_polymer.write_yaml('uniform_polymer.yaml')
    uniform_polymer.write_xyz('uniform_polymer.xyz')
    
    nonuniform_polymer.write_yaml('nonuniform_polymer.yaml')
    nonuniform_polymer.write_xyz('nonuniform_polymer.xyz')
Beispiel #2
0
def polymer_system(chains=10, mn=1000, pdi=1, density=0.3):
    if pdi != 1:
        print('disperse molecular weight distributions not supported yet')
        return
    
    mon = monomer()
    
    chain_length = int(mn/mon.mass)
    
    polym = random_walk(mon, chain_length, density=density/chains, forcefield=forcefield.Dreiding())
    
    for chain in range(chains-1):
        polym = random_walk(mon, chain_length, s_=polym, density=None, forcefield=forcefield.Dreiding())
    
    return polym
Beispiel #3
0
 def grow_polymer(self):
     self.polymer = random_walk(self.monomer,
                                self.chain_length,
                                forcefield=self.ff,
                                density=self.growth_density,
                                settings={'np': self.nproc})
     self.polymer.forcefield = self.ff.name
Beispiel #4
0
def run(test=False):
    # we'll create a pe monomer from the pysimm.models database
    pe = monomer()
    
    # 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
    pe.apply_charges(f, charges='gasteiger')
    
    # run the random_walk polymerization method making a chain of 10 repeat units
    # the forcefield object is supplied to get new forcefield types not in the monomer system
    polymer = random_walk(pe, 10, forcefield=f)
    
    # write a few different file formats
    polymer.write_xyz('polymer.xyz')
    polymer.write_yaml('polymer.yaml')
    polymer.write_lammps('polymer.lmps')
    polymer.write_chemdoodle_json('polymer.json')
    
    # if you want to restart a polymerization, the yaml file format retains linker information
    # random_walk looks for the last head and tail linkers, so just run a copolymerization with the original polymer chain and new monomers
    # we give the copolymer function a list of reference "monomers", but use the first polymer chain as the first "monomer" and only insert one
    # then we use the pattern argument to define how many of each "monomers" to add. Let's add 5 more monomers to our chain
    
    # first import the copolymer function
    
    from pysimm.apps.random_walk import copolymer
    
    # now read in the yaml file we saved after making our first polymer
    
    original_polymer = system.read_yaml('polymer.yaml')
    
    # we can use our original polyethylene monomer because it doesn't get modified during polymerization
    # the total number of monomers we're adding is 6, 1 for the original polymer chain, and 5 for our new monomers
    
    longer_polymer = copolymer([original_polymer, pe], 6, pattern=[1, 5], forcefield=f)
    
    longer_polymer.write_xyz('longer_polymer.xyz')
    longer_polymer.write_yaml('longer_polymer.yaml')
    longer_polymer.write_lammps('longer_polymer.lmps')
    longer_polymer.write_chemdoodle_json('longer_polymer.json')
Beispiel #5
0
def polymer_chain(length):
    mon = monomer()
    polym = random_walk(mon, length, forcefield=forcefield.Dreiding())
    return polym
Beispiel #6
0
         for x, y, z in zip(np.ndarray.flatten(X), np.ndarray.flatten(Y),
                            np.ndarray.flatten(Z))]

for ch in range(1, nchains + 1):
    mloc = mono.copy()
    mloc.dim.translate(*displ[2 * ch])
    mloc.shift_particles(*displ[2 * ch])

    sngl_chain = random_walk(mloc,
                             10,
                             density=0.01,
                             geometry_rule=position_rule_pim1,
                             extra_bonds=[1, 0],
                             traj=False,
                             unwrap=True,
                             settings={
                                 'np': 6,
                                 'length': 25000,
                                 'min_style': 'cg',
                                 'etol': 1e-5,
                                 'ftol': 1e-5,
                                 'maxiter': int(1e+7),
                                 'maxeval': int(1e+7)
                             })
    chains.append(sngl_chain)
    # remove litter
    os.remove('polymer.xyz')
    os.remove('polymer.lmps')

pim1_ld = system.System()
for prp in [
        'ff_class', 'forcefield', 'pair_style', 'bond_style', 'angle_style',
Beispiel #7
0
    cntrion_tp = ff.particle_types.get('SOD')[0].copy()
    chrg = 1
elif abs(monomer.charge - 1) < 0.1:
    print('\tAdding CLORINE counterion to equilibrate the system chargewise')
    cntrion_tp = ff.particle_types.get('CLA')[0].copy()
    chrg = -1
else:
    cntrion_tp = None

if cntrion_tp:
    monomer.particle_types.add(cntrion_tp)
    monomer.particles.add(system.Particle(x=monomer.cog[0], y=monomer.cog[1], z=monomer.cog[2] + 5.0, type=cntrion_tp,
                                      charge=chrg, molecule=monomer.molecules[1]))

# -------------> Polymer construction and tacticity check <--------------
sngl_chain = random_walk(monomer, chain_len, forcefield=ff, density=0.01, print_to_screen='true', traj=False, unwrap=True)

if is_cap:
    cap_with_methyls(sngl_chain, ff)

# After polymerisation and possibly capping is done let's cleanup: remove all counterions and reshape the simulation
# box so that the chain is in the center of a cube with padding of 3 nm

sngl_chain.center(what='particles', at=[0.0, 0.0, 0.0], move_both=False)

if cntrion_tp:
    for p in sngl_chain.particles:
        if p.type.name == cntrion_tp.name:
            sngl_chain.particles.remove(p.tag, update=False)
            sngl_chain.molecules[p.molecule.tag].particles.remove(p.tag, update=False)
    sngl_chain.objectify()
Beispiel #8
0
def polymer_chain(length, ff):
    return random_walk(monomer(ff), length, forcefield=ff)
Beispiel #9
0
# we'll instantiate a GAFF2 forcefield object for use later
f = forcefield.Gaff2()

# particles 1 and 2 in the monomer are going to be the head and tail linkers
s.particles[1].linker = 'head'
s.particles[2].linker = 'tail'

# the resulting system has sufficient information to type with the forcefield object we made earlier
# we will also determine partial charges using the gasteiger algorithm
s.apply_forcefield(f, charges='gasteiger')

# do a quick minimization of the monomer
lmps.quick_min(s, min_style='fire')

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

# run the random_walk polymerization method making a chain of 10 repeat units
# the forcefield object is supplied to get new forcefield types not in the monomer system
polymer = random_walk(s, 10, forcefield=f)

# write a few different file formats
polymer.write_xyz('polymer.xyz')
polymer.write_yaml('polymer.yaml')
polymer.write_lammps('polymer.lmps')
polymer.write_chemdoodle_json('polymer.json')
Beispiel #10
0
# we'll instantiate a GAFF2 forcefield object for use later
f = forcefield.Gaff2()

# particles 3 and 6 in the monomer are going to be the head and tail linkers
pmma.particles[3].linker = 'head'
pmma.particles[6].linker = 'tail'

# the resulting system has sufficient information to type with the forcefield object we made earlier
# we will also determine partial charges using the gasteiger algorithm
pmma.apply_forcefield(f, charges='gasteiger')

# do a quick minimization of the monomer
lmps.quick_min(pmma, min_style='fire')

# write a yaml file for the pmma monomer
pmma.write_yaml('pmma_monomer.yaml')

# we're going to make 4 chains, each of 5 repeat units
# the first system we make will be used as the initial system for the subsequent random walk calls
polymer = random_walk(pmma, nmon=5, forcefield=f, density=0.3 / 4)
polymer = random_walk(pmma, nmon=5, s_=polymer, forcefield=f)
polymer = random_walk(pmma, nmon=5, s_=polymer, forcefield=f)
polymer = random_walk(pmma, nmon=5, s_=polymer, forcefield=f)

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