Esempio n. 1
0
def test_null_repair():
    gf = sc.GasField()
    timeobj = sc.Time(delta_t=1 / 24, end_time=50)
    timeobj.current_time = 10
    np.random.seed(0)
    flux = np.random.uniform(0.1, 1, 100)
    end_time = np.random.exponential(10, 100)
    gf.initial_leaks = lcf.Leak(flux=flux, endtime=end_time)
    null = Dm.null.Null(timeobj, gf)
    null.null_detection(timeobj, gf)
    if np.sum(null.leaks.flux > 0) != 39:
        raise ValueError("unexpected number of leaks persisting")
    return None
Esempio n. 2
0
def test_emissions_enforcer_no_repairable():
    pad = sc.Site(site_em_dist=feast.GeneralClassesFunctions.
                  site_emission_methods.alvarez_colorado_em_dist)
    gf = sc.GasField(sites={'site0': {'number': 1, 'parameters': pad}})
    gf.initial_leaks = lcf.Leak(capacity=10,
                                flux=np.array([1000, 100, 10, 1, 0.1]),
                                site_index=np.array([0, 0, 0, 0, 0]),
                                comp_index=np.array([1, 2, 3, 4, 5]),
                                reparable=np.array(
                                    [False, False, False, False, False]))
    if np.sum(gf.initial_leaks.flux) != 1111.1:
        raise ValueError("lcf.Leak initializing unexpected emissions")
    np.random.seed(0)
    gf.site_emissions_enforcer(gf.sites['site0']['parameters'])
Esempio n. 3
0
def test_emissions_enforcer_low():
    pad = sc.Site(site_em_dist=feast.GeneralClassesFunctions.
                  site_emission_methods.alvarez_colorado_em_dist)
    gf = sc.GasField(sites={'site0': {'number': 1, 'parameters': pad}})
    gf.initial_leaks = lcf.Leak(capacity=1)
    if np.sum(gf.initial_leaks.flux) != 0:
        raise ValueError("lcf.Leak intializing non-zero emissions")
    gf.site_emissions_enforcer(gf.sites['site0']['parameters'])
    if np.sum(gf.initial_leaks.flux) <= 0:
        raise ValueError(
            "site_emissions_enforcer is not generating emissions when required"
        )
    if gf.initial_leaks.site_index != 0:
        raise ValueError(
            "site_emissions_enforcer does not set the site index correctly")
    if gf.initial_leaks.comp_index != -1:
        raise ValueError(
            "site_emissions_enforcer does not set the component index correctly"
        )
Esempio n. 4
0
def test_gasfield_leak_maker():
    gf = sc.GasField()
    new_leaks = lcf.Leak()
    time = sc.Time()
    time.current_time = 10
    np.random.seed(0)
    gf.leak_maker(10, new_leaks, 'default', 0, time,
                  gf.sites['default']['parameters'])
    expected = np.array([
        0.02689507, 0.00775865, 0.00228167, 0.01050579, 0.00157465, 0.0149844,
        0.04953858, 0.49138137, 0.09214868, 0.04406508
    ])
    if np.max(np.abs(expected - new_leaks.flux)) > 1e-8:
        raise ValueError("unexpected flux value")
    expected_endtimes = np.array([
        391.04863847, 165.94777145, 225.15696612, 14.85666044, 256.14930494,
        252.46640114, 255.67999985, 746.85338952, 303.1982008, 124.06931841
    ])
    if np.max(np.abs(expected_endtimes - new_leaks.endtime)) > 1e-6:
        raise ValueError("unexpected endtime")
    return None