Skip to content

Commit

Permalink
Test Szenario 1b
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofBernsteiner committed May 13, 2024
1 parent f4fa1a4 commit 9a0aadb
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 145 deletions.
282 changes: 141 additions & 141 deletions examples/Cell4LifeSimulationExecutorvII.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,147 @@

# # # #*************************************************

# # #Szenario 1b
# #Szenario 1b

# szenario = "1b"
szenario = "1b"
szenarioUnit = "-"


FuelCellPowerW_list = [45000] #Electricity Power of Fuel Cell Power in Watt
BatteryCapkWh_list = [100] #Total Capacity of Battery in kWh
Inverter_Ratio_list = [1]
BatterieFaktorList = [5]

#FuelCellPowerW_list = [200000, 100000, 50000, 25000, 12500] #Electricity Power of Fuel Cell Power in Watt
#Inverter_Ratio_list = [0.5, 0.333, 0.25, 0.2,0.1666] #Means: Inverter_power_demand = Battery capacity multiplied with a factor of the list; Battery Capacity = BatterieFaktor * (electrolyzer_energy + h2 storage)

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

prediction_horizon = 0
prediction_horizonUnit = "seconds"
if prediction_horizon != 0:
#Szenario 1a and 1b has no prediction integrated!
#So please choose a prediciton horizon of zero!
quit()


# PreResultNumber = 0
# 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:
for Inverter_Ratio in Inverter_Ratio_list:



# Lege neue Werte für Parameter in config_vars fest
param_df = pd.read_csv("examples/params_to_loop.csv", sep=",")
param_df["PreResultNumber"][0] = PreResultNumber
param_df["PreResultNumberUnit"][0] = PreResultNumberUnit
param_df["FuelCellPowerW"][0] = FuelCellPowerW
param_df["FuelCellPowerWUnit"][0] = FuelCellPowerWUnit
#param_df["BatteryCapkWh"][0] = BatteryCapkWh
#param_df["BatteryCapkWhUnit"][0] = BatteryCapkWhUnit
param_df["szenario"][0] = szenario
param_df["szenarioUnit"][0] = szenarioUnit
param_df["prediction_horizon"][0] = prediction_horizon
param_df["prediction_horizonUnit"][0] = prediction_horizonUnit


param_df.to_csv("examples/params_to_loop.csv", sep=",", index= False)


input_variablen = Cell4LifeSzenario1a_1b.InputParameter()

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"]

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

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.to_csv("examples/params_to_loop.csv", sep=",", index= False)
#del param_df
sys.argv = ["hisim_main.py", "examples/Cell4LifeSzenario1a_1b.py", "Cell4Life"]
with open("C:/Users/Standard/Desktop/hisim/HiSim/hisim/hisim_main.py") as f: #with --> Handler--> mach etwas mit ... führe es aus...mache es wieder zu -> with kümmert sich um das :)
exec(f.read())


#Do a copy of the economic assessment excel file

if PreResultNumber == 0:
pathbase = 'C://Users//Standard//Desktop//hisim//C4LResults//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//'
name2 = 'Sim_Oek_Assessment_v7'
filepath2 = copyfrompath + 'OriginalExcelFile//' + name2 + '.xlsx'
copytopath2 = ResultPathProviderSingleton().get_result_directory_name()
copytopath2 = copytopath2 + '//'

name2 = 'S'+ str(PreResultNumber) + '_Oek_Assessment'
excelfilepathresults2, excel_filename2 = Cell4Life_Postprocessing.makeacopyofevaluationfile(copytopath2, filepath2, name2)
del copytopath2, filepath2, name2

#For Excel Controll File, create a copy of original excel file
copyfrompath = 'C://Users//Standard//Desktop//hisim//C4LResults//results//'
name3 = 'ControllFileData-plotting'
filepath3 = copyfrompath + 'OriginalExcelFile//' + name3 + '.xlsx'
copytopath3 = ResultPathProviderSingleton().get_result_directory_name()
copytopath3 = copytopath3 + '//'

name3 = 'ControllFileData'
excelfilepathresults3, excel_filename3 = Cell4Life_Postprocessing.makeacopyofevaluationfile(copytopath3, filepath3, name3)
del copytopath3, filepath3, name3



#Save all Data in the created excel files
input_variablen = Cell4LifeSzenario1a_1b.InputParameter()
Cell4Life_Postprocessing.saveInputdata(input_variablen)
#Cell4Life_Postprocessing.saveexcelforevaluations(input_variablen, excelfilepathallresults1, excel_filename1)
Cell4Life_Postprocessing.save_data_in_excel_for_economic_assessment(input_variablen, excelfilepathresults2)
Cell4Life_ControllExcelSheet.ControllSheetExcel(excelfilepathresults3, input_variablen)

del excelfilepathresults2, excelfilepathresults3
finishtext = "---Parametervariation --vII: " + input_variablen["szenario"]["value"] + "-- abgeschlossen---"

del input_variablen
PreResultNumber += 1

print(finishtext)


# # # #*************************************************

