DOI: 10.5061/dryad.2280gb63j
title: Truck and grid code from: Impact of truck electrification on air pollution disparities in the U.S

description: Electrifying heavy trucks reduces on-road air pollutant emissions but
 shifts the burden to power generation facilities. The combined effects of
 grid decarbonization and truck electrification will alter the magnitude
 and distribution of air pollution burdens across the U.S. These
 investments are intended to facilitate a just energy transition per the
 Justice40 Initiative. With the provided code and data, we evaluated the
 combined effects of IRA grid decarbonization and truck electrification
 investments on a national scale to determine whether the air pollution
 benefits would meet this 40% goal. The “Truck Model” zip file contains the
 code and data to simulate Class 8 heavy-duty truck flows and emissions
 (air pollutants and greenhouse gases) along select inter-regional and
 drayage routes. This code also simulates charging load curves from
 electric trucks, which can be plugged into our grid model. The “Grid
 Model” zip file contains the code and data to run our electricity grid
 emissions model. This model estimates annual power flow and marginal
 electricity grid emissions on a national scale due to increases in demand.
 We projected results from present-day through 2050 and under multiple
 renewable energy and policy scenarios. After running both the truck and
 grid model, results can be used in an air quality model of the users’
 choice to estimate human health and equity impacts.
description: # Truck and Grid Code used in "Impact of Truck Electrification on Air
 Pollution Disparities in the U.S." The truck and grid model code are
 available on Dryad. DOI: 10.5061/dryad.2280gb63j The dataset contains two
 zip files, "Truck Model" and "Grid Model", which
 contain the truck code and grid code, respectively. # Description of the
 data and file structure # Truck Code Truck load curves from each of 200
 trucking corridors can be generated using
 "`Script_Main_Iteration.`" Annual diesel emissions can be
 generated using "`Script_Diesel_Inventory_Iteration.`" Both of
 these scripts call on the various functions in the folder. Results can be
 projected into future years through 2050 using
 "`Script_TRUE_year_iteration.`" Users will need to edit the file
 path and truck scenario in the code. Code requires truck highway counts in
 the format copied below (corridor_data.mat). Freight Analysis Framework -
 FHWA Freight Management and Operations
 ([https://ops.fhwa.dot.gov/freight/freight_analysis/faf/](https://ops.fhwa.dot.gov/freight/freight_analysis/faf/)) was used for highway truck counts in McNeil et al. (2025). The list of corridors used in McNeil et al. (2025) is available in "Corridor_start_and_end.xlsx." ## Entry point | File name | Vehicle system | Description | | :-------------------------- | :--------------------- | :------------------------------------------------ | | Script\_Main\_Test.m | Battery-electric truck | Used to debug and quickly generate results | | Script\_Diesel\_Inventory.m | Diesel truck | Used to generate results for all diesel scenarios | ### Structure **Script_Main_Test.m** • func_data_input • func_unit_conversion • func_truck_energy • func_truck_charging • func_truck_dispatch • func_electrification_load **Script_Diesel_Inventory.m** • func_data_input • func_unit_conversion • func_truck_energy • func_diesel_truck_emissions • func_kWhPerMile_to_MPG o Data  emissions_inventory_diesel.xlsx ### File structure 26 code files #### Level 1 – 4 files • Script_Main_Test.m • Script_Diesel_Inventory.m #### Level 2 – 7 files • func_data_input • func_unit_conversion • func_truck_energy • func_truck_charging • func_truck_dispatch • func_electrification_load_states • func_diesel_truck_emissions_iteration • func_BA_called • func_NERC_regions_called • func_penetration_rate_iteration • func_states_called #### Level 3 – 10 files • func_corridor_selection • func_vehicle_weight_electric • func_truck_speed • func_flow_at_a_distance_probability • func_vehicle_energy_model • func_kWhPerMile_to_MPG • func_segment_points • func_hour_vector_2_minute_vector • func_corridor_load_curves • func_load_aggregation #### Level 4 – 3 files • script_common_assumptions • func_time_sessions2sequence • func_time_min2pair #### 11 data files • corridor_data.mat (see structure below) • corridor_classification.xlsx • time_zone_data.xlsx • county_FIPS.mat • emissions_inventory_diesel.xlsx • BA_start_and_end.mat • Corridor_start_and_end.xlsx • state_and_NERC_codes.xlsx • State_code_abbreviations.xlsx • State_time_zones.xlsx • truck_dispatchmatrix4.mat ## corridor\_data.mat There are five variables * 'corridor_segment_count' * 'corridor_length' * 'number_of_corridors' * 'corridor_segment_index' * 'corridor_flow_data' Notably, 'corridor_flow_data' is a matrix/dataframe. Its rows are the segments in the database. There are about 60,000+ road segments. Its columns are (different) characteristics/metrics. There are 15 columns. Their corresponding units are in the parenthesis. (1) FAF4_ID (2) county FIPS index (3) State Code (4) NERC region index (5) NERC+CA region index (6) road length (mile) (7) SPD_LIMIT (mile per hour) (8) TERRAIN (discrete values) (9) FAF12 (#/day) (10) YKTON12 (tonnage k-short ton/year/section) (11) FAF45 (#/day) (12) YKTON45 (tonnage k-short ton/year/section) (13-14) one end point (long, lat) (15-16) another end point (long, lat) (17) Balancing area number ## Coding explanations Time series Natural time; these times are referred for the beginning of the minute. (0h, 00m), .., (0h, 59m), ... (23h, 00m), ..., (23h, 59m) 840 minutes for a day. Matlab’s vector representation \[1, 840] Matlab’s paired hour/min representation; these times are referred for the beginning of the minute. (1, 1), ..., (1, 60), ... (24, 1), ... (24, 60) Calculation of durations by hour Charging start times and charging end times are calculated by adding up the session blocks for these events. For instance, assuming there is a 30-minutes driving session, and a 5-minutes set-up session, the charging time start time then determined as 35. This actually means that it starts at the end of 35th minutes, or at the beginning of the 36th minute. Example 1. 59th -61st minutes at the charging station. Charging duration = 61 – 59 = 2 minutes. Natural time: started charging at 0h58m, and finished charging at 1h0m. Matlab’s paired hour/min representation (1, 59), (2, 1) Duration of charging in hours: 1=(60-59) minute in hour 1, and 1=(1-0) minute in hour 2. Example 2. 60th -110th minutes at the charging station. Charging duration = 110 – 60 = 50 minutes. Natural time: started charging at 0h59m, and finished charging at 1h49m. Matlab’s paired hour/min representation (1, 60), (2, 50) Duration of charging in hours: 0=(60-60) minute in hour 1, and 50=(50-0) minute in hour 2. # Grid Code Electricity grid emissions can be calculated using "`Script_McGrid_iteration`" and "`Script_McGrid_iteration_IRA`" for runs without and with Inflation Reduction Act tax credits for renewable energy, respectively. An hourly load curve (containing 8,760 hours in a year) from the truck code or elsewhere is the input to this model and the output is the annual grid emissions. User will need to edit the file path and grid scenario in the code. ## Required data to run this code T_region_hour - matrix of transmission connected regions (T-regions) for each hour of the year. Length is 1 to number of T-regions. Each cell contains balancing area numbers of balancing areas within T-region. Each renewable energy scenario and year requires its own file. Data source used in McNeil et al. (2024) and McNeil et al. (2025) is Cambium (NREL, 2021 and NREL, 2022) [https://www.nrel.gov/analysis/cambium.html](https://www.nrel.gov/analysis/cambium.html). See Cambium (NREL, 2021 and NREL, 2022), McNeil et al. (2024), and McNeil et al. (2025) for information on determining T-region extent. marg_gen - 8760 by 134 matrix. Rows are 8760 hours in the year. Columns are 134 balancing areas. Each cell contains the short-run marginal generator type (e.g., hydro) of a balancing area. Each renewable energy scenario and year requires its own file. Data source used in McNeil et al. (2024) and McNeil et al. (2025) is Cambium (NREL, 2021 and NREL, 2022) [https://www.nrel.gov/analysis/cambium.html](https://www.nrel.gov/analysis/cambium.html). data_T - power plant-level capacity, generation, greenhouse gas emission factors, and air pollutant emission factors. Nested structure. First level length: 1 to 8760 hours in a year. Second level: 1 to number of T-regions. Third level: matrix of plant-level data within given T-region. Each renewable energy scenario and year requires its own file. Plant-level data source used in McNeil et al. (2024) and McNeil et al. (2025) is Jenn, A., Clark-Sutton, K., Gallaher, M. & Petrusa, J. Environmental impacts of extreme fast charging. Environ. Res. Lett. 15, 094060 (2020). data_BA_sorted - length of cells is 1 to 134. Within each cell is balancing area-level transmission losses. Each renewable energy scenario and year requires its own file. Data source used in McNeil et al. (2024) and McNeil et al. (2025) is Cambium (NREL, 2021 and NREL, 2022) [https://www.nrel.gov/analysis/cambium.html](https://www.nrel.gov/analysis/cambium.html). ## Stack height If the user wants to know the stack height of the emissions for use in a subsequent air quality model, they can run the "`Script_stack_height_iteration`" or "`Script_stack_height_iteration_IRA`" code. User will need a database of all U.S. power plants, stack heights, and plant code. Data source used in McNeil et al. (2024) and McNeil et al. (2025) is U.S. EPA. 2017 National Emissions Inventory (NEI). # Sharing/Access information If original data sources become unavailable, please reach out to Wilson McNeil ([wilson_mcneil@berkeley.edu](mailto:wilson_mcneil@berkeley.edu)) or Corinne Scown ([cdscown@lbl.gov](mailto:cdscown@lbl.gov)). # Code/Software Data from the code was generated using MATLAB. The .m files included may be able to be run using open-source software such as Octave with minor revisions or translated into other languages such as Python.