コード例 #1
0
ファイル: run.py プロジェクト: yingli2009/pysimm
def run(test=False):
    # Setup the empty cubic box with
    bx_size = 60
    sst = system.System()
    sst.dim = system.Dimension(dx=bx_size,
                               dy=bx_size,
                               dz=bx_size,
                               center=[bx_size / 2, bx_size / 2, bx_size / 2])
    sst.forcefield = 'trappe/amber'

    molec = system.read_lammps('c2h4.lmps')
    molec.forcefield = 'trappe/amber'

    cs = cassandra.Cassandra(sst)
    npt_props = cs.read_input('props.inp')
    npt_props['Pressure_Info'] = 25  # Simulated pressure in bars
    npt_props['Start_Type'] = {'start_type': 'make_config', 'species': 300}
    npt_props['Run_Type'] = {'type': 'equilibration', 'steps': [1000, 100]}
    npt_props['Simulation_Length_Info'] = {'run': 10000}
    npt_props['Property_Info'] = {
        'prop1': 'energy_total',
        'prop2': 'volume',
        'prop3': 'mass_density'
    }

    cs.add_simulation('NPT',
                      species=molec,
                      is_rigid=True,
                      out_folder='results',
                      **npt_props)

    cs.run()

    lmps.check_lmps_attr(cs.system)
    cs.system.write_lammps('final_conf.lmps')
コード例 #2
0
 def make_system(self, text_output):
     sstm = system.System(ff_class='1')
     count = 0  # counter of the lines in the input file
     sys_idx = 0  # counter of the gas molecules to lookup
     while count < len(text_output) - 1:
         tmp = self.sst[sys_idx].copy()
         dictn = text_output[count:(len(tmp.particles) + count)]
         if self.__fit_atoms__(tmp, dictn):
             for p in tmp.particles:
                 vals = dictn[p.tag - 1].split()
                 # Read the coordinates from the text output of the CASSANDRA simulation
                 p.x, p.y, p.z = map(float, vals[1:4])
                 # Force velocities of the particles to be 0
                 p.vx, p.vy, p.vz = 0.0, 0.0, 0.0
                 p.molecule.syst_tag = 0
             if self.is_rigid[sys_idx]:
                 for p in tmp.particles:
                     p.is_rigid = True
             sstm.add(tmp)
             self.made_ins[sys_idx] += 1
             count += len(tmp.particles)
             sys_idx = 0
         else:
             sys_idx += 1
             if sys_idx >= len(self.sst):
                 self.logger.error(
                     'Wasn\'t able to read CASSANDRA .chk file. '
                     'Please check either MC-simulation provided to PySIMM or the CASSANDRA '
                     'checkpoint file ')
                 exit(1)
     sstm.update_tags()
     sstm.objectify()
     return sstm
コード例 #3
0
def run(test=False):
    # Setup the box with acetelene molecules on the regular grid
    sst = system.System()

    bx_size = 30
    sst.dim = system.Dimension(dx=bx_size,
                               dy=bx_size,
                               dz=bx_size,
                               center=[bx_size / 2, bx_size / 2, bx_size / 2])
    sst.forcefield = 'trappe/amber'

    molec = system.read_lammps('c2h4.lmps')
    molec.forcefield = 'trappe/amber'

    cs = cassandra.Cassandra(sst)
    nvt_props = cs.read_input('props.inp')

    nvt_props['Temperature_Info'] = 400
    nvt_props['Start_Type'] = {'start_type': 'make_config', 'species': 300}
    nvt_props['Simulation_Length_Info'] = {'run': 300000}
    nvt_props['Property_Info'] = {
        'prop1': 'energy_total',
        'prop2': 'pressure',
        'prop3': 'mass_density'
    }
    cs.add_nvt(species=molec, is_rigid=True, out_folder='results', **nvt_props)

    cs.run()

    lmps.check_lmps_attr(cs.system)
    cs.system.write_lammps('final_conf.lmps')
