Skip to content

Commit

Permalink
Bug Fixing --> Integration of CHP devision
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofBernsteiner committed May 22, 2024
1 parent 08121e8 commit 15e2311
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 121 deletions.
188 changes: 94 additions & 94 deletions examples/Cell4LifeSimulationExecutorvII.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
szenarioUnit = "-"


FuelCellPowerW_list = [45000] #Electricity Power of Fuel Cell Power in Watt
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]
Inverter_Ratio_list = [1, 2]
BatterieFaktorList = [5,10]

#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 Down Expand Up @@ -188,135 +188,135 @@
print(finishtext)


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

##Szenario 2a
# ##Szenario 2a

szenario = "2a"
szenarioUnit = "-"
# 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 = [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)
# #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 = "-"
# FuelCellPowerWUnit = "W"
# BatteryCapkWhUnit = "kWh"
# Inverter_RatioUnit = "-"

prediction_horizon = 3600*2
prediction_horizonUnit = "seconds"
# prediction_horizon = 3600*2
# prediction_horizonUnit = "seconds"


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

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

for BatterieFaktor in BatterieFaktorList:
# for BatterieFaktor in BatterieFaktorList:

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

for FuelCellPowerW in FuelCellPowerW_list:
# for BatteryCapkWh in BatteryCapkWh_list:
for Inverter_Ratio in Inverter_Ratio_list:
# 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
# # 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)
# param_df.to_csv("examples/params_to_loop.csv", sep=",", index= False)


input_variablen = Cell4LifeSzenario2a.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"]
# 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
# 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())
# 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
# #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_v9'
filepath2 = copyfrompath + 'OriginalExcelFile//' + name2 + '.xlsx'
copytopath2 = ResultPathProviderSingleton().get_result_directory_name()
copytopath2 = copytopath2 + '//'
# 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_v9'
# 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 + '//'
# 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
# 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)
# #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 excelfilepathresults2, excelfilepathresults3
# finishtext = "---Parametervariation --vII: " + input_variablen["szenario"]["value"] + "-- abgeschlossen---"

del input_variablen
PreResultNumber += 1
# del input_variablen
# PreResultNumber += 1



print(finishtext)
# print(finishtext)



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
1,50000,1155.0,2.0,-,W,kWh,-,1b,-,0,seconds
Loading

0 comments on commit 15e2311

Please sign in to comment.