def parametricReserve(mu,sigma):
    coefficients = [0.5, 0, 1.5, -mu/sigma]
    zeros = roots(coefficients)
    #print zeros
    realZeros = filter(isreal, zeros)
    result = realZeros[0]
    #print result
    return mu - (sigma * result)    
Exemple #2
0
    def __principals(vals):
        """Returns principal stresses [S1,S2,S3].

        Args:
            vals (list): six stresses [s11,s22,s33,s12,s13,s23]

        Returns:
            res (list): principal stresses [S1,S2,S3] stresses are high-to-low
        """
        # calculates and returns principal stresses, S1, S2, S3
        [s11, s22, s33, s12, s13, s23] = vals
        aval = 1
        bval = (s11 + s22 + s33)*-1.0
        cval = (s11*s22 + s11*s33 + s22*s33 - s12**2 - s13**2 - s23**2)
        dval = (s11*s22*s33 + 2*s12*s13*s23 - s11*(s23**2) - s22*(s13**2)
                - s33*(s12**2))*-1.0
        res = list(roots([aval, bval, cval, dval]))
        res = sorted(res, reverse=True)
        return res
Exemple #3
0
    def __principals(vals):
        """Returns principal stresses [S1,S2,S3].

        Args:
            vals (list): six stresses [s11,s22,s33,s12,s13,s23]

        Returns:
            res (list): principal stresses [S1,S2,S3] stresses are high-to-low
        """
        # calculates and returns principal stresses, S1, S2, S3
        [s11, s22, s33, s12, s13, s23] = vals
        aval = 1
        bval = (s11 + s22 + s33) * -1.0
        cval = (s11 * s22 + s11 * s33 + s22 * s33 - s12**2 - s13**2 - s23**2)
        dval = (s11 * s22 * s33 + 2 * s12 * s13 * s23 - s11 * (s23**2) - s22 *
                (s13**2) - s33 * (s12**2)) * -1.0
        res = list(roots([aval, bval, cval, dval]))
        res = sorted(res, reverse=True)
        return res
    y1 = r1 * r2 * cmath.exp(2 * g1 * L1 + 2 * 1j * k * n1 * L1)
    y2 = r1 * r2 * cmath.exp(2 * g2 * L2 + 2 * 1j * (k * delta_n3 * L3 + k * n2 * L2))
    yc = C11 * y1 + C22 * y2 - (C11 * C22 - C12 * C21) * y1 * y2 - 1
    yr = yc.real
    yi = yc.imag
    return [yr, yi]

I3 = numpy.arange(0, 0.8, 0.001)  # 波长转换区电流(A)
lambda1 = I3.copy()
for ii in range(0, I3.size):
    a = C
    b = B
    c1 = A
    d = -I3[ii] / e / V3
    D = [a, b, c1, d]
    NN3 = roots(D)
    for r in [0, 1, 2]:
        if (NN3[r].imag == 0) and (NN3[r] >= 0):
            N3 = NN3[r]
    delta_n3 = tau_p * dn_dN * N3  # the carrier-induced index change
 
    # Calculate threshold gains of various modes
    wl = numpy.arange(1, 10, 1)
    threshold_gain = numpy.arange(1, 10, 1)
    for m in range(m1 - 4, m1 + 5):
        lmd = 1e6 * c / (m * delta_f1)
        X1 = fsolve(VCCL_threshold_dynamic, [lmd, 0.95 * gain0])
        wl[m - m1 + 4] = X1[0] * 1000
        threshold_gain[m - m1 + 4] = X1[1]
    lambda1[ii] = wl[threshold_gain.argmin()]
pyplot.figure()