# Summary:
# a) division by zero can be a problem when 1/omg is part of the solution
# b) there's something wrong when time = [0,T]
# while omg*t = [0,2pi]. The solution is to integrate forward in
# radians so both are [0,2pi].

# =============================================================================

# non-dimensional time / frequency
T = 2. * np.pi  #10. # s, period
omg = 1.  #2.*np.pi/T
params = {'omg': omg}
Phi0 = 0.5
soln1 = Phi0 * np.exp(np.sin(2. * np.pi) / omg)  # analytical solution
Phin1, final_time = fn.rk4_time_step(params, Phi0, T / 2000, T, 'forcing_test')
"""
print('final time =', final_time)
print('final radians =', final_time*omg)
print('Nt = ',2000)
print('Analytical solution = ',soln1)
print('Computed solution = ',Phin1)
"""

# dimensional time
T = 10.  # s, period
omg = 2. * np.pi / T
params = {'omg': omg}
Phi0 = 0.5
soln = Phi0 * np.exp(np.sin(2. * np.pi) / omg)
Phin, final_time = fn.rk4_time_step(params, Phi0, T / 2000, T, 'forcing_test')
Esempio n. 2
0
            'dz': dz,
            'eye_matrix': eye_matrix,
            'freq': freq,
            'lBC': lBC,
            'lBC2': lBC2,
            'phi_path': phi_path,
            'psi_path': psi_path
        }
        Nc = fn.count_points(params)
        print('number of points within delta = %i' % (Nc))

        # initial conditions (prinicipal fundamental solution matrix):
        Phi0 = np.eye(int(Nz), int(Nz), 0, dtype=complex)

        # compute monodromy matrix:
        Phin, final_time = fn.rk4_time_step(params, Phi0, T / Nt, T, 'stokes')

        # store maxima:
        Fmult = np.linalg.eigvals(Phin)

        print('Should be exactly zero:')
        """
        for n in range(0,Nz):
            print('%.60f' %(np.real(Fmult[n])))
        print('\n')
        for n in range(0,Nz):
            print('%.60f' %(np.imag(Fmult[n])))
        """
        print(sum(np.real(FmultGOLD) - np.real(Fmult)))
        print(sum(np.imag(FmultGOLD) - np.imag(Fmult)))
Esempio n. 3
0
dT2 = np.zeros(np.shape(M))
for m in range(0, np.shape(M)[0]):

    Nt = int(M[m])
    dt = T / Nt
    dt2 = T2 / Nt
    #print(Nt,dt)
    dT[m] = dt
    dT2[m] = dt2

    Phin = np.eye(int(2), int(2), 0, dtype=complex)
    PhinOP = np.eye(int(2), int(2), 0, dtype=complex)
    PhinH = np.eye(int(2), int(2), 0, dtype=complex)
    PhinOPH = np.eye(int(2), int(2), 0, dtype=complex)

    Phin, final_time = fn.rk4_time_step(params, Phin, dt, T, 'analytical_test')
    PhinOP, final_timeOP = fn.op_time_step(params, PhinOP, dt, T,
                                           'analytical_test')
    PhinH, final_timeH = fn.rk4_time_step(paramsH, PhinH, dt2, T2,
                                          'Hills_equation')
    PhinOPH, final_timeOPH = fn.op_time_step(paramsH, PhinOPH, dt2, T2,
                                             'Hills_equation')

    # analytical solution:
    Phia = np.matrix([[np.exp(-alpha * (final_time)), 0.],
                      [0., np.exp(-beta * (final_time))]],
                     dtype=complex)
    wa = np.linalg.eigvals(Phia)
    # RK4 computed solution:
    w = np.linalg.eigvals(
        Phin)  # eigenvals, eigenvecs | eigenvals = floquet multipliers
Esempio n. 4
0
print('\nMathieu equation test running...\n')
for i in range(0, Ngrid):
    for j in range(0, Ngrid):

        #print(count)
        count = count + 1

        paramsH = {'a': a[i], 'b': b[j], 'freq': 0}

        #

        PhinH = np.eye(int(2), int(2), 0, dtype=complex)
        #PhinOPH = np.eye(int(2),int(2),0,dtype=complex)

        PhinH, final_timeM = fn.rk4_time_step(paramsH, PhinH, T / 100, T,
                                              'Hills_equation')
        #PhinOPH,final_timeOPM = fn.op_time_step( paramsH , PhinOPH , T/100, T , 'Hills_equation' )
        """
    TrH = np.abs(np.trace(PhinH))
    if TrH < 2.:
      strutt1[j,i] = 1. # 1 for stability
    
    TrOPH = np.abs(np.trace(PhinOPH))
    if TrOPH < 2.:
      strutt2[j,i] = 1.
    """
        modH = np.linalg.eigvals(PhinH)  # eigenvals = floquet multipliers
        #if modH[0] < 1. and modH[1] < 1.:
        #  strutt3[j,i] = 1.
        #print(np.real(modH))
