예제 #1
0
    def test_building_response(self):
        #Test that building response is the same as matlab

        periods=array([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
                       0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7,
                       1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
                       3])

        SA = array([0.017553049, 0.028380350, 0.036142210, 0.037701113,
                    0.039325398, 0.038083417, 0.036880517, 0.036190107,
                    0.035512489, 0.035088679, 0.034669917, 0.033162774,
                    0.030871523, 0.027841184, 0.025094836, 0.022850476,
                    0.021322256, 0.019895084, 0.018562342, 0.017317833,
                    0.016160874, 0.015195155, 0.014287144, 0.013433394,
                    0.012630662, 0.011875899, 0.011166239, 0.010498986,
                    0.009871606, 0.009281717, 0.008727078, 0.008140645,
                    0.007593619, 0.007083352, 0.006607374, 0.006163380])

        SA = SA[newaxis, newaxis, :]

        magnitudes = array([6.5])

        Btype = 'RM2L'

        eqrm_dir = determine_eqrm_path()
        default_input_dir = join(eqrm_dir, 'resources', 'data', '')
        building_parameters = \
            building_params_from_csv(building_classification_tag = '',
                                     damage_extent_tag = '',
                                     default_input_dir=default_input_dir)

        # Pull the parameters out:
        b_index = where([(bt == Btype) for bt in
                             building_parameters['structure_classification']])
        new_bp = {}
        for key in building_parameters:
            try:
                new_bp[key] = building_parameters[key][b_index]
            except:
                new_bp[key] = building_parameters[key]

        structures = Structures(latitude=[-31], longitude=[150],
                                building_parameters=new_bp,
                                #bridge_parameters={},
                                FCB_USAGE=array([111]),
                                STRUCTURE_CLASSIFICATION=array([Btype]),
                                STRUCTURE_CATEGORY=array(['BUILDING']))
        building_parameters = structures.building_parameters

        # All the same for this type anyway
        csm_use_variability = None
        csm_standard_deviation = None
        damage_model = Damage_model(structures, SA, periods, magnitudes,
                                    csm_use_variability, csm_standard_deviation)

        # set up the capacity model
        capacity_spectrum_model = Capacity_spectrum_model(periods, magnitudes,
                                                          building_parameters)

        capacity_spectrum_model.smooth_damping = True
        capacity_spectrum_model.use_displacement_corner_period = True
        capacity_spectrum_model.damp_corner_periods = True
        capacity_spectrum_model.use_exact_area = True
        capacity_spectrum_model.rtol = 0.01
        capacity_spectrum_model.csm_damping_max_iterations = 7

        ###########################################################

        damage_model.capacity_spectrum_model = capacity_spectrum_model

        # Warning, point is not used
        point = damage_model.get_building_displacement()

        # matlab values
        SAcr = 0.032208873
        SDcr = 0.97944026
        assert allclose(point[0], SAcr)
        assert allclose(point[1], SDcr)
        assert allclose(point, [[[SAcr]], [[SDcr]]])
