future-technology-transformation 0.1.0__tar.gz

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.
Files changed (69) hide show
  1. future_technology_transformation-0.1.0/LICENSE +21 -0
  2. future_technology_transformation-0.1.0/PKG-INFO +71 -0
  3. future_technology_transformation-0.1.0/README.md +48 -0
  4. future_technology_transformation-0.1.0/SourceCode/Freight/ftt_fr_lcof.py +297 -0
  5. future_technology_transformation-0.1.0/SourceCode/Freight/ftt_fr_main.py +504 -0
  6. future_technology_transformation-0.1.0/SourceCode/Heat/ftt_h_lcoh.py +218 -0
  7. future_technology_transformation-0.1.0/SourceCode/Heat/ftt_h_main.py +528 -0
  8. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/__init__.py +5 -0
  9. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/ftt_chi_main.py +632 -0
  10. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/ftt_fbt_main.py +628 -0
  11. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/ftt_mtm_main.py +637 -0
  12. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/ftt_nmm_main.py +632 -0
  13. future_technology_transformation-0.1.0/SourceCode/Industrial_Heat/ftt_ois_main.py +632 -0
  14. future_technology_transformation-0.1.0/SourceCode/Power/__init__.py +5 -0
  15. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_costc.py +512 -0
  16. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_dspch.py +278 -0
  17. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_early_scrapping_costs.py +61 -0
  18. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_fuel_price.py +295 -0
  19. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_integration_costs.py +124 -0
  20. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_lcoe.py +280 -0
  21. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_main.py +930 -0
  22. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_phase_out.py +47 -0
  23. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_rldc.py +1015 -0
  24. future_technology_transformation-0.1.0/SourceCode/Power/ftt_p_surv.py +111 -0
  25. future_technology_transformation-0.1.0/SourceCode/Transport/__init__.py +5 -0
  26. future_technology_transformation-0.1.0/SourceCode/Transport/ftt_tr_emission_corrections.py +118 -0
  27. future_technology_transformation-0.1.0/SourceCode/Transport/ftt_tr_lcot.py +193 -0
  28. future_technology_transformation-0.1.0/SourceCode/Transport/ftt_tr_main.py +519 -0
  29. future_technology_transformation-0.1.0/SourceCode/Transport/ftt_tr_survival.py +130 -0
  30. future_technology_transformation-0.1.0/SourceCode/__init__.py +22 -0
  31. future_technology_transformation-0.1.0/SourceCode/ftt_core/__init__.py +5 -0
  32. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_emissions_regulation.py +332 -0
  33. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_exogenous_capacity.py +60 -0
  34. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_exogenous_sales.py +60 -0
  35. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_mandate.py +257 -0
  36. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_sales_or_investments.py +147 -0
  37. future_technology_transformation-0.1.0/SourceCode/ftt_core/ftt_shares.py +375 -0
  38. future_technology_transformation-0.1.0/SourceCode/initialise_csv_files.py +118 -0
  39. future_technology_transformation-0.1.0/SourceCode/model_class.py +418 -0
  40. future_technology_transformation-0.1.0/SourceCode/paths.py +109 -0
  41. future_technology_transformation-0.1.0/SourceCode/sector_coupling/__init__.py +10 -0
  42. future_technology_transformation-0.1.0/SourceCode/sector_coupling/battery_lbd.py +167 -0
  43. future_technology_transformation-0.1.0/SourceCode/sector_coupling/electricity_demand.py +47 -0
  44. future_technology_transformation-0.1.0/SourceCode/sector_coupling/electricity_price.py +45 -0
  45. future_technology_transformation-0.1.0/SourceCode/sector_coupling/transport_batteries_to_power.py +192 -0
  46. future_technology_transformation-0.1.0/SourceCode/support/__init__.py +5 -0
  47. future_technology_transformation-0.1.0/SourceCode/support/check_market_shares.py +46 -0
  48. future_technology_transformation-0.1.0/SourceCode/support/convert_masterfiles_to_csv.py +586 -0
  49. future_technology_transformation-0.1.0/SourceCode/support/cross_section.py +108 -0
  50. future_technology_transformation-0.1.0/SourceCode/support/debug_messages.py +18 -0
  51. future_technology_transformation-0.1.0/SourceCode/support/dimensions_functions.py +55 -0
  52. future_technology_transformation-0.1.0/SourceCode/support/divide.py +28 -0
  53. future_technology_transformation-0.1.0/SourceCode/support/docstring_templates.py +119 -0
  54. future_technology_transformation-0.1.0/SourceCode/support/gamma_value_automation.py +623 -0
  55. future_technology_transformation-0.1.0/SourceCode/support/get_vars_to_copy.py +40 -0
  56. future_technology_transformation-0.1.0/SourceCode/support/input_functions.py +305 -0
  57. future_technology_transformation-0.1.0/SourceCode/support/output_functions.py +58 -0
  58. future_technology_transformation-0.1.0/SourceCode/support/paths_append.py +18 -0
  59. future_technology_transformation-0.1.0/SourceCode/support/read_support.py +30 -0
  60. future_technology_transformation-0.1.0/SourceCode/support/titles_functions.py +53 -0
  61. future_technology_transformation-0.1.0/future_technology_transformation/__init__.py +144 -0
  62. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/PKG-INFO +71 -0
  63. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/SOURCES.txt +67 -0
  64. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/dependency_links.txt +1 -0
  65. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/entry_points.txt +2 -0
  66. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/requires.txt +15 -0
  67. future_technology_transformation-0.1.0/future_technology_transformation.egg-info/top_level.txt +2 -0
  68. future_technology_transformation-0.1.0/pyproject.toml +29 -0
  69. future_technology_transformation-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Climate Policy Assessment Community of Models
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: future_technology_transformation
3
+ Version: 0.1.0
4
+ Summary: Future Technology Transformation (FTT) models
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: numpy
10
+ Requires-Dist: pandas
11
+ Requires-Dist: openpyxl
12
+ Requires-Dist: tqdm
13
+ Requires-Dist: numba
14
+ Provides-Extra: gui
15
+ Requires-Dist: nicegui; extra == "gui"
16
+ Requires-Dist: plotly; extra == "gui"
17
+ Requires-Dist: nest_asyncio; extra == "gui"
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: black; extra == "dev"
21
+ Requires-Dist: sphinx; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # Future Technology Transformation (FTT)
25
+
26
+ ## Modules
27
+ This repository contains a family of Future Technology Transformation (FTT) models. Models that are included are:
28
+
29
+ * FTT:Power (Mercure, 2012) - updated to 2022 (generation) and 2023 (prices)
30
+ * FTT:Heat (Knobloch et al, 2017) data up to 2020
31
+ * FTT:Industrial heat
32
+ * FTT:Transport (Mercure et al, 2018) - data up to 2022
33
+ * FTT:Freight - data up to 2023
34
+ * FTT:Hydrogen (*under review*)
35
+
36
+ ## Theoretical background
37
+ The FTT family of models are based on [evolutionary economics](https://en.wikipedia.org/wiki/Evolutionary_economics). The uptake of new technologies typically follows an S-curve, which can be represented well with evolutionary dynamics (Mercure et al, 2012). The core equations for all of the models in the model family are coupled logistic equations of the [Lotka-Volterra family](https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations), also known as the predator-prey equations. These equations are used to determine the evolution of the shares of various technologies in the models. Each model contains between ~10 to 25 technologies competing for market share.
38
+
39
+ ## FTT and macro-economic models
40
+ This repository contains the main version of FTT, written in Python. It comes as a package that can be imported into macro-economic models. A FORTRAN version of the model family is often used together with a macro-economic model as: [E3ME-FTT](https://www.e3me.com/). This model is managed by Cambridge Econometrics, and informs some of the inputs for the model. In specific, energy demand is an output from the coupled model.
41
+
42
+ ## Installation
43
+
44
+ Before you start, make sure that git is installed on your system, for instance by [installing GitHub Desktop](https://docs.github.com/en/desktop/installing-and-authenticating-to-github-desktop/installing-github-desktop)
45
+
46
+ 1. Open your terminal at a location where you want to install ftt. Type the following in your terminal to download the package from GitHub:
47
+
48
+ ```bash
49
+ git clone https://github.com/cpmodel/FTT_StandAlone.git
50
+ ```
51
+ 2. The python package requirements are curated in the `environment.yml` file.
52
+ Change directory to the repo, and then install the environment using:
53
+
54
+ ```bash
55
+ conda env create -f environment.yml
56
+ ```
57
+ 3. On Windows, you can start the frontend with `launch_frontend.bat`. If Python is not yet added to your path, [ensure you add this first](https://realpython.com/add-python-to-path/).
58
+
59
+ Alternatively, you can download ftt by clicking the green `Code` button in the top right, and selecting `Open with Github Desktop` if you have this installed. You can import the environment in Anaconda Navigator.
60
+
61
+ ## Running the model
62
+ 1. You can run the frontend of the model in your browser by either double clicking `open_frontend.bat` or by running `run_frontend.py`. Select the models to run and scenarios and explore the output.
63
+ 2. Alternatively, you can run the model from the run_file.py script. Output is saved to a pickle file in the Output folder. Select the models and scenarios from the settings.ini file.
64
+ 3. Create new scenarios by adding a new folder in the Inputs folder. Data is read in first from this folder, and missing data is read from the S0 baseline folder.
65
+
66
+ ## References
67
+ * Heat: Knobloch, F., Pollitt H., Chewpreecha U., Daioglou V. and Mercure J-F. (2018) ‘[Simulating the deep decarbonisation of residential heating for limiting global warming to 1.5°C](https://link.springer.com/article/10.1007/s12053-018-9710-0)’, Energy Efficiency **12**, Issue 2, pp 521–550.
68
+ * Power: Mercure (2012): [A global model of the power sector with induced technological change and natural resource depletion](https://www.sciencedirect.com/science/article/pii/S0301421512005356 ). Energy Policy **48**.
69
+ * Power: Nijsse et al. (2023): [The momentum of the solar energy transition ](https://doi.org/10.1038/s41467-023-41971-7). Nature Communications **14**
70
+ * Passenger transport: Mercure, J-F., Lam, A., Billington, S. and Pollitt, H. (2018) ‘[Integrated assessment modelling as a positive science: private passenger road transport policies to meet a climate target well below 2°C](https://pubmed.ncbi.nlm.nih.gov/30930506/)’, Climatic Change, November 2018, Volume 151, Issue 2, pp 109–129.
71
+ * Steel: Vercoulen, P.; Lee, S.; Han, X.; Zhang, W.; Cho, Y.; Pang, J. (2023) '[Carbon-Neutral Steel Production and Its Impact on the Economies of China, Japan, and Korea: A Simulation with E3ME-FTT:Steel](https://www.mdpi.com/1996-1073/16/11/4498). Energies **16**, 4498. https://doi.org/10.3390/en16114498
@@ -0,0 +1,48 @@
1
+ # Future Technology Transformation (FTT)
2
+
3
+ ## Modules
4
+ This repository contains a family of Future Technology Transformation (FTT) models. Models that are included are:
5
+
6
+ * FTT:Power (Mercure, 2012) - updated to 2022 (generation) and 2023 (prices)
7
+ * FTT:Heat (Knobloch et al, 2017) data up to 2020
8
+ * FTT:Industrial heat
9
+ * FTT:Transport (Mercure et al, 2018) - data up to 2022
10
+ * FTT:Freight - data up to 2023
11
+ * FTT:Hydrogen (*under review*)
12
+
13
+ ## Theoretical background
14
+ The FTT family of models are based on [evolutionary economics](https://en.wikipedia.org/wiki/Evolutionary_economics). The uptake of new technologies typically follows an S-curve, which can be represented well with evolutionary dynamics (Mercure et al, 2012). The core equations for all of the models in the model family are coupled logistic equations of the [Lotka-Volterra family](https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations), also known as the predator-prey equations. These equations are used to determine the evolution of the shares of various technologies in the models. Each model contains between ~10 to 25 technologies competing for market share.
15
+
16
+ ## FTT and macro-economic models
17
+ This repository contains the main version of FTT, written in Python. It comes as a package that can be imported into macro-economic models. A FORTRAN version of the model family is often used together with a macro-economic model as: [E3ME-FTT](https://www.e3me.com/). This model is managed by Cambridge Econometrics, and informs some of the inputs for the model. In specific, energy demand is an output from the coupled model.
18
+
19
+ ## Installation
20
+
21
+ Before you start, make sure that git is installed on your system, for instance by [installing GitHub Desktop](https://docs.github.com/en/desktop/installing-and-authenticating-to-github-desktop/installing-github-desktop)
22
+
23
+ 1. Open your terminal at a location where you want to install ftt. Type the following in your terminal to download the package from GitHub:
24
+
25
+ ```bash
26
+ git clone https://github.com/cpmodel/FTT_StandAlone.git
27
+ ```
28
+ 2. The python package requirements are curated in the `environment.yml` file.
29
+ Change directory to the repo, and then install the environment using:
30
+
31
+ ```bash
32
+ conda env create -f environment.yml
33
+ ```
34
+ 3. On Windows, you can start the frontend with `launch_frontend.bat`. If Python is not yet added to your path, [ensure you add this first](https://realpython.com/add-python-to-path/).
35
+
36
+ Alternatively, you can download ftt by clicking the green `Code` button in the top right, and selecting `Open with Github Desktop` if you have this installed. You can import the environment in Anaconda Navigator.
37
+
38
+ ## Running the model
39
+ 1. You can run the frontend of the model in your browser by either double clicking `open_frontend.bat` or by running `run_frontend.py`. Select the models to run and scenarios and explore the output.
40
+ 2. Alternatively, you can run the model from the run_file.py script. Output is saved to a pickle file in the Output folder. Select the models and scenarios from the settings.ini file.
41
+ 3. Create new scenarios by adding a new folder in the Inputs folder. Data is read in first from this folder, and missing data is read from the S0 baseline folder.
42
+
43
+ ## References
44
+ * Heat: Knobloch, F., Pollitt H., Chewpreecha U., Daioglou V. and Mercure J-F. (2018) ‘[Simulating the deep decarbonisation of residential heating for limiting global warming to 1.5°C](https://link.springer.com/article/10.1007/s12053-018-9710-0)’, Energy Efficiency **12**, Issue 2, pp 521–550.
45
+ * Power: Mercure (2012): [A global model of the power sector with induced technological change and natural resource depletion](https://www.sciencedirect.com/science/article/pii/S0301421512005356 ). Energy Policy **48**.
46
+ * Power: Nijsse et al. (2023): [The momentum of the solar energy transition ](https://doi.org/10.1038/s41467-023-41971-7). Nature Communications **14**
47
+ * Passenger transport: Mercure, J-F., Lam, A., Billington, S. and Pollitt, H. (2018) ‘[Integrated assessment modelling as a positive science: private passenger road transport policies to meet a climate target well below 2°C](https://pubmed.ncbi.nlm.nih.gov/30930506/)’, Climatic Change, November 2018, Volume 151, Issue 2, pp 109–129.
48
+ * Steel: Vercoulen, P.; Lee, S.; Han, X.; Zhang, W.; Cho, Y.; Pang, J. (2023) '[Carbon-Neutral Steel Production and Its Impact on the Economies of China, Japan, and Korea: A Simulation with E3ME-FTT:Steel](https://www.mdpi.com/1996-1073/16/11/4498). Energies **16**, 4498. https://doi.org/10.3390/en16114498
@@ -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