Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended precision polynomial construction #194

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 55 additions & 44 deletions dedalus/core/basis.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dedalus/core/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,14 +2858,14 @@ def radial_matrix(self, spinindex_in, spinindex_out, m):
radial_basis = self.input_basis
spintotal = radial_basis.spintotal(spinindex_in)
if spinindex_out in self.spinindex_out(spinindex_in):
return self._radial_matrix(radial_basis.Lmax, spintotal, m, self.dtype)
return self._radial_matrix(radial_basis.Lmax, spintotal, m)
else:
raise ValueError("This should never happen")

@staticmethod
@CachedMethod
def _radial_matrix(Lmax, spintotal, m, dtype):
matrix = dedalus_sphere.sphere.operator('Cos', dtype)(Lmax, m, spintotal).square
def _radial_matrix(Lmax, spintotal, m):
matrix = dedalus_sphere.sphere.operator('Cos')(Lmax, m, spintotal).square
# Pad to include invalid ells
trunc = abs(spintotal) - abs(m)
if trunc > 0:
Expand Down
1 change: 0 additions & 1 deletion dedalus/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np

from ..tools import jacobi
from ..tools.array import reshape_vector
from ..tools.cache import CachedMethod, CachedAttribute

Expand Down
258 changes: 229 additions & 29 deletions dedalus/core/transforms.py

Large diffs are not rendered by default.

85 changes: 48 additions & 37 deletions dedalus/libraries/dedalus_sphere/annulus.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
import numpy as np
import numpy as np
from . import jacobi

# The defalut configurations for the base Jacobi parameters.
alpha = (-0.5,-0.5)
alpha = (-0.5, -0.5)

def quadrature(Nmax,alpha=alpha,**kw):
return jacobi.quadrature(Nmax,alpha[0],alpha[1],**kw)

def trial_functions(Nmax,z,alpha=alpha):
def quadrature(Nmax, alpha=alpha, **kw):
return jacobi.quadrature(Nmax, alpha[0], alpha[1], **kw)

init = 1/np.sqrt(jacobi.mass(alpha[0],alpha[1])) + 0*z
return jacobi.recursion(Nmax,alpha[0],alpha[1],z,init)

def operator(dimension,op,Nmax,k,ell,radii,pad=0,alpha=alpha):
def trial_functions(Nmax, z, alpha=alpha):

init = 1 / np.sqrt(jacobi.mass(alpha[0], alpha[1])) + 0 * z
return jacobi.recursion(Nmax, alpha[0], alpha[1], z, init)


def operator(dimension, op, Nmax, k, ell, radii, pad=0, alpha=alpha):
# Pad the matrices by a safe amount before outputting the correct size.

if radii[1] <= radii[0]: raise ValueError('Inner radius must be greater than outer radius.')

gapwidth = radii[1] - radii[0]
aspectratio = (radii[1] + radii[0])/gapwidth

a, b, N = k+alpha[0], k+alpha[1], Nmax + pad


if radii[1] <= radii[0]:
raise ValueError('Inner radius must be greater than outer radius.')

gapwidth = radii[1] - radii[0]
aspectratio = (radii[1] + radii[0]) / gapwidth

a, b, N = k + alpha[0], k + alpha[1], Nmax + pad

# zeros
if (op == '0'): return jacobi.operator('0',N,a,b)

if op == '0':
return jacobi.operator('0', N, a, b)

# identity
if (op == 'I'): return jacobi.operator('I',N,a,b)

Z = aspectratio*jacobi.operator('I',N+2,a,b)
Z += jacobi.operator('J',N+2,a,b)

if op == 'I':
return jacobi.operator('I', N, a, b)

Z = aspectratio * jacobi.operator('I', N + 2, a, b)
Z += jacobi.operator('J', N + 2, a, b)

# r multiplication
if op == 'R': return (gapwidth/2)*Z[:N+1,:N+1]

E = jacobi.operator('A+',N+2,a,b+1) @ jacobi.operator('B+',N+2,a,b)

if op == 'R':
return (gapwidth / 2) * Z[: N + 1, : N + 1]

E = jacobi.operator('A+', N + 2, a, b + 1) @ jacobi.operator('B+', N + 2, a, b)

# conversion
if op == 'E': return 0.5*(E @ Z)[:N+1,:N+1]

D = jacobi.operator('D+',N+2,a,b) @ Z

if op == 'E':
return 0.5 * (E @ Z)[: N + 1, : N + 1]

D = jacobi.operator('D+', N + 2, a, b) @ Z

# derivatives
if op == 'D+': return (D - (ell+k+1 )*E)[:N+1,:N+1]/gapwidth
if op == 'D-': return (D + (ell-k+dimension-3)*E)[:N+1,:N+1]/gapwidth

# restriction
if op == 'r=Ri': return jacobi.operator('z=-1',N,a,b)
if op == 'r=Ro': return jacobi.operator('z=+1',N,a,b)
if op == 'D+':
return (D - (ell + k + 1) * E)[: N + 1, : N + 1] / gapwidth
if op == 'D-':
return (D + (ell - k + dimension - 3) * E)[: N + 1, : N + 1] / gapwidth

# restriction
if op == 'r=Ri':
return jacobi.operator('z=-1', N, a, b)
if op == 'r=Ro':
return jacobi.operator('z=+1', N, a, b)
Loading