Skip to content

Commit

Permalink
Change LiftTau to Lift and add tau method documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kburns committed Feb 14, 2022
1 parent 4b0602a commit 1a1f150
Show file tree
Hide file tree
Showing 21 changed files with 282 additions and 67 deletions.
4 changes: 2 additions & 2 deletions dedalus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# Warn if threading is not disabled
import os
if os.getenv("OMP_NUM_THREADS") != "1":
logger.warn('Threading has not been disabled. This may massively degrade Dedalus performance.')
logger.warn('We strongly suggest setting the "OMP_NUM_THREADS" environment variable to "1".')
logger.warning('Threading has not been disabled. This may massively degrade Dedalus performance.')
logger.warning('We strongly suggest setting the "OMP_NUM_THREADS" environment variable to "1".')

# Set numexpr threading to match OMP_NUM_THREADS to supress warning
# Could remove pending https://github.com/pydata/numexpr/issues/344
Expand Down
10 changes: 5 additions & 5 deletions dedalus/core/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def _full_matrix(input_basis, output_basis):
return integ_vector[None, :] * input_basis.COV.stretch


class LiftJacobi(operators.LiftTau, operators.Copy):
class LiftJacobi(operators.Lift, operators.Copy):
"""Jacobi polynomial lift."""

input_basis_type = type(None)
Expand Down Expand Up @@ -4420,7 +4420,7 @@ def _radial_matrix(basis, m, spintotal, position):
return reshape_vector(basis.interpolation(m, spintotal, position), dim=2, axis=1)


class LiftTauDisk(operators.LiftTau, operators.PolarMOperator):
class LiftDisk(operators.Lift, operators.PolarMOperator):

input_basis_type = (RealFourier, ComplexFourier)
output_basis_type = DiskBasis
Expand Down Expand Up @@ -4470,7 +4470,7 @@ def radial_matrix(self, spinindex_in, spinindex_out, m):
raise ValueError("This should never happen.")


class LiftTauBall(operators.LiftTau, operators.SphericalEllOperator):
class LiftBall(operators.Lift, operators.SphericalEllOperator):

input_basis_type = SphereBasis
output_basis_type = BallBasis
Expand Down Expand Up @@ -4524,7 +4524,7 @@ def radial_matrix(self, regindex_in, regindex_out, m):
raise ValueError("This should never happen.")


class LiftTauBallRadius(operators.LiftTau, operators.SphericalEllOperator):
class LiftBallRadius(operators.Lift, operators.SphericalEllOperator):

input_basis_type = type(None)
output_basis_type = BallRadialBasis
Expand Down Expand Up @@ -4578,7 +4578,7 @@ def radial_matrix(self, regindex_in, regindex_out, m):
raise ValueError("This should never happen.")


class LiftTauShell(operators.LiftTau, operators.SphericalEllOperator):
class LiftShell(operators.Lift, operators.SphericalEllOperator):

