示例#1
0
def run(test=False):
    # use a smiles string to query the pubchem search database and read the mol file returned from the http request
    # if cannot get to internet, read local cached response from pubchem
    try:
        s = system.read_pubchem_smiles('c1=cc=cc=c1')
    except:
        import os
        s = system.read_mol(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         os.pardir, 'c1=cc=cc=c1.mol'))

    # the resulting system (benzene) has alternating double bonds
    # we want pysimm to recognize the ring as aromatic, so we define each bond in the ring to be bond order 'A'
    for b in s.bonds:
        if b.a.elem == 'C' and b.b.elem == 'C':
            b.order = 'A'

    # the resulting system has sufficient information to type with a forcefield, here we will use the Dreiding force field
    # we will also determine partial charges using the gasteiger algorithm
    s.apply_forcefield(forcefield.Dreiding(), charges='gasteiger')

    # we'll perform a 2 step energy minimization using the steepest decent and conjugate gradient algorithms in LAMMPS
    lmps.quick_min(s, min_style='sd', name='min_sd')
    lmps.quick_min(s, min_style='cg', name='min_cg')

    # write a few different file formats
    s.write_xyz('benzene.xyz')
    s.write_yaml('benzene.yaml')
    s.write_lammps('benzene.lmps')
    s.write_chemdoodle_json('benzene.json')
示例#2
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.Gaff()
    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()

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

    s.add_particle_bonding()

    return s
示例#3
0
def monomer():
    try:
        s = system.read_pubchem_smiles('CC(C)C(=O)OC')
    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.Dreiding()
    
    s.apply_forcefield(f)
    
    c3 = s.particles[3]
    c4 = s.particles[4]
    
    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
示例#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.Gaff()

    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 SPC():
    try:
        s = system.read_pubchem_smiles('[H]O[H]')
    except:
        import os
        s = system.read_mol(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         os.pardir, 'CC.mol'))
    f = forcefield.Dreiding()
    s.apply_forcefield(f)
    for pb in s.particles:
        if pb.elem == 'H':
            pb.charge = 0.4238
        elif pb.elem == 'O':
            pb.charge = -0.8476

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

    return s
示例#6
0
def monomer(ff, is_capped=False):

    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, 'topologies', 'CCc1=cc=cc=c1.mol'))

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

    c1 = s.particles[1]
    c5 = s.particles[5]
    c1.linker = 'head'
    c5.linker = 'tail'

    if not is_capped:
        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.apply_forcefield(ff, charges='gasteiger')
    s.set_box(padding=10)

    sim = lmps.Simulation(s, print_to_screen=False, log='ps_mon_relax.log')
    sim.add(lmps.Init())
    sim.add_min(min_style='fire')
    sim.run()

    s.add_particle_bonding()
    return s
示例#7
0
def run(test=False):
    # use a smiles string to query the pubchem search database and read the mol file returned from the http request
    try:
        s = system.read_pubchem_smiles('CO')
    except:
        import os
        s = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'CO.mol'))
    
    # the resulting system has sufficient information to type with a forcefield, here we will use the GAFF2 force field
    s.apply_forcefield(forcefield.Gaff2())
    
    # we'll perform energy minimization using the fire algorithm in LAMMPS
    lmps.quick_min(s, min_style='fire')
    
    # write a few different file formats
    s.write_xyz('methanol.xyz')
    s.write_yaml('methanol.yaml')
    s.write_lammps('methanol.lmps')
    s.write_chemdoodle_json('methanol.json')
示例#8
0
 def test_read_pubchem_smiles(self):
     test_sst = system.read_pubchem_smiles('CC1=CC=C(C=C1)C')
     self.assertGreater(len(test_sst.particles), 0)
     self.assertGreater(len(test_sst.bonds), 0)
示例#9
0
from pysimm import system, lmps, forcefield

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
s = system.read_pubchem_smiles('CO')

# the resulting system has sufficient information to type with a forcefield, here we will use the GAFF2 force field
s.apply_forcefield(forcefield.Gaff2())

# we'll perform energy minimization using the fire algorithm in LAMMPS
lmps.quick_min(s, min_style='fire')

