Skip to content

Commit

Permalink
Debugging Postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofBernsteiner committed Jun 25, 2024
1 parent ddcf353 commit 92cc240
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 58 deletions.
83 changes: 53 additions & 30 deletions examples/Cell4LifeSimulationExecutorvII.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@
PV_Peak_in_W = PV_Peak_in_kW * 1000 # Umrechnung in Watt


#FuelCellPowerW_list = [PV_Peak_in_W/(2.1),PV_Peak_in_W/(2*2.1), PV_Peak_in_W/(4*2.1), PV_Peak_in_W/(6*2.1), PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1) ] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power
FuelCellPowerW_list = [PV_Peak_in_W/(2.1),PV_Peak_in_W/(2*2.1), PV_Peak_in_W/(4*2.1), PV_Peak_in_W/(6*2.1), PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1),PV_Peak_in_W/(12*2.1),PV_Peak_in_W/(14*2.1) ] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power

FuelCellPowerW_list = [PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1) , PV_Peak_in_W/(12*2.1)] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power
# FuelCellPowerW_list = [PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1) , PV_Peak_in_W/(12*2.1)] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power


Inverter_Ratio_list = [3, 2.5, 2, 1.5, 1] #Means: Inverter_power_demand = (electrolyzer_energy + h2 storage)*Inverter_Ratio_lis --> inverter is always able to deliver at least power demand of electrolyzer and h2 storage!

#BatterieFaktorList = [12,10, 8, 6, 4, 2, 1] # Battery Capacity =Inverter Power * Batteriefaktorlist --> Batteriekapazität = Faktor * Inverterleistung
BatterieFaktorList = [20, 18, 16,14, 12,10, 8, 6, 4, 2, 1] # Battery Capacity =Inverter Power * Batteriefaktorlist --> Batteriekapazität = Faktor * Inverterleistung

BatterieFaktorList = [16, 14]
#BatterieFaktorList = [16, 14]


FuelCellPowerWUnit = "W"
Expand All @@ -94,7 +94,7 @@
# PreResultNumber = 0
# PreResultNumberUnit = "-"

PreResultNumber = 11111
PreResultNumber = 0
PreResultNumberUnit = "-"

for BatterieFaktor in BatterieFaktorList:
Expand Down Expand Up @@ -205,47 +205,48 @@
print(finishtext)


# # # # #*************************************************
# # # # # #*************************************************
# # ##Szenario 2a

# ##Szenario 2a
# szenario = "2a"
# szenarioUnit = "-"
# print("Szenario ", szenario)

PV_Peak_in_kW = 781 # in kW
PV_Peak_in_W = PV_Peak_in_kW * 1000 # Umrechnung in Watt
# PV_Peak_in_kW = 781 # in kW
# PV_Peak_in_W = PV_Peak_in_kW * 1000 # Umrechnung in Watt

# #PV_Peak_in_W/(2.1)
# #FuelCellPowerW_list = [PV_Peak_in_W/(2.1),PV_Peak_in_W/(2*2.1), PV_Peak_in_W/(4*2.1), PV_Peak_in_W/(6*2.1), PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1), PV_Peak_in_W/(12*2.1) ] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power

#FuelCellPowerW_list = [PV_Peak_in_W/(2.1),PV_Peak_in_W/(2*2.1), PV_Peak_in_W/(4*2.1), PV_Peak_in_W/(6*2.1), PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1) ] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power
# FuelCellPowerW_list = [PV_Peak_in_W/(14*2.1)] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power

FuelCellPowerW_list = [PV_Peak_in_W/(8*2.1), PV_Peak_in_W/(10*2.1) , PV_Peak_in_W/(12*2.1)] #Electricity Power of Fuel Cell Power in Watt, depending on PV - Peak power
# Inverter_Ratio_list = [3, 2.5, 2, 1.5, 1] #Means: Inverter_power_demand = (electrolyzer_energy + h2 storage)*Inverter_Ratio_lis --> inverter is always able to deliver at least power demand of electrolyzer and h2 storage!

# BatterieFaktorList = [20, 18, 16,14, 12,10, 8, 6, 4, 2, 1] # Battery Capacity =Inverter Power * Batteriefaktorlist --> Batteriekapazität = Faktor * Inverterleistung

Inverter_Ratio_list = [3, 2.5, 2, 1.5, 1] #Means: Inverter_power_demand = (electrolyzer_energy + h2 storage)*Inverter_Ratio_lis --> inverter is always able to deliver at least power demand of electrolyzer and h2 storage!
# #BatterieFaktorList = [16, 14]

