Esempio n. 1
0
def model_mXX(idacm,idacr,a,ac,mc,T,pw,mr,meq,mend,mpeak,mf,Rmc,slmc,filletstyle,N):
    [Rcap,Rcap_mXX]=spo2ida_get_Rcap_pXXmXXcXXtXX(a,ac,T,meq,mpeak,Rmc,pw)
    [b0,b1]=spo2ida_get_ab_pXXtXX(0,T,pw) #This b0 will be used if filletstyle = 3
    for i in range(0,3):
     # the softening part starts at m=mc and ends at m==mr
     # compute the R-values. Note that "mc" is included though it
     # should not.
     #keyboard
        if filletstyle==0 or filletstyle==1 or filletstyle==2:
            # don't do any cute tricks. Just extend the pXX linearly
            # following the final slmc slope.
            RmXX=np.linspace(Rmc[i],Rcap[i],N+1)
            # try not to repeat the end of the last segment
            RmXX=RmXX[1:]
            newMu = mc+(RmXX-Rmc[i])*slmc[i]
            # this is something that I (Chiara) added, check with Dimitrios if it's ok
            if newMu[-1]>mf:
                f = np.nonzero(newMu<=mf)
                RmXX=RmXX[f]
                newMu = mc+(RmXX-Rmc[i])*slmc[i]
                
            idacr[i]=idacr[i] + RmXX.tolist()
            idacm[i]=idacm[i] + newMu.tolist()
            
        else:
#            # use a repeated midpoint insertion and a control polygon with spcrv to get the desired filleting.
#            # intersection of flatline and the tangent at end of pXX
            xi=(np.log(Rcap[i])-np.log(Rmc[i]))*slmc[i] + np.log(mc)
            # Controlling Polygon cp:
            cp_mu = [2*np.log(mc)-xi, xi, 2*np.log(mend)-xi]
            cp_R = [2*np.log(Rmc[i])-np.log(Rcap[i]), np.log(Rcap[i]), np.log(Rcap[i])]
            [newcx,newcy] = spline(cp_mu,cp_R)
            x_mc = np.nonzero(newcx>mc)[0]
            indy = [ele for ele in x_mc if newcx[ele]<=mr]
#            # add a "final point" right on mr. The filleting will  never do that by default, so make sure it happens!
#            # this is especially critical if the real mr > mf, so we are supplied a mr==mf here. So capacity really depends on us
#            # providing this point.
            m_rXX = mr
            if len(indy) == 0:
#            # then probably mc slightly less than mr. Then just interpolate between the closest values 
#            # surrounding "mc" (or "mr" they are actually the same values since mc,mr are so close).
                i1=np.max(np.nonzero(newcx<=mc))
                i2=i1+1
            else:
                if indy[-1]==len(newcx)-1:
#                # Linear extrapolation. Just so that you get a point right on the "mf" and capacity gets displayed correctly
                    i1=indy[-2] 
                    i2=indy[-1] 
                else:
#                # Interpolation between indy(end) and the indy(end)+1 point (if it has been calculated).
                    i1=indy[-1]
                    i2=indy[-1]+1
            
            R_rXX = newcy[i2]+(newcy[i2]-newcy[i1])/(newcx[i2]-newcx[i1])*(mr-newcx[i2])
            
            idacm[i]=idacm[i] + newcx[indy].tolist() + [m_rXX]
            idacr[i]=idacr[i] + newcy[indy].tolist() + [R_rXX]
                    
    return [idacm,idacr]
Esempio n. 2
0
def model_pXX(idacm,idacr,a,mc,T,pw,N):
    "This function gives R of the ida curve corresponding to the hardening branch"
#    a = params[0]
#    mc = params[1]
#    T=params[2]
#    pw=params[3]
    # the full model for any of the three fractiles is:
    # lm = b0*lR + b1*lR^2 (1)
    # or  mu = exp ( b0*logR + b1*logR^2)
    
    # Step 1: get the b0 and b1 parameters of the regression
    # The coefficients bo and b1 are a function of a and T
    #   b0=P4(a) 
    #   b1=P4(a)

    # Step 2: calculate the "end-of-hardening-R" and the corresponding local tangent slope.
    # to find the R at mu=mc, we need to solve (1)
    #  NOTE : mc>1 so log(mc)>0 always
    # b1*logR^2 + b0*logR - log(mc) = 0
    #   Diakrinousa = sqrt(b0^2 + 4*b1*log(mc)) > 0 (always)
    #    logR(1) = ( -b0 + sqrt(Diakr) ) / 4*b1 
    #    logR(2) = ( -b0 - sqrt(Diakr) ) / 4*b1
    # so just pick the root that is greater than one.

    # Step 1:
    [b0,b1]=spo2ida_get_ab_pXXtXX(a,T,pw)
    # Step 2
    [Rmc,slmc] = spo2ida_get_Rmc(mc,b0,b1)

    for i in range(0,3):
        # the hardening part ends at m==mc
        # compute the R-values. Note that "1" is included though it
        # should not.
        RpXX=np.linspace(1,Rmc[i],N+1)
        # try not to repeat the end of the last segment (i.e. remove "1")!
        RpXX=RpXX[1:]

         # method 1: keep lower part of mXX and multiply by local Rmc
         # slope, if it is greater than one
        idacr[i]=idacm[i]+RpXX.tolist()
        newMu = np.exp(b0[i]*np.log(RpXX) + b1[i]*np.power(np.log(RpXX),2))
        idacm[i] = idacm[i]+newMu.tolist()
         
    return [idacm, idacr,Rmc,slmc]