# write a few different file formats
s.write_xyz('methanol.xyz')
s.write_yaml('methanol.yaml')
s.write_lammps('methanol.lmps')
s.write_chemdoodle_json('methanol.json')
示例#10
0
def run(test=False):
    try:
        ethanol = system.read_pubchem_smiles('CCO')
    except:
        import os
        ethanol = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'CCO.mol'))
    try:
        acetone = system.read_pubchem_smiles('CC(=O)C')
    except:
        import os
        acetone = system.read_mol(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'CC(=O)C.mol'))

    f = forcefield.Gaff2()
    
    ethanol.apply_forcefield(f, charges='gasteiger')
    acetone.apply_forcefield(f, charges='gasteiger')
    
    # amber.calc_charges(ethanol)
    # amber.calc_charges(acetone)
    
    lmps.quick_min(ethanol, min_style='fire')
    lmps.quick_min(acetone, min_style='fire')
    
    molecule_list = [ethanol, acetone]
    
    if test:
        n_molecules = [20, 20]
    else:
        n_molecules = [200, 200]
    
    s = system.replicate(molecule_list, n_molecules, density=0.3)
    
    min_settings = {
        'name': 'cg_min',
        'min_style': 'cg',
        'maxiter': int(5e+5),
        'maxeval': int(5e+6),
    }
    
    nvt_settings = {
        'name': 'nvt_md',
        'print_to_screen': True,
        'ensemble': 'nvt',
        'temperature': {
            'start': 100,
            'stop': 300
        },
        'new_v': True,
        'length': 2500
    }
    
    npt_settings = {
        'name': 'npt_md',
        'print_to_screen': True,
        'ensemble': 'npt',
        'temperature': 300,
        'new_v': True,
        'pressure': {
            'start': 1000,
            'stop': 1
        },
        'length': 5000,
    }
    
    npt_settings_add = {
        'name': 'npt_md',
        'print_to_screen': True,
        'ensemble': 'npt',
        'temperature': 300,
        'new_v': True,
        'pressure': {
            'start': 1,
            'stop': 1
        },
        'length': 5000,
    }
    
    if test:
        nvt_settings['length'] = 2000
        npt_settings['length'] = 2000
        
    sim = lmps.Simulation(s)
    sim.add_min(**min_settings)
    
    sim.add(lmps.OutputSettings(thermo={'freq': 500, 
                                        'style': 'custom', 
                                        'args': ['step', 'temp', 'etotal', 'press', 'density']}))

    sim.add_md(**nvt_settings)
    sim.add_md(**npt_settings)
    sim.add_md(**npt_settings_add)
    sim.run()

    s.write_yaml('mixture.yaml')
    s.write_lammps('mixture.lmps')
示例#11
0
文件: run.py 项目: zidan1128/pysimm
def run(test=False):
    try:
        ethanol = system.read_pubchem_smiles('CCO')
    except:
        import os
        ethanol = system.read_mol(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         'CCO.mol'))
    try:
        acetone = system.read_pubchem_smiles('CC(=O)C')
    except:
        import os
        acetone = system.read_mol(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         'CC(=O)C.mol'))

    f = forcefield.Gaff2()

    ethanol.apply_forcefield(f, charges='gasteiger')
    acetone.apply_forcefield(f, charges='gasteiger')

    # amber.calc_charges(ethanol)
    # amber.calc_charges(acetone)

    lmps.quick_min(ethanol, min_style='fire')
    lmps.quick_min(acetone, min_style='fire')

    molecule_list = [ethanol, acetone]

    if test:
        n_molecules = [30, 20]
    else:
        n_molecules = [300, 200]

    s = system.replicate(molecule_list, n_molecules, density=0.3)

    min_settings = {
        'name': 'fire_min',
        'min_style': 'fire',
        'print_to_screen': True
    }

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

    if test:
        nvt_settings['length'] = 2000
        npt_settings['length'] = 2000

    lmps.quick_min(s, **min_settings)
    lmps.quick_md(s, **nvt_settings)
    lmps.quick_md(s, **npt_settings)

    s.write_xyz('mixture.xyz')
    s.write_yaml('mixture.yaml')
    s.write_lammps('mixture.lmps')
    s.write_chemdoodle_json('mixture.json')
示例#12
0
from pysimm import system, lmps, forcefield
from pysimm.apps.random_walk import copolymer

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
pe = system.read_pubchem_smiles('cc')

# 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
pe.particles[1].linker = 'head'
pe.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
pe.apply_forcefield(f, charges='gasteiger')

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

# write a yaml file for the pe monomer
pe.write_yaml('pe_monomer.yaml')

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
ps = system.read_pubchem_smiles('cc(C1=CC=CC=C1)')

# particles 8 and 7 in the monomer are going to be the head and tail linkers
ps.particles[8].linker = 'head'
ps.particles[7].linker = 'tail'

# like in example 3, we need to identify the bonds in the ring as aromatic
示例#13
0
        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.smiles:
        s = system.read_pubchem_smiles(args.smiles)
    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])
    elif args.lmps2cdjson:
        s = system.read_lammps(args.lmps2cdjson[0])
        s.write_chemdoodle_json(args.lmps2cdjson[1])

    if args.unwrap:
        try:
            print(
示例#14
0
from pysimm import system, lmps, forcefield
from pysimm.apps.random_walk import random_walk

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
s = system.read_pubchem_smiles('cc')

# 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
示例#15
0
from pysimm import system, lmps, forcefield

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
s = system.read_pubchem_smiles('c1=cc=cc=c1')

# the resulting system (benzene) has alternating double bonds
# we want pysimm to recognize the ring as aromatic, so we define each bond in the ring to be bond order 'A'
for b in s.bonds:
    if b.a.elem == 'C' and b.b.elem == 'C':
        b.order = 'A'

# the resulting system has sufficient information to type with a forcefield, here we will use the GAFF2 force field
# we will also determine partial charges using the gasteiger algorithm
s.apply_forcefield(forcefield.Gaff2(), charges='gasteiger')

# we'll perform energy minimization using the fire algorithm in LAMMPS
lmps.quick_min(s, min_style='fire')

# write a few different file formats
s.write_xyz('benzene.xyz')
s.write_yaml('benzene.yaml')
s.write_lammps('benzene.lmps')
s.write_chemdoodle_json('benzene.json')
示例#16
0
from pysimm import system, lmps, forcefield
from pysimm.apps.random_walk import random_walk

# use a smiles string to query the pubchem search database and read the mol file returned from the http request
pmma = system.read_pubchem_smiles('cc(C)(C(=O)OC)')

# 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