def test_scale_motion(self):
     data = np.array([1, 3, 7, -2, -10, 0])
     gm = GM(data, unit='g', dt=0.1)
     gm_scaled_1 = gm.scale_motion(factor=2.0)  # scale by 2.0
     gm_scaled_2 = gm.scale_motion(target_PGA_in_g=5.0)  # scale by 0.5
     self.assertTrue(np.allclose(gm.accel[:, 1] * 2, gm_scaled_1.accel[:, 1]))
     self.assertTrue(np.allclose(gm.accel[:, 1] * 0.5, gm_scaled_2.accel[:, 1]))
    def test_equiv_linear(self):
        gm_raw = Ground_Motion('./files/sample_accel.txt', unit='gal')
        # Make a very weak motion to speed up equivalent linear calculation
        gm = gm_raw.scale_motion(target_PGA_in_g=0.001)
        prof_2 = Vs_Profile('./files/profile_P001.txt')
        mgdc_2 = Multiple_GGmax_Damping_Curves(data='./files/curve_P001.txt')

        sim_2 = Equiv_Linear_Simulation(prof_2, gm, mgdc_2, boundary='elastic')
        sim_list = [sim_2]

        batch_sim = Batch_Simulation(sim_list)
        options = dict(show_fig=False, save_txt=False, verbose=True)
        non_par_results = batch_sim.run(parallel=False, options=options)
        par_results = batch_sim.run(parallel=True, n_cores=2, options=options)

        accel_out_0_non_par = non_par_results[0].accel_on_surface.accel
        accel_out_0_par = par_results[0].accel_on_surface.accel

        self.assertTrue(
            np.allclose(accel_out_0_non_par,
                        accel_out_0_par,
                        atol=0.0,
                        rtol=1e-3))