예제 #1
0
 def test_sigma_dorn_nan_a_d(self):
     m = GMS()
     material = test_material()
     material['a_d'][0] = 0
     target = np.nan
     result = m.sigma_dorn(material, temp, strain_rate)
     self.assertIs(result, target)
예제 #2
0
 def test_plot_topography(self):
     m = GMS(testmodel, verbosity=-1)
     t = m.plot_topography()
     self.assertIsInstance(t, tri.TriContourSet)
     levels = t.levels.tolist()
     levels_target = [-2.4999999999999994e-14, 0.0, 2.4999999999999994e-14]
     self.assertListEqual(levels, levels_target)
예제 #3
0
 def test_sigma_byerlee_ext(self):
     m = GMS()
     material = test_material()
     mode = 'extension'
     target = 116689950.0
     result = m.sigma_byerlee(material, depth, mode)
     self.assertEqual(result, target)
예제 #4
0
 def test_sigma_dorn_zero(self):
     m = GMS()
     material = test_material()
     temperature = 1500.0
     target = 0.0
     result = m.sigma_dorn(material, temperature, strain_rate)
     self.assertEqual(result, target)
예제 #5
0
 def test_sigma_byerlee_comp(self):
     m = GMS()
     material = test_material()
     mode = 'compression'
     target = 311173200.0,
     result = m.sigma_byerlee(material, depth, mode)
     self.assertEqual(result, target)
예제 #6
0
    def test_compute_bd_thickness_comp(self):
        m = GMS(testmodel, verbosity=-1)
        m.layer_add_var('T')
        m.set_rheology(strain_rate=strain_rate,
                       rheologies=[test_material_dict],
                       bodies=bodies)
        m.compute_bd_thickness(mode='compression')
        t_duct_sediments = m.t_ductile[2][0]
        t_duct_crust = m.t_ductile[2][1]
        t_duct_mantle = m.t_ductile[2][2]
        target_sediments = 0.
        target_crust = 24949.
        target_mantle = 9919.
        for val in t_duct_sediments:
            self.assertAlmostEqual(val, target_sediments, -1)
        for val in t_duct_crust:
            self.assertAlmostEqual(val, target_crust, -1)
        for val in t_duct_mantle:
            self.assertAlmostEqual(val, target_mantle, -1)

        t_brit_sediments = m.t_brittle[2][0]
        t_brit_crust = m.t_brittle[2][1]
        t_brit_mantle = m.t_brittle[2][2]
        target_sediments = 10020.
        target_crust = 5110.
        target_mantle = 0.
        for val in t_brit_sediments:
            self.assertAlmostEqual(val, target_sediments, -1)
        for val in t_brit_crust:
            self.assertAlmostEqual(val, target_crust, -1)
        for val in t_brit_mantle:
            self.assertAlmostEqual(val, target_mantle, -1)
