"""Evaluate the series solution V (constant data V0=1 on nu=0, V=0 on mu=6) and the single-mode solution.""" import sys, json from pathlib import Path import numpy as np HERE = Path(__file__).resolve().parent if "__file__" in globals() else Path.cwd() sys.path.insert(0, str(HERE)) from pbvp import * class Series: def __init__(self, fname=None, qmax=np.inf): if fname is None: fname = HERE / "series_Q240.json" d = [o for o in json.load(open(fname)) if o["q"] <= qmax] self.info = d self.modes = [Mode(o["n2"], o["q"]) for o in d] self.coef = np.array([o["coef"] for o in d]) def V_coords(self, mu, nu, la): mu, nu, la = np.broadcast_arrays(*map(np.asarray, (mu, nu, la))) out = np.zeros(mu.shape) for cf, M in zip(self.coef, self.modes): out = out + cf*M.V(mu, nu, la) return out def V(self, x, y, z): return self.V_coords(*coords(x, y, z)) def inside(x, y, z): mu, nu, la = coords(x, y, z) return (nu > nu0) & (mu < mu0) class SingleMode: """V = u_00 / u_00(origin): data on nu=0 is Ce_0(alpha,q00)ce_0(beta,q00) normalized to 1 at the vertex z=0.""" def __init__(self, q00): self.M = Mode(0, q00) self.norm = float(self.M.V(np.array(b), np.array(nu0), np.array(c))) # origin: mu=b, nu=0, lambda=c def V(self, x, y, z): return self.M.V(*coords(x, y, z))/self.norm