Пример #1
0
def test_disk_bessel_zeros(Nphi, Nr, m, radius, dtype):
    # Bases
    c = coords.PolarCoordinates('phi', 'r')
    d = distributor.Distributor((c, ))
    b = basis.DiskBasis(c, (Nphi, Nr), radius=radius, dtype=dtype)
    b_S1 = b.S1_basis()
    phi, r = b.local_grids((1, 1))
    # Fields
    f = field.Field(dist=d, bases=(b, ), dtype=dtype)
    τ_f = field.Field(dist=d, bases=(b_S1, ), dtype=dtype)
    k2 = field.Field(name='k2', dist=d, dtype=dtype)
    # Parameters and operators
    lap = lambda A: operators.Laplacian(A, c)
    Lift = lambda A: operators.Lift(A, b, -1)
    # Bessel equation: k^2*f + lap(f) = 0
    problem = problems.EVP([f, τ_f], k2)
    problem.add_equation((k2 * f + lap(f) + Lift(τ_f), 0))
    problem.add_equation((f(r=radius), 0))
    # Solver
    solver = solvers.EigenvalueSolver(problem)
    print(solver.subproblems[0].group)
    for sp in solver.subproblems:
        if sp.group[0] == m:
            break
    else:
        raise ValueError("Could not find subproblem with m = %i" % m)
    solver.solve_dense(sp)
    # Compare eigenvalues
    n_compare = 5
    selected_eigenvalues = np.sort(solver.eigenvalues)[:n_compare]
    analytic_eigenvalues = (spec.jn_zeros(m, n_compare) / radius)**2
    assert np.allclose(selected_eigenvalues, analytic_eigenvalues)
Пример #2
0
def build_disk(Nphi, Nr, dealias, dtype):
    c = coords.PolarCoordinates('phi', 'r')
    d = distributor.Distributor((c, ))
    b = basis.DiskBasis(c, (Nphi, Nr),
                        radius=radius_disk,
                        dealias=(dealias, dealias),
                        dtype=dtype)
    phi, r = b.local_grids()
    x, y = c.cartesian(phi, r)
    return c, d, b, phi, r, x, y
Пример #3
0
def build_disk(Nphi, Nr, radius, alpha, k, dealias, dtype):
    c = coords.PolarCoordinates('phi', 'r')
    d = distributor.Distributor((c, ))
    b = basis.DiskBasis(c, (Nphi, Nr),
                        dtype=dtype,
                        radius=radius,
                        alpha=alpha,
                        k=k,
                        dealias=(dealias, dealias))
    return c, d, b
Пример #4
0
def build_disk(Nphi, Nr, radius, dealias, dtype=np.float64, grid_scale=1):
    c = coords.PolarCoordinates('phi', 'r')
    d = distributor.Distributor((c, ))
    dealias_tuple = (dealias, dealias)
    b = basis.DiskBasis(c, (Nphi, Nr),
                        radius=radius,
                        dealias=dealias_tuple,
                        dtype=dtype)
    grid_scale_tuple = (grid_scale, grid_scale)
    phi, r = b.local_grids(grid_scale_tuple)
    x, y = c.cartesian(phi, r)
    return c, d, b, phi, r, x, y
Пример #5
0
dtype = np.float64

# Parameters
radius = 1
Mmax = 31
Nmax = 31
Ampl = 1e-6
Pr = 1
Ra = 1e6
nu = np.sqrt(Pr/Ra)
kappa = nu/Pr

# Bases
c = coords.PolarCoordinates('phi', 'r')
d = distributor.Distributor((c,))
b = basis.DiskBasis(c, (Mmax+1, Nmax+1), radius=radius, dtype=dtype)
cb = b.S1_basis(radius=radius)

phi, r = b.local_grids((1, 1, 1))

# Fields
u = field.Field(dist=d, bases=(b,), tensorsig=(c,),dtype=dtype)
T = field.Field(dist=d, bases=(b,), dtype=dtype)
p = field.Field(dist=d, bases=(b,), dtype=dtype)
tau_u = field.Field(dist=d, bases=(cb,), tensorsig=(c,), dtype=dtype)
tau_T = field.Field(dist=d, bases=(cb,), dtype=dtype)

# parameters
S = field.Field(dist=d, bases=(b,), dtype=dtype)
g = field.Field(dist=d, bases=(b,), tensorsig=(c,), dtype=dtype)