Exemplo n.º 1
0
def create_source_file():
    source = get_silicon_element()

    input_file_path = get_current_module_path(
        __file__, "../test_data/test_Element.hdf5")
    hdf5_file = write(input_file_path)

    source.write(hdf5_file)
Exemplo n.º 2
0
    def write(self):
        hdf5_file = write(self.input_file_path)

        group = hdf5_file.require_group(GROUP_SIMULATION)
        group.attrs[ATTRIBUTE_VERSION] = self.version

        self.options.write(group)
        self.results.write(group)
Exemplo n.º 3
0
def create_source_file():
    material = get_silicon_material()

    input_file_path = get_current_module_path(
        __file__, "../test_data/test_Material.hdf5")
    hdf5_file = write(input_file_path)

    material.write(hdf5_file)
Exemplo n.º 4
0
def create_source_file():
    source = Source()
    source.position_nm = Point(-1, -2, -3)
    source.direction = Point(0.2, 0.4, 0.6)
    source.kinetic_energy_keV = 53.1156
    source.mass_amu = 68.93
    source.atomic_number = 31

    input_file_path = get_current_module_path(__file__,
                                              "../test_data/test_Source.hdf5")
    hdf5_file = write(input_file_path)

    source.write(hdf5_file)
Exemplo n.º 5
0
def test_write(tmpdir):
    file_path = tmpdir.join("output.hdf5")
    point = Point(-1, -2, -3)

    hdf5_file = write(file_path)
    point.write(hdf5_file)
    hdf5_file.close()

    point = Point(1, 2, 3)
    hdf5_file = read(file_path)
    point.read(hdf5_file)
    assert point.x == -1
    assert point.y == -2
    assert point.z == -3
Exemplo n.º 6
0
def test_write(tmpdir):
    file_path = tmpdir.join("output.hdf5")

    element = get_silicon_element()

    hdf5_file = write(file_path)
    element.write(hdf5_file)
    hdf5_file.close()

    element = Element()
    hdf5_file = read(file_path)
    element.read(hdf5_file)

    assert element != get_vacuum_element()
    assert element == get_silicon_element()
Exemplo n.º 7
0
def test_write(tmpdir):
    file_path = tmpdir.join("output.hdf5")

    material = get_silicon_material()

    hdf5_file = write(file_path)
    material.write(hdf5_file)
    hdf5_file.close()

    material = Material()
    hdf5_file = read(file_path)
    material.read(hdf5_file)

    assert material != get_vacuum_material()
    material_si = get_silicon_material()
    assert material == material_si
Exemplo n.º 8
0
def test_write_read(tmpdir):
    file_path = tmpdir.join("output.hdf5")

    hdf5_file = write(file_path)
    assert hdf5_file.filename == file_path
    assert hdf5_file.mode == "r+"
    assert hdf5_file.driver == "core"
    assert hdf5_file.userblock_size == 0

    hdf5_file.close()

    hdf5_file = read(file_path)
    assert hdf5_file.filename == file_path
    assert hdf5_file.mode == "r"
    assert hdf5_file.driver == "core"
    assert hdf5_file.userblock_size == 0
Exemplo n.º 9
0
def test_write(tmpdir):
    file_path = tmpdir.join("output.hdf5")

    source = Source()
    source.position_nm = Point(-1, -2, -3)
    source.direction = Point(0.2, 0.4, 0.6)
    source.kinetic_energy_keV = 53.1156
    source.mass_amu = 68.93
    source.atomic_number = 31

    hdf5_file = write(file_path)
    source.write(hdf5_file)
    hdf5_file.close()

    source = Source()
    hdf5_file = read(file_path)
    source.read(hdf5_file)
    _compare_values(source)
Exemplo n.º 10
0
def create_point_file():
    input_file_path = get_current_module_path(__file__, "test_Point.hdf5")
    hdf5_file = write(input_file_path)

    point = Point(1, 2, 3)
    point.write(hdf5_file)