예제 #7
0
 def test_integrated_strength_comp(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.set_rheology(strain_rate=strain_rate,
                    rheologies=[test_material_dict],
                    bodies=bodies)
     m.compute_integrated_strength(nz=10, mode='compression')
     target = 3674238431772.26
     for val in m.integrated_strength[:, 2]:
         self.assertAlmostEqual(val, target, places=1)
예제 #8
0
 def test_integrated_strength_ext(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.set_rheology(strain_rate=strain_rate,
                    rheologies=[test_material_dict],
                    bodies=bodies)
     m.compute_integrated_strength(nz=10, mode='extension')
     target = -1873467598438.9
     for val in m.integrated_strength[:, 2]:
         self.assertAlmostEqual(val, target, places=1)
예제 #9
0
 def test_sigma_d_comp(self):
     m = GMS()
     material = test_material()
     mode = 'compression'
     processes = ['dislocation', 'dorn']
     outputs = ['byerlee', 'dislocation', 'dorn']
     target = {
         'dsigma_max': -1452181.9550299197,
         'byerlee': -311173200.0,
         'dislocation': -1452181.9550299197,
         'dorn': -182170257.3512531
     }
     result = m.sigma_d(material, depth, temp,
                        strain_rate=strain_rate,
                        compute=processes,
                        mode=mode,
                        output=outputs)
     self.assertEqual(result, target)
예제 #10
0
 def test_plot_strength_profile(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.set_rheology(strain_rate=strain_rate,
                    rheologies=[test_material_dict],
                    bodies=bodies)
     obj = m.plot_strength_profile(0, 0, 100e3, 100e3, num=10,
                                   show_competent=True)
     self.assertIsInstance(obj, tri.TriContourSet)
예제 #11
0
 def test_plot_yse(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.set_rheology(strain_rate=strain_rate,
                    rheologies=[test_material_dict],
                    bodies=bodies)
     te = m.plot_yse((50e3, 50e3), return_params=['Te'])
     te_target = 21442.885771543086
     self.assertAlmostEqual(te, te_target)
예제 #12
0
 def test_compute_elastic_thickness_comp(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.set_rheology(strain_rate=strain_rate,
                    rheologies=[test_material_dict],
                    bodies=bodies)
     m.compute_elastic_thickness()
     competent_layers, eet = m.elastic_thickness[strain_rate]
     target_competent_layers = 1
     target_eet = 21442.
     for val in competent_layers:
         self.assertEqual(val, target_competent_layers)
     for val in eet[:, 2]:
         self.assertAlmostEqual(val, target_eet, -1)
예제 #13
0
 def test_sigma_byerlee_fail(self):
     m = GMS()
     material = test_material()
     mode = 'c'
     with self.assertRaises(ValueError):
         m.sigma_byerlee(material, depth, mode)
예제 #14
0
 def test_getitem_layer_str_fail(self):
     m = GMS(testmodel, verbosity=-1)
     with self.assertRaises(ValueError):
         m['fail']
예제 #15
0
 def test_getitem_layer_str(self):
     m = GMS(testmodel, verbosity=-1)
     self.assertIsInstance(m['Sediments'], Layer)
예제 #16
0
 def test_sigma_d_fail_z(self):
     m = GMS()
     material = test_material()
     with self.assertRaises(ValueError):
         m.sigma_d(material, -100, temp)
예제 #17
0
 def test_get_ylim(self):
     m = GMS(testmodel, verbosity=-1)
     self.assertTupleEqual(m.ylim, (0., 100e3))
예제 #18
0
 def test_sigma_dorn(self):
     m = GMS()
     material = test_material()
     target = 182170257.3512531
     result = m.sigma_dorn(material, temp, strain_rate)
     self.assertEqual(result, target)
예제 #19
0
 def test_get_zlim(self):
     m = GMS(testmodel, verbosity=-1)
     self.assertTupleEqual(m.zlim, (-50e3, 0.))
예제 #20
0
 def test_plot_profile(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     obj = m.plot_profile(0, 0, 100e3, 100e3, num=10, annotate=True)
     self.assertIsInstance(obj, tri.TriContourSet)
예제 #21
0
 def test_info_df(self):
     m = GMS(testmodel, verbosity=-1)
     m.info
     self.assertIsInstance(m._info_df, DataFrame)
예제 #22
0
 def test_sigma_dislocation(self):
     m = GMS()
     material = test_material()
     target = 1452181.9550299197
     result = m.sigma_dislocation(material, temp, strain_rate)
     self.assertEqual(result, target)
예제 #23
0
 def test_getitem_laye_int(self):
     m = GMS(testmodel, verbosity=-1)
     self.assertIsInstance(m[0], Layer)
예제 #24
0
 def test_plot_grad(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     w = m.get_well(0, 0, 'T')
     for grad in w.plot_grad('T', return_array=True, absolute=True):
         self.assertAlmostEqual(grad, 0.02)
예제 #25
0
 def test_call(self):
     m = GMS(testmodel, verbosity=-1)
     w = m.get_well(0, 0 )
     self.assertListEqual(w().tolist(), [0., -10e3, -40e3, -50e3])
예제 #26
0
 def test_heat_flow(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     m.compute_surface_heat_flow()
     for val in m.surface_heat_flow[:, 2]:
         self.assertAlmostEqual(val, 0.042)
예제 #27
0
 def test_getitem(self):
     m = GMS(testmodel, verbosity=-1)
     m.layer_add_var('T')
     w = m.get_well(0, 0, 'T')
     self.assertListEqual(w['T'].tolist(), [0., 200., 800., 1000.])
예제 #28
0
 def test_sigma_diffusion(self):
     m = GMS()
     material = test_material()
     target = 18.20267567303978
     result = m.sigma_diffusion(material, temp, strain_rate)
     self.assertEqual(result, target)
예제 #29
0
    return sys.argv[1], sys.argv[2::]


if __name__ == '__main__':
    from pyGMS.utils import check_ipython
    check_ipython()
    import os
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import tri
    from matplotlib.ticker import FuncFormatter
    from pyGMS import GMS
    f_fem, f_profiles = read_args()
    # Assume that the structure of each profile file is
    # Dist[m] Z[m] DSIGMA_C[MPa] X[m] Y[m]
    model = GMS(f_fem)
    for f in f_profiles:
        print('Processing', f)
        raw_data = np.loadtxt(f, skiprows=1, delimiter=' ')
        x0, y0 = raw_data[0, 3:5]
        x1, y1 = raw_data[-1, 3:5]
        d = raw_data[:, 0]*0.001              # Distance / km
        z = raw_data[:, 1]*0.001              # Depth / km
        dsigma = np.abs(raw_data[:, 2])*0.001  # Diff. stress / GPa

        # Plot
        gs_kwd = dict(width_ratios=(5, 1), wspace=0.01)
        fig, axes = plt.subplots(1, 2, gridspec_kw=gs_kwd, figsize=(18, 5))

        # Profile
        ax = axes[0]
예제 #30
0
 def test_call_depth(self):
     m = GMS(testmodel, verbosity=-1)
     result = m(50e3, 50e3, -5e3)
     target = [0, 'Sediments']
     self.assertListEqual(result, target)