import math def layerxt(p, h, utop, ubot): # returns [dx, dt, irtr] if p >= utop: return [0.0, 0.0, 0] elif h==0: return [0.0, 0.0, -1] else: b = 1.0/(ubot*h) - 1.0/(utop*h) def eta(u): return math.sqrt(u**2-p**2) def x(u): return eta(u)/(u*b*p) def t(u): return (math.log((u+eta(u))/p))/b if utop == ubot: return [h*p/eta(utop), h*utop**2/eta(utop), 1 ] elif p>=ubot: return [x(utop), t(utop), 2] else: return [x(utop) - x(ubot), t(utop)-t(ubot), 1]