예제 #1
0
    def trace_ideal_lens(self,beam1):

        beam=beam1.duplicate()


        t = self.p / beam.vy
        beam.x = beam.x + beam.vx * t
        beam.y = beam.y + beam.vy * t
        beam.z = beam.z + beam.vz * t

        gamma = np.arctan( beam.x/self.fx)
        alpha = np.arctan( -beam.z/self.fz)


        velocity = Vector(beam.vx, beam.vy, beam.vz)

        velocity.rotation(gamma, "z")
        velocity.rotation(alpha, "x")

        [beam.vx, beam.vy, beam.vz] = [velocity.x, velocity.y, velocity.z]


        #self.q=0
        t = self.q / beam.vy
        beam.x = beam.x + beam.vx * t
        beam.y = beam.y + beam.vy * t
        beam.z = beam.z + beam.vz * t

        beam.y *= 0.

        return beam
예제 #2
0
    def translation_to_the_optical_element(self, beam):
        vector_point=Vector(0,self.p,0)
        vector_point.rotation(self.alpha,"y")
        vector_point.rotation(-(np.pi/2-self.theta),"x")

        beam.x=beam.x-vector_point.x
        beam.y=beam.y-vector_point.y
        beam.z=beam.z-vector_point.z
예제 #3
0
 def test_rotation_1(self):
     print(">> test_rotation_1")
     theta=0*np.pi/180
     v = Vector(0,1,0)
     v.rotation(-(90*np.pi/180-theta),"x")
     print(v.info())
     assert_almost_equal ( v.x , 0.0 , 15)
     assert_almost_equal ( v.y , 0.0 , 15)
     assert_almost_equal ( v.z , -1.0 , 15)
예제 #4
0
 def test_rotation_3(self):
     print(">> test_rotation_3")
     alpha=90*np.pi/180
     v = Vector(0,1,0)
     v.rotation(alpha,"y")
     print(v.info())
     assert_almost_equal ( v.x , 0.0 , 15)
     assert_almost_equal ( v.y , 1.0 , 15)
     assert_almost_equal ( v.z , 0.0 , 15)
예제 #5
0
 def test_rotation_2(self):
     print(">> test_rotation_2")
     theta=45*np.pi/180
     v = Vector(0,1,0)
     v.rotation(-(90*np.pi/180-theta),"x")
     print(v.info())
     assert_almost_equal ( v.x , 0.0 , 15)
     assert_almost_equal ( v.y , 1/np.sqrt(2) , 15)
     assert_almost_equal ( v.z , -1/np.sqrt(2) , 15)
예제 #6
0
    def lens_output_direction(self,beam):

        gamma = np.arctan( beam.x/self.fx)
        alpha = np.arctan( -beam.y/self.fz)


        velocity = Vector(beam.vx, beam.vy, beam.vz)
        velocity.rotation(gamma, "y")
        velocity.rotation(alpha, "x")

        [beam.vx, beam.vy, beam.vz] = [velocity.x, velocity.y, velocity.z]
예제 #7
0
    def rotation(self, beam, angle, axis):
        velocity = Vector(beam.vx, beam.vy, beam.vz)
        position = Vector(beam.x, beam.y, beam.z)

        velocity.rotation(angle, axis)
        position.rotation(angle, axis)

        beam.x = position.x
        beam.y = position.y
        beam.z = position.z

        beam.vx = velocity.x
        beam.vy = velocity.y
        beam.vz = velocity.z
예제 #8
0
def tras_rot2(beam, p, theta):
    theta_grazing = np.pi / 2 - theta
    y = Vector(0., 1., 0.)
    y.rotation(-theta_grazing, 'x')
    x = Vector(1., 0., 0.)
    xp = x.vector_product(y)
    vrot = y.rodrigues_formula(xp, -theta_grazing)
    vrot.normalization()

    position = Vector(beam.x, beam.y, beam.z)
    velocity = Vector(beam.vx, beam.vy, beam.vz)
    position.rotation(-theta_grazing, 'x')
    velocity.rotation(-theta_grazing, 'x')
    #position = position.rodrigues_formula(xp, -theta_grazing)
    #velocity = velocity.rodrigues_formula(xp, -theta_grazing)
    velocity.normalization()
    beam.vx = velocity.x
    beam.vy = velocity.y
    beam.vz = velocity.z

    vector_point = Vector(0, p, 0)
    vector_point.rotation(-theta_grazing, "x")
    print(vector_point.info())
    #vector_point = vector_point.rodrigues_formula(xp, -theta_grazing)
    vector_point.normalization()

    beam.x = position.x - vector_point.x * p
    beam.y = position.y - vector_point.y * p
    beam.z = position.z - vector_point.z * p
예제 #9
0
    def test_rotation_10_array(self):
        print(">> test_rotation_10_array")
        theta = 45*np.pi/180
        alpha = 90*np.pi/180
        x=np.zeros(10)
        y=np.ones(10)
        z=np.zeros(10)
        v=Vector(x,y,z)
        v.rotation(alpha,"y")
        v.rotation(-(90*np.pi/180 - theta), "x")
        print (v.info())

        assert_almost_equal(v.x,np.zeros(10))
        assert_almost_equal(v.y,1/np.sqrt(2) *np.ones(10))
        assert_almost_equal(v.z,-1/np.sqrt(2)*np.ones(10))
