示例#1
0
def Cl():
    s = system.System()
    m = s.molecules.add(system.Molecule())
    f = forcefield.Dreiding()
    dreiding_Na_ = s.particle_types.add(f.particle_types.get('Cl')[0].copy())
    s.particles.add(system.Particle(type=dreiding_Na_, x=0, y=0, z=0, charge=-1, molecule=m))
    s.apply_forcefield(f)
    s.pair_style = 'lj/cut'

    lmps.quick_min(s, min_style='fire')
    return s
示例#2
0
from pysimm import system, lmps, forcefield

# create empty system
s = system.System()

# create new molecule in our system
m = s.molecules.add(system.Molecule())

# retrieve GAFF2 parameters
f = forcefield.Gaff2()

# get a copy of the c3 particle type object from GAFF
# get method returns a list, we need the first element
gaff_c3 = s.particle_types.add(f.particle_types.get('c3')[0].copy())

# we'll first make the carbon atom at the origin
# we'll include gasteiger charges later
c1 = s.particles.add(
    system.Particle(type=gaff_c3, x=0, y=0, z=0, charge=0, molecule=m))

# get hc particle type object from GAFF
gaff_hc = f.particle_types.get('hc')[0].copy()

# add hc particle type to system
s.particle_types.add(gaff_hc)

# now we'll add 4 hydrogen atoms bonded to our carbon atom
# these atoms will be placed randomly 1.5 angstroms from the carbon atom
# we'll optimize the structure using LAMMPS afterwords
# we supply the GAFF forcefield object so that bond and angle types can be added as well
h1 = s.add_particle_bonded_to(
示例#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()
    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')
示例#4
0
def run(test=False):
    # create empty system
    print('Example progress: Creating an empty system...')
    s = system.System()

    # create new molecule in our system
    print(
        'Example progress: Adding an empty molecule container to our system...'
    )
    m = s.molecules.add(system.Molecule())

    # retrieve GAFF2 parameters
    print('Example progress: Retrieving Dreiding force field parameters...')
    f = forcefield.Gaff2()
    s.forcefield = f.name

    # get a copy of the c3 particle type object from GAFF
    # get method returns a list, we need the first element
    gaff_c3 = s.particle_types.add(f.particle_types.get('c3')[0].copy())

    # get hc particle type object from GAFF
    gaff_hc = s.particle_types.add(f.particle_types.get('hc')[0].copy())

    # we'll first make the carbon atom at the origin
    # we'll include gasteiger charges later
    print('Example progress: Adding carbon atom at origin...')
    c1 = s.particles.add(
        system.Particle(type=gaff_c3, x=0, y=0, z=0, charge=0, molecule=m))

    # now we'll add 4 hydrogen atoms bonded to our carbon atom
    # these atoms will be placed randomly 1.5 angstroms from the carbon atom
    # we'll optimize the structure using LAMMPS afterwords
    # we supply the GAFF forcefield object so that bond and angle types can be added as well
    print(
        'Example progress: Adding 4 hydrogen atoms at random positions bonded to the carbon atom...'
    )
    h1 = s.add_particle_bonded_to(
        system.Particle(type=gaff_hc, charge=0, molecule=m), c1, f)
    h2 = s.add_particle_bonded_to(
        system.Particle(type=gaff_hc, charge=0, molecule=m), c1, f)
    h3 = s.add_particle_bonded_to(
        system.Particle(type=gaff_hc, charge=0, molecule=m), c1, f)
    h4 = s.add_particle_bonded_to(
        system.Particle(type=gaff_hc, charge=0, molecule=m), c1, f)

    # let's add gasteiger charges
    print('Example progress: Deriving Gasteiger charges...')
    s.apply_charges(f, charges='gasteiger')

    # right now there is no simulation box defined
    # we'll define a box surrounding our methane molecule with a 10 angstrom padding
    print(
        'Example progress: Constructing Simulation box surrounding our new molecule...'
    )
    s.set_box(padding=10)

    # before we optimize our structure, LAMMPS needs to know what type of
    # pair, bond, and angle interactions we are using
    # these are determined by the forcefield being used
    s.pair_style = 'lj'
    s.bond_style = 'harmonic'
    s.angle_style = 'harmonic'

    # we'll perform energy minimization using the fire algorithm in LAMMPS
    print('Example progress: Optimizing structure using LAMMPS...')
    lmps.quick_min(s,
                   min_style='fire',
                   name='fire_min',
                   etol=1e-10,
                   ftol=1e-10)

    # write xyz, YAML, LAMMPS data, and chemdoodle json files
    print('Example progress: Saving structure to files...')
    s.write_xyz('methane.xyz')
    s.write_yaml('methane.yaml')
    s.write_lammps('methane.lmps')
    s.write_chemdoodle_json('methane.json')

    print('Example progress: Complete!')