def ddx_exactVeen(x): _, u = exactVeen(x) Qg = ug * Hg tmp = Qg + Mg * (x - xg) Cs = (rho * g * omega / (4.0 * Bg))**n dudx = Cs * tmp**n / u**n dHdx = (Mg * u - tmp * dudx) / u**2 return dHdx, dudx
def getsides(x): if x <= xg: H, u, _ = exactBod(x) T, B = exactBodBueler(x) dH, du = ddx_exactBod(x) LL = np.array([[(2.0/n)*B*H*du**q, 0, 0], [H, u, 0], [0, -rg*H, 1]]) RR = np.array([[0, -2.0*B*du**(1.0/n), 1], [-dH, -du, 0], [-k*rg*H, -k*rg*u+rg*dH, 0]]) else: H, u = exactVeen(x) dH, du = ddx_exactVeen(x) LL = np.array([[(2.0/n)*Bg*H*du**q, 0, 0], [H, u, 0], [0, -omega*rg*H, 1]]) RR = np.array([[0, -2.0*Bg*du**(1.0/n), 1], [-dH, -du, 0], [0, omega*rg*dH, 0]]) return LL, RR
ax2fig3.set_ylim(0.0,2.0) bbeta[x > exactsolns.xg] = 0.0 ax1fig3.plot((x-exactsolns.xa)/1000.0,bbeta/1.0e10,'k:',lw=1.5) imagename = nameroot + '-beta-T.pdf' plt.savefig(imagename) print ' image file %s saved' % imagename #plt.show() # thickness error and velocity error in figure 5 Hexact = np.zeros(np.shape(H)) uexact = np.zeros(np.shape(u)) for j in range(len(x)): if x[j] < exactsolns.xg: Hexact[j], uexact[j], _ = exactsolns.exactBod(x[j]) else: Hexact[j], uexact[j] = exactsolns.exactVeen(x[j]) fig = plt.figure(figsize=(6,5)) plt.subplot(2,1,1) plt.semilogy((x-exactsolns.xa)/1000.0,abs(H-Hexact),'k',lw=2.0) plt.semilogy((x-exactsolns.xa)/1000.0,abs(Hmid-Hexact),'k--',lw=3.0) ax1 = plt.gca() ax1.set_xlim([0.0,(xoceanend-exactsolns.xa)/1000.0]) plt.grid(True) plt.ylabel("H error (m)", fontsize=14) plt.subplot(2,1,2) plt.semilogy((x-exactsolns.xa)/1000.0,abs(u-uexact) * exactsolns.secpera,'k',lw=2.0) plt.semilogy((x-exactsolns.xa)/1000.0,abs(umid-uexact) * exactsolns.secpera,'k--',lw=3.0) ax2 = plt.gca() ax2.set_xlim([0.0,(xoceanend-exactsolns.xa)/1000.0]) ax2.set_yticks([1.0e-14,1.0e-12,1.0e-10,1.0e-8,1.0e-6,1.0e-4,1.0e-2]) plt.grid(True)