Пример #1
0
def fragility_process(an_type, T, Gamma, w, EDPlim, dcroof, EDPvec, RDvec, SPO, bUthd, noBlg, g, MC, Sa_ratios, plot_feature, N, Tc, Td):
    plotflag, linew, fontsize, units, iml = plot_feature[0:5]
    allSa, allbTSa, allLR50, allbLR = [],[],[],[]     
    for blg in range(0,noBlg):
        # Derive median Sa value (median of Sa) of capacity for each Limit State and corresponding overall dispersion std(log(Sa))
        if an_type==0: # Ruiz-Garcia Miranda's method
            [SaT50, bTSa] = simplified_bilinear(T[blg], Gamma[blg], EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], g, MC)
        elif an_type==2: # Dolsek and Fajfar's method
            [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg]) # Convert MDoF into SDoF
            [SaT50,bTSa] = DFfragility(T[blg], Gamma[blg], EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], mc, r, g, Tc, Td, MC)
        else: # Vamvatsikos and Cornell's method
            [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg]) # Convert MDoF into SDoF
            [idacm, idacr] = spo2ida_allT(mc,a,ac,r,mf,T[blg],pw,plotflag[1],filletstyle,N,linew,fontsize) # apply SPO2IDA procedure
            [SaT50,bTSa] = spo2ida(idacm, idacr, mf, T[blg], Gamma[blg], g, EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], MC)
        
        # Converting the Sa(T1) to Sa(Tav), the common IM
        SaTlogmean_av, bTSa_av = np.log(SaT50)*Sa_ratios[blg], np.array(bTSa)*Sa_ratios[blg]
        if blg<20:
            plot_fragility(iml,np.exp(SaTlogmean_av),bTSa_av,0.5,fontsize,units,'off')
        allSa.append(SaTlogmean_av)
        allbTSa.append(bTSa_av)

    # Combine the fragility of each building in a single lognormal curve with
    # mean = weighted_mean(means) and std = SRSS(weighted_std(means),weighted_mean(stds))
    log_meanSa, log_stSa = [],[]
    for i in range(0,len(dcroof[0])):
        SaLS = [ele[i] for ele in allSa]
        StdSaLS = [ele[i] for ele in allbTSa]
        log_meanSa.append(np.average(SaLS,weights = w)) # weighted log-mean mean(log(Sa))
        log_stSa.append(np.sqrt(np.sum(w*(np.power((SaLS-log_meanSa[i]),2)+np.power(StdSaLS,2))))) # weighted log-std (dispersion)
    
    return [log_meanSa, log_stSa]