Esempio n. 5
0
            'lBC': lBC,
            'lBC2': lBC2
        }
        Nc = fn.count_points(params)
        print('number of points within delta = %i' % (Nc))

        # initial conditions (prinicipal fundamental solution matrix):
        Phi0 = np.eye(int(2 * Nz), int(2 * Nz), 0, dtype=complex)

        # correct:
        Bn = Phi0[Nz:int(2 * Nz), :]  # zeta
        Zn = Phi0[0:Nz, :]  # buoyancy
        Pn = np.real(np.dot(params['inv_psi'], Zn))  # psi

        # compute monodromy matrix:
        Phin, final_time = fn.rk4_time_step(params, Phi0, T / Nt, T,
                                            'zeta1')  # streamwise vorticity

        # store maxima:
        Fmult = np.linalg.eigvals(Phin)
        # find locations where imag >= 0.5, then zero out those locations:
        # Fmult2 = fn.remove_high_frequency( Fmult )

        print(Fmult)

        M[j, i] = np.amax(
            np.abs(Fmult))  # maximum modulus, eigenvals = floquet multipliers
        Mr[j, i] = np.amax(np.real(Fmult))
        Mi[j, i] = np.amax(np.imag(Fmult))
        print('\nmax. modulus mu = ', M[j, i])
        print('\nmax. real mu = ', Mr[j, i])
        print('\nmax. imag mu = ', Mi[j, i])
Esempio n. 6
0
            'lBC': lBC,
            'lBC2': lBC2
        }
        Nc = fn.count_points(params)
        print('number of points within delta = %i' % (Nc))

        # initial conditions (prinicipal fundamental solution matrix):
        Phi0 = np.eye(int(2 * Nz), int(2 * Nz), 0, dtype=complex)

        # correct:
        #Bn = Phi0[Nz:int(2*Nz),:] # zeta
        #Zn = Phi0[0:Nz,:] # buoyancy
        #Pn = np.real(np.dot(params['inv_psi'],Zn)) # psi

        # compute monodromy matrix:
        Phin, final_time = fn.rk4_time_step(params, Phi0, T / Nt, T,
                                            'zeta2')  # spanwise vorticity

        # store maxima:
        Fmult = np.linalg.eigvals(Phin)
        # find locations where imag >= 0.5, then zero out those locations:
        # Fmult2 = fn.remove_high_frequency( Fmult )

        print(Fmult)

        M[j, i] = np.amax(
            np.abs(Fmult))  # maximum modulus, eigenvals = floquet multipliers
        Mr[j, i] = np.amax(np.real(Fmult))
        Mi[j, i] = np.amax(np.imag(Fmult))
        print('\nmax. modulus mu = ', M[j, i])
        print('\nmax. real mu = ', Mr[j, i])
        print('\nmax. imag mu = ', Mi[j, i])
Esempio n. 7
0
# loop over temporal resolution:
M = [2, 10, 100, 1000, 10000]
Linf = np.zeros(np.shape(M))
LinfOP = np.zeros(np.shape(M))
dT = np.zeros(np.shape(M))
for m in range(0, np.shape(M)[0]):

    Nt = int(M[m])
    dt = T / Nt
    #print(Nt,dt)
    dT[m] = dt

    Phin = np.eye(int(2), int(2), 0, dtype=complex)
    PhinOP = np.eye(int(2), int(2), 0, dtype=complex)

    Phin, final_time = fn.rk4_time_step(params, Phin, dt, dt,
                                        'analytical_test')
    PhinOP, final_timeOP = fn.op_time_step(params, PhinOP, dt, dt,
                                           'analytical_test')

    # analytical solution:
    Phia = np.matrix([[np.exp(-alpha * (final_time)), 0.],
                      [0., np.exp(-beta * (final_time))]],
                     dtype=complex)
    wa, va = np.linalg.eig(Phia)
    # RK4 computed solution:
    w, v = np.linalg.eig(
        Phin)  # eigenvals, eigenvecs | eigenvals = floquet multipliers
    # ordered product computed solution:
    wOP, vOP = np.linalg.eig(
        PhinOP)  # eigenvals, eigenvecs | eigenvals = floquet multipliers
    percent_error_mu1 = abs((w[0] - wa[0])) / abs(wa[0]) * 100.