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
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
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')
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')
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.Dreiding() 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' lmps.quick_min(s, min_style='fire') s.add_particle_bonding() return s
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')
def run(test=False): # we'll make a vinyl-type polynorbornene monomer from the pysimm models database A = NbTMS(isomer="exo_exo") setattr(A.particles[1], 'rnd_wlk_tag', 'tail_cap') setattr(A.particles[49], 'rnd_wlk_tag', 'head_cap') # 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 A.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 A.pair_style = 'lj/cut' # run the polymer random walk tacticity method with 10 total repeat units, all isotactic insertions, no minimizations polymer = random_walk_tacticity(A, 10, forcefield=f, capped=True, tacticity='isotactic', sim='no', rotation=180) write_file_formats(polymer, "isotactic_PNB_nosim10") # run the polymer random walk tacticity method with 10 total repeat units, all syndiotactic insertions, no minimizations polymer = random_walk_tacticity(A, 10, forcefield=f, capped=True, tacticity='syndiotactic', sim='no', rotation=180) write_file_formats(polymer, "syndiotactic_PNB_nosim10") # run the polymer random walk tacticity method with 50 total repeat units with minimizations and error # checking (when a hardcore overlap is found, the last inserted monomer shrunken and gradually re-expanded) polymer = random_walk_tacticity(A, 50, forcefield=f, capped=True, tacticity='syndiotactic', error_check=True, rotation=180, md_spacing=1) write_file_formats(polymer, "syndiotactic_PNB_sim50") # pack and equilibrate eight 20mers of exo_exo and exo_endo isomers to compare densities pack_and_equil(A, 20, 8, f, "exo") A = NbTMS(isomer="exo_endo") A.apply_charges(f, charges='gasteiger') A.pair_style = 'lj/cut' pack_and_equil(A, 20, 8, f, "endo")
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
def run(test=False): # we'll take a polystyrene monomer from the pysimm models database monomer = ps(is_capped=True) # we'll decorate atoms of PS monomer with tags that are needed for more elaborate polymerisation # procedure that takes into account tacticity setattr(monomer.particles[9], 'linker', 'mirror') setattr(monomer.particles[9], 'rnd_wlk_tag', 'head_cap') setattr(monomer.particles[13], 'rnd_wlk_tag', 'tail_cap') # 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 monomer.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 monomer.pair_style = 'lj/cut' # run the polymer random walk tacticity method with 10 total repeat units polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity='isotactic', sim='no') # write a few different file formats polymer.write_xyz('isotactic.xyz') polymer.write_yaml('isotactic.yaml') polymer.write_lammps('isotactic.lmps') polymer.write_chemdoodle_json('isotactic.json') # run the polymer random walk tacticity method with 10 total repeat units polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity='syndiotactic', sim='no') # write a few different file formats polymer.write_xyz('syndiotactic.xyz') polymer.write_yaml('syndiotactic.yaml') polymer.write_lammps('syndiotactic.lmps') polymer.write_chemdoodle_json('syndiotactic.json') # run the polymer random walk tacticity method with 10 total repeat units polymer = random_walk_tacticity(monomer, 10, forcefield=f, tacticity=0.2, sim='no') # write a few different file formats polymer.write_xyz('iso_20_syndio_80.xyz') polymer.write_yaml('iso_20_syndio_80.yaml') polymer.write_lammps('iso_20_syndio_80.lmps') polymer.write_chemdoodle_json('iso_20_syndio_80.json')
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.Dreiding() 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
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.Dreiding() 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
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
def monomer(**kwargs): isomer = kwargs.get('isomer', {}) try: import os if isomer == 'endo': s = system.read_mol( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'NbTMS_H2_endo.mol')) elif isomer == 'exo_endo': s = system.read_mol( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'NbTMS_H2_exo_endo.mol')) else: s = system.read_mol( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'NbTMS_H2_exo_exo.mol')) except: print("!!!could not read mol!!!") raise f = forcefield.Dreiding() for b in s.bonds: if b.a.bonds.count == 3 and b.b.bonds.count == 3: b.order = 4 s.apply_forcefield(f) h = s.particles[7] t = s.particles[8] m = s.particles[32] s.remove_spare_bonding() s.set_box(padding=10) h.linker = 'head' t.linker = 'tail' m.linker = 'mirror' # lmps.quick_min(s, min_style='fire') s.add_particle_bonding() return s
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.Dreiding() 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
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)
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')
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'))
elem=elem, type_name=ptype, x=float(x), y=float(y), z=float(z), bonds=bonds) s.particles.add(p) for p in s.particles: for pb in p.bonds: if p.tag < pb: s.bonds.add(system.Bond(a=p, b=s.particles[pb])) s.add_particle_bonding() # Assign Dreiding forcefield parameters to the atoms of the structure f = forcefield.Dreiding() o_3 = s.particle_types.add(f.particle_types.get('O_3')[0].copy()) o_r = s.particle_types.add(f.particle_types.get('O_R')[0].copy()) c_r = s.particle_types.add(f.particle_types.get('C_R')[0].copy()) zn = s.particle_types.add(f.particle_types.get('Zn')[0].copy()) h_ = s.particle_types.add(f.particle_types.get('H_')[0].copy()) for p in s.particles: if p.elem == 'O': if p.bonds.count == 4: p.type = o_3 else: p.type = o_r if p.elem == 'C': p.type = c_r if p.elem == 'Zn': p.type = zn
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() # 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') 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' ######## 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 = 100000 # Number of Water Molecules Try to keep it at 10,000 for your 10mers 100,000 for 100mers ##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')
def run(test=False): # we'll make a polystyrene monomer from the pysimm models database A = NbTMS(isomer="exoexo") # 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 A.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 A.pair_style = 'lj/cut' # run the polymer random walk tacticity method with 10 total repeat units polymer = random_walk_tacticity(A, 20, forcefield=f, capped=True, tacticity='syndiotactic', rotation=180, errorCheck=False, sim=0) writeFileFormats(polymer, "polymer", unwrap=True) #quick opt of polymer lmps.quick_min(polymer, min_style='fire', etol=1.0e-4, maxiter=100000) # write a few different file formats polymer.unwrap() writeFileFormats(polymer, "polymer_fired") #pack multiple copies of polymer polymers = system.replicate(polymer, 8, density=0.005) #polymers = polymer writeFileFormats(polymers, "polymers") lmps.quick_min(polymers, min_style='fire', etol=1.0e-4, maxiter=100000) writeFileFormats(polymers, "polymers_fired") #quickmd 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' } #nvt runs okay, but npt fails...need to add neigh_modify command to reneighbor more often during compression of npt step #lmps.quick_md(polymers, debug=True, **nvt_settings) #writeFileFormats(polymers,"polymers_nvt") #lmps.quick_md(polymers, debug=True, **npt_settings) #lmps.quick_md(polymers) #writeFileFormats(polymers,"polymers_npt") sim = lmps.Simulation(polymers, name='nptAndReneighbor', debug=True) sim.add_custom('neigh_modify delay 0') sim.add(lmps.Velocity(temperature=1000)) sim.add_md(length=10000, ensemble='npt', temperature=1000, pressure=5000) sim.run() writeFileFormats(polymers, "polymers_npt") writeFileFormats(polymers, "polymers_npt_unwrapped", unwrap=True) #21-step equilibration equil(polymers, np=1, pmax=50000) writeFileFormats(polymers, "polymers_equil") polymers.unwrap() writeFileFormats(polymers, "polymers_equil_unwrap")
print('\nWelcome to the pySIMM command line interface\n') print( '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')
def polymer_chain(length): mon = monomer() polym = random_walk(mon, length, forcefield=forcefield.Dreiding()) return polym
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 Dreiding parameters print('Example progress: Retrieving Dreiding force field parameters...') f = forcefield.Dreiding() s.forcefield = f.name # get a copy of the C_ particle type object from Dreiding # get method returns a list, we need the first element dreiding_C_ = s.particle_types.add(f.particle_types.get('C_3')[0].copy()) # get H_ particle type object from Dreiding dreiding_H_ = s.particle_types.add(f.particle_types.get('H_')[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=dreiding_C_, 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 Dreiding 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=dreiding_H_, charge=0, molecule=m), c1, f) h2 = s.add_particle_bonded_to( system.Particle(type=dreiding_H_, charge=0, molecule=m), c1, f) h3 = s.add_particle_bonded_to( system.Particle(type=dreiding_H_, charge=0, molecule=m), c1, f) h4 = s.add_particle_bonded_to( system.Particle(type=dreiding_H_, 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 = 'buck' 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!')