Beispiel #1
0
    # generating the grid is the longest part
    start = time.time()
    mins = np.array((10, 0.25))
    maxs = np.array((50, 0.75))
    nums = np.array((10, 10))
    try:
        cf.load_grid('TASBL_Re0_growth_rates.h5')
    except:
        cf.grid_generator(mins, maxs, nums)
        if comm.rank == 0:
            cf.save_grid('TASBL_Re0_growth_rates')
    end = time.time()
    if comm.rank == 0:
        print("grid generation time: {:10.5f} sec".format(end - start))

    cf.root_finder()
    crit = cf.crit_finder(find_freq=True)

    if comm.rank == 0:
        print("crit = {}".format(crit))
        print("critical wavenumber alpha = {:10.5f}".format(crit[1]))
        print("critical Re = {:10.5f}".format(crit[0]))
        print("critical omega = {:10.5f}".format(crit[2]))

        cf.save_grid('orr_sommerfeld_growth_rates')
        cf.plot_crit()
else:
    gr, idx, freq = EP.growth_rate({})
    print("TASBL growth rate = {0:10.5e}".format(gr))
        problem.add_bc("left(ωy)   = 0")
        problem.add_bc("left(ωz)   = 0")
        problem.add_bc("left(bx)   = 0")
        problem.add_bc("left(jxx)  = 0")

        problem.add_bc("right(ωy)  = 0")
        problem.add_bc("right(ωz)  = 0")
        problem.add_bc("right(bx)  = 0")
        problem.add_bc("right(jxx) = 0")



# GO
EP = Eigenproblem(problem)
t1 = time.time()
gr, idx, freq = EP.growth_rate(sparse=sparse)
t2 = time.time()
logger.info("Solve time: {}".format(t2-t1))
logger.info("growth rate = {}, freq = {}".format(gr,freq))

#     save_vtk = False
#     if save_vtk:
#         vtkfile = filename.stem + '.vtk'
#         from pyevtk.hl import gridToVTK 
#         pointData = {'p':p.copy(), 'u':u.copy(), 'v':v.copy(), 'w':w.copy(),
#                      'Bx':Bx.copy(), 'By':By.copy(), 'Bz':Bz.copy()}
#         print("p flags", pointData['p'].flags)

#         gridToVTK(vtkfile, xx, yy, zz, pointData=pointData)

