示例#1
0
def monomer():
    try:
        s = system.read_pubchem_smiles('CC')
    except:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'CC.mol'))
    f = forcefield.Pcff()
    s.apply_forcefield(f)
    
    c1 = s.particles[1]
    c2 = s.particles[2]
    c1.linker = 'head'
    c2.linker = 'tail'
    
    for b in c1.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c1 else b.b
            s.particles.remove(pb.tag, update=False)
            break
        
    for b in c2.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c2 else b.b
            s.particles.remove(pb.tag, update=False)
            break
            
    s.remove_spare_bonding()
    
    s.pair_style = 'lj/cut'
    
    lmps.quick_min(s, min_style='fire')

    s.add_particle_bonding()

    return s
示例#2
0
def monomer():
    try:
        s = system.read_pubchem_smiles('O=C(OCCCC)CC')
    except:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'CC(C)C(=O)OC.mol'))
    f = forcefield.Pcff()
    s.apply_forcefield(f)

    c3 = s.particles[7]
    c4 = s.particles[9]

    for b in c3.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c3 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    for b in c4.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c4 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    s.remove_spare_bonding()

    c3.linker = 'head'
    c4.linker = 'tail'

    lmps.quick_min(s, min_style='fire')

    s.add_particle_bonding()

    return s
示例#3
0
 def setUp(self):
     self.sst = system.read_pubchem_cid(6360)
     self.sst.dim = system.Dimension(xlo=-10,
                                     ylo=-10,
                                     zlo=-10,
                                     xhi=10,
                                     yhi=10,
                                     zhi=10)
     self.sst.apply_forcefield(forcefield.Pcff(), charges='gasteiger')
     self.fname_temp = 'testfile.output.{}'
     self.fname = ''
示例#4
0
def monomer():
    try:
        s = system.read_pubchem_smiles('CCc1=cc=cc=c1')
    except:
        import os
        s = system.read_mol(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         os.pardir, 'CCc1=cc=cc=c1.mol'))
    m = s.molecules[1]
    f = forcefield.Pcff()

    for b in s.bonds:
        if b.a.bonds.count == 3 and b.b.bonds.count == 3:
            b.order = 4

    s.apply_forcefield(f)

    c1 = s.particles[1]
    c5 = s.particles[5]

    for b in c1.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c1 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    for b in c5.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c5 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    s.remove_spare_bonding()

    s.set_box(padding=10)

    c1.linker = 'head'
    c5.linker = 'tail'

    lmps.quick_min(s, min_style='fire')

    s.add_particle_bonding()

    return s
示例#5
0
def get_types():
    types = []
    desc = []
    molfile = request.form['mol']
    ff = request.form['ff']
    typer = request.form['typer']
    s = system.read_mol(molfile)
    try:
        if ff == 'Dreiding':
            f = forcefield.Dreiding()
            s.apply_forcefield(f)
        elif ff == 'Polymer Consistent Force Field (PCFF)':
            f = forcefield.Pcff()
            s.apply_forcefield(f)
        elif ff == 'Generalized Amber Force Field (GAFF)':
            f = forcefield.Gaff2()
            if typer == 'pysimm':
                s.apply_forcefield(f)
            elif typer == 'antechamber':
                cwd = os.getcwd()
                tempdir = tempfile.mkdtemp()
                print(tempdir)
                os.chdir(tempdir)
                amber.get_forcefield_types(s, f=f)
                os.chdir(cwd)
                shutil.rmtree(tempdir)
        types = [p.type.name for p in s.particles]
        desc = [p.type.desc for p in s.particles]
    except:
        print('error typing occurred')
    p_elems = set(p.elem for p in s.particles)
    possible_types = {e: [] for e in p_elems}
    possible_types_desc = {e: [] for e in p_elems}
    for pt in f.particle_types:
        if pt.elem in p_elems:
            possible_types[pt.elem].append(pt.name)
            possible_types_desc[pt.elem].append(pt.desc)

    return jsonify(types=types,
                   desc=desc,
                   possible_types=possible_types,
                   possible_types_desc=possible_types_desc)
