from pathlib import Path import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt def elliptic_ke_from_complement(b): # b=sqrt(1-k^2), evaluated geometrically without cancellation near a ring. a=np.ones_like(b) total=(1-b*b)/2 weight=1. for _ in range(18): c=(a-b)/2 total=total+weight*c*c a,b=(a+b)/2,np.sqrt(a*b) weight*=2 K=np.pi/(2*a) E=K*(1-total) return K,E def disk_speed_squared(r,sigma0,rt,nodes,weights): if r==0:return 0. if r==rt:return np.nan if r