Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
    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}
Exemplo n.º 5
0
def EQBWTRCO(pref, k, dref, aI, d, nu, lequ, g):

    Rc = 170.0

    # used in solving the transmission and reflection coefficients
    ss = (pref / 0.45)**2
    nors = pref / math.sqrt(ss)
    kon = k * pref
    nkol = kon * lequ
    betar = 2.7 * ((1.0 - pref) / (pref**3 * dref))

    # guess a lambda (intermediate value) and a value for F...iterate until the
    # difference is less than 2%
    diff = 100.0
    lambdaVal = 1.0
    F = 0.0
    loopCount = 0
    while ComplexUtil.greaterThan(diff, 0.02):
        Fnew = F
        U = aI * math.sqrt(g / d) / (1.0 + lambdaVal)
        Rd = U * dref / nu
        F = pref / (k * lequ)
        F = F * (math.sqrt(1.0 + (1.0 + Rc / Rd) * (16.0 * betar * aI * lequ /
                                                    (3.0 * math.pi * d))) - 1)
        lambdaVal = k * lequ * F / (2.0 * pref)
        #calculate new lambda
        diff = abs(Fnew - F) / F

        loopCount += 1
        if loopCount > 20:
            break

    # used in solving the transmission and reflection coefficients
    fos = F / ss

    #call function MADSN1 which solves for Ti and Ri
    Ti, Ri = MADSN1(nors, fos, nkol)

    return Ti, Ri
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    def performCalculations(self, caseInputList, caseIndex = 0):
        Hmo, Tp, d = self.getCalcValues(caseInputList)
        dataDict = {"Hmo": Hmo, "Tp": Tp, "d": d}

        Htype = []
        Htype.append(0.50) #Hmed;
        Htype.append(0.66) #H1/3 (1-1/3);
        Htype.append(0.90) #H1/10 (1-1/10);
        Htype.append(0.99) #H1/100 (1-1/100);

        Hb = ERRWAVBRK1(d, 0.9)
        if Hmo >= Hb:
            self.errorMsg =\
                "Error: Input wave broken (Hb = %6.2f %s)" % (Hb, self.labelUnitDist)

            print(self.errorMsg)
            self.fileOutputWriteMain(dataDict, caseIndex)
            return

        L, k = WAVELEN(d, Tp, 50, self.g)
        steep, maxstp = ERRSTP(Hmo, d, L)
        if ComplexUtil.greaterThanEqual(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

        dterm = d/(self.g*Tp**2)
        k = 0
        sum1 = 0

        if dterm > 0.01:
            print("Input conditions indicate Rayleigh distribution")
            Hb = math.sqrt(5)*Hmo
            Hinc = Hb/10000
            sigma = Hmo/4
            Hrms = 2*math.sqrt(2)*sigma

            H = [0]
            p = [0]
            index = [0, 0, 0, 0]
            for i in range(2, 10002):
                # Rayleigh distribution
                H.append(Hinc * (i - 1))
                term1 = math.exp(-(H[i - 1]/Hrms)**2)
                term2 = (2 * H[i - 1])/Hrms**2
                p.append(term1 * term2)

                sum1 = sum1 + (p[i - 1]*Hinc)
                if k < 4 and sum1 > Htype[k]:
                    index[k] = i
                    k = k + 1

            Hout = []
            for k in range(1, 4):
                sum2 = 0
                Hstart = H[index[k]]
                Hinc = (Hb - Hstart)/10000
                pprv = p[index[k]]
                Hprv = Hstart

                for i in range(2, 10001):
                    Hnxt = Hstart + Hinc*(i - 1)
                    term1 = math.exp(-(Hnxt/Hrms)**2)
                    term2 = (2 * Hnxt)/Hrms**2
                    pnxt = term1 * term2
                    darea = 0.5*(pprv + pnxt)*Hinc # area of a trapezoid
                    sum2 = sum2 + (Hinc/2.0 + Hprv)*darea
                    pprv = pnxt
                    Hprv = Hnxt
                Hout.append(sum2 / (1 - Htype[k])) # computing centroid (areasum = 1-Htype)
        else:
            Hb = d
            Hinc = Hb / 100.0
            print("Input conditions indicate Beta-Rayleigh distribution")
            a1 = 0.00089
            b1 = 0.834
            a2 = 0.000098
            b2 = 1.208

            d1 = a1*dterm**(-b1)
            if d1 > 35.0:
                self.errorMsg = "Error: d/gT^2 approaching infinity"

                print(self.errorMsg)
                self.fileOutputWriteMain(dataDict, caseIndex)
                return

            Hrms = (1/math.sqrt(2))*math.exp(d1)*Hmo # root-mean-square wave height

            d2 = a2 * dterm**(-b2)
            if d2 > 35.0:
                self.errorMsg = "Error: d/gT^2 approaching infinity"

                print(self.errorMsg)
                self.fileOutputWriteMain(dataDict, caseIndex)
                return

            Hrmsq = (1/math.sqrt(2))*math.exp(d2)*Hmo**2 # root-mean-quad wave height

            # Computing alpha and beta
            K1 = (Hrms / Hb)**2
            K2 = (Hrmsq**2) / (Hb**4)

            alpha = (K1*(K2 - K1))/(K1**2 - K2)
            beta = ((1.0 - K1)*(K2 - K1))/(K1**2 - K2)

            term1 = (2*sp.gamma(alpha + beta))/(sp.gamma(alpha)*sp.gamma(beta))

            H = []
            p = []
            index = [0, 0, 0, 0]
            for i in range(101):
                # Beta-Rayleigh distribution
                H.append(Hinc*i)
                
                # Avoid division by zero
                try:
                    term2 = (H[i]**(2*alpha - 1))/(Hb**(2*alpha))
                except:
                    term2 = float('inf')
                
                # Avoid division by zero
                try:
                    term3 = (1.0 - (H[i]/Hb)**2)**(beta - 1.0)
                except:
                    term3 = float('inf')
                
                p.append(term1 * term2 * term3)

                sum1 = sum1 + (p[i]*Hinc)
                if k < 4 and sum1 > Htype[k]:
                    index[k] = i
                    k = k + 1

            Hout = []
            for k in range(1, 4):
                sum2 = 0
                Hstart = H[index[k]]
                Hinc = (Hb - Hstart)/20
                pprv = p[index[k]]
                Hprv = Hstart

                for i in range(1, 20):
                    Hnxt = Hstart + Hinc*i
                    term2 = (Hnxt**(2*alpha - 1))/(Hb**(2*alpha))
                    
                    # Avoid division by zero
                    try:
                        term3 = (1 - (Hnxt/Hb)**2)**(beta - 1)
                    except:
                        term3 = float('inf')
                        
                    pnxt = term1*term2*term3
                    darea = 0.5*(pprv + pnxt)*Hinc # area of a trapezoid
                    sum2 = sum2 + (Hinc/2.0 + Hprv)*darea
                    pprv = pnxt
                    Hprv = Hnxt

                Hout.append(sum2 / (1 - Htype[k])) # computing centroid (areasum = 1-Htype)

        Hmed = H[index[0]]

        print("Wave heights")
        print("Hrms\t\t%6.2f %s" % (Hrms, self.labelUnitDist))
        print("Hmed\t\t%6.2f %s" % (Hmed, self.labelUnitDist))
        print("H(1/3)\t\t%6.2f %s" % (Hout[0], self.labelUnitDist))
        print("H(1/10)\t\t%6.2f %s" % (Hout[1], self.labelUnitDist))
        print("H(1/100)\t%6.2f %s" % (Hout[2], self.labelUnitDist))

        dataDict["Hrms"] = Hrms
        dataDict["Hmed"] = Hmed
        dataDict["Hout"] = Hout
        self.fileOutputWriteMain(dataDict, caseIndex)

        if self.isSingleCase:
            self.plotDict = {"Hrms": Hrms, "Hmed": Hmed, "Hout": Hout,\
                "H": H, "p": p}