#BatterieFaktorList = [12,10, 8, 6, 4, 2, 1] # Battery Capacity =Inverter Power * Batteriefaktorlist --> Batteriekapazität = Faktor * Inverterleistung

BatterieFaktorList = [16, 14]
# FuelCellPowerWUnit = "W"
# BatteryCapkWhUnit = "kWh"
# Inverter_RatioUnit = "-"


FuelCellPowerWUnit = "W"
BatteryCapkWhUnit = "kWh"
Inverter_RatioUnit = "-"

# prediction_horizon = 3600*2
# prediction_horizon = 3600*3 # Based on "Kurzfristprognosen" laut zamg Seite: https://data.hub.geosphere.at/group/wettervorhersagen --> Kurzfristprognosen gibt es für die nächsten 3 Stunden jeweils
# prediction_horizonUnit = "seconds"


# # PreResultNumber = 0
# # PreResultNumberUnit = "-"
# PreResultNumber = 385
# PreResultNumberUnit = "-"

# #BatterieFaktorList = [4,5,6,7,8]
# #BatterieFaktorList = [6,7,8,]

# for BatterieFaktor in BatterieFaktorList:

# PreResultNumber = 0
# PreResultNumberUnit = "-"


# for FuelCellPowerW in FuelCellPowerW_list:
# # for BatteryCapkWh in BatteryCapkWh_list:
# FuelCellPowerW = int(math.ceil(FuelCellPowerW))
# for Inverter_Ratio in Inverter_Ratio_list:


Expand All @@ -269,18 +270,36 @@

# input_variablen = Cell4LifeSzenario2a.InputParameter()

# '''
# ### aus 1b kopiert
# charging_rate = input_variablen["p_el_elektrolyzer"]["value"] / (3600*40000) #umrechnung von Watt [=Joule/Sekunde, Leistung) p_el in kg/s H2
# power_demand_charging_h2storage = charging_rate * input_variablen["h_fuel"]["value"] * 3.6e3 * 1000 * input_variablen["h2storage_energy_for_charge_based_on_massflow_h_fuel"]["value"]/100 # electricity power_demand of hydrogen storage for compression of H2 in Watt;


# inverte_power_demand = int(math.ceil((power_demand_charging_h2storage + input_variablen["p_el_elektrolyzer"]["value"])*Inverter_Ratio)) # Inverterleistung hängt von
# inverte_power_demandUnit = 'W'

# BatteryCapkWh = int(math.ceil((inverte_power_demand/1000)*BatterieFaktor)) #Befehl Ceil Rundet auf; BatteryCKapazität in kWh...Batterie-Kapazität hängt von Elektrolyzer + H2 Storage Verbrauch ab!


# ###
# '''

# charging_rate = input_variablen["p_el_elektrolyzer"]["value"] / (3600*40000) #umrechnung von Watt [=Joule/Sekunde, Leistung) p_el in kg/s H2
# power_demand_charging_h2storage = charging_rate * input_variablen["h_fuel"]["value"] * 3.6e3 * 1000 * input_variablen["h2storage_energy_for_charge_based_on_massflow_h_fuel"]["value"]/100 # electricity power_demand of hydrogen storage for compression of H2 in Watt;
# inverte_power_demand_min = power_demand_charging_h2storage + input_variablen["p_el_elektrolyzer"]["value"]
# inverte_power_demand = int(math.ceil((power_demand_charging_h2storage + input_variablen["p_el_elektrolyzer"]["value"])*Inverter_Ratio))
# inverte_power_demandUnit = 'W'

# BatteryCapkWh = math.ceil(inverte_power_demand_min / 1000 * BatterieFaktor) #Befehl Ceil Rundet auf; BatteryCKapazität in kWh..INverterleistung in Watt gerechnet; Minimum Inverterleistung = 0,25 der Batteriekapazität --> folglich ist die Batteriekapazität immer 4* der Inverterleistung
# BatteryCapkWh = int(math.ceil(inverte_power_demand / 1000 * BatterieFaktor)) #Befehl Ceil Rundet auf; BatteryCKapazität in kWh..INverterleistung in Watt gerechnet; Minimum Inverterleistung = 0,25 der Batteriekapazität --> folglich ist die Batteriekapazität immer 4* der Inverterleistung


# param_df["BatteryCapkWh"][0] = BatteryCapkWh
# param_df["BatteryCapkWhUnit"][0] = BatteryCapkWhUnit
# param_df["Inverter_Ratio"][0] = Inverter_Ratio
# param_df["Inverter_RatioUnit"][0] = Inverter_RatioUnit
# param_df["inverte_power_demand"][0] = inverte_power_demand
# param_df["inverte_power_demandUnit"][0] = inverte_power_demandUnit


