diff --git a/carculator_truck/data/default_parameters.json b/carculator_truck/data/default_parameters.json index 7d420ce..5f15e94 100644 --- a/carculator_truck/data/default_parameters.json +++ b/carculator_truck/data/default_parameters.json @@ -30648,7 +30648,7 @@ "maximum": 24 }, "1088-2000-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30666,12 +30666,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1089-2010-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30689,12 +30689,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1090-2020-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30712,12 +30712,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1091-2030-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30735,12 +30735,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1092-2040-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30758,12 +30758,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1093-2050-power to mass ratio": { - "amount": 52.800000000000004, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30781,12 +30781,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 52.800000000000004, - "minimum": 47.52, - "maximum": 58.08000000000001 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1094-2000-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30804,12 +30804,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1095-2010-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30827,12 +30827,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1096-2020-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30850,12 +30850,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1097-2030-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30873,12 +30873,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1098-2040-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30896,12 +30896,12 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1099-2050-power to mass ratio": { - "amount": 30.400000000000002, + "amount": 30, "category": "Glider", "powertrain": [ "BEV", @@ -30919,9 +30919,9 @@ "status": "Good", "kind": "distribution", "uncertainty_type": 5, - "loc": 30.400000000000002, - "minimum": 27.360000000000003, - "maximum": 33.440000000000005 + "loc": 30, + "minimum": 27, + "maximum": 33 }, "1100-2000-power to mass ratio": { "amount": 30, diff --git a/carculator_truck/model.py b/carculator_truck/model.py index bbee157..f83e77c 100644 --- a/carculator_truck/model.py +++ b/carculator_truck/model.py @@ -12,12 +12,7 @@ DEFAULT_MAPPINGS = { "electric": {"BEV", "PHEV-e"}, - "combustion": { - "HEV-d", - "ICEV-g", - "ICEV-d", - "PHEV-c-d", - }, + "combustion": {"HEV-d", "ICEV-g", "ICEV-d", "PHEV-c-d",}, "combustion_wo_cng": {"HEV-d", "ICEV-d", "PHEV-c-d"}, "pure_combustion": {"ICEV-g", "ICEV-d"}, "petrol": {"PHEV-c-p"}, @@ -83,7 +78,9 @@ def __init__( } l_pwt = [ - pt for pt in ("BEV", "FCEV", "HEV-d", "PHEV-e") if pt in self.array.powertrain.values + pt + for pt in ("BEV", "FCEV", "HEV-d", "PHEV-e") + if pt in self.array.powertrain.values ] for pt in l_pwt: @@ -153,9 +150,7 @@ def __init__( if s in self.array.coords["size"].values ], ) - ] *= ( - 1 - 0.67 - ) + ] *= (1 - 0.67) if any( s in self.array.coords["size"].values for s in ["32t", "40t", "60t"] @@ -169,9 +164,7 @@ def __init__( if s in self.array.coords["size"].values ], ) - ] *= ( - 1 - 0.33 - ) + ] *= (1 - 0.33) if self.cycle == "Urban delivery": self.array.loc[dict(parameter="kilometers per year")] *= 1 - 0.39 @@ -189,9 +182,7 @@ def __init__( if s in self.array.coords["size"].values ], ) - ] *= ( - 1 - 0.67 - ) + ] *= (1 - 0.67) if any( s in self.array.coords["size"].values for s in ["32t", "40t", "60t"] @@ -205,9 +196,7 @@ def __init__( if s in self.array.coords["size"].values ], ) - ] *= ( - 1 - 0.33 - ) + ] *= (1 - 0.33) def __call__(self, key): """ @@ -333,6 +322,8 @@ def set_all(self): print("'*' ICEV that do not comply with the set energy reduction target.") print("'/' vehicles not available for the specified year.") + self["is_compliant"] *= (self["driving mass"] < self["gross mass"]) + # If the number of remaining non-compliant vehicles is not zero, then if len([y for y in self.array.year.values if y > 2020]) > 0: @@ -388,6 +379,19 @@ def set_all(self): ).values.tolist() ] ) + + # indicate vehicles that do not comply with energy target + vals = np.where( + ( + self.array.sel( + parameter="driving mass", powertrain=pt, year=y, value=0 + ).values + < self.array.sel(parameter="gross mass", powertrain=pt, year=y, value=0) + ), + vals, + "-", + ) + # indicate vehicles that do not comply with energy target vals = np.where( self.array.sel( @@ -477,16 +481,13 @@ def adjust_combustion_power_share(self): ) if arr.sum() > 0: - new_shares = ( - self.array.loc[ - dict( - powertrain=l_pwt, - parameter="combustion power share", - year=actual_years, - ) - ] - - (arr * 0.02) - ) + new_shares = self.array.loc[ + dict( + powertrain=l_pwt, + parameter="combustion power share", + year=actual_years, + ) + ] - (arr * 0.02) self.array.loc[ dict( powertrain=l_pwt, @@ -574,11 +575,7 @@ def adjust_cost(self): # Correction of combustion powertrain cost for ICEV-g if "ICEV-g" in self.array.powertrain.values: self.array.loc[ - :, - ["ICEV-g"], - "combustion powertrain cost per kW", - :, - :, + :, ["ICEV-g"], "combustion powertrain cost per kW", :, :, ] = np.reshape( (5.92e160 * np.exp(-0.1819 * self.array.year.values) + 26.76) * cost_factor, @@ -594,15 +591,7 @@ def drop_hybrid(self): l_pwt = [ p for p in self.array.powertrain.values - if p - in [ - "ICEV-d", - "ICEV-g", - "PHEV-d", - "FCEV", - "BEV", - "HEV-d", - ] + if p in ["ICEV-d", "ICEV-g", "PHEV-d", "FCEV", "BEV", "HEV-d",] ] self.array = self.array.sel(powertrain=l_pwt) @@ -696,10 +685,11 @@ def calculate_ttw_energy(self): if len(l_pwt) > 0: self.energy.loc[dict(parameter="power load", powertrain=l_pwt)] = ( - motive_power.T[:, idx, ...] + recuperated_power.T[:, idx, ...] - ) / self.array.sel(parameter="electric power", powertrain=l_pwt).values[ - ..., None - ] + (motive_power.T[:, idx, ...] + recuperated_power.T[:, idx, ...]) + / self.array.sel(parameter="electric power", powertrain=l_pwt).values[ + ..., None + ] + ) self.energy.loc[dict(parameter="power load")] = np.clip( self.energy.loc[dict(parameter="power load")], 0, 1 @@ -720,7 +710,6 @@ def calculate_ttw_energy(self): # as documented in # https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/121450/1/2539-07.pdf - l_pwt = [ p for p in self.array.powertrain.values @@ -730,10 +719,7 @@ def calculate_ttw_energy(self): if len(l_pwt) > 0: self.energy.loc[ - dict( - parameter="engine efficiency", - powertrain=l_pwt, - ) + dict(parameter="engine efficiency", powertrain=l_pwt,) ] = np.clip( np.interp( self.energy.loc[dict(parameter="power load", powertrain=l_pwt)], @@ -761,9 +747,12 @@ def calculate_ttw_energy(self): if "ICEV-g" in self.array.powertrain.values: self.energy.loc[ dict(parameter="engine efficiency", powertrain="ICEV-g") - ] *= 1 - self.array.sel( - parameter="CNG engine efficiency correction factor", - powertrain="ICEV-g", + ] *= ( + 1 + - self.array.sel( + parameter="CNG engine efficiency correction factor", + powertrain="ICEV-g", + ) ) # correction for BEVs and FCEVs @@ -772,9 +761,15 @@ def calculate_ttw_energy(self): ] if len(l_pwt) > 0: self.energy.loc[ - dict(parameter=["engine efficiency", "transmission efficiency"], powertrain=l_pwt) + dict( + parameter=["engine efficiency", "transmission efficiency"], + powertrain=l_pwt, + ) ] = self.array.loc[ - dict(parameter=["engine efficiency", "transmission efficiency"], powertrain=l_pwt) + dict( + parameter=["engine efficiency", "transmission efficiency"], + powertrain=l_pwt, + ) ].values[ ..., None ] @@ -884,11 +879,15 @@ def calculate_ttw_energy(self): axis=-1, ) - self.array.loc[dict(parameter="transmission efficiency", powertrain=pwt)] = np.nanmean( + self.array.loc[ + dict(parameter="transmission efficiency", powertrain=pwt) + ] = np.nanmean( np.where( self.energy.loc[dict(parameter="power load", powertrain=pwt)] == 0, np.nan, - self.energy.loc[dict(parameter="transmission efficiency", powertrain=pwt)], + self.energy.loc[ + dict(parameter="transmission efficiency", powertrain=pwt) + ], ), axis=-1, ) @@ -982,7 +981,8 @@ def set_battery_fuel_cell_replacements(self): ]: with self(pt) as cpm: battery_tech_label = ( - "battery cycle life, " + self.energy_storage["electric"][pt].split("-")[0] + "battery cycle life, " + + self.energy_storage["electric"][pt].split("-")[0] ) cpm["battery lifetime replacements"] = finite( np.ceil( @@ -1393,15 +1393,15 @@ def set_energy_stored_properties(self): ) cpm["battery cell mass"] = ( - cpm["electric energy stored"] / cpm[battery_tech_label] + cpm["electric energy stored"] / cpm[battery_tech_label] ) cpm["energy battery mass"] = ( - cpm["battery cell mass"] / cpm["battery cell mass share"] + cpm["battery cell mass"] / cpm["battery cell mass share"] ) cpm["battery BoP mass"] = ( - cpm["energy battery mass"] - cpm["battery cell mass"] + cpm["energy battery mass"] - cpm["battery cell mass"] ) # kWh electricity/kg battery cell @@ -1758,18 +1758,12 @@ def set_hot_emissions(self): if len(l_pwt) > 0: self.array.loc[ - dict( - powertrain=l_pwt, - parameter=list_direct_emissions, - ) + dict(powertrain=l_pwt, parameter=list_direct_emissions,) ] = hem.get_emissions_per_powertrain( powertrain_type="diesel", euro_classes=l_y, lifetime_km=self.array.loc[ - dict( - powertrain=l_pwt, - parameter="lifetime kilometers", - ) + dict(powertrain=l_pwt, parameter="lifetime kilometers",) ], energy_consumption=self.energy.sel( powertrain=l_pwt, @@ -1790,10 +1784,7 @@ def set_hot_emissions(self): powertrain_type="cng", euro_classes=l_y, lifetime_km=self.array.loc[ - dict( - powertrain="ICEV-g", - parameter="lifetime kilometers", - ) + dict(powertrain="ICEV-g", parameter="lifetime kilometers",) ], energy_consumption=self.energy.sel( powertrain=["ICEV-g"], @@ -2028,10 +2019,7 @@ def get_share_biofuel(self): share_biofuel = ( self.bs.biofuel.sel( - region=region, - value=0, - fuel_type="Biomass fuel", - scenario=scenario, + region=region, value=0, fuel_type="Biomass fuel", scenario=scenario, ) .interp( year=self.array.coords["year"].values, diff --git a/dev/Input data_truck.xlsx b/dev/Input data_truck.xlsx index 498b45a..d30e4ab 100644 Binary files a/dev/Input data_truck.xlsx and b/dev/Input data_truck.xlsx differ diff --git a/tests/test_truck_model.py b/tests/test_truck_model.py index 48cd74e..86a6ec4 100644 --- a/tests/test_truck_model.py +++ b/tests/test_truck_model.py @@ -100,7 +100,7 @@ def test_battery_mass(): with tm("BEV") as cpm: assert np.allclose( cpm["battery cell mass"], - cpm["electric energy stored"] / cpm["battery cell energy density, NMC-111"], + cpm["electric energy stored"] / cpm["battery cell energy density"], )