Пример #1
0
 def test_get_special_MFP(self, create_shield):
     start = [0, 0, 0]
     end = [100, 0, 0]
     aRay = ray.FiniteLengthRay(start, end)
     mfp = create_shield.get_crossing_mfp(aRay, 1)
     # data extracted from materialLibrary.yml for iron at 1 MeV
     xsec = 5.957E-02
     density = 7.874
     calculated_mfp = xsec * density * 10  # 10 cm width of shield
     assert mfp == pytest.approx(calculated_mfp)
Пример #2
0
def test_ray_unit_vector():
    start = [1, 1, 1]
    end = [2, 2, 2]
    aaa = ray.FiniteLengthRay(start, end)
    part = 1. / math.sqrt(3.)
    # the following creates a vector of numerical tests and then
    # checks to ensure they all came back true
    assert (aaa.dir == np.array([part, part, part])).all
    assert (aaa.invdir == np.array([1 / part, 1 / part, 1 / part])).all
    assert (aaa.sign == np.array([False, False, False])).all
Пример #3
0
 def test_crossing_length5(self, create_shield):
     # and back again
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([0, 0, 60], [0, 0, -60]))
     assert length == 100
Пример #4
0
 def test_crossing_length8(self, create_shield):
     # outside to inside wall
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([-20, 0, 0], [-5, 0, 0]))
     assert length == 5
Пример #5
0
 def test_crossing_length7(self, create_shield):
     # ray contained entirely within the slab
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([11, 11, 11], [16, 16, 16]))
     assert length == pytest.approx(math.sqrt(25 * 3))
Пример #6
0
 def test_crossing_length4(self, create_shield):
     # two rays that start inside the box and traverse outwards
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([2, 3, 3], [20, 3, 3]))
     assert length == 3
Пример #7
0
 def test_crossing_length3(self, create_shield):
     # ray misses the slab
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([30, 0, 0], [30, 0, 30]))
     assert length == 0
Пример #8
0
 def test_crossing_length5(self, create_shield):
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([30, 30, 30], [15, 15, 15]))
     assert length == pytest.approx(17.320508 / 2)
Пример #9
0
 def test_crossing_length4(self, create_shield):
     # completely inside annulus (miss)
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([1, 0, -60], [1.5, 0, 60]))
     assert length == 0
Пример #10
0
 def test_crossing_length11(self, create_shield):
     # and back again
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([1, 1, 45], [1, 1, 55]))
     assert length == 5
Пример #11
0
 def create_ray(self):
     start = [0, 0, 0]
     end = [30, 30, 30]
     aRay = ray.FiniteLengthRay(start, end)
     return aRay
Пример #12
0
 def test_crossing_length1(self, create_shield):
     # completely inside annulus
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([2.5, 0, -8], [3.5, 0, 8]))
     assert length == math.sqrt(1 + 16**2)
Пример #13
0
 def test_crossing_length7(self, create_shield):
     # ray contained entirely within the box
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([2, 3, 3], [-3, 3, 3]))
     assert length == 5
Пример #14
0
 def test_crossing_length6(self, create_shield):
     # ray start outside the box and ends inside the box
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([20, 3, 3], [2, 3, 3]))
     assert length == 3
Пример #15
0
 def test_crossing_length5(self, create_shield):
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([2, 3, 3], [-20, 3, 3]))
     assert length == 7
Пример #16
0
 def test_crossing_length9(self, create_shield):
     # and back again
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([-5, 0, 0], [-20, 0, 0]))
     assert length == 5
Пример #17
0
 def test_crossing_length10(self, create_shield):
     # center to inside annulus
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([1, 0, 55], [2.5, 0, 55]))
     assert length == 0.5
Пример #18
0
 def test_crossing_length10(self, create_shield):
     # outside to inside cap
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([1, 1, 55], [1, 1, 45]))
     assert length == 5
Пример #19
0
 def test_crossing_length0(self, create_shield):
     # complete miss
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([15, 0, -60], [15, 0, 60]))
     assert length == 0
Пример #20
0
 def test_crossing_length(self, create_shield):
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([2, 2, -60], [2, 2, 60]))
     assert length == 100
Пример #21
0
 def test_crossing_length1(self, create_shield):
     # completely inside
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([0, 0, -8], [0, 0, 8]))
     assert length == 16
Пример #22
0
 def test_crossing_length4(self, create_shield):
     # two rays that start inside the slab and traverse outwards
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([15, 15, 15], [30, 30, 30]))
     assert length == pytest.approx(17.320508 / 2)
Пример #23
0
def test_ray_length():
    start = [1, 1, 1]
    end = [2, 2, 2]
    aaa = ray.FiniteLengthRay(start, end)
    assert (aaa.origin == np.array(start)).all
    assert aaa.length == pytest.approx(math.sqrt(3.))
Пример #24
0
 def test_crossing_length6(self, create_shield):
     # ray start outside the slab and ends inside the slab
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([0, 0, 0], [15, 15, 15]))
     assert length == pytest.approx(17.320508 / 2)
Пример #25
0
 def test_crossing_length1(self, create_shield):
     # basic ray crossing
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([-10, 3, 3], [20, 3, 3]))
     assert length == 10
Пример #26
0
 def test_crossing_length2(self, create_shield):
     # side-to-side
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([-20, 0, 0], [20, 0, 0]))
     assert length == 20
Пример #27
0
 def test_crossing_length2(self, create_shield):
     # try reversing the direction
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([20, 3, 3], [-10, 3, 3]))
     assert length == 10
Пример #28
0
 def test_crossing_length4(self, create_shield):
     # end-to-end
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([0, 0, -60], [0, 0, 60]))
     assert length == 100
Пример #29
0
 def test_crossing_length0(self, create_shield):
     # test a pure diagonal crossing
     length = create_shield._get_crossing_length(
         ray.FiniteLengthRay([-5, -5, -5], [15, 15, 15]))
     assert length == math.sqrt(3 * (10**2))