# param_df.to_csv("examples/params_to_loop.csv", sep=",", index= False)
# #del param_df
Expand All @@ -292,14 +311,14 @@
# #Do a copy of the economic assessment excel file

# # if PreResultNumber == 0:
# # pathbase = 'C://Users//Standard//Desktop//hisim//C4LResults//results//'
# # pathbase = 'C://Users//Standard//Desktop//hisim//results//'
# # name1 = '20231107_AllSimulationResults_Assessment_v5'
# # filepath1 = pathbase + 'OriginalExcelFile//' + name1 + '.xlsx'
# # copytopath1= pathbase
# # excelfilepathallresults1, excel_filename1 = Cell4Life_Postprocessing.makeacopyofevaluationfile(copytopath1, filepath1, name1)

# #For economic assessment, create a copy of original excel file
# copyfrompath = 'C://Users//Standard//Desktop//hisim//C4LResults//results//'
# copyfrompath = 'C://Users//Standard//Desktop//hisim//results//'
# name2 = 'Sim_Oek_Assessment_v12'
# filepath2 = copyfrompath + 'OriginalExcelFile//' + name2 + '.xlsx'
# copytopath2 = ResultPathProviderSingleton().get_result_directory_name()
Expand All @@ -310,7 +329,7 @@
# del copytopath2, filepath2, name2

# #For Excel Controll File, create a copy of original excel file
# copyfrompath = 'C://Users//Standard//Desktop//hisim//C4LResults//results//'
# copyfrompath = 'C://Users//Standard//Desktop//hisim//results//'
# name3 = 'ControllFileData-plotting'
# filepath3 = copyfrompath + 'OriginalExcelFile//' + name3 + '.xlsx'
# copytopath3 = ResultPathProviderSingleton().get_result_directory_name()
Expand All @@ -333,6 +352,10 @@
# finishtext = "---Parametervariation --vII: " + input_variablen["szenario"]["value"] + "-- abgeschlossen---"

# del input_variablen

# print('Stop')
# print('Stop')

# PreResultNumber += 1