예제 #10
0
    def rotation_to_the_optical_element(self, beam):

        position = Vector(beam.x,beam.y,beam.z)
        velocity = Vector(beam.vx,beam.vy,beam.vz)
        position.rotation(self.alpha,"y")
        position.rotation(-(np.pi/2-self.theta),"x")
        velocity.rotation(self.alpha,"y")
        velocity.rotation(-(np.pi/2-self.theta),"x")
        [beam.x,beam.y,beam.z] = [position.x,position.y,position.z]
        [beam.vx,beam.vy,beam.vz] = [velocity.x,velocity.y,velocity.z]
예제 #11
0
def tras_rot(beam, p):
    velocity = Vector(beam.vx, beam.vy, beam.vz)
    velocity.rotation(-gamma, 'z')
    velocity.rotation(-alpha, 'x')
    velocity.normalization()
    beam.vx = velocity.x
    beam.vy = velocity.y
    beam.vz = velocity.z

    position = Vector(beam.x, beam.y, beam.z)
    position.rotation(-gamma, 'z')
    position.rotation(-alpha, 'x')
    beam.x = position.x
    beam.y = position.y
    beam.z = position.z

    beam.x -= beam.vx[0] * p
    beam.y -= beam.vy[0] * p
    beam.z -= beam.vz[0] * p
예제 #12
0
    def rotation_to_the_screen(self,beam):

        position = Vector(beam.x,beam.y,beam.z)
        velocity = Vector(beam.vx,beam.vy,beam.vz)

        if self.type == "Ideal lens":
            position.rotation((np.pi/2-self.theta),"x")
            velocity.rotation((np.pi/2-self.theta),"x")
        else:
            position.rotation(-(np.pi/2-self.theta),"x")
            velocity.rotation(-(np.pi/2-self.theta),"x")
        [beam.x,beam.y,beam.z] = [position.x,position.y,position.z]
        [beam.vx,beam.vy,beam.vz] = [velocity.x,velocity.y,velocity.z]
예제 #13
0
def out(beam, q):
    print("\nOut")
    velocity = Vector(beam.vx, beam.vy, beam.vz)
    velocity.rotation(-alpha, 'x')
    print(velocity.x[0], velocity.y[0], velocity.z[0])
    velocity.rotation(-gamma, 'z')
    print(velocity.x[0], velocity.y[0], velocity.z[0])
    beam.vx = velocity.x
    beam.vy = velocity.y
    beam.vz = velocity.z

    position = Vector(beam.x, beam.y, beam.z)
    position.rotation(-alpha, 'x')
    position.rotation(-gamma, 'z')
    beam.x = position.x
    beam.y = position.y
    beam.z = position.z

    beam.retrace(q)
예제 #14
0
y = Vector(0., 1., 0.)
y.z = -np.tan(theta_grazing) / np.sqrt(1 + np.tan(theta_grazing)**2)
y.x = +np.tan(theta_grazing) / np.sqrt(1 + np.tan(theta_grazing)**2)
y.y = np.sqrt(1 - y.x**2 - y.z**2)

y.x = y.x
y.y = y.y
y.z = y.z
print(y.x, y.y, y.z)

print(
    np.arctan(y.x / np.sqrt(y.y**2 + y.z**2)) * 180 / np.pi - 90.,
    90. + np.arctan(y.z / np.sqrt(y.y**2 + y.x**2)) * 180 / np.pi)

alpha = -np.arctan(y.z / y.y)
y.rotation(alpha, 'x')
gamma = np.arctan(y.x / y.y)
y.rotation(gamma, 'z')
print(y.x, y.y, y.z)

y = Vector(0., 1., 0.)
y.rotation(-gamma, 'z')
y.rotation(-alpha, 'x')
print(y.x, y.y, y.z)

print("End Vector")

#y = Vector(0., 1., 0.)
#y.z = - np.tan(theta_grazing) / np.sqrt(2 + (np.tan(theta_grazing))**2)
#y.x =  np.tan(theta_grazing) / np.sqrt(2 + (np.tan(theta_grazing))**2)
#y.y =  1 / np.sqrt(2 + np.tan(theta_grazing)**2)
예제 #15
0
    z = f - p * np.cos(beta)

    v = Vector(0., y, z - f)
    v.normalization()
    v0 = Vector(0., 0., -1.)
    v0.normalization()
    alpha = np.arccos(v.dot(v0))

    t = (-v.x * beam.x - v.y * beam.y -
         v.z * beam.z) / (v.x * beam.vx + v.y * beam.vy + v.z * beam.vz)
    beam.x += beam.vx * t
    beam.y += beam.vy * t
    beam.z += beam.vz * t

    velocity = Vector(beam.vx, beam.vz, -beam.vy)
    velocity.rotation(-alpha, 'x')

    beam.vx = velocity.x
    beam.vy = velocity.y
    beam.vz = velocity.z

    wolter_japanese.oe[0].set_parameters(p=0., q=0., theta=90 * np.pi / 180)

    ########################################################################################################################

    wolter_japanese.oe[0].intersection_with_optical_element(beam)
    wolter_japanese.oe[0].output_direction_from_optical_element(beam)
    wolter_japanese.oe[1].intersection_with_optical_element(beam)
    wolter_japanese.oe[1].output_direction_from_optical_element(beam)

    ccc = wolter_japanese.oe[1].ccc_object.get_coefficients()