Пример #1
0
def compute_rad_robin_eigenfrequencies(param, l, n_roots=10, show_plot=False):

    a2, a1, a0, alpha, beta = param
    eta = -a1 / 2. / a2

    def characteristic_equation(om):
        if round(om, 200) != 0.:
            zero = (alpha + beta) * np.cos(om * l) + ((eta + beta) * (alpha - eta) / om - om) * np.sin(om * l)
        else:
            zero = (alpha + beta) * np.cos(om * l) + (eta + beta) * (alpha - eta) * l - om * np.sin(om * l)
        return zero

    def complex_characteristic_equation(om):
        if round(om, 200) != 0.:
            zero = (alpha + beta) * np.cosh(om * l) + ((eta + beta) * (alpha - eta) / om + om) * np.sinh(om * l)
        else:
            zero = (alpha + beta) * np.cosh(om * l) + (eta + beta) * (alpha - eta) * l + om * np.sinh(om * l)
        return zero

    # assume 1 root per pi/l (safety factor = 3)
    om_end = 3 * n_roots * np.pi / l
    start_values = np.arange(0, om_end, .1)
    om = ut.find_roots(characteristic_equation, 2*n_roots, start_values, rtol=int(np.log10(l) - 6),
                       show_plot=show_plot).tolist()

    # delete all around om = 0
    om.reverse()
    for i in xrange(np.sum(np.array(om) < np.pi / l / 2e1)):
        om.pop()
    om.reverse()

    # if om = 0 is a root then add 0 to the list
    zero_limit = alpha + beta + (eta + beta) * (alpha - eta) * l
    if round(zero_limit, 6 + int(np.log10(l))) == 0.:
        om.insert(0, 0.)

    # regard complex roots
    om_squared = np.power(om, 2).tolist()
    complex_root = fsolve(complex_characteristic_equation, om_end)
    if round(complex_root, 6 + int(np.log10(l))) != 0.:
        om_squared.insert(0, -complex_root[0] ** 2)

    # basically complex eigenfrequencies
    om = np.sqrt(np.array(om_squared).astype(complex))

    if len(om) < n_roots:
        raise ValueError("RadRobinEigenvalues.compute_eigen_frequencies()"
                         "can not find enough roots")


    eig_frequencies = om[:n_roots]
    eig_values = a0 - a2 * eig_frequencies**2 - a1 ** 2 / 4. / a2
    return eig_frequencies, eig_values
Пример #2
0
    a_s.append(a)

C1, C2, C3 = a_s[np.argmin(s2s)]
Y_ = Y_s[np.argmin(s2s)]

print C1, C2, C3
ha1 = (-C2 + np.sqrt(C2**2. - 4*C1*C3)) / (2.*C3)
ha2 = (-C2 - np.sqrt(C2**2. - 4*C1*C3)) / (2.*C3)
print ha1
print ha2
'''

# Get theoretical MF values from bessel function
fR_range = np.arange(-2.0, 2.0, 0.0005)
bessel_y = bessel(fR_range)
expected_roots = np.array(find_roots(fR_range, bessel_y))

R_known = np.deg2rad(0.26)
expected_freqs = expected_roots / R_known


# plt.plot(moon["t"], moon["volts"])
minima_spots = [(7000, 11000)]
obs_zeros = []
plottypairs = []
for start, end in minima_spots:
    # Cut out a small window around the guessed envelope
    # fit a quadratic to find minima
    (C1, C2, C3), Y_, s2, cov = fit_components(moon["ha"][start: end], moon.envelope(50)[start:end],
        lambda ha: ha ** 2,
        lambda ha: ha,