Exemple #1
0
    def test_collapse_interaction(self):

        tower_dic = self.tower_dic.copy()
        tower_dic.update({
            'axisaz': 91,
            'no_sims': 5000,
            'cond_pc_interaction_no': [1, 3, 5, 7],
            'cond_pc_interaction_cprob': [0.2, 0.3, 0.31, 0.311],
            'cond_pc_interaction_prob': {
                1: 0.2,
                3: 0.1,
                5: 0.01,
                7: 0.001
            }
        })
        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(130.0, 1.072)

        #tower.collapse_interaction
        x = tower.collapse_interaction.groupby(['id_time', 'no_collapse'
                                                ]).apply(len).reset_index()
        for _, row in x.iterrows():
            expected = tower.dmg['collapse'].iloc[
                row['id_time']] * tower.cond_pc_interaction_prob[
                    row['no_collapse']]
            result = row[0] / tower.no_sims
            np.testing.assert_allclose(expected, result, atol=ATOL, rtol=RTOL)
Exemple #2
0
    def test_logger_collapse_interaction(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:
            tower_dic = self.tower_dic.copy()
            tower_dic.update({
                'axisaz':
                91,
                'no_sims':
                50,
                'cond_pc_interaction_no': [1, 3, 5, 7],
                'cond_pc_interaction_cprob': [0.2, 0.3, 0.31, 0.311],
                'cond_pc_interaction_prob': {
                    1: 0.2,
                    3: 0.1,
                    5: 0.01,
                    7: 0.001
                }
            })
            tower = Tower(**tower_dic)
            tower.init()
            prob_dic = {1: 0.2, 3: 0.1, 5: 0.01, 7: 0.001}
            tower._wind = create_wind_given_bearing(130.0, 1.072)
            tower.collapse_interaction

        msg = f'WARNING:wistl.tower:Pc_interaction({tower.name})'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:3]))
Exemple #3
0
    def test_logger_collapse_adj_sim(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:
            # tower14 (idl: 13,
            tower_dic = self.tower_dic.copy()
            tower = Tower(**tower_dic)
            tower.init()
            tower.no_sims = 10
            tower._wind = create_wind_given_bearing(
                130.0, 1.0712)  # 1.05*np.exp(0.02)
            tower.collapse_adj_sim

        msg = 'WARNING:wistl.tower'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:2]))
Exemple #4
0
    def test_collapse_adj_sim(self):

        # tower14 (idl: 13,
        tower_dic = self.tower_dic.copy()
        tower_dic.update({
            'axisaz': 90,
            'no_sims': 5000,
            'function': 'strainer'
        })

        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(130.0,
                                                1.2282)  # 1.18*np.exp(0.04)
        tower.collapse_adj_sim
Exemple #5
0
    def test_logger_dmg_sim(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:

            tower_dic = self.tower_dic.copy()
            tower = Tower(**tower_dic)
            tower.init()
            tower.no_sims = 10
            # 1. determine damage state of tower due to wind
            tower._wind = create_wind_given_bearing(
                130.0, 1.0712)  # 1.05*np.exp(0.02)
            tower.dmg_sim

        msg = 'WARNING:wistl.tower'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:2]))
Exemple #6
0
    def test_collapse_adj_sim(self):

        # tower14 (idl: 13,
        tower_dic = self.tower_dic.copy()
        tower_dic.update({'axisaz': 90, 'no_sims': 6000})

        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(
            [130, 130, 120, 130],
            [0.0712, 1.0712, 1.0712, 0.0712])  # 1.05*np.exp(0.02)
        df = tower.collapse_adj_sim.groupby(['id_time', 'id_adj'
                                             ]).apply(len).reset_index()
        for idl in tower.cond_pc_adj.keys():
            x = df.loc[df['id_adj'].apply(lambda x: idl in x)].groupby(
                'id_time').sum() / tower.no_sims
            np.testing.assert_allclose(x[0].values,
                                       tower.collapse_adj[idl],
                                       atol=ATOL,
                                       rtol=RTOL)