예제 #2
0
    def test_building_response(self):
        #Test that building response is the same as matlab

        periods=array([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
                       0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7,
                       1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
                       3])

        SA = array([0.017553049, 0.028380350, 0.036142210, 0.037701113,
                    0.039325398, 0.038083417, 0.036880517, 0.036190107,
                    0.035512489, 0.035088679, 0.034669917, 0.033162774,
                    0.030871523, 0.027841184, 0.025094836, 0.022850476,
                    0.021322256, 0.019895084, 0.018562342, 0.017317833,
                    0.016160874, 0.015195155, 0.014287144, 0.013433394,
                    0.012630662, 0.011875899, 0.011166239, 0.010498986,
                    0.009871606, 0.009281717, 0.008727078, 0.008140645,
                    0.007593619, 0.007083352, 0.006607374, 0.006163380])

        SA = SA[newaxis, newaxis, :]

        magnitudes = array([6.5])

        Btype = 'RM2L'

        eqrm_dir = determine_eqrm_path()
        default_input_dir = join(eqrm_dir, 'resources', 'data', '')
        building_parameters = \
            building_params_from_csv(building_classification_tag = '',
                                     damage_extent_tag = '',
                                     default_input_dir=default_input_dir)

        # Pull the parameters out:
        b_index = where([(bt == Btype) for bt in
                             building_parameters['structure_classification']])
        new_bp = {}
        for key in building_parameters:
            try:
                new_bp[key] = building_parameters[key][b_index]
            except:
                new_bp[key] = building_parameters[key]

        structures = Structures(latitude=[-31], longitude=[150],
                                building_parameters=new_bp,
                                #bridge_parameters={},
                                FCB_USAGE=array([111]),
                                STRUCTURE_CLASSIFICATION=array([Btype]),
                                STRUCTURE_CATEGORY=array(['BUILDING']))
        building_parameters = structures.building_parameters

        # All the same for this type anyway
        csm_use_variability = None
        csm_standard_deviation = None
        damage_model = Damage_model(structures, SA, periods, magnitudes,
                                    csm_use_variability, csm_standard_deviation)

        # set up the capacity model
        capacity_spectrum_model = Capacity_spectrum_model(periods, magnitudes,
                                                          building_parameters)

        capacity_spectrum_model.smooth_damping = True
        capacity_spectrum_model.use_displacement_corner_period = True
        capacity_spectrum_model.damp_corner_periods = True
        capacity_spectrum_model.use_exact_area = True
        capacity_spectrum_model.rtol = 0.01
        capacity_spectrum_model.csm_damping_max_iterations = 7

        ###########################################################

        damage_model.capacity_spectrum_model = capacity_spectrum_model

        # Warning, point is not used
        point = damage_model.get_building_displacement()

        # matlab values
        SAcr = 0.032208873
        SDcr = 0.97944026
        assert allclose(point[0], SAcr)
        assert allclose(point[1], SDcr)
        assert allclose(point, [[[SAcr]], [[SDcr]]])
예제 #3
0
    def test_capacity_method(self):
        #in
        (Ay, Dy, Au, Du) =(0.13417, 2.9975, 0.26833, 41.964)
        (aa, bb, cc, kappa) =(-0.3647, 0.33362, 0.26833, 0.001)
        capacity_parameters = (Dy, Ay, Du, Au, aa, bb, cc)

        SA_Regolith = array([0.342012967618843, 0.763365709250557,
                             0.653837319165796, 0.530630921234538,
                             0.442943423800148, 0.383969335597378,
                             0.344524949645552, 0.321240620786007,
                             0.302941865445212, 0.27664105478319,
                             0.248309353527187, 0.15957588550857,
                             0.110047888697209, 0.0801793140567643,
                             0.0550935180421332, 0.0397236036505722,
                             0.0291049436633207, 0.0214091242649845,
                             0.0157482043977009])
        SA_Regolith.shape = (1, 1, -1)

        params = (0.069, 13, 0.3, 0.9, 0.7, 1.75, 2, 7)
        dparams = (0.001, 0.001, 0.001, 0.08)

        (C, height, T, a1, a2, y, h, u) =params
        magnitudes = array([7.2])
        (damping_s, damping_m, damping_l, initial_damping) = dparams

        periods = array([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
                         0.9, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])

        building_parameters = {}

        building_parameters['design_strength'] = array([C])
        building_parameters['natural_elastic_period'] = array([T])
        building_parameters['fraction_in_first_mode'] = array([a1])
        building_parameters['height_to_displacement'] = array([a2])
        building_parameters['yield_to_design'] = array([y])
        building_parameters['ultimate_to_yield'] = array([h])
        building_parameters['ductility'] = array([u])
        building_parameters['damping_s'] = array([damping_s])
        building_parameters['damping_m'] = array([damping_m])
        building_parameters['damping_l'] = array([damping_l])
        building_parameters['damping_Be'] = array([initial_damping])
        building_parameters['structure_classification'] = ['test_blg']
        
        csm = Capacity_spectrum_model(periods, magnitudes, building_parameters)
        csm.rtol = 0.01
        csm.csm_damping_max_iterations = 7
        csm.use_displacement_corner_period = True
        csm.use_exact_area = True
        csm.damp_corner_periods = True
        point = csm.building_response(SA_Regolith)

        #final
        SDnew = [0, 1.6012, 5.486, 10.017, 15.022, 20.783, 27.144, 34.449,
                 42.431, 49.04, 54.342, 78.577, 96.336, 109.67, 108.51, 106.5,
                 101.91, 94.879, 86.162]

        SAnew = [0, 1.6012, 5.486, 10.017, 15.022, 20.783, 27.144, 34.449,
                 42.431, 49.04, 54.342, 78.577, 96.336, 109.67, 108.51, 106.5,
                 101.91, 94.879, 86.162]

        SDcr = 41.810644943005

        SAcr = 0.26833301410569

        assert allclose(SAcr, point[0])
        assert allclose(SDcr, point[1])
