def run(test=False): logFileName = 'steps.log' # use an import from .yaml to get of previously created pmma-based 4-chain polymer structure polymer = system.read_yaml(os.path.join(os.path.dirname(os.path.realpath(__file__)), "polymer.yaml")) polymer.forcefield = 'dreiding' # Initialize the wrapper object around the polymer that will organize the work with LAMMPS print('Creating Simulation object with log-file in "{0:s}"\n'.format(logFileName)) sim = lmps.Simulation(polymer, log= 'steps.log') # setting up the parameters for the energy optimization # add_min() method will add the "Minimization" task to the task que of the # Simulation object that is stored in sim.sim list print('Creating and running energy-minimization task:') sim.add_min(min_style = 'fire', name = 'min_fire', etol = 1.0e-5, ftol = 1.0e-5) print('Creating and running molecular dynamics task:') # Let's set up the Molecular dynamics task sim.add_md(ensemble='nvt', timestep=0.5) print('List of simulation tasks ready to run:') print(sim.sim) print('Input that will be passed to LAMMPS when the simulation is performed:') sim.write_input() print(sim.input) # call run to run the simulation sim.run()
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')
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]) elif args.lmps2cdjson: s = system.read_lammps(args.lmps2cdjson[0]) s.write_chemdoodle_json(args.lmps2cdjson[1]) if args.unwrap: try: print(