"""Trapped note in a pipe: lowest antisymmetric eigenvalue for a thin plate on the centreline. Channel -1= nx: d += 2; continue # u=0 at x=L (ghost -u) if jj >= ny: continue # hard wall y=1 if jj < 0: if x < a: continue # plate: hard d += 2; continue # odd across y=0 rows.append(p); cols.append(idx(ii, jj)); vals.append(-1.0); d += 1 rows.append(p); cols.append(p); vals.append(d) A = sp.csr_matrix((vals, (rows, cols)), shape=(N, N)) / h**2 w = sl.eigsh(A, k=1, sigma=0, which='LM', return_eigenvectors=False) return float(np.sqrt(w[0])) if __name__ == '__main__': # writes data/trapped.json: python3 code/trapped.py data/trapped.json out = {} for a in (0.5, 1.0, 2.0): k1, k2, k3 = (trapped_k(a, h) for h in (0.05, 0.025, 0.0125)) out[str(a)] = {'h0.05': round(k1, 5), 'h0.025': round(k2, 5), 'h0.0125': round(k3, 5), 'extrapolated': round(2 * k3 - k2, 4)} json.dump({'note': 'k for half-width 1; cutoff pi/2. From code/trapped.py (cell-centred FD, eigsh). extrapolated = 2*k(h/2)-k(h), assuming error ~h.', 'cutoff': 1.5708, 'plates': out}, open(sys.argv[1] if len(sys.argv) > 1 else 'trapped.json', 'w'), indent=1)