Expand Down
34 changes: 21 additions & 13 deletions examples/Cell4LifeSzenario2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def Cell4Life(


# Build Results Path
name = input_variablen["szenario"]["value"] + "_S" + str(input_variablen["PreResultNumber"]["value"])+"_BCap._" + str(math.ceil(input_variablen["battery_capacity"]["value"])) + "kWh_Inv_" + str(math.ceil(input_variablen["battery_inverter_power"]["value"]/1000)) + "kW_FCPow_" + str(math.ceil(input_variablen["fuel_cell_power"]["value"]/1000)) +"kW"
name = "S" + str(input_variablen["PreResultNumber"]["value"])+"_BCap._" + str(math.ceil(input_variablen["battery_capacity"]["value"])) + "kWh_Inv_" + str(math.ceil(input_variablen["battery_inverter_power"]["value"]/1000)) + "kW_FCPow_" + str(math.ceil(input_variablen["fuel_cell_power"]["value"]/1000)) +"kW"

ResultPathProviderSingleton().set_important_result_path_information(
module_directory = "C://Users//Standard//Desktop//hisim//C4LResults",
module_directory = "C://Users//Standard//Desktop//hisim//",
model_name= name,
#variant_name=my_sim.setup_function,
variant_name = '',
Expand Down Expand Up @@ -400,6 +400,12 @@ def InputParameter():

prediction_horizon = param_df["prediction_horizon"][0]
prediction_horizonUnit = param_df["prediction_horizonUnit"][0]

inverte_power_demand = param_df["inverte_power_demand"][0]
inverte_power_demandUnit = param_df["inverte_power_demandUnit"][0]



#Variation Parameters:
battery_capacity: Optional[float] = BatteryCapkWh #Total Capacity of Battery in kWh
battery_capacityUnit = BatteryCapkWhUnit
Expand All @@ -414,11 +420,12 @@ def InputParameter():
p_el_percentage_standby_fuelcell = 10 #If fuel cell is running in standby, it needs so much electricity power in % of its electricitiy production power if it is running
p_el_percentage_standby_fuelcellUnit = "%" #10 % assumption is based on [42] "Dynamics and control of a thermally self-sustaining energy storage system using integrated solid oxide cells for an islanded building" from Pegah Mottaghizadeh, Mahshid Fardadi, Faryar Jabbari, Jack Brouwer

del BatteryCapkWh, FuelCellPowerW, BatteryCapkWhUnit, FuelCellPowerWUnit

#Following parameter depends on a "variation parameter"
battery_inverter_power = battery_capacity*1000*Inverter_Ratio #in Watt: Batterie Inverter power is assumed to depend on Battery Capacity which is given in kWh!
battery_inverter_powerUnit = "W"
battery_inverter_power = inverte_power_demand #in Watt: Batterie Inverter power is assumed to depend on Battery Capacity which is given in kWh!
battery_inverter_powerUnit = inverte_power_demandUnit

del BatteryCapkWh, FuelCellPowerW, BatteryCapkWhUnit, FuelCellPowerWUnit, inverte_power_demand, inverte_power_demandUnit


#Static Parameters:
Expand All @@ -431,7 +438,7 @@ def InputParameter():
init_source_weight_battery = 1
init_source_weight_batteryUnit = "-"

electricity_threshold = 0 #Minium required power to activate fuel cell
electricity_threshold = '-' #Minium required power to activate fuel cell
electricity_thresholdUnit = "W"

init_source_weight_hydrogenstorage = 999 #init_source_weight_electrolyzer
Expand All @@ -449,16 +456,16 @@ def InputParameter():
electrolyzer_source_weight = 999
electrolyzer_source_weightUnit = "-"

min_operation_time_in_seconds_chp = 0.00000001 #
min_operation_time_in_seconds_chp = prediction_horizon #
min_operation_time_in_seconds_chpUnit = "s"

minstandbytime_fuelcell = 0.00000001 #
minstandbytime_fuelcell = prediction_horizon #
minstandbytime_fuelcellUnit = "s"

min_operation_time_in_seconds_electrolyzer = 0.00000001 #
min_operation_time_in_seconds_electrolyzer = prediction_horizon #
min_operation_time_in_seconds_electrolyzerUnit = "s"

minstandbytime_electrolyzer = 0.00000001 #
minstandbytime_electrolyzer = prediction_horizon #
minstandbytime_electrolyzerUnit = "s"

h2_soc_lower_threshold_chp = 0.1 # Minimum state of charge to start operating the fuel cell in %
Expand Down Expand Up @@ -517,16 +524,16 @@ def InputParameter():
Electrical_power_demand_related_to_fuelcell_percentage = 100
Electrical_power_demand_related_to_fuelcell_percentageUnit = "%" #Faktor in % which represents the ratio between [HouseConsumption-PV]/FuelCell (each in Watt)...--> 100 % means, that the energy demand (houseconsumption-PV) is equivalent to fuel cell output; at this ratio, the fuel cell could be turned on if the next decisions in the decision tree are answered positively, or the Fuel Cell stays turned on if it is already running

minbatterystateofcharge_electrolyzer_turnon = 80 #minimal battery state of charge, which is necessary, to turn on electrolyzer... in %
minbatterystateofcharge_electrolyzer_turnon = 50 #minimal battery state of charge, which is necessary, to turn on electrolyzer... in %
minbatterystateofcharge_electrolyzer_turnonUnit = "%"

minbatterystateofcharge_let_electrolyzer_staysturnedon = 0.1 #Minimal battery state of charge, which is necessary, that electrolyzer stays turned on, in %
minbatterystateofcharge_let_electrolyzer_staysturnedonUnit = "%"

maxbatterystateofcharge_fuelcell_turnon = 80 #maximum battery state of charge; if the actual battery state of charge is above this level, then the fuel cell will not be turned on
maxbatterystateofcharge_fuelcell_turnon = 50 #maximum battery state of charge; if the actual battery state of charge is above this level, then the fuel cell will not be turned on
maxbatterystateofcharge_fuelcell_turnonUnit = "%"

maxbatterystateofcharge_let_fuelcell_staysturnedon = 95 #Maximum battery state of charge; if that threshold is exceeded, then the fuel cell will be turned off
maxbatterystateofcharge_let_fuelcell_staysturnedon = 90 #Maximum battery state of charge; if that threshold is exceeded, then the fuel cell will be turned off
maxbatterystateofcharge_let_fuelcell_staysturnedonUnit = "%"
#FOLLOWING FACTORS Electrolyzer:
#****
Expand Down Expand Up @@ -591,6 +598,7 @@ def InputParameter():
"value": electricity_threshold,
"unit": electricity_thresholdUnit,
},

"init_source_weight_hydrogenstorage": {
"value": init_source_weight_hydrogenstorage,
"unit":init_source_weight_hydrogenstorageUnit,
Expand Down
2 changes: 1 addition & 1 deletion examples/params_to_loop.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PreResultNumber,FuelCellPowerW,BatteryCapkWh,Inverter_Ratio,PreResultNumberUnit,FuelCellPowerWUnit,BatteryCapkWhUnit,Inverter_RatioUnit,szenario,szenarioUnit,prediction_horizon,prediction_horizonUnit,inverte_power_demand,inverte_power_demandUnit
11113,46489.0,3437.0,2.0,-,W,kWh,-,1b,-,0,seconds,214760.0,W
439,26565.0,62.0,1.0,-,W,kWh,-,1b,-,0,seconds,61361.0,W
18 changes: 9 additions & 9 deletions hisim/postprocessing/4D_Plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


# Lese die Excel-Datei und das Tabellenblatt "Bezug" ein
df = pd.read_excel('C://Users//Standard//Desktop//hisim//results//1b20240619//Gesamtergebnis.xlsx', sheet_name='Netzbezug')
df = pd.read_excel('C://Users//Standard//Desktop//hisim//results//2a20240624//Gesamtergebnis.xlsx', sheet_name='Netzbezug')
print(df.head())
# Extrahiere die relevanten Spalten
brennstoffzellenleistung = df['FuelCellPowerkWh'] # Spalte B
Expand Down Expand Up @@ -38,7 +38,7 @@
cbar.set_label('Netzbezugsmenge Strom in MWh/a')

# Beschrifte die Achsen
ax.set_xlabel('Brennstoffzellenleistung in kW')
ax.set_xlabel('rSOC-Leistung in kW')
ax.set_ylabel('Batteriekapazität in kWh')
ax.set_zlabel('Inverterleistung in kW')

Expand All @@ -56,7 +56,7 @@

# Zeige den Plot an
#plt.show()
plt.savefig('C://Users//Standard//Desktop//hisim//results//1b20240619//Netzbezug_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung
plt.savefig('C://Users//Standard//Desktop//hisim//results//2a20240624//Netzbezug_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung


############################################################################# 2
Expand All @@ -83,7 +83,7 @@
cbar.set_label('Kapitalwert nach 20 Jahren (negativ)')

# Beschrifte die Achsen
ax.set_xlabel('Brennstoffzellenleistung in kW')
ax.set_xlabel('rSOC-Leistung in kW')
ax.set_ylabel('Batteriekapazität in kWh')
ax.set_zlabel('Inverterleistung in kW')

Expand All @@ -95,7 +95,7 @@

# Zeige den Plot an
#plt.show()
plt.savefig('C://Users//Standard//Desktop//hisim//results//1b20240619//Kapitalwert_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung
plt.savefig('C://Users//Standard//Desktop//hisim//results//2a20240624//Kapitalwert_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung


############################################################################# 3
Expand Down Expand Up @@ -130,7 +130,7 @@
cbar.set_label('Netzbezugsmenge Strom in MWh/a')

# Beschrifte die Achsen
ax.set_xlabel('Brennstoffzellenleistung in kW')
ax.set_xlabel('rSOC-Leistung in kW')
ax.set_ylabel('Batteriekapazität in kWh')
ax.set_zlabel('Inverterleistung in kW')

Expand All @@ -145,7 +145,7 @@
ax.set_ylim(1500, batteriekapazität_max__small)
ax.set_zlim(50, inverterleistung_max__small)
#plt.show()
plt.savefig('C://Users//Standard//Desktop//hisim//results//1b20240619//Netzbezug_20kleisnten_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung
plt.savefig('C://Users//Standard//Desktop//hisim//results//2a20240624//Netzbezug_20kleisnten_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung



Expand All @@ -169,7 +169,7 @@
cbar.set_label('Kapitalwert nach 20 Jahren (negativ)')

# Beschrifte die Achsen
ax.set_xlabel('Brennstoffzellenleistung in kW')
ax.set_xlabel('rSOC-Leistung in kW')
ax.set_ylabel('Batteriekapazität in kWh')
ax.set_zlabel('Inverterleistung in kW')

Expand All @@ -187,4 +187,4 @@

# Zeige den Plot an
#plt.show()
plt.savefig('C://Users//Standard//Desktop//hisim//results//1b20240619//Kapitalwerte_zu_Netzbezug_20kleisnten_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung
plt.savefig('C://Users//Standard//Desktop//hisim//results//2a20240624//Kapitalwerte_zu_Netzbezug_20kleisnten_scatter.png', dpi=300) # Speichert als PNG mit 300 DPI Auflösung
Loading

0 comments on commit 92cc240

Please sign in to comment.