Indexed text attachment
verify-pde.py
Source for Partial Differential Equations in Higher Categories
View paper · Download original file
Lines 1601–1640 of 1640. Source text is displayed literally.
1601 1602def ellK(m):1603 a, b = 1.0, math.sqrt(1 - m * m)1604 for _ in range(40):1605 a, b = 0.5 * (a + b), math.sqrt(a * b)1606 return PI / (2 * a)1607 1608 1609lb = 2.01610okb, lams = True, []1611for Amp in (0.2, 1.0, 2.0):1612 lam = (2 * ellK(math.sin(Amp / 2)) / lb) ** 21613 y = [Amp, 0.0]1614 for _ in range(4000):1615 y = rk4(lambda yy: [yy[1], -lam * math.sin(yy[0])], y, lb / 4000)1616 okb = okb and abs(y[1]) < 1e-8 and abs(y[0] + Amp) < 1e-81617 lams.append(lam / (PI / lb) ** 2)1618check('X9 buckling, u\'\' + lambda sin u = 0 with u\' = 0 at both ends: the first branch leaves the trivial solution at lambda = pi^2/l^2 and bends'1619 ' to the right, with lambda/lambda_1 = (2K(sin(A/2))/pi)^2 = 1 + A^2/8 + ...', okb and lams[0] < lams[1] < lams[2] and abs(lams[0] - 1 - 0.2 ** 2 / 8) < 1e-4,1620 'lambda/lambda_1 at amplitude 0.2, 1, 2: %.5f, %.5f, %.5f' % tuple(lams))1621gg, hh = 9.81, 3.01622 1623 1624def ww(kk):1625 om_ = math.sqrt(gg * kk * math.tanh(kk * hh))1626 pot = lambda x, z, t: math.cosh(kk * (z + hh)) * math.sin(kk * x - om_ * t)1627 harm = d2(lambda x: pot(x, -0.7, 0.3), 0.4) + d2(lambda z: pot(0.4, z, 0.3), -0.7)1628 surf = d2(lambda t: pot(0.4, 0.0, t), 0.3) + gg * d1(lambda z: pot(0.4, z, 0.3), 0.0)1629 bott = d1(lambda z: pot(0.4, z, 0.3), -hh)1630 return max(abs(harm), abs(surf), abs(bott)) / math.cosh(kk * hh), om_ / kk1631 1632 1633r1_, cmid = ww(0.9)1634cshal, cdeep = math.sqrt(gg * math.tanh(0.003 * hh) / 0.003), math.sqrt(gg * math.tanh(20.0 * hh) / 20.0)1635check('X10 linear water waves: the potential cosh(k(z+h)) sin(kx - omega t) is harmonic, has no flow through the bottom, and satisfies the surface'1636 ' condition exactly when omega^2 = g k tanh(kh); the speed is sqrt(gh) in shallow water and sqrt(g/k) in deep water',1637 r1_ < 1e-5 and abs(cshal - math.sqrt(gg * hh)) < 1e-3 and abs(cdeep - math.sqrt(gg / 20.0)) < 1e-12)1638 1639footer()1640