Пример #2
0
def vulnerability_process(an_type, T, Gamma, w, EDPlim, dcroof, EDPvec, RDvec, SPO, bUthd, noBlg, g, MC, Sa_ratios, plot_feature, N, Tc, Td):
    plotflag,linew,fontsize,units,iml = plot_feature[0:5]
    LR50s = []
    bLRs = []
    for blg in range(0,noBlg):
        LRs = []
        # Vamvatsikos and Cornell's method
        if np.array(bUthd[blg]).any()>0:
        # If some damage criteria have uncertainty
        # Monte Carlo realisations of damage criteria e derivation of fragility curves 
        # for each sample, mean loss ratios are computed at each IML from all samples 
            for i in range (0,MC):
                dc_sample = np.zeros_like(dcroof[blg])
                EDP_sample = np.zeros(len(dcroof[blg])+1)
                for j in range(0,len(dcroof[blg])):
                    if bUthd[blg][j]>0:
                        EDP_sample[j+1] = np.random.lognormal(np.log(EDPlim[blg][j]),bUthd[blg][j],1)
                        while (EDP_sample[j+1]<=EDP_sample[j]):
                            EDP_sample[j+1] = np.random.lognormal(np.log(EDPlim[blg][j]),bUthd[blg][j],1)
                    else:
                        EDP_sample[j+1] = EDPlim[blg][j]
                    dc_sample[j] = np.interp(EDP_sample[j+1],EDPvec[blg],RDvec[blg]);
                EDP_sample = EDP_sample[1::]
 
                if an_type == 0:
                    [SaT50, bTSa] = simplified_bilinear(T[blg], Gamma[blg], EDP_sample, dc_sample, EDPvec[blg], RDvec[blg], SPO[blg], np.zeros_like(bUthd[blg]), g, MC)
                elif an_type==2: # Dolsek and Fajfar's method
                    [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg]) # Convert MDoF into SDoF
                    [SaT50,bTSa] = DFfragility(T[blg], Gamma[blg], EDP_sample, dc_sample, EDPvec[blg], RDvec[blg], SPO[blg], np.zeros_like(bUthd[blg]), mc, r, g, Tc, Td, MC)
                else:
                    [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg])
                    [idacm, idacr] = spo2ida_allT(mc,a,ac,r,mf,T[blg],pw,[0],filletstyle,N,linew,fontsize)
                    [SaT50,bTSa] = spo2ida(idacm, idacr, mf, T[blg], Gamma[blg], g, EDP_sample, dc_sample, EDPvec[blg], RDvec[blg], SPO[blg], np.zeros_like(bUthd[blg]), MC)
                # Conversions
                SaTlogmean_av, bTSa_av = np.log(SaT50)*Sa_ratios[blg], np.array(bTSa)*Sa_ratios[blg]
                LRs.append(damage_to_loss(SaTlogmean_av,bTSa_av,iml,cd+'/NSP/inputs'))
        else: 
        # If any damage criteria have uncertainty
            if an_type == 0:
            # Ruiz-Garcia Miranda's method the uncertainty in the damage criteria is already included in the total dispersion in a simplified way
                [SaT50, bTSa] = simplified_bilinear(T[blg], Gamma[blg], EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], g, MC)
            elif an_type == 2:
                [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg]) # Convert MDoF into SDoF
                [SaT50,bTSa] = DFfragility(T[blg], Gamma[blg], EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], mc, r, g, Tc, Td, MC)
            else:
                [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg])
                [idacm, idacr] = spo2ida_allT(mc,a,ac,r,mf,T[blg],pw,[0],filletstyle,N,linew,fontsize)
                [SaT50,bTSa] = spo2ida(idacm, idacr, mf, T[blg], Gamma[blg], g, EDPlim[blg], dcroof[blg], EDPvec[blg], RDvec[blg], SPO[blg], bUthd[blg], MC)
            # Conversions
            SaTlogmean_av, bTSa_av = np.log(SaT50)*Sa_ratios[blg], np.array(bTSa)*Sa_ratios[blg]
            LR50 = damage_to_loss(SaTlogmean_av,bTSa_av,iml,cd+'/NSP/inputs')
            LRs.append(LR50)
                    
        # Define Vulnerability curve for each building
        LR50s.append(np.mean(LRs,axis = 0))
        bLRs.append(np.std(LRs, axis = 0))
        
    # Combine the Loss Ratios of each building in a single LR for each iml, 
    # with mean = mean(LRs) and std = std(LRs)
    lr = np.array(LR50s)
    bLRs = np.array(bLRs)
    LR50 = np.average(lr, axis=0, weights=w) # weighted mean
    w2 = np.array([np.repeat(ele,len(iml)) for ele in w])
    bLR = np.sqrt(np.sum(np.multiply(np.power(bLRs,2)+np.power(lr-LR50,2),w2),axis=0))
        
    return [LR50, bLR]
Пример #3
0
Created on Thu May 29 16:10:42 2014

