Exemplo n.º 1
0
def _one_dim_lens_eq_calcs(args, phi):
    """Calculates intermediate quantities that are needed for several of the subsequent functions"""
    b, t, y1, y2, q, gamma1, gamma2 = args
    y = (y1 + y2 * 1j)

    rhat = 1 / (1 - gamma1**2 - gamma2**2) * (
        ((1 + gamma1) * np.cos(phi) + gamma2 * np.sin(phi)) + 1j *
        (gamma2 * np.cos(phi) + (1 - gamma1) * np.sin(phi)))
    thetahat = 1 / (1 - gamma1**2 - gamma2**2) * (
        ((1 + gamma1) * np.sin(phi) - gamma2 * np.cos(phi)) + 1j *
        (gamma2 * np.sin(phi) - (1 - gamma1) * np.cos(phi)))

    frac_Roverrsh, phiell = pol_to_ell(1, phi, q)
    Omega = omega(phiell, t, q)
    const = 2 * b / (1 + q)
    if abs(t - 1) > 1e-4:
        b_over_r_pow_tm1 = -cdot(y, thetahat) / (const * cdot(Omega, thetahat))
        R = b * np.abs(b_over_r_pow_tm1)**(1 /
                                           (1 - t)) * np.sign(b_over_r_pow_tm1)
    else:
        Omega_ort = 1j * Omega
        x = ((1 - gamma1) * np.cos(phi) -
             gamma2 * np.sin(phi)) + 1j * (-gamma2 * np.cos(phi) +
                                           (1 + gamma1) * np.sin(phi))
        R = cdot(Omega_ort, y) / cdot(Omega_ort, x) * frac_Roverrsh
    r, theta = ell_to_pol(R, phiell, q)
    return Omega, const, phiell, q, r, rhat, t, b, thetahat, y
Exemplo n.º 2
0
def _one_dim_lens_eq_unsmooth(phi, args):
    """Calculates the not-smooth 1-dimensional lens equation to to solve - to be used by a root-finder.
    For some parameters and solutions, numerical issues make solving this one feasible while the other is not."""
    Omega, const, phiell, q, r, rhat, t, b, thetahat, y = _one_dim_lens_eq_calcs(
        args, phi)

    rr, thetaa = ell_to_pol(1, phiell, q)
    ip = cdot(y, rhat) * cdot(Omega, thetahat) - cdot(Omega, rhat) * cdot(
        y, thetahat)
    eq_notsmooth = ps(rr * b, 1 - t) * (cdot(y, thetahat) / const) * np.abs(
        ip)**t + ip * np.abs(cdot(Omega, thetahat))**(+t)
    return eq_notsmooth
Exemplo n.º 3
0
def _one_dim_lens_eq(phi, args):
    """Calculates the smooth 1-dimensional lens equation to solve - to be used by a root-finder"""
    Omega, const, phiell, q, r, rhat, t, b, thetahat, y = _one_dim_lens_eq_calcs(
        args, phi)

    rr, thetaa = ell_to_pol(1, phiell, q)
    ip = cdot(y, rhat) * cdot(Omega, thetahat) - cdot(Omega, rhat) * cdot(
        y, thetahat)
    eq = (rr * b)**(2 / t - 2) * ps(
        (cdot(y, thetahat) / const), 2 / t) * ip**2 + ps(ip, 2 / t) * cdot(
            Omega, thetahat)**2
    return eq
Exemplo n.º 4
0
def _one_dim_lens_eq_both(phi, args):
    """Calculates and returns simultaneously both the smooth and the not-smooth 1-dimensional lens equation
    that needs to be solved"""
    Omega, const, phiell, q, r, rhat, t, b, thetahat, y = _one_dim_lens_eq_calcs(
        args, phi)
    rr, thetaa = ell_to_pol(1, phiell, q)
    ip = cdot(y, rhat) * cdot(Omega, thetahat) - cdot(Omega, rhat) * cdot(
        y, thetahat)
    # The derivations are lost somewhere in my notes...
    eq = (rr * b)**(2 / t - 2) * ps(
        (cdot(y, thetahat) / const), 2 / t) * ip**2 + ps(ip, 2 / t) * cdot(
            Omega, thetahat)**2
    eq_notsmooth = ps(rr * b, 1 - t) * (cdot(y, thetahat) / const) * np.abs(
        ip)**t + ip * np.abs(cdot(Omega, thetahat))**(+t)
    return eq, eq_notsmooth