Пример #1
0
def test_stopdecel(wltc_class):
    V = datamodel.get_class_v_cycle(wltc_class)
    cb = CycleBuilder(V)
    cycle = cycler.PhaseMarker().add_phase_markers(cb.cycle, cb.V, cb.A)
    n_stops = (cycle["stop"].astype(int).diff() < 0).sum(None)
    n_decels = (cycle["decel"].astype(int).diff() < 0).sum(None)
    n_stopdecels = (cycle["stopdecel"].astype(int).diff() < 0).sum(None)
    assert n_stopdecels < n_decels
    ##  The initial stop has no deceleration before it BUT no diff >0 either!
    assert n_stopdecels == n_stops
Пример #2
0
def test_validate_t_start(wltc_class, t_cold_end, err):
    """
    .. TODO:: move `t_cold_end` check in validations pipeline.
    """
    V = datamodel.get_class_v_cycle(wltc_class)
    wltc_parts = datamodel.get_class_parts_limits(wltc_class)

    cb = CycleBuilder(V)
    cb.cycle = cycler.PhaseMarker().add_phase_markers(cb.cycle, cb.V, cb.A)
    with pytest.raises(type(err), match=str(err)):
        for err in cb.validate_nims_t_cold_end(t_cold_end, wltc_parts):
            raise err
Пример #3
0
def test_full_build_smoketest(h5_accdb):
    vehnum = 8
    veh_class = 3  # v008's class
    t_cold_end = 470  # stop in all classes
    prop, wot, n2vs = vehdb.load_vehicle_accdb(h5_accdb, vehnum)
    renames = vehdb.accdb_renames()
    prop = prop.rename(renames)
    wot = wot.rename(renames, axis=1)
    wot["n"] = wot.index

    V = datamodel.get_class_v_cycle(veh_class)
    wltc_parts = datamodel.get_class_parts_limits(veh_class)

    pm = cycler.PhaseMarker()
    cb = cycler.CycleBuilder(V)
    cb.cycle = pm.add_phase_markers(cb.cycle, cb.V, cb.A)
    for err in cb.validate_nims_t_cold_end(t_cold_end, wltc_parts):
        raise err
    cb.cycle = pm.add_class_phase_markers(cb.cycle, wltc_parts)

    SM = 0.1
    gwots = engine.interpolate_wot_on_v_grid(wot, n2vs)
    gwots = engine.calc_p_avail_in_gwots(gwots, SM=SM)
    gwots["p_resist"] = vehicle.calc_road_load_power(gwots.index, prop.f0,
                                                     prop.f1, prop.f2)

    kr = 1.03
    cb.add_wots(gwots)

    cb.cycle["p_inert"] = vehicle.calc_inertial_power(cb.V, cb.A,
                                                      prop.test_mass, kr)
    cb.cycle["p_req"] = vehicle.calc_required_power(cb.cycle["p_inert"],
                                                    cb.cycle["p_resist"])

    acc_cycle = vehdb.load_vehicle_nodes(h5_accdb, vehnum, "cycle")

    diffs = {}

    def cmpr_cols(c1, c2):
        diffs[c1.name] = (c1 - c2).abs()

    acc_cycle["P_tot"], "p_required"
Пример #4
0
# %%
print(list(acc_cycle.columns))
print(list(mdl.keys()))

# %%
gwots = engine.interpolate_wot_on_v_grid(wot, n2vs)
gwots = engine.attach_p_avail_in_gwots(gwots, f_safety_margin=0.1)
gwots["p_resist"] = vehicle.calc_p_resist(gwots.index, mdl["f0"], mdl["f1"], mdl["f2"])

# %%
V = datamodel.get_class_v_cycle(3)

# %%
cb = cycler.CycleBuilder(V)
pm = cycler.PhaseMarker()

# %%
wltc_parts = datamodel.get_class_parts_limits(3, edges=True)
cb.cycle = pm.add_class_phase_markers(cb.cycle, wltc_parts)

# %%
cb.cycle = pm.add_phase_markers(cb.cycle, cb.V, cb.A)
cb.cycle.select_dtypes(bool).sum()

# %%
t_cold_end = 470  # gap for all classes
for err in cb.validate_nims_t_cold_end(t_cold_end, wltc_parts):
    raise err

# %%