Exemplo n.º 1
0
import numpy as np
from h5md_module import File, element

import sys

with File(sys.argv[1], 'r') as f:
    all_particles = f.particles_group('all')

    for loc, name in (
        (f['observables'], 'v'),
        (all_particles, 'mass'),
        (all_particles['box'], 'edges'),
        (all_particles, 'id'),
        (all_particles, 'position'),
        (all_particles, 'force'),
        (all_particles, 'velocity'),
    ):
        if name not in loc:
            continue
        el = element(loc, name)
        print '---------------------------------------------------------------'
        print '%-10s ----------------------------------------------------' % name
        print el.element_type
        print el.value.shape, el.step, el.step_offset, el.time, el.time_offset, el.value
Exemplo n.º 2
0
import numpy as np
from h5md_module import File, element

N = 32
DT = 0.1

with File('example_for_1.1.h5', 'w',author='Pierre', creator='run.py') as f:

    f.observables = f.require_group('observables')
    f.connectivity = f.require_group('connectivity')
    v_e = element(f.observables, 'v', store='linear', data=1, step=10, step_offset=10, time=5., time_offset=5.)

    f.all = f.particles_group('all')

    f.all.create_box(dimension=3, boundary=['periodic']*3,
                     store='time', shape=(0,)+(3,), maxshape=(None,3), dtype=np.float64)

    pos = np.zeros((N, 3))
    pos_e = element(f.all, 'position', store='time', data=pos, step_from=f.all.box.edges)

    vel = np.random.random(pos.shape)-0.5
    vel_e = element(f.all, 'velocity', store='time', data=vel, time=5.)

    force = np.random.random(pos.shape)-0.5
    force_e = element(f.all, 'force', store='time', data=force, time=True)

    mass = np.ones((N,))*100.0
    element(f.all, 'mass', store='fixed', data=mass)

    charge = np.ones((N,))*5.
    element(f.all, 'charge', store='fixed', data=charge)
Exemplo n.º 3
0
    if rank==0:
        data = np.arange(N*size, dtype=int)
        np.random.shuffle(data)
        for i in range(1, size):
            comm.Send(data[i*N:(i+1)*N], dest=i, tag=11)
        local_ids = data[0:N]
    else:
        comm.Recv(local_ids, source=0, tag=11)


with File('parallel_example_for_1.1.h5', 'w',author='Pierre', creator='run.py',
          driver='mpio', comm=comm) as f:

    f.observables = f.require_group('observables')
    f.connectivity = f.require_group('connectivity')
    v_e = element(f.observables, 'v', store='linear', data=1, step=10, step_offset=10, time=5., time_offset=5.)

    f.all = f.particles_group('all')

    f.all.create_box(dimension=3, boundary=['periodic']*3,
                     store='time', shape=(0,)+(3,), maxshape=(None,3), dtype=np.float64)

    id_e = element(f.all, 'id', store='time', shape=(0, N*size,), dtype=int, maxshape=(None, N*size))

    pos = np.zeros((N, 3))
    pos_e = element(f.all, 'position', store='time', shape=(0, N*size, 3), maxshape=(None, N*size, 3), dtype=np.float64, step_from=f.all.box.edges)

    vel = np.random.random(pos.shape)-0.5
    vel_e = element(f.all, 'velocity', store='time', shape=(0, N*size, 3), maxshape=(None, N*size, 3), dtype=np.float64, time=5.)

    force = np.random.random(pos.shape)-0.5