Exemplo n.º 1
0
def test_force1():
    """
    Test gravitational force from point mass at a meter on a point mass at the
    origin.

    Tests
    -----
    mplb.multipole_force : function
    """
    m1 = np.array([[1, 0, 0, 0]])
    m2 = np.array([[1, 1, 0, 0]])
    q1 = pgm.qmoments(10, m1)
    q2 = pgm.Qmomentsb(10, m2)
    force = mplb.multipole_force(10, q1, q2, 0, 0, 0)
    assert (abs(force[0] - mplb.BIG_G) < 10 * np.finfo(float).eps)
    m2 = np.array([[1, 0, 1, 0]])
    q2 = pgm.Qmomentsb(10, m2)
    force = mplb.multipole_force(10, q1, q2, 0, 0, 0)
    assert (abs(force[1] - mplb.BIG_G) < 10 * np.finfo(float).eps)
    m2 = np.array([[1, 0, 0, 1]])
    q2 = pgm.Qmomentsb(10, m2)
    force = mplb.multipole_force(10, q1, q2, 0, 0, 0)
    assert (abs(force[2] - mplb.BIG_G) < 10 * np.finfo(float).eps)
Exemplo n.º 2
0
def test_force2():
    """
    Test gravitational force from point mass at two meters on point mass away
    from the origin.

    Tests
    -----
    mplb.multipole_force : function
    """
    m1b = np.array([[1, 0, 0, 1]])
    m2 = np.array([[1, 0, 0, 2]])
    q1b = pgm.qmoments(20, m1b)
    q2 = pgm.Qmomentsb(20, m2)
    # Check force for where m1 is placed
    force = mplb.multipole_force(20, q1b, q2, 0, 0, 0)
    assert (abs(force[2] - mplb.BIG_G) < 10 * np.finfo(float).eps)
    # Check force at if displace inner moments to origin
    force = mplb.multipole_force(20, q1b, q2, 0, 0, -1)
    assert (abs(force[2] - mplb.BIG_G / 4) < 10 * np.finfo(float).eps)
    m1b = np.array([[1, 1, 0, 0]])
    m2 = np.array([[1, 2, 0, 0]])
    q1b = pgm.qmoments(20, m1b)
    q2 = pgm.Qmomentsb(20, m2)
    # Check force for where m1 is placed
    force = mplb.multipole_force(20, q1b, q2, 0, 0, 0)
    assert (abs(force[0] - mplb.BIG_G) < 10 * np.finfo(float).eps)
    # Check force at if displace inner moments to origin
    force = mplb.multipole_force(20, q1b, q2, -1, 0, 0)
    assert (abs(force[0] - mplb.BIG_G / 4) < 10 * np.finfo(float).eps)
    m1b = np.array([[1, 0, 1, 0]])
    m2 = np.array([[1, 0, 2, 0]])
    q1b = pgm.qmoments(20, m1b)
    q2 = pgm.Qmomentsb(20, m2)
    # Check force for where m1 is placed
    force = mplb.multipole_force(20, q1b, q2, 0, 0, 0)
    assert (abs(force[1] - mplb.BIG_G) < 10 * np.finfo(float).eps)
    # Check force at if displace inner moments to origin
    force = mplb.multipole_force(20, q1b, q2, 0, -1, 0)
    assert (abs(force[1] - mplb.BIG_G / 4) < 10 * np.finfo(float).eps)
Exemplo n.º 3
0
cylhtot += rot.rotate_qlm(cylh3i, 4*np.pi/3, 0, 0)
cylhtot += rot.rotate_qlm(cylh3i, 5*np.pi/3, 0, 0)
cylhtot += cylh2i
cylhtot += rot.rotate_qlm(cylh2i, np.pi/2, 0, 0)
cylhtot += rot.rotate_qlm(cylh2i, np.pi, 0, 0)
cylhtot += rot.rotate_qlm(cylh2i, 3*np.pi/2, 0, 0)
#cyltot += cylhtot

# create a test-mirror
tm = qlm.cylinder(LMax, mtm, htm, rtm)
tm = rot.rotate_qlm(tm, np.pi/2, np.pi/2, -np.pi/2)
tm = trs.translate_q2Q(tm, [dx, dy, 0])

# Figure out the force at different rotor angles
nAng = 120
forces = np.zeros([nAng, 3], dtype='complex')
nlm, nc, ns = mplb.torque_lm(LMax, cyltot, tm)
dphi = 2*np.pi/nAng
# Now rotate the cylindrical test-masses through various angles and calculate
# the forces
# seems like last rotation matrix may have error, compute extra to be safe
ds = rot.wignerDl(LMax+1, dphi, 0, 0)
for k in range(nAng):
    print('Angle = ', np.round((k+1)*dphi*180/np.pi, 2), ' degrees')
    cyltot = rot.rotate_qlm_Ds(cyltot, ds[:-1])
    forces[k] = mplb.multipole_force(LMax, cyltot, tm, 0, 0, 0)

# plot some forces against angle
fig, ax = plt.subplots(1, 1)
ax.scatter(np.arange(1, nAng+1)*dphi, np.real(forces[:, 0]))