# ##Szenario 2a

# szenario = "2a"
# szenarioUnit = "-"


# FuelCellPowerW_list = [50000] #Electricity Power of Fuel Cell Power in Watt
# BatteryCapkWh_list = [100] #Total Capacity of Battery in kWh
# Inverter_Ratio_list = [1]
# BatterieFaktorList = [5]
# BatterieFaktorList = [1]

# #FuelCellPowerW_list = [200000, 100000, 50000, 25000, 12500] #Electricity Power of Fuel Cell Power in Watt
# #Inverter_Ratio_list = [0.5, 0.333, 0.25, 0.2,0.1666] #Means: Inverter_power_demand = Battery capacity multiplied with a factor of the list; Battery Capacity = BatterieFaktor * (electrolyzer_energy + h2 storage)
Expand All @@ -77,19 +208,15 @@
# BatteryCapkWhUnit = "kWh"
# Inverter_RatioUnit = "-"

# prediction_horizon = 0
# prediction_horizon = 3600*2
# prediction_horizonUnit = "seconds"
# if prediction_horizon != 0:
# #Szenario 1a and 1b has no prediction integrated!
# #So please choose a prediciton horizon of zero!
# quit()


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

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

# for BatterieFaktor in BatterieFaktorList:

Expand Down Expand Up @@ -119,22 +246,24 @@
# param_df.to_csv("examples/params_to_loop.csv", sep=",", index= False)


# input_variablen = Cell4LifeSzenario1a_1b.InputParameter()
# input_variablen = Cell4LifeSzenario2a.InputParameter()


# 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"]

# 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


# 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.to_csv("examples/params_to_loop.csv", sep=",", index= False)
# #del param_df
# sys.argv = ["hisim_main.py", "examples/Cell4LifeSzenario1a_1b.py", "Cell4Life"]
# sys.argv = ["hisim_main.py", "examples/Cell4LifeSzenario2a.py", "Cell4Life"]
# with open("C:/Users/Standard/Desktop/hisim/HiSim/hisim/hisim_main.py") as f: #with --> Handler--> mach etwas mit ... führe es aus...mache es wieder zu -> with kümmert sich um das :)
# exec(f.read())

Expand Down Expand Up @@ -173,7 +302,7 @@


# #Save all Data in the created excel files
# input_variablen = Cell4LifeSzenario1a_1b.InputParameter()
# input_variablen = Cell4LifeSzenario2a.InputParameter()
# Cell4Life_Postprocessing.saveInputdata(input_variablen)
# #Cell4Life_Postprocessing.saveexcelforevaluations(input_variablen, excelfilepathallresults1, excel_filename1)
# Cell4Life_Postprocessing.save_data_in_excel_for_economic_assessment(input_variablen, excelfilepathresults2)
Expand All @@ -185,135 +314,6 @@
# del input_variablen
# PreResultNumber += 1

# print(finishtext)


# # #*************************************************

##Szenario 2a

szenario = "2a"
szenarioUnit = "-"


FuelCellPowerW_list = [50000] #Electricity Power of Fuel Cell Power in Watt
BatteryCapkWh_list = [100] #Total Capacity of Battery in kWh
Inverter_Ratio_list = [1]
BatterieFaktorList = [1]

#FuelCellPowerW_list = [200000, 100000, 50000, 25000, 12500] #Electricity Power of Fuel Cell Power in Watt
#Inverter_Ratio_list = [0.5, 0.333, 0.25, 0.2,0.1666] #Means: Inverter_power_demand = Battery capacity multiplied with a factor of the list; Battery Capacity = BatterieFaktor * (electrolyzer_energy + h2 storage)

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

prediction_horizon = 3600*2
prediction_horizonUnit = "seconds"


# PreResultNumber = 0
# 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:
for Inverter_Ratio in Inverter_Ratio_list:



# Lege neue Werte für Parameter in config_vars fest
param_df = pd.read_csv("examples/params_to_loop.csv", sep=",")
param_df["PreResultNumber"][0] = PreResultNumber
param_df["PreResultNumberUnit"][0] = PreResultNumberUnit
param_df["FuelCellPowerW"][0] = FuelCellPowerW
param_df["FuelCellPowerWUnit"][0] = FuelCellPowerWUnit
#param_df["BatteryCapkWh"][0] = BatteryCapkWh
#param_df["BatteryCapkWhUnit"][0] = BatteryCapkWhUnit
param_df["szenario"][0] = szenario
param_df["szenarioUnit"][0] = szenarioUnit
param_df["prediction_horizon"][0] = prediction_horizon
param_df["prediction_horizonUnit"][0] = prediction_horizonUnit


param_df.to_csv("examples/params_to_loop.csv", sep=",", index= False)


input_variablen = Cell4LifeSzenario2a.InputParameter()


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"]

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


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.to_csv("examples/params_to_loop.csv", sep=",", index= False)
#del param_df
sys.argv = ["hisim_main.py", "examples/Cell4LifeSzenario2a.py", "Cell4Life"]
with open("C:/Users/Standard/Desktop/hisim/HiSim/hisim/hisim_main.py") as f: #with --> Handler--> mach etwas mit ... führe es aus...mache es wieder zu -> with kümmert sich um das :)
exec(f.read())