예제 #4
0
    def test_capacity_method(self):
        #in
        (Ay, Dy, Au, Du) =(0.13417, 2.9975, 0.26833, 41.964)
        (aa, bb, cc, kappa) =(-0.3647, 0.33362, 0.26833, 0.001)
        capacity_parameters = (Dy, Ay, Du, Au, aa, bb, cc)

        SA_Regolith = array([0.342012967618843, 0.763365709250557,
                             0.653837319165796, 0.530630921234538,
                             0.442943423800148, 0.383969335597378,
                             0.344524949645552, 0.321240620786007,
                             0.302941865445212, 0.27664105478319,
                             0.248309353527187, 0.15957588550857,
                             0.110047888697209, 0.0801793140567643,
                             0.0550935180421332, 0.0397236036505722,
                             0.0291049436633207, 0.0214091242649845,
                             0.0157482043977009])
        SA_Regolith.shape = (1, 1, -1)

        params = (0.069, 13, 0.3, 0.9, 0.7, 1.75, 2, 7)
        dparams = (0.001, 0.001, 0.001, 0.08)

        (C, height, T, a1, a2, y, h, u) =params
        magnitudes = array([7.2])
        (damping_s, damping_m, damping_l, initial_damping) = dparams

        periods = array([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
                         0.9, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])

        building_parameters = {}

        building_parameters['design_strength'] = array([C])
        building_parameters['natural_elastic_period'] = array([T])
        building_parameters['fraction_in_first_mode'] = array([a1])
        building_parameters['height_to_displacement'] = array([a2])
        building_parameters['yield_to_design'] = array([y])
        building_parameters['ultimate_to_yield'] = array([h])
        building_parameters['ductility'] = array([u])
        building_parameters['damping_s'] = array([damping_s])
        building_parameters['damping_m'] = array([damping_m])
        building_parameters['damping_l'] = array([damping_l])
        building_parameters['damping_Be'] = array([initial_damping])
        building_parameters['structure_classification'] = ['test_blg']
        
        csm = Capacity_spectrum_model(periods, magnitudes, building_parameters)
        csm.rtol = 0.01
        csm.csm_damping_max_iterations = 7
        csm.use_displacement_corner_period = True
        csm.use_exact_area = True
        csm.damp_corner_periods = True
        point = csm.building_response(SA_Regolith)

        #final
        SDnew = [0, 1.6012, 5.486, 10.017, 15.022, 20.783, 27.144, 34.449,
                 42.431, 49.04, 54.342, 78.577, 96.336, 109.67, 108.51, 106.5,
                 101.91, 94.879, 86.162]

        SAnew = [0, 1.6012, 5.486, 10.017, 15.022, 20.783, 27.144, 34.449,
                 42.431, 49.04, 54.342, 78.577, 96.336, 109.67, 108.51, 106.5,
                 101.91, 94.879, 86.162]

        SDcr = 41.810644943005

        SAcr = 0.26833301410569

        assert allclose(SAcr, point[0])
        assert allclose(SDcr, point[1])