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]]])