input_basis_type = SphereBasis
output_basis_type = SphericalShellBasis
Expand Down
2 changes: 1 addition & 1 deletion dedalus/core/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def __init__(self, base_path, *args, max_writes=np.inf, max_size=2**30, parallel
last_write_num = testfile['/scales/write_number'][-1]
else:
last_write_num = 0
logger.warn("Cannot determine write num from files. Restarting count.")
logger.warning("Cannot determine write num from files. Restarting count.")
else:
max_set = 0
last_write_num = 0
Expand Down
2 changes: 1 addition & 1 deletion dedalus/core/evaluator.py.master
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class FileHandler(Handler):
last_write_num = testfile['/scales/write_number'][-1]
else:
last_write_num = 0
logger.warn("Cannot determine write num from files. Restarting count.")
logger.warning("Cannot determine write num from files. Restarting count.")
else:
max_set = 0
last_write_num = 0
Expand Down
16 changes: 12 additions & 4 deletions dedalus/core/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from inspect import isclass
from operator import add
from ..libraries import dedalus_sphere
import logging
logger = logging.getLogger(__name__.split('.')[-1])

from .domain import Domain
from . import coords
Expand Down Expand Up @@ -47,7 +49,8 @@
'Divergence',
'Curl',
'Laplacian',
'LiftTau',
'Lift',
'LiftTau', # deprecated
'AdvectiveCFL',
'SphericalEllProduct',
'UnaryGridFunction',
Expand Down Expand Up @@ -3850,9 +3853,9 @@ def _radial_matrix(radial_basis, spintotal, m):


@alias("lift")
class LiftTau(LinearOperator, metaclass=MultiClass):
class Lift(LinearOperator, metaclass=MultiClass):

name = "LiftTau"
name = "Lift"

@classmethod
def _preprocess_args(cls, operand, output_basis, n, out=None):
Expand Down Expand Up @@ -3890,7 +3893,12 @@ def __init__(self, operand, output_basis, n, out=None):
self.dtype = operand.dtype

def new_operand(self, operand, **kw):
return LiftTau(operand, self.output_basis, self.n)
return Lift(operand, self.output_basis, self.n)


def LiftTau(*args, **kw):
logger.warning("'LiftTau' is deprecated. Use 'Lift' instead.")
return Lift(*args, **kw)


"""
Expand Down
3 changes: 1 addition & 2 deletions dedalus/core/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ def get_wall_time(self):

@property
def ok(self):
import warnings
warnings.warn("solver.ok is deprecated, use solver.proceed instead")
logger.warning("'solver.ok' is deprecated. Use 'solver.proceed' instead.")
return self.proceed

@property
Expand Down
4 changes: 2 additions & 2 deletions dedalus/core/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ def _forward_disk_matrix(Ng, Nc, k0, k, m):
z_grid, weights = dedalus_sphere.disk128.quadrature(Ng-1, k=k0, niter=3)
# Get functions
Nc_max = Nc
logger.warn("No truncation")
logger.warning("No truncation")
Q = dedalus_sphere.disk128.polynomials(Nc_max-1, k=k, m=m, z=z_grid)
# Pad to square transform
Qfull = np.zeros((Nc, Ng))
Expand All @@ -1587,7 +1587,7 @@ def _backward_disk_matrix(Nc, Ng, k0, k, m):
z_grid, weights = dedalus_sphere.disk128.quadrature(Ng-1, k=k0, niter=3)
# Get functions
Nc_max = Nc
logger.warn("No truncation")
logger.warning("No truncation")
Q = dedalus_sphere.disk128.polynomials(Nc_max-1, k=k, m=m, z=z_grid)
# Pad to square transform
Qfull = np.zeros((Nc, Ng))
Expand Down
3 changes: 1 addition & 2 deletions dedalus/extras/flow_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ def __init__(self, solver, initial_dt, cadence=1, safety=1., max_dt=np.inf,
self.frequencies = self.solver.evaluator.add_dictionary_handler(iter=cadence)

def compute_dt(self):
import warnings
warnings.warn("compute_dt is deprecated, use compute_timestep instead")
logger.warning("'CFL.compute_dt' is deprecated. Use 'CFL.compute_timestep' instead.")
return self.compute_timestep()

def compute_timestep(self):
Expand Down
2 changes: 1 addition & 1 deletion dedalus/tests/test_cartesian_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def test_curl_implicit_FFC(basis, N, dealias, dtype):
c, d, b, r = basis(N, dealias, dtype)
Lz = b[2].bounds[1]
lift_basis = b[2].clone_with(a=1/2, b=1/2) # First derivative basis
lift = lambda A, n: d3.LiftTau(A, lift_basis, n)
lift = lambda A, n: d3.Lift(A, lift_basis, n)
integ = lambda A: d3.Integrate(d3.Integrate(d3.Integrate(A,c.coords[0]),c.coords[1]),c.coords[2])
tau1 = d.VectorField(c, name='tau1', bases=b[0:2])
tau2 = d.Field(name='tau2', bases=b[0:2])
Expand Down
12 changes: 6 additions & 6 deletions dedalus/tests/test_evp.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ def test_disk_bessel_zeros(Nphi, Nr, m, radius, dtype):
k2 = field.Field(name='k2', dist=d, dtype=dtype)
# Parameters and operators
lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
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) + LiftTau(τ_f), 0))
problem.add_equation((k2*f + lap(f) + Lift(τ_f), 0))
problem.add_equation((f(r=radius), 0))
# Solver
solver = solvers.EigenvalueSolver(problem)
Expand Down Expand Up @@ -170,10 +170,10 @@ def test_ball_bessel_eigenfunction(Lmax, Nmax, Leig, Neig, radius, dtype):
k2 = field.Field(name='k2', dist=d, dtype=dtype)
# Parameters and operators
lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
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) + LiftTau(τ_f), 0))
problem.add_equation((k2*f + lap(f) + Lift(τ_f), 0))
problem.add_equation((f(r=radius), 0))
# Solver
solver = solvers.EigenvalueSolver(problem)
Expand Down Expand Up @@ -222,11 +222,11 @@ def test_ball_diffusion(Lmax, Nmax, Leig, radius, bc, dtype):
trans = lambda A: operators.TransposeComponents(A)
radial = lambda A, index: operators.RadialComponent(A, index=index)
angular = lambda A, index: operators.AngularComponent(A, index=index)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
# Problem
problem = problems.EVP([φ,A,τ_A], λ)
problem.add_equation((div(A), 0))
problem.add_equation((-λ*A + grad(φ) - lap(A) + LiftTau(τ_A), 0))
problem.add_equation((-λ*A + grad(φ) - lap(A) + Lift(τ_A), 0))
if bc == 'no-slip':
problem.add_equation((A(r=radius), 0))
elif bc == 'stress-free':
Expand Down
7 changes: 3 additions & 4 deletions dedalus/tests/test_ivp.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def test_mag_BC(N, dtype):
A = d.VectorField(c, name='A', bases=b)
Phi = d.Field(name='Phi', bases=b)
tau_A = d.VectorField(c, name='A_tau', bases=b.S2_basis())
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
# Problem
problem = problems.IVP([A, Phi, tau_A], namespace=locals())
problem.add_equation("div(A) = 0")
problem.add_equation("dt(A) - grad(Phi) - lap(A) + LiftTau(tau_A) = 0")
problem.add_equation("dt(A) - grad(Phi) - lap(A) + Lift(tau_A) = 0")
problem.add_equation("angular(A(r=1), index=0) = 0")
problem.add_equation("Phi(r=1) = 0")
# Solver
Expand Down Expand Up @@ -154,8 +154,7 @@ def test_flow_tools_cfl(x_basis_class, Nx, Nz, timestepper, dtype, safety, z_vel
u['g'][1] = chebyshev_velocity(z)
solver.step(dt)
solver.step(dt) #need two timesteps to get past stored_dt per compute_timestep logic
dt = cfl.compute_dt()

dt = cfl.compute_timestep()
op = operators.AdvectiveCFL(u, c)
cfl_freq = np.abs(u['g'][0] / op.cfl_spacing(u)[0] )
cfl_freq += np.abs(u['g'][1] / op.cfl_spacing(u)[1] )
Expand Down
38 changes: 19 additions & 19 deletions dedalus/tests/test_lbvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_poisson_1d_jacobi(Nx, a0, b0, da, db, dtype):
# Substitutions
dx = lambda A: d3.Differentiate(A, coord)
lift_basis = basis.clone_with(a=a0+da+2, b=b0+db+2)
lift = lambda A, n: d3.LiftTau(A, lift_basis, n)
lift = lambda A, n: d3.Lift(A, lift_basis, n)
F = dist.Field(bases=basis)
F['g'] = -np.sin(x)
# Problem
Expand Down Expand Up @@ -106,9 +106,9 @@ def test_scalar_heat_disk_axisymm(Nr, Nphi, dtype):
F['g'] = 4
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), F))
problem.add_equation((Lap(u) + Lift(τu), F))
problem.add_equation((u(r=radius_disk), 0))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand Down Expand Up @@ -136,9 +136,9 @@ def test_scalar_heat_disk(Nr, Nphi, dtype):
g['g'] = xr**3 - yr**2
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), f))
problem.add_equation((Lap(u) + Lift(τu), f))
problem.add_equation((u(r=radius_disk), g))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand Down Expand Up @@ -166,9 +166,9 @@ def test_vector_heat_disk_dirichlet(Nr, Nphi, dtype):
vph= operators.AzimuthalComponent(v(r=radius_disk))
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), 0))
problem.add_equation((Lap(u) + Lift(τu), 0))
problem.add_equation((u(r=radius_disk), v(r=radius_disk)))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand All @@ -194,9 +194,9 @@ def test_vector_heat_disk_components(Nr, Nphi, dtype):
vph= operators.AzimuthalComponent(v(r=radius_disk))
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), 0))
problem.add_equation((Lap(u) + Lift(τu), 0))
problem.add_equation((operators.RadialComponent(u(r=radius_disk)), vr))
problem.add_equation((operators.AzimuthalComponent(u(r=radius_disk)), vph))
# Solver
Expand Down Expand Up @@ -233,9 +233,9 @@ def test_heat_ball(Nmax, Lmax, dtype):
F['g'] = 6
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), F))
problem.add_equation((Lap(u) + Lift(τu), F))
problem.add_equation((u(r=radius_ball), 0))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand Down Expand Up @@ -264,9 +264,9 @@ def test_heat_ball_cart(Nmax, Lmax, dtype):
g['g'] = xr**4 - yr**3 + zr**2
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((Lap(u) + LiftTau(τu), f))
problem.add_equation((Lap(u) + Lift(τu), f))
problem.add_equation((u(r=radius_ball), g))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand Down Expand Up @@ -305,9 +305,9 @@ def test_heat_shell(Nmax, Lmax, dtype):
F['g'] = 6
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A, n: operators.LiftTau(A, b, n)
Lift = lambda A, n: operators.Lift(A, b, n)
problem = problems.LBVP([u, τu1, τu2])
problem.add_equation((Lap(u) + LiftTau(τu1,-1) + LiftTau(τu2,-2), F))
problem.add_equation((Lap(u) + Lift(τu1,-1) + Lift(τu2,-2), F))
problem.add_equation((u(r=r0), 0))
problem.add_equation((u(r=r1), 0))
# Solver
Expand Down Expand Up @@ -373,9 +373,9 @@ def test_heat_ncc_shell(Nmax, Lmax, ncc_exponent, ncc_location, ncc_scale, dtype
ncc['g'] # force transform
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A, n: operators.LiftTau(A, b, n)
Lift = lambda A, n: operators.Lift(A, b, n)
problem = problems.LBVP([u, τu1, τu2])
problem.add_equation((ncc*Lap(u) + LiftTau(τu1,-1) + LiftTau(τu2,-2), F))
problem.add_equation((ncc*Lap(u) + Lift(τu1,-1) + Lift(τu2,-2), F))
problem.add_equation((u(r=r0), 0))
problem.add_equation((u(r=r1), 0))
# Solver
Expand Down Expand Up @@ -407,9 +407,9 @@ def test_heat_ncc_cos_ball(Nmax, Lmax, ncc_scale, dtype):
ncc['g'] # force transform
# Problem
Lap = lambda A: operators.Laplacian(A, c)
LiftTau = lambda A: operators.LiftTau(A, b, -1)
Lift = lambda A: operators.Lift(A, b, -1)
problem = problems.LBVP([u, τu])
problem.add_equation((ncc*Lap(u) + LiftTau(τu), F))
problem.add_equation((ncc*Lap(u) + Lift(τu), F))
problem.add_equation((u(r=radius_ball), 0))
# Solver
solver = solvers.LinearBoundaryValueSolver(problem)
Expand Down

0 comments on commit 1a1f150

Please sign in to comment.