Example #1
0
    def test_GIVEN_unpolarised_mode_and_beamline_parameters_are_set_WHEN_move_THEN_components_move_onto_beam_line(self):
        slit2 = Component("s2", LinearMovement(0, z_position=10, angle=90))
        ideal_sample_point = ReflectingComponent("ideal_sample_point", LinearMovement(0, z_position=20, angle=90))
        detector = Component("detector", LinearMovement(0, z_position=30, angle=90))
        components = [slit2, ideal_sample_point, detector]

        parameters = [
            TrackingPosition("slit2height", slit2),
            TrackingPosition("height", ideal_sample_point),
            Theta("theta", ideal_sample_point),
            TrackingPosition("detectorheight", detector)]
                      #parameters["detectorAngle": TrackingAngle(detector)
        beam = PositionAndAngle(0, 0, -45)
        beamline = Beamline(components, parameters, [], [DataMother.BEAMLINE_MODE_NEUTRON_REFLECTION])
        beamline.set_incoming_beam(beam)
        beamline.active_mode = DataMother.BEAMLINE_MODE_NEUTRON_REFLECTION
        beamline.parameter("theta").sp_no_move = 45
        beamline.parameter("height").sp_no_move = 0
        beamline.parameter("slit2height").sp_no_move = 0
        beamline.parameter("detectorheight").sp_no_move = 0

        beamline.move = 1

        assert_that(slit2.sp_position(), is_(position(Position(-10, 10))))
        assert_that(ideal_sample_point.sp_position(), is_(position(Position(-20, 20))))
        assert_that(detector.sp_position(), is_(position(Position(-10, 30))))
Example #2
0
    def test_GIVEN_movement_45_to_z_at_beam_angle_along_z_WHEN_get_intercept_THEN_position_is_initial_position(
            self, angle):
        y = 0
        z = 10
        movement = LinearMovement(y, z, 45)
        beam = PositionAndAngle(0, 0, angle)

        result = movement.calculate_interception(beam)

        assert_that(result, is_(position(Position(y, z))))
Example #3
0
    def test_GIVEN_movement_perpendicular_to_z_at_beam_angle_0_WHEN_get_intercept_THEN_position_is_initial_position(
            self):
        y = 0
        z = 10
        movement = LinearMovement(y, z, 90)
        beam = PositionAndAngle(0, 0, 0)

        result = movement.calculate_interception(beam)

        assert_that(result, is_(position(Position(y, z))))
Example #4
0
    def test_GIVEN_movement_anti_perpendicular_to_z_at_beam_angle_10_WHEN_get_intercept_THEN_position_is_z_as_initial_y_as_right_angle_triangle(
            self):
        y = 0
        z = 10
        beam_angle = 10
        movement = LinearMovement(y, z, -90)
        beam = PositionAndAngle(0, 0, beam_angle)
        expected_y = z * tan(radians(beam_angle))

        result = movement.calculate_interception(beam)

        assert_that(result, is_(position(Position(expected_y, z))))
Example #5
0
    def test_GIVEN_movement_along_z_WHEN_set_position_relative_to_beam_to_10_THEN_position_is_at_10_along_intercept(
            self):
        movement = LinearMovement(0, 10, 0)
        beam_intercept = Position(0, 10)
        dist = 10

        movement.set_position_relative_to_beam(beam_intercept, dist)
        result = movement.sp_position()

        assert_that(
            result,
            is_(position(Position(beam_intercept.y, beam_intercept.z + dist))))
Example #6
0
    def test_GIVEN_movement_0_to_z_and_beam_angle_45_WHEN_get_intercept_THEN_position_is_on_movement_axis(
            self):
        y = 20
        z = 10
        movement = LinearMovement(y, z, 0)
        beam = PositionAndAngle(0, 0, 45)
        expected_y = y
        expected_z = y

        result = movement.calculate_interception(beam)

        assert_that(result, is_(position(Position(expected_y, expected_z))))
Example #7
0
    def test_GIVEN_jaw_at_10_input_beam_is_at_0_deg_and_z0_y0_WHEN_get_position_THEN_z_is_jaw_position_y_is_0(
            self):
        jaws_z_position = 10
        beam_start = PositionAndAngle(y=0, z=0, angle=0)
        expected_position = Position(y=0, z=jaws_z_position)
        jaws = Component("component",
                         movement_strategy=LinearMovement(
                             0, jaws_z_position, 90))
        jaws.set_incoming_beam(beam_start)

        result = jaws.calculate_beam_interception()

        assert_that(result, is_(position(expected_position)))
Example #8
0
    def test_GIVEN_movement_20_to_z_and_beam_angle_45_WHEN_get_intercept_THEN_position_is_on_movement_axis(
            self):
        beam = PositionAndAngle(0, 0, 45)
        expected_y = 4
        expected_z = 4

        move_angle = 20
        move_z = 2
        move_y = expected_y - (expected_z - move_z) * tan(radians(move_angle))
        movement = LinearMovement(move_y, move_z, move_angle)

        result = movement.calculate_interception(beam)

        assert_that(result, is_(position(Position(expected_y, expected_z))))
Example #9
0
    def test_GIVEN_jaw_at_10_input_beam_is_at_60_deg_and_z5_y30_WHEN_get_position_THEN_z_is_jaw_position_y_is_at_tan_minus_60_times_distance_between_input_beam_and_component_plus_original_beam_y(
            self):
        distance_between = 5.0
        start_z = 5.0
        start_y = 30
        beam_angle = 60.0
        jaws_z_position = distance_between + start_z
        beam_start = PositionAndAngle(y=start_y, z=start_z, angle=beam_angle)
        expected_position = Position(
            y=tan(radians(beam_angle)) * distance_between + start_y,
            z=jaws_z_position)
        jaws = Component("component",
                         movement_strategy=LinearMovement(
                             0, jaws_z_position, 90))
        jaws.set_incoming_beam(beam_start)

        result = jaws.calculate_beam_interception()

        assert_that(result, is_(position(expected_position)))