示例#6
0
def monomer():
    try:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'disGde.mol'))
       # s = system.read_pubchem_smiles('O=C(OCCSSCCC(O)=O)CC')
    except:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'CC(C)C(=O)OC.mol'))
    f = forcefield.Pcff()
    s.apply_forcefield(f)

    c3 = s.particles[1]
    c4 = s.particles[2]

    for b in c3.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c3 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    for b in c4.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c4 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    s.remove_spare_bonding()

    c3.linker = 'head'
    c4.linker = 'tail'

    lmps.quick_min(s, min_style='cg')

    s.add_particle_bonding()
    s.apply_charges(f,charges ='gasteiger')
    signal = 0
    for pb in s.particles:
        if pb.elem == 'O' and 1 in pb.bond_orders and len(set(pb.bond_orders)) == 1:
            signal+=1
        if signal ==2 and pb.elem == 'O' and 1 in pb.bond_orders and len(set(pb.bond_orders)) == 1:
            pb.charge = pb.charge -1
    return s
示例#7
0
def monomer():
    try:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'disIpro.mol'))

      #  s = system.read_pubchem_smiles('CCC(OCCSSCCN)=O')
    except:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'CC(C)C(=O)OC.mol'))
    f = forcefield.Pcff()
    s.apply_forcefield(f)

    c3 = s.particles[1]
    c4 = s.particles[2]

    for b in c3.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c3 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    for b in c4.bonds:
        if b.a.elem == 'H' or b.b.elem == 'H':
            pb = b.a if b.b is c4 else b.b
            s.particles.remove(pb.tag, update=False)
            break

    s.remove_spare_bonding()

    c3.linker = 'head'
    c4.linker = 'tail'

    lmps.quick_min(s, min_style='cg')

    s.add_particle_bonding()
    s.apply_charges(f,charges = 'gasteiger')
    for pb in s.particles:
        if pb.elem == 'N':
            pb.charge = pb.charge + 1.0

    return s
示例#8
0
def get_lmps():
    molfile = request.form['mol']
    type_names = map(lambda x: x.split()[-1],
                     request.form.getlist('typeNames[]'))
    ff = request.form['ff']
    if ff == 'Dreiding':
        f = forcefield.Dreiding()
    elif ff == 'Polymer Consistent Force Field (PCFF)':
        f = forcefield.Pcff()
    elif ff == 'Generalized Amber Force Field (GAFF)':
        f = forcefield.Gaff2()
    s = system.read_mol(molfile)
    types = {
        name: s.particle_types.add(f.particle_types.get(name)[0].copy())
        for name in set(type_names)
    }
    for p, pname in zip(s.particles, type_names):
        p.type = types[pname]
    s.apply_forcefield(f, skip_ptypes=True)
    s.pair_style = f.pair_style
    return jsonify(lmpsData=s.write_lammps('string'))
示例#9
0
        'This is no more than a python2.7 interactive shell with certain pySIMM modules imported for your convenience'
    )
    print('Importing modules now...')

    from pysimm import system, amber, lmps, forcefield

    if args.lammps_data:
        s = system.read_lammps(args.lammps_data)
    elif args.molfile:
        s = system.read_mol(args.molfile)
        if args.forcefield and args.forcefield in supported_forcefields:
            if args.forcefield.lower() == 'dreiding':
                print('typing with %s' % args.forcefield)
                s.apply_forcefield(forcefield.Dreiding())
            elif args.forcefield.lower() == 'pcff':
                s.apply_forcefield(forcefield.Pcff())
        elif args.forcefield:
            print('forcefield %s is not supported in '
                  'command line interface at this time')
    elif args.cml_file:
        s = system.read_cml(args.cml_file)
    elif args.yaml_file:
        s = system.read_yaml(args.yaml_file)
    elif args.lmps2xyz:
        s = system.read_lammps(args.lmps2xyz[0])
        if args.unwrap:
            print(
                'unwrapping system so bonds do no cross simulation boundaries...'
                'this may take a while if your system is large')
            s.unwrap()
        s.write_xyz(args.lmps2xyz[1])
示例#10
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.Pcff()

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





    ##### Specifiy What Monomer that you are going to use and the frequency of each Monomer
    polist = [ba, amide, disg,disi,dise]
    monlist = [2,2,1,1,1]
    n_molecules = 10000 # 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")



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