コード例 #4
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
コード例 #5
0
    def test_nonames_mc(self):
        sst = system.System()
        sst.dim = system.Dimension(dx=40, dy=40, dz=40, center=[0, 0, 0])
        sst.forcefield = 'trappe/amber'
        css = cassandra.Cassandra(sst)
        my_gcmc_props = css.read_input(osp.join(self.data_path, 'props.inp'))

        specie = system.read_lammps(osp.join(self.data_path, 'toluene_nonames.lmps'))
        specie.forcefield = 'trappe/amber'

        with pytest.raises(SystemExit) as err_back:
            css.add_gcmc(species=specie, is_rigid=True, max_ins=200,
                         chem_pot=-30.34, out_folder=self.data_path, **my_gcmc_props)
            assert err_back.type == SystemExit
コード例 #6
0
def run(test=False):
    # In order to run CASSANDRA GCMC one need to create the CASSANDRA object
    sst = system.System()
    sst.dim = system.Dimension(dx=40, dy=40, dz=45, center=[0, 0, 0])
    sst.forcefield = 'trappe/amber'
    lmps.check_lmps_attr(sst)

    css = cassandra.Cassandra(sst)

    # Read the CASSANDRA .inp parameters file -- common way to setup simulations.
    # Any of the read properties can be modified here afterwards
    my_gcmc_props = css.read_input('props.inp')

    # The prefix for the all files that will be created by this run
    my_gcmc_props['Run_Name'] = 'gas_adsorb'

    # Set the gas (gas system) to be purged in a box
    specie1 = system.read_lammps('co2.lmps')
    specie2 = system.read_lammps('ch4.lmps')
    specie3 = system.read_lammps('m-xylene.lmps')
    for s in [specie1, specie2, specie3]:
        s.forcefield = 'trappe/amber'

    css.add_gcmc(species=[specie1, specie2, specie3],
                 is_rigid=[True, False, True],
                 max_ins=[2000, 1000, 500],
                 chem_pot=[-27.34, -29.34, -24.59],
                 out_folder='gas_adsorb_results',
                 **my_gcmc_props)
    css.run()

    for pt in css.system.particle_types:
        pt.elem = pt.real_elem

    css.system.write_lammps('gas_adsorb.lmps')
    css.system.write_xyz('gas_adsorb.xyz')
コード例 #7
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(
コード例 #8
0
ファイル: run.py プロジェクト: polysimtools/pysimm
                             unwrap=True,
                             settings={
                                 'np': 6,
                                 'length': 25000,
                                 'min_style': 'cg',
                                 'etol': 1e-5,
                                 'ftol': 1e-5,
                                 'maxiter': int(1e+7),
                                 'maxeval': int(1e+7)
                             })
    chains.append(sngl_chain)
    # remove litter
    os.remove('polymer.xyz')
    os.remove('polymer.lmps')

pim1_ld = system.System()
for prp in [
        'ff_class', 'forcefield', 'pair_style', 'bond_style', 'angle_style',
        'dihedral_style', 'improper_style'
]:
    setattr(pim1_ld, prp, getattr(mono, prp))

pim1_ld.dim.dx = ld_box_size
pim1_ld.dim.dy = ld_box_size
pim1_ld.dim.dz = ld_box_size

for idx in range(10):
    tmp = chains[idx].copy()
    tmp.shift_particles(*displ[2 * idx])
    pim1_ld.add(tmp, change_dim=False)
コード例 #9
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!')
コード例 #10
0
from pysimm import system, cassandra
from collections import OrderedDict

# In order to run CASSANDRA GCMC one need to create the CASSANDRA object
sst = system.System()
sst.dim = system.Dimension(dx=45, dy=45, dz=45, center=[0, 0, 0])
css = cassandra.Cassandra(sst)

# Read the CASSANDRA .inp parameters file -- common way to setup simulations.
# Any of the read properties can be modified here afterwards
my_gcmc_props = css.read_input('props.inp')

# The prefix for the all files that will be created by this run
my_gcmc_props['Run_Name'] = 'gas_adsorb'

# Set the gas (gas system) to be purged in a box
specie1 = system.read_lammps('co2.lmps')
specie2 = system.read_lammps('ch4.lmps')
specie3 = system.read_lammps('m-xylene.lmps')

css.add_gcmc(species=[specie1, specie2, specie3],
             max_ins=[2000, 1000, 500],
             chem_pot=[-27.34, -29.34, -24.59],
             out_folder='gas_adsorb_results',
             **my_gcmc_props)
css.run()

for pt in css.final_sst.particle_types:
    pt.elem = pt.real_elem

css.final_sst.write_lammps('gas_adsorb.lmps')