示例#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)
示例#2
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)
示例#3
0
def test_read():
    file_path = get_current_module_path(__file__,
                                        "../../../test_data/test_Source.hdf5")
    if not os.path.isfile(file_path):  # pragma: no cover
        pytest.skip("File does not exist: {}".format(file_path))

    hdf5_file = read(file_path)
    source = Source()
    source.read(hdf5_file)
    _compare_values(source)
def test_read_version_0_1_0():
    file_path = get_current_module_path(
        __file__, "../../test_data/simple_simulation_v0.1.0.hdf5")
    if not os.path.isfile(file_path):  # pragma: no cover
        pytest.skip("File does not exist: {}".format(file_path))

    simulation = Simulation(file_path, None)
    simulation.version = ""

    simulation.read()
    assert simulation.version == "0.1.0"
示例#5
0
def test_read():
    file_path = get_current_module_path(
        __file__, "../../../test_data/test_Element.hdf5")
    if not os.path.isfile(file_path):  # pragma: no cover
        pytest.skip("File does not exist: {}".format(file_path))

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

    assert element != get_vacuum_element()
    assert element == get_silicon_element()
示例#6
0
def test_read():
    file_path = get_current_module_path(
        __file__, "../../../test_data/test_Material.hdf5")
    if not os.path.isfile(file_path):  # pragma: no cover
        pytest.skip("File does not exist: {}".format(file_path))

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

    assert material != get_vacuum_material()
    assert material == get_silicon_material()
示例#7
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)
示例#8
0
def test_point_read():
    file_path = get_current_module_path(__file__, "../../test_data/test_Point.hdf5")
    if not os.path.isfile(file_path):  # pragma: no cover
        pytest.skip("File does not exist: {}".format(file_path))

    hdf5_file = read(file_path)
    point = Point(0, 0, 0)
    assert point.x != 1
    assert point.y != 2
    assert point.z != 3

    point.read(hdf5_file)
    assert point.x == 1
    assert point.y == 2
    assert point.z == 3
示例#9
0
def test_get_current_module_path_invalid_file():
    path = get_current_module_path(__file__, 'bad_file.bad')
    assert not os.path.isdir(path)
    assert not os.path.isfile(path)
    assert not os.path.exists(path)
示例#10
0
def test_get_current_module_path():
    path = get_current_module_path(__file__)
    assert os.path.isdir(path)
示例#11
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)
示例#12
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Standard library modules.

# Third party modules.

# Local modules.

# Project modules.
from trim.montecarlo.simulation import Simulation
from trim.montecarlo import get_current_module_path

# Globals and constants variables.


if __name__ == '__main__':  # pragma: no cover
    input_file_path = get_current_module_path(__file__, "simple_simulation.hdf5")

    simulation = Simulation(input_file_path, None)
    simulation.write()