Example #1
0
def run(test=False):

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

    # we'll make a polyethylene monomer and a polystyrene monomer from the pysimm models database
    pe = pe_monomer(f)
    ps = ps_monomer(f)

    # the monomers do not have any charges, so we will derive partial charges using the gasteiger algorithm
    pe.apply_charges(f, charges='gasteiger')
    ps.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
    pe.pair_style = 'lj/cut'
    ps.pair_style = 'lj/cut'

    # run the copolymer random walk method with 10 total repeat units, using an alternating pattern
    polymer = copolymer([pe, ps], 10, pattern=[1, 1], 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')
Example #2
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')
Example #3
0
def run(test=False):
    # we'll make a polyethylene monomer and a polystyrene monomer from the pysimm models database
    pe = pe_monomer()
    ps = ps_monomer()

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

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

    # run the copolymer random walk method with 10 total repeat units, using an alternating pattern
    polymer = copolymer([pe, ps], 10, pattern=[1, 1], 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')
Example #4
0
def run(test=False):
    # we'll make a polyethylene monomer and a polystyrene monomer from the pysimm models database
    pe = pe_monomer()
    ps = ps_monomer()
    ba = ba_monomer()
    H20 = water_water()
    dise = dise_monomer()
    disg = disg_monomer()
    disi = disi_monomer()
    amide = amide_monomer()
    peg = peg_monomer()
    Na = pos_salt()
    Cl = neg_salt()

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

    # the monomers do not have any charges, so we will derive partial charges using the gasteiger algorithm
    pe.apply_charges(f, charges='gasteiger')
    ps.apply_charges(f, charges='gasteiger')
    #H20.apply_charges(f,charges = 'gasteiger')
    ba.apply_charges(f, charges='gasteiger')
    peg.apply_charges(f, charges='gasteiger')
    amide.apply_charges(f, charges='gasteiger')
    dise.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
    pe.pair_style = 'lj/cut'
    ps.pair_style = 'lj/cut'
    H20.pair_style = 'lj/cut'
    ba.pair_style = 'lj/cut'
    dise.pair_style = 'lj/cut'
    disg.pair_style = 'lj/cut'
    peg.pair_style = 'lj/cut'
    amide.pair_style = 'lj/cut'
    disi.pair_style = 'lj/cut'
    Na.pair_style = 'lj/cut'
    Cl.pair_style = 'lj/cut'

    ######## Heres the Paramaters you can edit ##########
    ##### Specifiy What Monomer that you are going to use and the frequency of each Monomer
    polist = [ba, amide, disg, disi, dise]
    monlist = [10, 80, 5, 4, 1]
    n_molecules = 50000  # Number of Water Molecules Try to keep it at 10,000

    ##Current Monomers available
    # PEG5 : peg
    # Butyl Acrylate : ba
    # amide monomer: amide
    # Ethelyne: pa
    # Polystyrene: ps
    # MethylAcrylate: pmma
    # disulfideG: disg
    # disulfideI: disi
    # disulfideE: dise
    ####################################################################################

    pattern = shuffle(monlist, polist)

    # run the copolymer random walk method with 10 total repeat units, using an alternating pattern
    z = np.ones(len(pattern))
    setter = []
    for elem in range(0, len(z)):
        setter.append(int(z[elem]))
    print(setter)
    polymer = copolymer(pattern, len(pattern), pattern=setter, forcefield=f)

    polymer.write_xyz('polymernonsolvated.xyz')

    charge = 0
    for pb in polymer.particles:
        charge = charge + pb.charge
    print("The System has: " + str(charge) + " charge")

    numSa = round(charge)
    if charge < 0:
        salt = 'Na'
        charg = +1
    else:
        salt = 'Cl'
        charg = -1

    partition = n_molecules / (abs(numSa) + 1)
    if round(charge) == 0:
        system.replicate([H20], n_molecules, s_=polymer, density=0.6)
    else:
        for iters in range(0, abs(numSa) + 1):

            system.replicate([H20],
                             abs(int(partition)),
                             s_=polymer,
                             density=0.6)
            if iters == abs(numSa):
                lmps.quick_min(polymer, min_style='sd')
                break
            m = polymer.molecules.add(system.Molecule())
            dreiding_salt_ = polymer.particle_types.add(
                f.particle_types.get(salt)[0].copy())
            polymer.particles.add(
                system.Particle(type=dreiding_salt_,
                                x=polymer.dim.dx / 2,
                                y=polymer.dim.dy / 2,
                                z=polymer.dim.dz / 2,
                                charge=charg,
                                molecule=m))
            lmps.quick_min(polymer, min_style='sd')

    charge = 0
    for pb in polymer.particles:
        charge = charge + pb.charge
    print("The System has: " + str(charge) + " charge")

    if charge < 0:
        salt = 'Na'
        charg = +1
    else:
        salt = 'Cl'
        charg = -1

    m = polymer.molecules.add(system.Molecule())
    dreiding_salt_ = polymer.particle_types.add(
        f.particle_types.get(salt)[0].copy())
    polymer.particles.add(
        system.Particle(type=dreiding_salt_,
                        x=polymer.dim.dx / 2,
                        y=polymer.dim.dy / 2,
                        z=polymer.dim.dz / 2,
                        charge=-charge,
                        molecule=m))
    lmps.quick_min(polymer, min_style='sd')

    charge = 0
    for pb in polymer.particles:
        charge = charge + pb.charge
    print("The System has: " + str(charge) + " charge")

    # write a few different file formats
    polymer.write_xyz('polymersolvated.xyz')
    # polymer.write_yaml('polymer.yaml')
    polymer.write_lammps('polymer.lmps')
Example #5
0
ps.particles[7].linker = 'tail'

# like in example 3, we need to identify the bonds in the ring as aromatic
for b in ps.bonds:
    if (not b.a.linker
            and not b.b.linker) and b.a.elem == 'C' and b.b.elem == 'C':
        b.order = 'A'

# 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
ps.apply_forcefield(f, charges='gasteiger')

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

# write a yaml file for the ps monomer
ps.write_yaml('ps_monomer.yaml')

# run the copolymer random walk method with 10 total repeat units, using an alternating pattern
# here, settings is passed to the LAMMPS simulations during the polymerization, and we will use 2 processors
polymer = copolymer([pe, ps],
                    10,
                    pattern=[1, 1],
                    forcefield=f,
                    settings={'np': 2})

# 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')