Example #1
0
def fullrange_multi_rootfind(m, qlists, kvals, aympcompare=False, saving=False):
    """
    Does multi_rootfind per qlist in qlists, for all values of k given in kvals
    Will save the data as part of the process so the plotting can be done
    much quicker in later times, if the saving argument is used
    Will plot a comparison to Townsend2003's asymptotic approximations if that
    argument is used, otherwise it will only plot the found solutions

    Should replace the is_even check with the mode_admin setup I created
    this will allow for more flexibility down the line with e.g. varying k *and* m
    """
    if aympcompare:
        plotting.asymptotic_plotting(m)
    for qlist in qlists:
        for k in kvals:
            is_even = LaPlace.check_is_even(m, k)
            print is_even

            qlist, found_lamlist = roots.multi_rootfind(m, k, qlist, is_even)
            plt.plot(qlist, found_lamlist, color="black", ls="--")
            if saving:
                savestring = "data/Townsend2003/range_{}_{}_steps_{}_kval_{}.txt"\
                                    .format(qlist[0],qlist[-1],len(qlist),str(k))
                np.savetxt(savestring, found_lamlist)
    plt.yscale('log')
    plt.show()
Example #2
0
def simple_numasyplot(m):
    custom_lines = [Line2D([0], [0], color="black", lw=2.5, linestyle="--", label="Numeric"),
                    Line2D([0], [0], color="blue", lw=2.5, label="2nd order"),
                    Line2D([0], [0], color="blue", lw=2.5, linestyle="-.", label="1st order")]
    plotting.asymptotic_plotting(m)
    plotting.townsend_plotting()
    plt.xlim([-5, 5])
    plt.ylim([3.8, 1400])  #5500 works for this setup
    plt.title("Asymptotic 1st and 2nd order compared with numerical solutions, m=-2")
    plt.xlabel(r"Spin parameter q = $2\Omega/\omega$")
    plt.ylabel(r"Eigenvalue $\lambda$")
    plt.text(-4.25, 1000, "g-mode", fontsize=21)
    plt.text(-4.75, 310, "g-mode", fontsize=21)
    plt.text(-4.75, 102, "g-mode", fontsize=21)
    plt.text(3.75, 220, "g-mode", fontsize=21)
    plt.text(4., 28, "y-mode", fontsize=21)
    plt.text(4, 4.5, "k-mode", fontsize=21)
    plt.text(-4.75, 8.25, "y-mode", fontsize=21)
#    plt.legend(handles=custom_lines, fontsize=24, frameon=True, fancybox=True, edgecolor="#000000", loc='upper right', bbox_to_anchor=(1, 1))
#    plt.savefig("TEST.png")
    plt.show()
Example #3
0
def compare_newfile(m):
    qneg = np.linspace(0, -10, 9.5e2+4)
    qpos = np.linspace(0, 10, 9.5e2+4)
    plotting.asymptotic_plotting(m)
    pro1 = asym.g_modes_list(m, 2, qpos)
    pro2 = asym.yanai_modes(m, qpos)
    pro3 = asym.kelvin_modes(m, qpos)
    ret1 = asym.g_modes_list(m, 2, qneg)
    ret2 = asym.g_modes_list(m, 1, qneg)
    ret3 = asym.g_modes_list(m, 0, qneg)
    plt.plot(qpos, pro1, label="new p1")
    plt.plot(qpos, pro2, label="new p2")
    plt.plot(qpos, pro3, label="new p3")
    plt.plot(qneg, ret1, label="new r1")
    plt.plot(qneg, ret2, label="new r2")
    plt.plot(qneg, ret3, label="new r3")
    plt.xlim([-5, 5])
    plt.ylim([3.8, 1400])
    plt.xlabel(r"Spin parameter q = $2\Omega/\omega$")
    plt.ylabel(r"Eigenvalue $\lambda$")
    plt.legend(fontsize=24, frameon=True, fancybox=True, edgecolor="#000000")
    plt.show()
Example #4
0
def fullrange_multi_rootfind_curvi(m, kvals, qlists, r_eq, mass, period, \
                                    aympcompare=False, saving=False):
    """
    Curvilinear version of fullrange_multi_rootfind

    Not yet in final version! and DO NOT USE the saving argument!
    """
    if aympcompare:
        plotting.asymptotic_plotting(m)
    for qlist in qlists:
        for k in kvals:
            is_even = Curvilinear.check_is_even(m, k)
            print is_even

            qlist, found_lamlist = roots.multi_rootfind_curvilinear(
                m, k, qlist, is_even, r_eq, mass, period)
            plt.plot(qlist, found_lamlist, color="black", ls="--")
            if saving:
                savestring = "data/Curvilinear/range_{}_{}_steps_{}_kval_{}.txt"\
                                    .format(qlist[0],qlist[-1],len(qlist),str(k))
                np.savetxt(savestring, found_lamlist)
    plt.yscale('log')
    plt.show()
Example #5
0
def simple_numasyplot_rmodesINC(m, k, is_even):
    r_eq, mass, period = 10e3, 1.4*1.9885e30, np.inf
    r_qlist = np.linspace(-10., -6.025, 225)  # r-modes are fine with fewer steps really
    y_qlist = np.linspace(-10., -3.05, 325)
    r_guesslist = asym.r_modes(m, k, r_qlist)
    y_guesslist = asym.yanai_modes(m, y_qlist)
    r_qlist, r_found_lamlist = roots.multi_rootfind_fromguess(m, r_qlist, is_even, r_guesslist, r_eq, mass, period, verbose=False, inc=1.05)
    y_qlist, y_found_lamlist = roots.multi_rootfind_fromguess(m, y_qlist, not is_even, y_guesslist, r_eq, mass, period, verbose=False, inc=1.08)

    custom_lines = [Line2D([0], [0], color="black", lw=2.5, linestyle="--", label="Numeric"),
                    Line2D([0], [0], color="blue", lw=2.5, label="2nd order"),
                    Line2D([0], [0], color="blue", lw=2.5, linestyle="-.", label="1st order")]
    plotting.asymptotic_plotting(m)
    plotting.townsend_plotting()

    plt.plot(r_qlist, r_found_lamlist, ls="--", color='black')
    plt.plot(y_qlist, y_found_lamlist, ls="--", color='black')

    plt.xlim([-10, 10])
    plt.ylim([.1, 6000])
    plt.title("Asymptotic 1st and 2nd order compared with numerical solutions, m=-2")
    plt.xlabel(r"Spin parameter q = $2\Omega/\omega$")
    plt.ylabel(r"Eigenvalue $\lambda$")
    plt.show()