@author: chiaracasotto
"""
# Clear existing variables
def clearall():
    all = [var for var in globals() if var[0] != "_"]
    for var in all:
        del globals()[var]
clearall()
import pandas as pd
import numpy as np
from rmtk.vulnerability.NSP.spo2ida_based.get_spo2ida_parameters import get_spo2ida_parameters

Gamma = [1.292]
T = [1.612]
Tav = [1.612]
Sa_ratios = 1
SPO=[[0.104435862,0.233993594,0.897709787,0.940278828, 2093.9,2093.9,91.43446494]];

# <codecell>

[mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[0], T[0], Gamma[0])

# <codecell>

d = {'mc':mc,'a':a,'ac':ac,'r':r,'mf':mf}
data = pd.DataFrame(d, index = np.arange(1))
data.to_csv('results/spo2ida_parameters.csv',header=True,index=False)

Пример #4
0
EDPvec = [np.array([float(ele[0]) for ele in newlist]),[0, 1000]]
RDvec = [np.array([float(ele[1]) for ele in newlist]),[0, 1000]]
noBlg = 1
w = 1
dispersion = [np.repeat(0.,len(dcroof[0])), np.repeat(0.25,len(dcroof[0]))]
g=9.81
Tc=0.5
Td=1.8
mc = 2.24
r = 0.04
MC = 25
data = pd.DataFrame(columns=['Sa50-EdpRd0-beta0','bTSa50-EdpRd0-beta0'],index=np.arange(len(dcroof[0])))

# <codecell>

for k in range(0,len(EDPvec)):
    for j in range(0,len(dispersion)):
        bUthd = [dispersion[j]]*noBlg
        [mc,a,ac,r,mf] = get_spo2ida_parameters(SPO[0], T[0], Gamma[0]) # Convert MDoF into SDoF
        [idacm, idacr] = spo2ida_allT(mc,a,ac,r,mf,T[0],1,0,3,50,2,14) # apply SPO2IDA procedure
        [SaT50,bTSa] = spo2ida(idacm, idacr, mf, T[0], Gamma[0], g, EDPlim[k], dcroof[0], EDPvec[k], RDvec[k],  SPO[0], bUthd[0], MC)
        data['Sa50-EdpRd'+str(k)+'-beta'+str(j)] = pd.DataFrame(SaT50)
        data['bTSa50-EdpRd'+str(k)+'-beta'+str(j)] = pd.DataFrame(bTSa)
        
# <codecell>

data.to_csv('results/SPO2IDA_fragility.csv',header=True,index=True)

# <codecell>

Пример #5
0
# Clear existing variables
def clearall():
    all = [var for var in globals() if var[0] != "_"]
    for var in all:
        del globals()[var]


clearall()
import pandas as pd
import numpy as np
from rmtk.vulnerability.NSP.spo2ida_based.get_spo2ida_parameters import get_spo2ida_parameters

Gamma = [1.292]
T = [1.612]
Tav = [1.612]
Sa_ratios = 1
SPO = [[
    0.104435862, 0.233993594, 0.897709787, 0.940278828, 2093.9, 2093.9,
    91.43446494
]]

# <codecell>

[mc, a, ac, r, mf] = get_spo2ida_parameters(SPO[0], T[0], Gamma[0])

# <codecell>

d = {'mc': mc, 'a': a, 'ac': ac, 'r': r, 'mf': mf}
data = pd.DataFrame(d, index=np.arange(1))
data.to_csv('results/spo2ida_parameters.csv', header=True, index=False)
Пример #6
0
def vulnerability_process(an_type, T, Gamma, w, EDPlim, dcroof, EDPvec, RDvec,
                          SPO, bUthd, noBlg, g, MC, Sa_ratios, plot_feature, N,
                          Tc, Td):
    plotflag, linew, fontsize, units, iml = plot_feature[0:5]
    LR50s = []
    bLRs = []
    for blg in range(0, noBlg):
        LRs = []
        # Vamvatsikos and Cornell's method
        if np.array(bUthd[blg]).any() > 0:
            # If some damage criteria have uncertainty
            # Monte Carlo realisations of damage criteria e derivation of fragility curves
            # for each sample, mean loss ratios are computed at each IML from all samples
            for i in range(0, MC):
                dc_sample = np.zeros_like(dcroof[blg])
                EDP_sample = np.zeros(len(dcroof[blg]) + 1)
                for j in range(0, len(dcroof[blg])):
                    if bUthd[blg][j] > 0:
                        EDP_sample[j + 1] = np.random.lognormal(
                            np.log(EDPlim[blg][j]), bUthd[blg][j], 1)
                        while (EDP_sample[j + 1] <= EDP_sample[j]):
                            EDP_sample[j + 1] = np.random.lognormal(
                                np.log(EDPlim[blg][j]), bUthd[blg][j], 1)
                    else:
                        EDP_sample[j + 1] = EDPlim[blg][j]
                    dc_sample[j] = np.interp(EDP_sample[j + 1], EDPvec[blg],
                                             RDvec[blg])
                EDP_sample = EDP_sample[1::]

                if an_type == 0:
                    [SaT50, bTSa
                     ] = simplified_bilinear(T[blg], Gamma[blg], EDP_sample,
                                             dc_sample, EDPvec[blg],
                                             RDvec[blg], SPO[blg],
                                             np.zeros_like(bUthd[blg]), g, MC)
                elif an_type == 2:  # Dolsek and Fajfar's method
                    [mc, a, ac, r, mf] = get_spo2ida_parameters(
                        SPO[blg], T[blg], Gamma[blg])  # Convert MDoF into SDoF
                    [SaT50, bTSa] = DFfragility(T[blg], Gamma[blg], EDP_sample,
                                                dc_sample, EDPvec[blg],
                                                RDvec[blg], SPO[blg],
                                                np.zeros_like(bUthd[blg]), mc,
                                                r, g, Tc, Td, MC)
                else:
                    [mc, a, ac, r,
                     mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg])
                    [idacm,
                     idacr] = spo2ida_allT(mc, a, ac, r, mf, T[blg], pw, [0],
                                           filletstyle, N, linew, fontsize)
                    [SaT50,
                     bTSa] = spo2ida(idacm, idacr, mf, T[blg], Gamma[blg], g,
                                     EDP_sample, dc_sample, EDPvec[blg],
                                     RDvec[blg], SPO[blg],
                                     np.zeros_like(bUthd[blg]), MC)
                # Conversions
                SaTlogmean_av, bTSa_av = np.log(
                    SaT50) * Sa_ratios[blg], np.array(bTSa) * Sa_ratios[blg]
                LRs.append(
                    damage_to_loss(SaTlogmean_av, bTSa_av, iml,
                                   cd + '/NSP/inputs'))
        else:
            # If any damage criteria have uncertainty
            if an_type == 0:
                # Ruiz-Garcia Miranda's method the uncertainty in the damage criteria is already included in the total dispersion in a simplified way
                [SaT50,
                 bTSa] = simplified_bilinear(T[blg], Gamma[blg], EDPlim[blg],
                                             dcroof[blg], EDPvec[blg],
                                             RDvec[blg], SPO[blg], bUthd[blg],
                                             g, MC)
            elif an_type == 2:
                [mc, a, ac, r, mf] = get_spo2ida_parameters(
                    SPO[blg], T[blg], Gamma[blg])  # Convert MDoF into SDoF
                [SaT50, bTSa] = DFfragility(T[blg], Gamma[blg], EDPlim[blg],
                                            dcroof[blg], EDPvec[blg],
                                            RDvec[blg], SPO[blg], bUthd[blg],
                                            mc, r, g, Tc, Td, MC)
            else:
                [mc, a, ac, r,
                 mf] = get_spo2ida_parameters(SPO[blg], T[blg], Gamma[blg])
                [idacm,
                 idacr] = spo2ida_allT(mc, a, ac, r, mf, T[blg], pw, [0],
                                       filletstyle, N, linew, fontsize)
                [SaT50,
                 bTSa] = spo2ida(idacm, idacr, mf, T[blg], Gamma[blg], g,
                                 EDPlim[blg], dcroof[blg], EDPvec[blg],
                                 RDvec[blg], SPO[blg], bUthd[blg], MC)
            # Conversions
            SaTlogmean_av, bTSa_av = np.log(SaT50) * Sa_ratios[blg], np.array(
                bTSa) * Sa_ratios[blg]
            LR50 = damage_to_loss(SaTlogmean_av, bTSa_av, iml,
                                  cd + '/NSP/inputs')
            LRs.append(LR50)

        # Define Vulnerability curve for each building
        LR50s.append(np.mean(LRs, axis=0))
        bLRs.append(np.std(LRs, axis=0))

    # Combine the Loss Ratios of each building in a single LR for each iml,
    # with mean = mean(LRs) and std = std(LRs)
    lr = np.array(LR50s)
    bLRs = np.array(bLRs)
    LR50 = np.average(lr, axis=0, weights=w)  # weighted mean
    w2 = np.array([np.repeat(ele, len(iml)) for ele in w])
    bLR = np.sqrt(
        np.sum(np.multiply(np.power(bLRs, 2) + np.power(lr - LR50, 2), w2),
               axis=0))

    return [LR50, bLR]