Skip to content

Commit

Permalink
Move the co2_factors into a csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bachibouzouk committed Apr 28, 2024
1 parent e34f01f commit 84d6ddd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
15 changes: 15 additions & 0 deletions docs/energy_co2_conversion_factors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
energy_carrier_name,unit,value,energy_carrier_unit,information source,CO2 per energy_carrier_unit
Biodiesel,kWh_eleq/l,0.06290669,l,,0
Crude_oil,kWh_eleq/kg,11.63042204,kg,,0
Diesel,kWh_eleq/l,9.48030688,l,"https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l",0
Electricity,kWh_eleq/kWh_el,1,kWh_el,,0
Ethane,kWh_eleq/l,5.149767951,l,,0
Ethanol,kWh_eleq/l,0.04242544,l,,0
Gas,kWh_eleq/m3,0.00933273,l,"https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l",0
Gasoline,kWh_eleq/l,8.735753974,l,,0
H2,kWh_eleq/kgH2,33.47281985,kgH2,"https://epact.energy.gov/fuel-conversion-factors",0
Heat,KWh_eleq/kWh_therm,1.0002163,kWh_therm,,0
Kerosene,kWh_eleq/l,8.908073954,l,,0
LNG,kWh_eleq/kg,12.69270292,kg,,0
LPG,kWh_eleq/l,6.472821609,l,,0
Natural_gas,kWh_eleq/m3,0.00933273,l,"https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l",0
8 changes: 4 additions & 4 deletions prepare_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
os.path.join(".", pgk_data_src), os.path.join(pkg_data_folder, pkg_data_dest)
)
# Move the MVS parameters from the docs into the package_data folder
shutil.copyfile(
os.path.join(".", "docs", "MVS_parameters_list.csv"),
os.path.join(pkg_data_folder, "MVS_parameters_list.csv"),
)
for doc_file in ("MVS_parameters_list.csv", "energy_co2_conversion_factors.csv"):
shutil.copyfile(
os.path.join(".", "docs", doc_file), os.path.join(pkg_data_folder, doc_file),
)

# Rebuild the package
os.system("python setup.py sdist bdist_wheel")
Expand Down
59 changes: 22 additions & 37 deletions src/multi_vector_simulator/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=================
"""
import os
import pandas as pd
from copy import deepcopy

from multi_vector_simulator.utils.constants_json_strings import *
Expand Down Expand Up @@ -289,43 +290,27 @@
},
}

ENERGY_CARRIER_UNIT = "energy_carrier_unit"
DEFAULT_WEIGHTS_ENERGY_CARRIERS = {
"LNG": {UNIT: "kWh_eleq/kg", VALUE: 12.69270292, ENERGY_CARRIER_UNIT: "kg",},
"Crude_oil": {UNIT: "kWh_eleq/kg", VALUE: 11.63042204, ENERGY_CARRIER_UNIT: "kg",},
"Diesel": {
UNIT: "kWh_eleq/l",
VALUE: 9.48030688,
ENERGY_CARRIER_UNIT: "l",
}, # https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l
"Kerosene": {UNIT: "kWh_eleq/l", VALUE: 8.908073954, ENERGY_CARRIER_UNIT: "l",},
"Gasoline": {UNIT: "kWh_eleq/l", VALUE: 8.735753974, ENERGY_CARRIER_UNIT: "l",},
"LPG": {UNIT: "kWh_eleq/l", VALUE: 6.472821609, ENERGY_CARRIER_UNIT: "l",},
"Ethane": {UNIT: "kWh_eleq/l", VALUE: 5.149767951, ENERGY_CARRIER_UNIT: "l",},
"H2": {
UNIT: "kWh_eleq/kgH2",
VALUE: 33.47281985,
ENERGY_CARRIER_UNIT: "kgH2",
}, # https://epact.energy.gov/fuel-conversion-factors
"Electricity": {UNIT: "kWh_eleq/kWh_el", VALUE: 1, ENERGY_CARRIER_UNIT: "kWh_el",},
"Biodiesel": {UNIT: "kWh_eleq/l", VALUE: 0.06290669, ENERGY_CARRIER_UNIT: "l",},
"Ethanol": {UNIT: "kWh_eleq/l", VALUE: 0.04242544, ENERGY_CARRIER_UNIT: "l",},
"Natural_gas": {
UNIT: "kWh_eleq/m3",
VALUE: 0.00933273,
ENERGY_CARRIER_UNIT: "l",
}, # https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l
"Gas": {
UNIT: "kWh_eleq/m3",
VALUE: 0.00933273,
ENERGY_CARRIER_UNIT: "l",
}, # https://epact.energy.gov/fuel-conversion-factors, conversion gallon->4.546092 l
"Heat": {
UNIT: "KWh_eleq/kWh_therm",
VALUE: 1.0002163,
ENERGY_CARRIER_UNIT: "kWh_therm",
},
}
WEIGHTS_ENERGY_CARRIER = "weights_energy_carrier"

try:
energy_carriers_file = "energy_co2_conversion_factors.csv"
FILE_PATH = os.path.join(
os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
),
"docs",
)
if os.path.exists(FILE_PATH):
FILE_PATH = PACKAGE_DATA_PATH

df = pd.read_csv(
os.path.join(FILE_PATH, "energy_co2_conversion_factors.csv"), index_col=0
)

DEFAULT_WEIGHTS_ENERGY_CARRIERS = df.to_dict(orient="index")
except FileNotFoundError:
DEFAULT_WEIGHTS_ENERGY_CARRIERS = None


# dict keys in results_json file
TIMESERIES = "timeseries"
Expand Down

0 comments on commit 84d6ddd

Please sign in to comment.