def LWTDWS(alpha, c, cg, c0, H): alpha0 = None H0 = None errorMsg = None deg2rad = math.pi / 180.0 arg = (c0 / c) * cmath.sin(alpha * deg2rad) if ComplexUtil.greaterThanEqual(arg, 1): errorMsg = "Error: Violation of assumptions for Snells Law" return alpha0, H0, errorMsg alpha0 = (cmath.asin(arg)) / deg2rad ksf = cmath.sqrt(c0 / (2 * cg)) # shoaling coefficient alphaCos = cmath.cos(alpha0 * deg2rad) / cmath.cos(alpha * deg2rad) if ComplexUtil.lessThan(alphaCos, 0): errorMsg = "Error: Alpha1 data out of range" return alpha0, H0, errorMsg krf = cmath.sqrt(alphaCos) # refraction coefficient H0 = H / (ksf * krf) return alpha0, H0, errorMsg
def MADSN2(lsub, phi, k): L = (2.0*math.pi)/k lsol = lsub/L fb = math.tan(2.0*phi) c1 = 2.0*k*lsub c2 = cmath.sqrt(complex(1.0, -fb)) arg = complex(c1, 0.0)*c2 J0 = sp.jv(0.0, arg) J1 = sp.jv(1.0, arg) c3 = (complex(0.0, 1.0)/c2)*J1 denom = J0 + c3 psi = complex(c1/2.0, 0.0)*c2 req = ((J0 - c3)/denom)*cmath.exp(complex(0.0, c1)) R = abs(req) rueq = cmath.exp(complex(0.0, c1/2.0))/denom Ru = abs(rueq) if ComplexUtil.lessThan(lsol, 0.05): fsc = 0.84242 else: topint, err = integrate.quad(integrandTop, 0.0, 1.0, args=(psi)) botint, err = integrate.quad(integrandBottom, 0.0, 1.0, args=(psi)) fsc = (4.0/(3.0*math.pi))*(topint/botint) return R, Ru, fsc
def LWTTWM(cg, h, H, L, reldep, rho, g, k): E = (1.0 / 8.0) * rho * g * (H**2) P = E * cg Ur = (H * (L**2)) / (h**3) # if reldep < 0.5 or (isinstance(reldep, complex) and abs(reldep) < 0.5): if ComplexUtil.lessThan(reldep, 0.5): setdown = (k * H**2) / (8.0 * cmath.sinh(2 * k * h)) else: setdown = 0 return E, P, Ur, setdown
def performCalculations(self, caseInputList, caseIndex=0): d, Hi, T, chi, cotphi = self.getCalcValues(caseInputList) dataDict = {"d": d, "Hi": Hi, "T": T, "chi": chi, "cotphi": cotphi} H20weight = self.rho * self.g m = 1.0 / cotphi if np.isclose(m, 0.0): Hbs = ERRWAVBRK1(d, 0.78) else: Hbs = ERRWAVBRK2(T, m, d) if not (Hi < Hbs): self.errorMsg = "Error: Wave broken at structure (Hbs = %6.2f %s)" %\ (Hbs, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return L, k = WAVELEN(d, T, 50, self.g) steep, maxstp = ERRSTP(Hi, d, L) # assert(steep<maxstp,'Error: Input wave unstable (Max: %0.4f, [H/L] = %0.4f)',maxstp,steep') if not ComplexUtil.lessThan(steep, maxstp): self.errorMsg = "Error: Input wave unstable (Max: %0.4f, [H/L] = %0.4f)" %\ (maxstp.real, steep.real) MR, S, MRintc, MRintt, Sintc, Sintt = WFVW1(d, Hi, chi, L, H20weight) print('\n\t\t\t\t %s \t\t %s' % ('Miche-Rundgren', 'Sainflou')) print( "Wave Position at Wall\t\tCrest\t\tTrough\t\tCrest\t\tTrough\t\tUnits" ) print("Hgt above bottom \t\t %-6.2f \t %6.2f \t %-6.2f \t %6.2f \t %s" %\ (MR[0].real, MR[3].real, S[0].real, S[3].real, self.labelUnitDist)) print("Integrated force \t\t %-6.2f \t %6.2f \t %-6.2f \t %6.2f \t %s/%s" %\ (MR[1].real, MR[4].real, S[1].real, S[4].real, self.labelUnitWt, self.labelUnitDist)) print("Integrated moment \t\t %-6.2f \t %6.2f \t %-6.2f \t %6.2f \t %s-%s/%s" %\ (MR[2].real, MR[5].real, S[2].real, S[5].real, self.labelUnitWt, self.labelUnitDist, self.labelUnitDist)) dataDict.update({"MR": MR, "S": S}) self.fileOutputWriteMain(dataDict, caseIndex) if self.isSingleCase: self.plotDict = {"MRintc": MRintc, "MRintt": MRintt,\ "Sintc": Sintc, "Sintt": Sintt}
def performCalculations(self, caseInputList, caseIndex=0): H, T, ds, cotphi, Kp, de, ht, unitwt =\ self.getCalcValues(caseInputList) dataDict = {"H": H, "T": T, "ds": ds, "cotphi": cotphi,\ "Kp": Kp, "de": de, "ht": ht, "unitwt": unitwt} H20weight = self.g * self.rho specgrav = unitwt / H20weight dl = ds - ht m = 1.0 / cotphi if not (ds / (T**2) > 0.0037424): self.errorMsg = "Error: Limiting value detected...Hbs cannot be solved." print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return Hbs = ERRWAVBRK2(T, m, ds) if not (H < Hbs): self.errorMsg = "Error: Wave broken at structure (Hbs = %6.2f %s)" %\ (Hbs, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return L, k = WAVELEN(dl, T, 50, self.g) steep, maxstp = ERRSTP(H, dl, L) if not ComplexUtil.lessThan(steep, maxstp): self.errorMsg = "Error: Input wave unstable (Max: %0.4f, [H/L] = %0.4f)" %\ (maxstp.real, steep.real) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return b1 = de * Kp b2 = 2.0 * H b3 = 0.4 * ds b = [1.0, b1, b2, b3] b = max(b) arg1 = (4.0 * math.pi * dl / L) kappa = (arg1 / cmath.sinh(arg1)) * ( (cmath.sin(2.0 * math.pi * b / L))**2) arg2 = ((1.0 - kappa) / (kappa**(1.0 / 3.0))) * (dl / H) Ns = 1.3 * arg2 + 1.8 * cmath.exp(-1.5 * (1.0 - kappa) * arg2) # Ns = max(Ns, 1.8) if ComplexUtil.getCompVal(Ns) < 1.8: Ns = 1.8 w = (unitwt * (H**3)) / ((Ns**3) * ((specgrav - 1.0)**3)) print("\nWidth of toe apron\t\t%6.2f %s" %\ (b, self.labelUnitDist)) print("Weight of individual armor unit\t%6.2f %s" %\ (w.real, self.labelUnitWt)) print("Water depth at top of tow\t%6.2f %s" %\ (dl, self.labelUnitDist)) dataDict.update({"b": b, "w": w, "dl": dl}) self.fileOutputWriteMain(dataDict, caseIndex)
def WFVW1(d, H, x, L, ww): N = 90 #Pressure values included hydrostatic pressure ycm, ytm, pcm, ptm, mcm, mtm = WFVW2(N, d, L, H, x, ww, 0) ycs, yts, pcs, pts, mcs, mts = WFVW2(N, d, L, H, x, ww, 1) ycrm = ycm[N] + d ycrs = ycrm # Crest at Wall # Integrate for Miche-Rundgren force value fcrm = WFVW3(N, ycm, pcm) # Integrate for Sainflou force value fcrs = WFVW3(N, ycs, pcs) # Integrate for Miche-Rundgren moment value mcrm = WFVW3(N, ycm, mcm) # Integrate for Sainfluo moment value mcrs = WFVW3(N, ycs, mcs) # Trough at Wall ytrm = ytm[N] + d ytrs = ytrm # Integrate for Miche-Rundgren force value ftrm = WFVW3(N, ytm, ptm) #Integrate for Sainflou force value ftrs = WFVW3(N, yts, pts) #Integrate for Miche-Rundgren moment value mtrm = WFVW3(N, ytm, mtm) #Integrate for Sainfluo moment value mtrs = WFVW3(N, yts, mts) if ComplexUtil.lessThan(fcrm, fcrs) and\ ComplexUtil.lessThan(mcrm, mcrs): #Equation delivering lowest result should be used in design print('Miche-Rundgren is recommendend for this case.') else: print('Sainflou is recommended for this case.') MR = [ycrm, fcrm, mcrm, ytrm, ftrm, mtrm] S = [ycrs, fcrs, mcrs, ytrs, ftrs, mtrs] #Seperates wave pressure and hydrostatic pressure hpcm, wpcm = WFVW4(N, ycm, pcm, ww) hptm, wptm = WFVW4(N, ytm, ptm, ww) hpcs, wpcs = WFVW4(N, ycs, pcs, ww) hpts, wpts = WFVW4(N, yts, pts, ww) MRintc = [ycm, wpcm, hpcm, pcm, mcm] MRintt = [ytm, wptm, hptm, ptm, mtm] Sintc = [ycs, wpcs, hpcs, pcs, mcs] Sintt = [yts, wpts, hpts, pts, mts] return MR, S, MRintc, MRintt, Sintc, Sintt
def performCalculations(self, caseInputList, caseIndex = 0): H1, T, d1, alpha1, cotphi, d2 =\ self.getCalcValues(caseInputList) dataDict = {"H1": H1, "T": T, "d1": d1, "alpha1": alpha1,\ "cotphi": cotphi, "d2": d2} m = 1.0 / cotphi Hb = ERRWAVBRK1(d1, 0.78) if not (H1 < Hb): self.errorMsg = "Error: Known wave broken (Hb = %6.2f %s)" %\ (Hb, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return #determine known wave properties c1, c0, cg1, cg0, k1, L1, L0, reldep1 = LWTGEN(d1, T, self.g) E1, P1, Ur1, setdown1 = LWTTWM(cg1, d1, H1, L1, reldep1, self.rho, self.g, k1) steep, maxstp = ERRSTP(H1, d1, L1) if not ComplexUtil.lessThan(steep, maxstp): self.errorMsg = "Error: Known wave unstable (Max: %0.4f, [H/L] = %0.4f)" %\ (maxstp.real, steep.real) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return #determine deepwater wave properties alpha0, H0, self.errorMsg = LWTDWS(alpha1, c1, cg1, c0, H1) if self.errorMsg != None: print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return E0 = (1.0/8.0)*self.rho*self.g*(H0**2) P0 = E0*cg0 HL = H0/L0 if not ComplexUtil.lessThan(HL, (1.0/7.0)): self.errorMsg = "Error: Deepwater wave unstable, [H0/L0] > (1/7)" print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return #determine subject wave properties c2, c0, cg2, cg0, k2, L2, L0, reldep2 = LWTGEN(d2, T, self.g) alpha2, H2, kr, ks = LWTTWS(alpha0, c2, cg2, c0, H0) E2, P2, Ur2, sedown2 = LWTTWM(cg2, d2, H2, L2, reldep2, self.rho, self.g, k2) Hb, db = ERRWAVBRK3(H0, L0, T, m) if not ComplexUtil.lessThan(H2, Hb): self.errorMsg = "Error: Subject wave broken (Hb = %6.2f %s, hb = %6.2f %s)" %\ (Hb.real, self.labelUnitDist, db.real, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return steep, maxstp = ERRSTP(H2, d2, L2) if not ComplexUtil.lessThan(steep, maxstp): self.errorMsg = "Error: Subject wave unstable (Max: %0.4f, [H/L] = %0.4f)" %\ (maxstp.real, steep.real) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return print("\t\t\tKnown\t\tDeepwater\t\tSubject\t\tUnits") print("Wave height\t\t%-5.2f\t\t%-5.2f\t\t\t%-5.2f\t\t%s" %\ (H1, H0.real, H2.real, self.labelUnitDist)) print("Wave crest angle\t%-5.2f\t\t%-5.2f\t\t\t%-5.2f\t\tdeg" %\ (alpha1, alpha0.real, alpha2.real)) print("Wavelength\t\t%-5.2f\t\t%-5.2f\t\t\t%-5.2f\t\t%s" %\ (L1.real, L0.real, L2.real, self.labelUnitDist)) print("Celerity\t\t%-5.2f\t\t%-5.2f\t\t\t%-5.2f\t\t%s/s" %\ (c1.real, c0.real, c2.real, self.labelUnitDist)) print("Group speed\t\t%-5.2f\t\t%-5.2f\t\t\t%-5.2f\t\t%s/s" %\ (cg1.real, cg0.real, cg2.real, self.labelUnitDist)) print("Energy density\t\t%-8.2f\t%-8.2f\t\t%-8.2f\t%s-%s/%s^2" %\ (E1.real, E0.real, E2.real, self.labelUnitDist, self.labelUnitWt, self.labelUnitDist)) print("Energy flux\t\t%-8.2f\t%-8.2f\t\t%-8.2f\t%s-%s/sec-%s" %\ (P1.real, P0.real, P2.real, self.labelUnitDist, self.labelUnitWt, self.labelUnitDist)) print("Ursell number\t\t%-5.2f\t\t\t\t\t%-5.2f" % (Ur1.real, Ur2.real)) print("Wave steepness\t\t\t\t%-5.2f" % HL.real) print("\nBreaking Parameters") print("Breaking height\t\t%-5.2f %s" % (Hb.real, self.labelUnitDist)) print("Breaking depth\t\t%-5.2f %s" % (db.real, self.labelUnitDist)) dataDict.update({"H0": H0, "H2": H2,\ "alpha0": alpha0, "alpha2": alpha2, "L1": L1,\ "L0": L0, "L2": L2, "c1": c1, "c0": c0, "c2": c2,\ "cg1": cg1, "cg0": cg0, "cg2": cg2, "E1": E1, "E0": E0,\ "E2": E2, "P1": P1, "P0": P0, "P2": P2, "Ur1": Ur1,\ "Ur2": Ur2, "HL": HL, "Hb": Hb, "db": db}) self.fileOutputWriteMain(dataDict, caseIndex)
def performCalculations(self, caseInputList, caseIndex=0): H, T, ds, d50, por, hs, cottheta, b, th, hlen =\ self.getCalcValues(caseInputList) dataDict = {"H": H, "T": T, "ds": ds, "d50": d50, "por": por,\ "hs": hs, "cottheta": cottheta, "b": b, "th": th,\ "hlen": hlen} if not self.isMetric: if self.water == "S" or self.water == "s": nu = 14.643223710**(-6) #salt water else: nu = 0.0000141 #ft^2/s KINEMATIC VISCOSITY OF THE WATER AT 50 DEGREES FAHRENHEIT else: if self.water == "S" or self.water == "s": nu = 1.3604 * 10**(-6) # salt water else: nu = 1.307 * 10**(-6) # m^2/s fresh Hb = ERRWAVBRK1(ds, 0.78) if not (H < Hb): self.errorMsg = "Error: Input wave broken (Hb = %6.2f %s)" % ( Hb, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return Hbs = ERRWAVBRK2(T, 1.0 / cottheta, ds) if not (H < Hbs): self.errorMsg = "Error: Input wave breaking at toe of the structure (Hbs = %6.2f %s)" % ( Hbs, self.labelUnitDist) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return L, k = WAVELEN(ds, T, 50, self.g) steep, maxstp = ERRSTP(H, ds, L) if not ComplexUtil.lessThan(steep, maxstp): self.errorMsg = "Error: Input wave unstable (Max: %0.4f, [H/L] = %0.4f)" %\ (ComplexUtil.getDisplayVal(maxstp), ComplexUtil.getDisplayVal(steep)) print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return if not (ds < hs): self.errorMsg = "Error: Method does not apply to submerged structures." print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return if not (np.isclose(sum(th), ds)): self.errorMsg = "Error: Water depth must equal sum of all layer thicknesses." print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return KTt, Kto, KT, Kr, Ht, L, self.errorMsg = MADSEELG(\ H, T, ds, hs, b, self.NL, th, hlen, self.NM, d50, por, cottheta, nu, self.g) if self.errorMsg != None: print(self.errorMsg) self.fileOutputWriteMain(dataDict, caseIndex) return print("Reflection coefficient, Kr\t\t%-6.3f" % Kr) print("Wave transmission coefficient") print("Wave Transmission (Through), KTt\t%-6.3f" % KTt) print("Wave Transmission (Overtopping), KTo\t%-6.3f" % Kto) print("Wave Transmission (Total), KT\t\t%-6.3f" % KT) print("Transmitted wave height, Ht\t\t%-6.2f %s" % (Ht, self.labelUnitDist)) dataDict.update({"Kr": Kr, "KTt": KTt, "Kto": Kto, "KT": KT, "Ht": Ht}) self.fileOutputWriteMain(dataDict)