widegap.add_bc('left(B + r*Br) = 0') widegap.add_bc('right(B + r*Br) = 0') # axial component of current = 0 # create an Eigenproblem object EP = Eigenproblem(widegap) # create a shim function to translate (x, y) to the parameters for the eigenvalue problem: def shim(x,y): gr, indx, freq = EP.growth_rate({"Rm":x,"k":y}) val = gr + 1j*freq if type(val) == np.ndarray: return val[0] else: return val cf = CriticalFinder(shim, comm) # generating the grid is the longest part start = time.time() gridl = 10 mins = np.array((0.5, 0.001)) maxs = np.array((2.0, 0.1)) num = np.array((gridl, gridl)) logs = np.array((False, True)) cf.grid_generator(mins, maxs, num, logs) # Rm = (0.5, 2.0); k = (0.001, 0.1) is not a bracketing interval for Pm = 1E-4. neither is (0.5, 2.0, 0.0001, 0.001) end = time.time() if comm.rank == 0: print("grid generation time: {:10.5f} sec".format(end-start)) print(cf.grid) print(cf.grid.shape)
problem.add_bc("left(v) = 0") problem.add_bc("left(w) = 0") EP = Eigenproblem(problem, sparse=True) if find_crit: def shim(x, y): gr, indx, freq = EP.growth_rate({"Ra": x, "ky": y}) ret = gr + 1j * freq if type(ret) == np.ndarray: return ret[0] else: return ret cf = CriticalFinder(shim, comm) # 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))
) orr_somerfeld.add_equation('dz(w)-wz = 0') orr_somerfeld.add_equation('dz(wz)-wzz = 0') orr_somerfeld.add_equation('dz(wzz)-wzzz = 0') orr_somerfeld.add_bc('left(w) = 0') orr_somerfeld.add_bc('right(w) = 0') orr_somerfeld.add_bc('left(wz) = 0') orr_somerfeld.add_bc('right(wz) = 0') # create an Eigenproblem object EP = Eigenproblem(orr_somerfeld) # create a shim function to translate (x, y) to the parameters for the eigenvalue problem: cf = CriticalFinder(EP, ("alpha", "Re"), comm, find_freq=True) # generating the grid is the longest part start = time.time() nx = 20 ny = 20 xpoints = np.linspace(1.0, 1.1, nx) ypoints = np.linspace(5500, 6000, ny) try: cf.load_grid('{}.h5'.format(file_name)) except: cf.grid_generator((xpoints, ypoints), sparse=True) if comm.rank == 0: cf.save_grid(file_name) end = time.time() if comm.rank == 0:
rayleigh_benard.add_bc('right(b) = 0') #Impenetrable rayleigh_benard.add_bc('left(w) = 0') rayleigh_benard.add_bc('right(w) = 0') if no_slip: rayleigh_benard.add_bc('left(u) = 0') rayleigh_benard.add_bc('right(u) = 0') elif stress_free: rayleigh_benard.add_bc('left(uz) = 0') rayleigh_benard.add_bc('right(uz) = 0') # create an Eigenproblem object EP = Eigenproblem(rayleigh_benard) cf = CriticalFinder(EP, ("k", "Ra"), comm, find_freq=True) # generating the grid is the longest part start = time.time() if no_slip: nx = 20 ny = 20 xpoints = np.linspace(2, 4, ny) ypoints = np.linspace(1000, 3000, nx) elif stress_free: #657.5, 2.221 nx = 10 ny = 10 xpoints = np.linspace(2, 2.4, ny) ypoints = np.linspace(550, 700, nx)
# create an Eigenproblem object EP = Eigenproblem(mri, sparse=True) # create a shim function to translate (x, y) to the parameters for the eigenvalue problem: def shim(x, y): iRm = 1 / x iRe = (iRm * Pm) print("Rm = {}; Re = {}; Pm = {}".format(1 / iRm, 1 / iRe, Pm)) gr, indx, freq = EP.growth_rate({"Q": y, "iRm": iRm, "iR": iRe}) ret = gr + 1j * freq return ret cf = CriticalFinder(shim, comm) # generating the grid is the longest part start = time.time() mins = np.array((4.6, 0.5)) maxs = np.array((5.5, 1.5)) ns = np.array((10, 10)) logs = np.array((False, False)) #cf.load_grid('mri_growth_rates.h5') cf.grid_generator(mins, maxs, ns, logs=logs) if comm.rank == 0: cf.save_grid('mri_growth_rates') end = time.time() print("grid generation time: {:10.5f} sec".format(end - start)) cf.root_finder()
EP = Eigenproblem(rayleigh_benard, sparse=True) # create a shim function to translate (x, y) to the parameters for the eigenvalue problem: def shim(x, y): # print(f"Processor: {comm.rank} \n Ra={int(x)}, k={y:.3}") gr, indx, freq = EP.growth_rate({"Ra": x, "k": y}) # print(f"Processor: {comm.rank} \n Ra={int(x)}, k={y:.3}, gr={gr}") ret = gr + 1j * freq if type(ret) == np.ndarray: return ret[0] else: return ret cf = CriticalFinder(shim, comm) if comm.rank == 0: print('\n### Generating Grid ###\n') start = time.time() # Load in data file if previously run (commented out while fiddling) try: cf.load_grid(f'{direc}.h5') except: # Generates the grid of growth rates (solves the EVP's here) # generating the grid is the longest part cf.grid_generator(mins, maxs, nums) if comm.rank == 0: cf.save_grid(direc)
"""finds the critical Renoylds number and wave number for the Orr-Somerfeld eigenvalue equation. """ from mpi4py import MPI from eigentools import Eigenproblem, CriticalFinder import h5py def fake(x, y): return x, y comm = MPI.COMM_WORLD cf = CriticalFinder(fake, comm) cf.load_grid("orr_sommerfeld_growth_rates.h5") cf.root_finder() crit = cf.crit_finder() if comm.rank == 0: print("critical wavenumber alpha = {:10.5f}".format(crit[0])) print("critical Re = {:10.5f}".format(crit[1])) cf.plot_crit()
# create an Eigenproblem object EP = Eigenproblem(rayleigh_benard, sparse=True) # create a shim function to translate (x, y) to the parameters for the eigenvalue problem: def shim(x, y): gr, indx, freq = EP.growth_rate({"Ra": x, "k": y}) ret = gr + 1j * freq if type(ret) == np.ndarray: return ret[0] else: return ret cf = CriticalFinder(shim, comm) # generating the grid is the longest part start = time.time() if no_slip: mins = np.array((1000, 2)) maxs = np.array((3000, 4)) elif stress_free: #657.5, 2.221 mins = np.array((400, 1.6)) maxs = np.array((1000, 3)) nums = np.array((20, 20)) try: cf.load_grid('{}.h5'.format(file_name)) except: cf.grid_generator(mins, maxs, nums)
mri.add_bc("left(u) = 0") mri.add_bc("right(u) = 0") mri.add_bc("left(psi) = 0") mri.add_bc("right(psi) = 0") mri.add_bc("left(A) = 0") mri.add_bc("right(A) = 0") mri.add_bc("left(psix) = 0") mri.add_bc("right(psix) = 0") mri.add_bc("left(Bx) = 0") mri.add_bc("right(Bx) = 0") # create an Eigenproblem object EP = Eigenproblem(mri) cf = CriticalFinder(EP, ("Q", "Rm"), comm, find_freq=False) # generating the grid is the longest part nx = 20 ny = 20 xpoints = np.linspace(0.5, 1.5, nx) ypoints = np.linspace(4.6, 5.5, ny) file_name = 'mri_growth_rate' try: cf.load_grid('{}.h5'.format(file_name)) except: start = time.time() cf.grid_generator((xpoints, ypoints), sparse=True) end = time.time()