Beispiel #3
0
def linearStabilityAnalysisPar(f, tht, kappa, Pr, U, Uz, V, Vz, B, Bz, nz, H,
                               l, k, domain):
    # Need to decide whether input variables are in rotated frame or not.
    import sys
    import numpy as np
    import pdb
    from mpi4py import MPI
    from eigentools import Eigenproblem, CriticalFinder
    #    import matplotlib.pyplot as plt
    #    from pylab import *
    #    import scipy.integrate as integrate
    from dedalus import public as de

    #    import logging
    #    logger = logging.getLogger(__name__)

    # LOAD IN PARAMETERS
    #f = parameters, tht, kappa, Pr, U, Uz, V, Vz, B, Bz, nz, H, ll, domain)
    #    f, tht, kappa, Pr, U, Uz, V, Vz, B, Bz, nz, H, ll, domain):
    #        pdb.set_trace()

    #    f = args[0]
    #    tht = args[1]
    #    kappa = args[2]
    #    Pr = args[3]
    #    U = args[4]
    #    Uz = args[5]
    #    V = args[6]
    #    Vz = args[7]
    #    B = args[8]
    #    Bz = args[9]
    #    nz = args[10]
    #    H = args[11]
    #    ll = args[12]
    ##    domain = args[13]
    #    z_basis = de.Chebyshev('z', nz, interval=(0, H))
    #    domain = de.Domain([z_basis], np.complex128)
    # non-constant coefficients
    #    kap = domain.new_field(name='kap')
    #    z = domain.grid(0)
    #    kap['g'] = kapi
    # SETUP LINEAR STABILITY ANALYSIS
    problem = de.EVP(
        domain,
        variables=['u', 'v', 'w', 'b', 'p', 'uz', 'vz', 'wz', 'bz'],
        eigenvalue='omg',
        tolerance=1e-3)
    problem.parameters['U'] = U
    problem.parameters['V'] = V
    problem.parameters['B'] = B
    problem.parameters['Uz'] = Uz
    problem.parameters['Vz'] = Vz
    problem.parameters['Bz'] = Bz
    problem.parameters['f'] = f
    problem.parameters['tht'] = tht
    problem.parameters['kap'] = kappa
    problem.parameters['Pr'] = Pr
    problem.parameters['k'] = 0.  # will be set in loop
    problem.parameters['l'] = 0.  # will be set in loop
    problem.substitutions['dx(A)'] = "1j*k*A"
    problem.substitutions['dy(A)'] = "1j*l*A"
    problem.substitutions['dt(A)'] = "-1j*omg*A"
    problem.add_equation(
        ('dt(u) + U*dx(u) + V*dy(u) + w*Uz - f*v*cos(tht) + dx(p)'
         '- b*sin(tht) - Pr*(kap*dx(dx(u)) + kap*dy(dy(u)) + dz(kap)*uz'
         '+ kap*dz(uz)) = 0'))
    problem.add_equation(
        ('dt(v) + U*dx(v) + V*dy(v) + w*Vz + f*u*cos(tht)'
         '- f*w*sin(tht) + dy(p) - Pr*(kap*dx(dx(v)) + kap*dy(dy(v))'
         '+ dz(kap)*vz + kap*dz(vz)) = 0'))
    #    problem.add_equation(('dt(w) + U*dx(w) + V*dy(w) + f*v*sin(tht) + dz(p)'
    #            '- b*cos(tht) - Pr*(kap*dx(dx(w)) + kap*dy(dy(w)) + dz(kap)*wz'
    #            '+ kap*dz(wz)) = 0'))
    problem.add_equation(
        '0*(dt(w) + U*dx(w) + V*dy(w)) + f*v*sin(tht) + dz(p)'
        '- b*cos(tht) - Pr*(kap*dx(dx(w)) + kap*dy(dy(w)) + dz(kap)*wz'
        '+ kap*dz(wz)) = 0')
    #    problem.add_equation(('dt(b) + U*dx(b) + V*dy(b) + u*N**2*sin(tht)'
    #            '+ w*(N**2*cos(tht) + Bz) - kap*dx(dx(b)) - kap*dy(dy(b)) - dz(kap)*bz'
    #            '- kap*dz(bz) = 0'))
    problem.add_equation(
        ('dt(b) + U*dx(b) + V*dy(b) + u*Vz*f'
         '+ w*(Bz) - kap*dx(dx(b)) - kap*dy(dy(b)) - dz(kap)*bz'
         '- kap*dz(bz) = 0'))
    problem.add_equation('dx(u) + dy(v) + wz = 0')
    problem.add_equation('uz - dz(u) = 0')
    problem.add_equation('vz - dz(v) = 0')
    problem.add_equation('wz - dz(w) = 0')
    problem.add_equation('bz - dz(b) = 0')
    problem.add_bc('left(u) = 0')
    problem.add_bc('left(v) = 0')
    problem.add_bc('left(w) = 0')
    problem.add_bc('left(bz) = 0')
    problem.add_bc('right(uz) = 0')
    problem.add_bc('right(vz) = 0')
    problem.add_bc('right(w) = 0')
    problem.add_bc('right(bz) = 0')

    problem.namespace['k'].value = k
    problem.namespace['l'].value = l

    # solve problem
    EP = Eigenproblem(problem)

    (gr, idx, freq) = EP.growth_rate({})
    #    print(str(np.max(idx)))
    #    print(str(idx[-1]))
    #    if idx[-1]>nz:
    #        grt = 0
    gr = np.array([gr])

    #    #get full eigenvectors and eigenvalues for l with largest growth
    ##    idx = sorted_eigen(0., ll[np.argmax(gr)])
    #    solver.set_state(idx[-1])
    #
    #    # collect eigenvector
    #    u = solver.state['u']
    #    v = solver.state['v']
    #    w = solver.state['w']
    #    b = solver.state['b']

    # shear production
    #    SP = -2*np.real(np.conj(w['g'])*(u['g']*Uz['g']+v['g']*Vz['g']))
    #
    #    # buoyancy production
    #    BP = 2*np.real((u['g']*np.sin(tht)+w['g']*np.cos(tht))*np.conj(b['g']))

    return (gr, 0, 0, 0, 0)
Beispiel #4
0
    "r*r*dt(u) - nu*Lap_r - 2*r*v0*v + r*v0*dtheta(u) + r*r*dr(p) = 0")
problem.add_equation(
    "r*r*dt(v) - nu*Lap_t + r*r*dv0dr*u + r*v0*u + r*v0*dtheta(v) + r*dtheta(p)  = 0"
)
problem.add_equation("r*r*dt(w) - nu*Lap_z + r*r*dz(p) + r*v0*dtheta(w) = 0.")

#continuity
problem.add_equation("r*ur + u + dtheta(v) + r*dz(w) = 0")

#Auxillilary equations
problem.add_equation("ur - dr(u) = 0")
problem.add_equation("vr - dr(v) = 0")
problem.add_equation("wr - dr(w) = 0")

#Boundary Conditions
problem.add_bc("left(u) = 0")
problem.add_bc("right(u) = 0")
problem.add_bc("left(v) = 0")
problem.add_bc("right(v) = 0")
problem.add_bc("left(w) = 0")
problem.add_bc("right(w) = 0")

ep = Eigenproblem(problem)

growth, index, freq = ep.growth_rate({})

logger.info("Growth rate = {:16.15e}; frequency = {:16.15e}".format(
    growth, freq[0]))

#ep.spectrum(spectype='hires')