#Do a copy of the economic assessment excel file

if PreResultNumber == 0:
pathbase = 'C://Users//Standard//Desktop//hisim//C4LResults//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//'
name2 = 'Sim_Oek_Assessment_v7'
filepath2 = copyfrompath + 'OriginalExcelFile//' + name2 + '.xlsx'
copytopath2 = ResultPathProviderSingleton().get_result_directory_name()
copytopath2 = copytopath2 + '//'

name2 = 'S'+ str(PreResultNumber) + '_Oek_Assessment'
excelfilepathresults2, excel_filename2 = Cell4Life_Postprocessing.makeacopyofevaluationfile(copytopath2, filepath2, name2)
del copytopath2, filepath2, name2

#For Excel Controll File, create a copy of original excel file
copyfrompath = 'C://Users//Standard//Desktop//hisim//C4LResults//results//'
name3 = 'ControllFileData-plotting'
filepath3 = copyfrompath + 'OriginalExcelFile//' + name3 + '.xlsx'
copytopath3 = ResultPathProviderSingleton().get_result_directory_name()
copytopath3 = copytopath3 + '//'

name3 = 'ControllFileData'
excelfilepathresults3, excel_filename3 = Cell4Life_Postprocessing.makeacopyofevaluationfile(copytopath3, filepath3, name3)
del copytopath3, filepath3, name3



#Save all Data in the created excel files
input_variablen = Cell4LifeSzenario2a.InputParameter()
Cell4Life_Postprocessing.saveInputdata(input_variablen)
#Cell4Life_Postprocessing.saveexcelforevaluations(input_variablen, excelfilepathallresults1, excel_filename1)
Cell4Life_Postprocessing.save_data_in_excel_for_economic_assessment(input_variablen, excelfilepathresults2)
Cell4Life_ControllExcelSheet.ControllSheetExcel(excelfilepathresults3, input_variablen)

del excelfilepathresults2, excelfilepathresults3
finishtext = "---Parametervariation --vII: " + input_variablen["szenario"]["value"] + "-- abgeschlossen---"

del input_variablen
PreResultNumber += 1



print(finishtext)
Expand Down
4 changes: 2 additions & 2 deletions examples/Cell4LifeSzenario2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def InputParameter():

# [ ] Change to fuel consumption if it is in standby!
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 = "%"
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

Expand Down Expand Up @@ -444,7 +444,7 @@ def InputParameter():
p_el_elektrolyzerUnit = "W"

p_el_percentage_standby_electrolyzer = 7 #if electrolyzer runs in standby, than it needs "p_el_percentage_standby_electrolyzer" (%) electricity power of the operating power
p_el_percentage_standby_electrolyzerUnit = "%" #Value for standby energy consumption based on [43] https://pubs.rsc.org/en/content/articlepdf/2023/se/d2se01473d Table 1
p_el_percentage_standby_electrolyzerUnit = "%" #7 % Value for standby energy consumption based on [43] https://pubs.rsc.org/en/content/articlepdf/2023/se/d2se01473d Table 1 --> "Operation strategies for a flexible megawatt scale electrolysis system for synthesis gas and hydrogen production with direct air capture of carbon dioxide" from markus Thomberg et al 2023

electrolyzer_source_weight = 999
electrolyzer_source_weightUnit = "-"
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
0,50000,116.0,1.0,-,W,kWh,-,2a,-,7200,seconds
0,45000,520.0,1.0,-,W,kWh,-,1b,-,0,seconds
4 changes: 3 additions & 1 deletion hisim/components/generic_CHP.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def get_default_config_fuelcell(thermal_power: float) -> "CHPConfig":
@staticmethod
def get_default_config_fuelcell_p_el_based(fuel_cell_power: float) -> "CHPConfig":
'''
Assumption based on Dominik Mail of 4. October 2023: 1 Watt fuel power is converted to 58 % electrical voltage. Thermal power corresponds to 1/2 of the electrical voltage; 1 watt --> 0.58 el. + 0.29 th. = 0.87 total '''
Assumption based on Dominik Mail of 4. October 2023: 1 Watt fuel power is converted to 58 % electrical voltage. Thermal power corresponds to 1/2 of the electrical voltage; 1 watt --> 0.58 el. + 0.29 th. = 0.87 total
Dominik made this assumption based on a SOEC Fuel Cell from Bosch: https://www.bosch-hydrogen-energy.com/de/sofc/nutzen/
'''

config = CHPConfig(
# name="CHP", source_weight=1, use=lt.LoadTypes.HYDROGEN, p_el = fuel_cell_power, p_th = fuel_cell_power * (0.43 / 0.48), p_fuel=(1 / 0.43) * (fuel_cell_power * (0.43 / 0.48)),
Expand Down

0 comments on commit 9a0aadb

Please sign in to comment.