Ejemplo n.º 1
0
 def fromfile(cls, filename):
     cbuffer = CBuffer.fromfile(filename)
     return cls(cbuffer=cbuffer)
Ejemplo n.º 2
0
 def fromfile(cls, filename):
     cbuffer = CBuffer.fromfile(filename)
     return cls(cbuffer=cbuffer)
Ejemplo n.º 3
0
        raise SystemExit("support for cuda required for this test")

    path_to_testdir = testlib.config.PATH_TO_TESTDATA_DIR
    assert path_to_testdir is not None
    assert os.path.exists(path_to_testdir)
    assert os.path.isdir(path_to_testdir)

    path_to_particle_data = os.path.join(
        path_to_testdir, "beambeam", "particles_dump.bin")
    assert os.path.exists(path_to_particle_data)

    path_to_beam_elements_data = os.path.join(
        path_to_testdir, "beambeam", "beam_elements.bin")
    assert os.path.exists(path_to_beam_elements_data)

    pb = CBuffer.fromfile(path_to_particle_data)
    initial_particles = pb.get_object(0, cls=pyst.Particles)

    track_pb = CBuffer()
    particles = pyst.makeCopy(initial_particles, cbuffer=track_pb)

    eb = CBuffer.fromfile(path_to_beam_elements_data)
    num_beam_elements = eb.n_objects

    ctx = st.st_CudaContext_create()
    assert ctx != st.st_NullCudaContext

    lattice = st.st_Buffer_new_mapped_on_cbuffer(eb)
    assert lattice != st.st_NullBuffer

    lattice_arg = st.st_CudaArgument_new(ctx)
Ejemplo n.º 4
0
if __name__ == '__main__':
    path_to_testdir = testlib.config.PATH_TO_TESTDATA_DIR
    assert path_to_testdir is not None
    assert os.path.exists(path_to_testdir)
    assert os.path.isdir(path_to_testdir)

    path_to_particle_data = os.path.join(path_to_testdir, "beambeam",
                                         "particles_dump.bin")
    assert os.path.exists(path_to_particle_data)

    path_to_beam_elements_data = os.path.join(path_to_testdir, "beambeam",
                                              "beam_elements.bin")
    assert os.path.exists(path_to_beam_elements_data)

    pb = CBuffer.fromfile(path_to_particle_data)

    num_elem_by_elem_turns = 1
    eb = CBuffer.fromfile(path_to_beam_elements_data)

    until_turn_elem_by_elem = 1
    until_turn_turn_by_turn = 5
    until_turn = 100
    skip_turns = 10

    # ------------------------------------------------------------------------
    initial_num_beam_elements = eb.n_objects

    num_beam_monitors = st.beam_elements.append_beam_monitors_to_lattice(
        eb, until_turn_elem_by_elem, until_turn_turn_by_turn, until_turn,
        skip_turns)
Ejemplo n.º 5
0
obj=MyObj()
print(obj)
obj._buffer.info()

obj.a=2
obj.b=3.5
obj.c[2]=1.5
obj.d=2
obj.e=[3,4]
print(obj)

b=CBuffer()
obj1=MyObj(cbuffer=b)
b.check_pointers()
obj2=MyObj(cbuffer=b)
b.check_pointers()
obj2.e=[3,4]
print(obj1)
print(obj2)

b.tofile('test.np')
import numpy as np
data=np.fromfile('test.np',dtype='uint64')
print(data)
c=CBuffer.fromfile('test.np')
obj0=c.get_object(MyObj,0)

ffi,lib,cobj=obj1._cdebug()
#c=CBuffer.from_file('test_buffer_common.bin')
Ejemplo n.º 6
0
        path_to_testdir, "beambeam", "particles_dump.bin")
    assert(os.path.exists(path_to_particle_data))

    pb = st.st_Buffer_new_from_file(path_to_particle_data.encode('utf-8'))
    assert(pb != st.st_NullBuffer)
    num_particle_sets = st.st_Particles_buffer_get_num_of_particle_blocks(pb)
    assert(num_particle_sets > 0)
    total_num_particles = st.st_Particles_buffer_get_total_num_of_particles(pb)
    assert(total_num_particles > num_particle_sets)
    particles = st.st_Particles_buffer_get_particles(pb, 0)
    assert(particles != st.st_NullParticles)
    num_particles = st.st_Particles_get_num_of_particles(particles)
    assert(num_particles > 0)

    # Load the same data file into a CBuffer instance
    cobj_pb = CBuffer.fromfile(path_to_particle_data)
    assert(cobj_pb.n_objects > 0)
    assert(cobj_pb.n_objects == num_particle_sets)
    cmp_particles = cobj_pb.get_object(0, cls=pyst.Particles)
    cmp_num_particles = cmp_particles.num_particles
    assert(cmp_particles.num_particles == num_particles)

    # Provide a buffer for calculating the difference
    diff_buffer = st.st_Buffer_new(0)
    assert(diff_buffer != st.st_NullBuffer)

    diff = st.st_Particles_new(diff_buffer, num_particles)
    assert(diff != st.st_NullParticles)
    assert(num_particles == st.st_Particles_get_num_of_particles(diff))

    # Calculate the difference between the particles stored on the NS(Buffer)