future-technology-transformation 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- SourceCode/Freight/ftt_fr_lcof.py +297 -0
- SourceCode/Freight/ftt_fr_main.py +504 -0
- SourceCode/Heat/ftt_h_lcoh.py +218 -0
- SourceCode/Heat/ftt_h_main.py +528 -0
- SourceCode/Industrial_Heat/__init__.py +5 -0
- SourceCode/Industrial_Heat/ftt_chi_main.py +632 -0
- SourceCode/Industrial_Heat/ftt_fbt_main.py +628 -0
- SourceCode/Industrial_Heat/ftt_mtm_main.py +637 -0
- SourceCode/Industrial_Heat/ftt_nmm_main.py +632 -0
- SourceCode/Industrial_Heat/ftt_ois_main.py +632 -0
- SourceCode/Power/__init__.py +5 -0
- SourceCode/Power/ftt_p_costc.py +512 -0
- SourceCode/Power/ftt_p_dspch.py +278 -0
- SourceCode/Power/ftt_p_early_scrapping_costs.py +61 -0
- SourceCode/Power/ftt_p_fuel_price.py +295 -0
- SourceCode/Power/ftt_p_integration_costs.py +124 -0
- SourceCode/Power/ftt_p_lcoe.py +280 -0
- SourceCode/Power/ftt_p_main.py +930 -0
- SourceCode/Power/ftt_p_phase_out.py +47 -0
- SourceCode/Power/ftt_p_rldc.py +1015 -0
- SourceCode/Power/ftt_p_surv.py +111 -0
- SourceCode/Transport/__init__.py +5 -0
- SourceCode/Transport/ftt_tr_emission_corrections.py +118 -0
- SourceCode/Transport/ftt_tr_lcot.py +193 -0
- SourceCode/Transport/ftt_tr_main.py +519 -0
- SourceCode/Transport/ftt_tr_survival.py +130 -0
- SourceCode/__init__.py +22 -0
- SourceCode/ftt_core/__init__.py +5 -0
- SourceCode/ftt_core/ftt_emissions_regulation.py +332 -0
- SourceCode/ftt_core/ftt_exogenous_capacity.py +60 -0
- SourceCode/ftt_core/ftt_exogenous_sales.py +60 -0
- SourceCode/ftt_core/ftt_mandate.py +257 -0
- SourceCode/ftt_core/ftt_sales_or_investments.py +147 -0
- SourceCode/ftt_core/ftt_shares.py +375 -0
- SourceCode/initialise_csv_files.py +118 -0
- SourceCode/model_class.py +418 -0
- SourceCode/paths.py +109 -0
- SourceCode/sector_coupling/__init__.py +10 -0
- SourceCode/sector_coupling/battery_lbd.py +167 -0
- SourceCode/sector_coupling/electricity_demand.py +47 -0
- SourceCode/sector_coupling/electricity_price.py +45 -0
- SourceCode/sector_coupling/transport_batteries_to_power.py +192 -0
- SourceCode/support/__init__.py +5 -0
- SourceCode/support/check_market_shares.py +46 -0
- SourceCode/support/convert_masterfiles_to_csv.py +586 -0
- SourceCode/support/cross_section.py +108 -0
- SourceCode/support/debug_messages.py +18 -0
- SourceCode/support/dimensions_functions.py +55 -0
- SourceCode/support/divide.py +28 -0
- SourceCode/support/docstring_templates.py +119 -0
- SourceCode/support/gamma_value_automation.py +623 -0
- SourceCode/support/get_vars_to_copy.py +40 -0
- SourceCode/support/input_functions.py +305 -0
- SourceCode/support/output_functions.py +58 -0
- SourceCode/support/paths_append.py +18 -0
- SourceCode/support/read_support.py +30 -0
- SourceCode/support/titles_functions.py +53 -0
- future_technology_transformation/__init__.py +144 -0
- future_technology_transformation-0.1.0.dist-info/METADATA +71 -0
- future_technology_transformation-0.1.0.dist-info/RECORD +64 -0
- future_technology_transformation-0.1.0.dist-info/WHEEL +5 -0
- future_technology_transformation-0.1.0.dist-info/entry_points.txt +2 -0
- future_technology_transformation-0.1.0.dist-info/licenses/LICENSE +21 -0
- future_technology_transformation-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
=========================================
|
|
4
|
+
ftt_fr_lcof.py
|
|
5
|
+
=========================================
|
|
6
|
+
Freight LCOF FTT module with optional feebate system.
|
|
7
|
+
########################
|
|
8
|
+
|
|
9
|
+
Functions included:
|
|
10
|
+
- set_carbon_tax: Calculate carbon tax costs
|
|
11
|
+
- verify_revenue_neutrality: Check feebate balance
|
|
12
|
+
- get_lcof: Calculate levelized costs with optional feebate system
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def set_carbon_tax(data, c6ti):
|
|
19
|
+
"""
|
|
20
|
+
Apply the carbon price to freight sector technologies based on their emission factors
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Carbon costs per country and technology (2D)
|
|
24
|
+
"""
|
|
25
|
+
carbon_costs = (
|
|
26
|
+
data["CO2taxFr"][:, :, 0] # Carbon price in USD/tCO2
|
|
27
|
+
* data["BZTC"][:, :, c6ti["12 CO2 emissions (gCO2/km)"]] # g CO2 / km
|
|
28
|
+
/ 10**6 # Conversion from g to tonne
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
if np.isnan(carbon_costs).any():
|
|
32
|
+
print(f"The arguments of the nans are {np.argwhere(np.isnan(carbon_costs))}")
|
|
33
|
+
print(
|
|
34
|
+
f"Emissions intensity {data['BZTC'][:, :, c6ti['12 CO2 emissions (gCO2/km)']]}"
|
|
35
|
+
)
|
|
36
|
+
raise ValueError
|
|
37
|
+
|
|
38
|
+
return carbon_costs
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def verify_revenue_neutrality(data, titles, c6ti):
|
|
42
|
+
"""
|
|
43
|
+
Verify revenue neutrality of the feebate system for countries with active subsidies.
|
|
44
|
+
Only checks regions where BEV subsidies are implemented.
|
|
45
|
+
"""
|
|
46
|
+
n_veh_classes = 5
|
|
47
|
+
results = {}
|
|
48
|
+
|
|
49
|
+
for r in range(len(titles["RTI"])):
|
|
50
|
+
region = titles["RTI"][r]
|
|
51
|
+
|
|
52
|
+
# Check if this region has any BEV subsidies
|
|
53
|
+
bev_indices = [31, 32, 33] # BEV indices
|
|
54
|
+
has_subsidies = np.any(data["ZTVT"][r, bev_indices, 0] < 0)
|
|
55
|
+
|
|
56
|
+
if not has_subsidies:
|
|
57
|
+
continue
|
|
58
|
+
|
|
59
|
+
results[region] = {"subsidy_costs": [], "tax_revenues": []}
|
|
60
|
+
print(f"\nChecking revenue neutrality for {region}")
|
|
61
|
+
|
|
62
|
+
for veh_class in range(n_veh_classes):
|
|
63
|
+
bev_indices_class = [
|
|
64
|
+
idx for idx in [31, 32, 33] if idx % n_veh_classes == veh_class
|
|
65
|
+
]
|
|
66
|
+
ice_indices_class = [
|
|
67
|
+
idx for idx in range(25) if idx % n_veh_classes == veh_class
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
# Calculate total subsidy being paid out
|
|
71
|
+
bev_costs = data["BZTC"][
|
|
72
|
+
r, bev_indices_class, c6ti["1 Purchase cost (USD/veh)"]
|
|
73
|
+
]
|
|
74
|
+
bev_numbers = data["ZEWI"][r, bev_indices_class, 0]
|
|
75
|
+
bev_subsidy_rates = data["ZTVT"][r, bev_indices_class, 0]
|
|
76
|
+
total_subsidy = np.sum(bev_costs * bev_numbers * abs(bev_subsidy_rates))
|
|
77
|
+
|
|
78
|
+
if total_subsidy > 0:
|
|
79
|
+
# Calculate total tax being collected
|
|
80
|
+
ice_costs = data["BZTC"][
|
|
81
|
+
r, ice_indices_class, c6ti["1 Purchase cost (USD/veh)"]
|
|
82
|
+
]
|
|
83
|
+
ice_numbers = data["ZEWI"][r, ice_indices_class, 0]
|
|
84
|
+
ice_tax_rates = data["ZTVT"][r, ice_indices_class, 0]
|
|
85
|
+
total_tax = np.sum(ice_costs * ice_numbers * ice_tax_rates)
|
|
86
|
+
|
|
87
|
+
results[region]["subsidy_costs"].append(total_subsidy)
|
|
88
|
+
results[region]["tax_revenues"].append(total_tax)
|
|
89
|
+
|
|
90
|
+
print(f"\nVehicle Class {veh_class}")
|
|
91
|
+
print(f"Total BEV subsidy cost: ${total_subsidy:,.2f}")
|
|
92
|
+
print(f"Total ICE tax revenue: ${total_tax:,.2f}")
|
|
93
|
+
print(f"Difference: ${total_tax - total_subsidy:,.2f}")
|
|
94
|
+
print(f"Revenue neutral? {abs(total_tax - total_subsidy) < 1e-6}")
|
|
95
|
+
|
|
96
|
+
if results[region]["subsidy_costs"]:
|
|
97
|
+
total_subsidies = sum(results[region]["subsidy_costs"])
|
|
98
|
+
total_taxes = sum(results[region]["tax_revenues"])
|
|
99
|
+
print(f"\nTOTALS FOR {region}:")
|
|
100
|
+
print(f"Total subsidies: ${total_subsidies:,.2f}")
|
|
101
|
+
print(f"Total tax revenue: ${total_taxes:,.2f}")
|
|
102
|
+
print(f"Overall difference: ${total_taxes - total_subsidies:,.2f}")
|
|
103
|
+
print("-" * 50)
|
|
104
|
+
|
|
105
|
+
return results
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def calculate_feebate_rates(data, titles, c6ti, n_veh_classes):
|
|
109
|
+
"""Calculate feebate rates for each vehicle class to maintain revenue neutrality"""
|
|
110
|
+
for r in range(len(titles["RTI"])):
|
|
111
|
+
for veh_class in range(n_veh_classes):
|
|
112
|
+
# Get indices for this vehicle class
|
|
113
|
+
bev_indices_class = [
|
|
114
|
+
idx for idx in [31, 32, 33] if idx % n_veh_classes == veh_class
|
|
115
|
+
]
|
|
116
|
+
ice_indices_class = [
|
|
117
|
+
idx for idx in range(25) if idx % n_veh_classes == veh_class
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
# Calculate BEV subsidies for this class
|
|
121
|
+
bev_costs = data["BZTC"][
|
|
122
|
+
r, bev_indices_class, c6ti["1 Purchase cost (USD/veh)"]
|
|
123
|
+
]
|
|
124
|
+
bev_numbers = data["ZEWI"][r, bev_indices_class, 0]
|
|
125
|
+
total_subsidy = np.sum(
|
|
126
|
+
bev_costs * bev_numbers * abs(data["ZTVT"][r, bev_indices_class, 0])
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Calculate ICE tax rate for this class
|
|
130
|
+
ice_numbers = data["ZEWI"][r, ice_indices_class, 0]
|
|
131
|
+
ice_costs = data["BZTC"][
|
|
132
|
+
r, ice_indices_class, c6ti["1 Purchase cost (USD/veh)"]
|
|
133
|
+
]
|
|
134
|
+
denominator = np.sum(ice_costs * ice_numbers)
|
|
135
|
+
|
|
136
|
+
if denominator > 0:
|
|
137
|
+
ice_tax_rate = total_subsidy / denominator
|
|
138
|
+
ice_tax_rate = min(ice_tax_rate, 1.0) # Cap at 100%
|
|
139
|
+
data["ZTVT"][r, ice_indices_class, 0] = ice_tax_rate
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def get_lcof(data, titles, carbon_costs, year):
|
|
143
|
+
"""
|
|
144
|
+
Calculate levelized costs.
|
|
145
|
+
|
|
146
|
+
Calculates the levelised cost of freight transport in 2012$/t-km per
|
|
147
|
+
vehicle type. These costs are then converted into 2010 Euros/t-km per vehicle type.
|
|
148
|
+
It includes intangible costs (gamma values) and together
|
|
149
|
+
determines the investor preferences.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
-----------
|
|
153
|
+
data: dictionary
|
|
154
|
+
Dictionary with the data of the current year for all variables.
|
|
155
|
+
variables. Variable names are keys and the values are 3D NumPy arrays.
|
|
156
|
+
titles: dictionary
|
|
157
|
+
Titles is a container of all permissible dimension titles of the model.
|
|
158
|
+
|
|
159
|
+
Returns
|
|
160
|
+
----------
|
|
161
|
+
data: dictionary
|
|
162
|
+
Data is a dictionary with the data of the current year for all variables.
|
|
163
|
+
Variable names are keys and the values are 3D NumPy arrays.
|
|
164
|
+
The values inside the container are updated and returned to the main
|
|
165
|
+
routine.
|
|
166
|
+
|
|
167
|
+
Notes
|
|
168
|
+
---------
|
|
169
|
+
Calculate levelized costs with optional feebate system.
|
|
170
|
+
Feebate is activated if Feebate_active flag in data is set to 1.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
# Categories for the cost matrix (BZTC)
|
|
174
|
+
c6ti = {category: index for index, category in enumerate(titles["C6TI"])}
|
|
175
|
+
n_veh_classes = 5
|
|
176
|
+
|
|
177
|
+
# Check if feebate system is active
|
|
178
|
+
if data.get("Feebate active", np.zeros((1, 1, 1)))[0, 0, 0] == 1:
|
|
179
|
+
if data.get("iteration", 0) == 0:
|
|
180
|
+
print("\nFeebate system is active")
|
|
181
|
+
calculate_feebate_rates(data, titles, c6ti, n_veh_classes)
|
|
182
|
+
print("\nVerifying revenue neutrality...")
|
|
183
|
+
verify_revenue_neutrality(data, titles, c6ti)
|
|
184
|
+
|
|
185
|
+
tf = np.ones([len(titles["FTTI"]), 1])
|
|
186
|
+
tf[20:45] = 0 # CNG, PHEV, BEV, bio-ethanol, FCEV exempt
|
|
187
|
+
taxable_fuels = np.zeros([len(titles["RTI"]), len(titles["FTTI"]), 1])
|
|
188
|
+
|
|
189
|
+
bztc = data["BZTC"]
|
|
190
|
+
|
|
191
|
+
# Lifetimes and build years
|
|
192
|
+
lt = bztc[:, :, c6ti["8 Lifetime (y)"]]
|
|
193
|
+
max_lt = int(np.max(lt))
|
|
194
|
+
full_lt_mat = np.arange(max_lt)
|
|
195
|
+
lt_mask = full_lt_mat <= (lt[..., None] - 1) # Life time mask
|
|
196
|
+
bt_mask = full_lt_mat < np.ones_like(lt[..., None]) # Build time mask
|
|
197
|
+
|
|
198
|
+
def get_cost_elem(base_cost, conversion_factor, mask):
|
|
199
|
+
"""Mask costs during build or life time, and apply
|
|
200
|
+
conversion to generation where appropriate"""
|
|
201
|
+
cost = np.multiply(base_cost[..., None], conversion_factor)
|
|
202
|
+
return np.multiply(cost, mask)
|
|
203
|
+
|
|
204
|
+
It = get_cost_elem(
|
|
205
|
+
bztc[:, :, c6ti["1 Purchase cost (USD/veh)"]]
|
|
206
|
+
/ bztc[:, :, c6ti["15 Average mileage (km/y)"]],
|
|
207
|
+
1,
|
|
208
|
+
bt_mask,
|
|
209
|
+
)
|
|
210
|
+
dIt = get_cost_elem(
|
|
211
|
+
bztc[:, :, c6ti["2 Std of purchase cost"]]
|
|
212
|
+
/ bztc[:, :, c6ti["15 Average mileage (km/y)"]],
|
|
213
|
+
1,
|
|
214
|
+
bt_mask,
|
|
215
|
+
)
|
|
216
|
+
# Reg tax based on carbon price, RTCOt = ($/tCO2/km)/(tCO2/km)
|
|
217
|
+
RZCOt = get_cost_elem(
|
|
218
|
+
bztc[:, :, c6ti["12 CO2 emissions (gCO2/km)"]] * data["RZCO"][:, 0], 1, bt_mask
|
|
219
|
+
)
|
|
220
|
+
# Registration taxes, ZTVT is vehicle tax or subsidy (in percentage)
|
|
221
|
+
ItVT = get_cost_elem(It[:, :, 0] * data["ZTVT"][:, :, 0], 1, bt_mask)
|
|
222
|
+
Ft = get_cost_elem(bztc[:, :, c6ti["3 fuel cost (USD/km)"]], 1, lt_mask)
|
|
223
|
+
dFt = get_cost_elem(bztc[:, :, c6ti["4 std fuel cost"]], 1, lt_mask)
|
|
224
|
+
ct = get_cost_elem(carbon_costs, 1, lt_mask)
|
|
225
|
+
# fuel tax/subsidies
|
|
226
|
+
fft = get_cost_elem(
|
|
227
|
+
data["RZFT"][:, 0]
|
|
228
|
+
* bztc[:, :, c6ti["9 Energy use (MJ/vkm)"]]
|
|
229
|
+
* taxable_fuels[:, :, 0],
|
|
230
|
+
1,
|
|
231
|
+
lt_mask,
|
|
232
|
+
)
|
|
233
|
+
OMt = get_cost_elem(bztc[:, :, c6ti["5 O&M costs (USD/km)"]], 1, lt_mask)
|
|
234
|
+
dOMt = get_cost_elem(bztc[:, :, c6ti["6 std O&M"]], 1, lt_mask)
|
|
235
|
+
RT = get_cost_elem(data["ZTRT"][:, :, 0], 1, lt_mask)
|
|
236
|
+
|
|
237
|
+
Lfactor = bztc[:, :, c6ti["10 Loads (t or passengers/veh)"], np.newaxis]
|
|
238
|
+
|
|
239
|
+
# Discount rate
|
|
240
|
+
dr = bztc[:, :, c6ti["7 Discount rate"], np.newaxis]
|
|
241
|
+
denominator = (1 + dr) ** full_lt_mat
|
|
242
|
+
|
|
243
|
+
# Calculate LCOF without policy, and find standard deviation
|
|
244
|
+
npv_expenses_bare = (It + Ft + OMt) / Lfactor
|
|
245
|
+
npv_expenses_bare = npv_expenses_bare / denominator
|
|
246
|
+
|
|
247
|
+
# Calculate LCOF with policy, and find standard deviation
|
|
248
|
+
npv_expenses_policy = (It + ct + RZCOt + ItVT + Ft + fft + OMt + RT) / Lfactor
|
|
249
|
+
npv_expenses_policy = npv_expenses_policy / denominator
|
|
250
|
+
|
|
251
|
+
# 3 – Utility
|
|
252
|
+
npv_utility = np.where(lt_mask, 1, 0) / denominator
|
|
253
|
+
utility_sum = np.sum(npv_utility, axis=2)
|
|
254
|
+
|
|
255
|
+
# Standard deviation calculation
|
|
256
|
+
# First sum the variances
|
|
257
|
+
variance_terms = dIt**2 + dFt**2 + dOMt**2
|
|
258
|
+
# Scale variances by load factor
|
|
259
|
+
scaled_variance = variance_terms / (Lfactor**2)
|
|
260
|
+
# Apply proper discounting (squared) and sum
|
|
261
|
+
summed_variance = np.sum(scaled_variance / (denominator**2), axis=2)
|
|
262
|
+
# TODO, softcode. Hardcoded uncertainty With uncertainty in load factors ()
|
|
263
|
+
variance_plus_dcf = (
|
|
264
|
+
summed_variance + (np.sum(npv_expenses_bare, axis=2) * 0.15) ** 2
|
|
265
|
+
)
|
|
266
|
+
# Calculate final standard deviation
|
|
267
|
+
|
|
268
|
+
LCOF = np.sum(npv_expenses_bare, axis=2) / utility_sum
|
|
269
|
+
dLCOF = np.sqrt(variance_plus_dcf) / utility_sum
|
|
270
|
+
|
|
271
|
+
TLCOF = np.sum(npv_expenses_policy, axis=2) / utility_sum
|
|
272
|
+
|
|
273
|
+
# Introduce Gamma Values
|
|
274
|
+
TLCOFG = TLCOF * (1 + bztc[:, :, c6ti["11 Gamma"]])
|
|
275
|
+
|
|
276
|
+
# Compute levelised cost in freight in $/tkm
|
|
277
|
+
data["ZTLC"][:, :, 0] = LCOF # LCOF without policy
|
|
278
|
+
data["ZTLD"][:, :, 0] = dLCOF # LCOF without policy SD
|
|
279
|
+
data["ZTTC"][:, :, 0] = TLCOF # LCOF with policy
|
|
280
|
+
data["ZTTD"][:, :, 0] = dLCOF # LCOF with policy SD
|
|
281
|
+
data["ZEGC"][:, :, 0] = TLCOFG # LCOF with policy and gamma
|
|
282
|
+
|
|
283
|
+
# Vehicle price components for front end ($/veh)
|
|
284
|
+
data["ZWIC"][:, :, 0] = (
|
|
285
|
+
bztc[:, :, c6ti["1 Purchase cost (USD/veh)"]] * (1 + data["ZTVT"][:, :, 0])
|
|
286
|
+
+ bztc[:, :, c6ti["12 CO2 emissions (gCO2/km)"]] * data["RZCO"][:, 0]
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
# Vehicle fuel price components for front end ($/km)
|
|
290
|
+
data["ZWFC"][:, :, 0] = (
|
|
291
|
+
bztc[:, :, c6ti["3 fuel cost (USD/km)"]]
|
|
292
|
+
+ data["RZFT"][:, 0]
|
|
293
|
+
* bztc[:, :, c6ti["9 Energy use (MJ/vkm)"]]
|
|
294
|
+
* taxable_fuels[:, :, 0]
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
return data
|