Ejemplo n.º 1
0
 def setUpClass(cls):
     write_ordered = False
     from espressomd.io.writer import h5md
     h5_units = h5md.UnitSystem(time='ps', mass='u', length='m', charge='e')
     h5 = h5md.H5md(
         filename="test.h5",
         write_pos=True,
         write_vel=True,
         write_force=True,
         write_species=True,
         write_mass=True,
         write_charge=True,
         write_ordered=write_ordered,
         unit_system=h5_units)
     h5.write()
     h5.flush()
     h5.close()
     cls.py_file = h5py.File("test.h5", 'r')
     cls.py_pos = cls.py_file['particles/atoms/position/value'][0]
     cls.py_img = cls.py_file['particles/atoms/image/value'][0]
     cls.py_vel = cls.py_file['particles/atoms/velocity/value'][0]
     if espressomd.has_features(['ELECTROSTATICS']):
         cls.py_crg = cls.py_file['particles/atoms/charge/value'][0]
     cls.py_f = cls.py_file['particles/atoms/force/value'][0]
     cls.py_id = cls.py_file['particles/atoms/id/value'][0]
     cls.py_bonds = cls.py_file['connectivity/atoms']
Ejemplo n.º 2
0
system = espressomd.System(box_l=[100.0, 100.0, 100.0])

system.time_step = 0.01
system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)
system.cell_system.skin = 0.4

fene = interactions.FeneBond(k=10, d_r_max=2)
system.bonded_inter.add(fene)

positions = polymer.linear_polymer_positions(n_polymers=5,
                                             beads_per_chain=50,
                                             bond_length=1.0,
                                             seed=1234)
for polymer in positions:
    for i, pos in enumerate(polymer):
        id = len(system.part)
        system.part.add(id=id, pos=pos)
        if i > 0:
            system.part[id].add_bond((fene, id - 1))

h5_units = h5md.UnitSystem(time='ps', mass='u', length='nm', charge='e')
h5_file = h5md.H5md(file_path="sample.h5", unit_system=h5_units)

for i in range(2):
    h5_file.write()
    system.integrator.run(steps=10)

h5_file.flush()
h5_file.close()