-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uniform output #312
Uniform output #312
Changes from 8 commits
85ab4a7
e9c9a03
b65d3f7
35db74a
4d32521
c1eda3f
3f2eb25
9071f72
bce329e
0614b62
4f18de3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -794,11 +794,11 @@ def add_turbines(ax, turbine_x, turbine_y, radius, color): | |
e_side_x = electrolyzer_area / e_side_y | ||
d_side_y = equipment_platform_side_length | ||
d_side_x = desal_equipment_area / d_side_y | ||
ex = dx + d_side_x | ||
ey = dy | ||
electrolyzer_x = dx + d_side_x | ||
electrolyzer_y = dy | ||
|
||
electrolyzer_patch = patches.Rectangle( | ||
(ex, ey), | ||
(electrolyzer_x, electrolyzer_y), | ||
e_side_x, | ||
e_side_y, | ||
color=electrolyzer_color, | ||
|
@@ -1293,10 +1293,12 @@ def add_turbines(ax, turbine_x, turbine_y, radius, color): | |
return 0 | ||
|
||
|
||
def save_power_series( | ||
hybrid_plant: HoppInterface.system, ax=None, simulation_length=8760, output_dir="./output/", | ||
def save_energy_flows( | ||
hybrid_plant: HoppInterface.system, electrolyzer_physics_results, solver_results, hours, ax=None, simulation_length=8760, output_dir="./output/", | ||
): | ||
|
||
|
||
|
||
if ax == None: | ||
fig, ax = plt.subplots(1) | ||
|
||
|
@@ -1305,30 +1307,41 @@ def save_power_series( | |
solar_plant_power = np.array( | ||
hybrid_plant.pv.generation_profile[0:simulation_length] | ||
) | ||
output.update({"pv": solar_plant_power}) | ||
output.update({"pv generation [kW]": solar_plant_power}) | ||
if hybrid_plant.wind: | ||
wind_plant_power = np.array( | ||
hybrid_plant.wind.generation_profile[0:simulation_length] | ||
) | ||
output.update({"wind": wind_plant_power}) | ||
output.update({"wind generation [kW]": wind_plant_power}) | ||
if hybrid_plant.wave: | ||
wave_plant_power = np.array( | ||
hybrid_plant.wave.generation_profile[0:simulation_length] | ||
) | ||
output.update({"wave": wave_plant_power}) | ||
output.update({"wave generation [kW]": wave_plant_power}) | ||
if hybrid_plant.battery: | ||
battery_power_out = hybrid_plant.battery.outputs.dispatch_P | ||
output.update({"battery": battery_power_out}) | ||
|
||
battery_power_out_mw = hybrid_plant.battery.outputs.P | ||
output.update({"battery discharge [kW]": [(int(p>0))*p*1E3 for p in battery_power_out_mw]}) # convert from MW to kW and extract only discharging | ||
output.update({"battery charge [kW]": [-(int(p<0))*p*1E3 for p in battery_power_out_mw]}) # convert from MW to kW and extract only charging | ||
output.update({"battery state of charge [%]": hybrid_plant.battery.outputs.dispatch_SOC}) | ||
|
||
output.update({"total renewable energy production hourly [kW]": [solver_results[0]]*simulation_length}) | ||
output.update({"grid energy usage hourly [kW]": [solver_results[1]]*simulation_length}) | ||
output.update({"desal energy hourly [kW]": [solver_results[2]]*simulation_length}) | ||
output.update({"electrolyzer energy hourly [kW]": electrolyzer_physics_results["power_to_electrolyzer_kw"]}) | ||
output.update({"transport compressor energy hourly [kW]": [solver_results[3]]*simulation_length}) | ||
output.update({"storage energy hourly [kW]": [solver_results[4]]*simulation_length}) | ||
output.update({"h2 production hourly [kg]": electrolyzer_physics_results["H2_Results"]["Hydrogen Hourly Production [kg/hr]"]}) | ||
|
||
df = pd.DataFrame.from_dict(output) | ||
|
||
filepath = os.path.abspath(output_dir + "data/production/") | ||
|
||
if not os.path.exists(filepath): | ||
os.makedirs(filepath) | ||
|
||
df.to_csv(os.path.join(filepath, "power_series.csv")) | ||
df.to_csv(os.path.join(filepath, "energy_flows.csv")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think as we keep generating more figures and data files, we should try to settle on what sort of information should be included in the file name. This format only works in the single run case which can make running sweeps difficult There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, data and figure handling is a mess and should be cleaned up, unified, and generalized. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think should be made an issue so we can address it, but not in this PR |
||
|
||
return 0 | ||
return output | ||
|
||
|
||
# set up function to post-process HOPP results | ||
|
@@ -1576,6 +1589,10 @@ def post_process_simulation( | |
) | ||
|
||
# save production information | ||
save_power_series(hopp_results["hybrid_plant"]) | ||
hourly_energy_breakdown = save_energy_flows(hopp_results["hybrid_plant"], electrolyzer_physics_results, solver_results, hours) | ||
|
||
# save hydrogen information | ||
key = "Hydrogen Hourly Production [kg/hr]" | ||
np.savetxt(output_dir+"h2_usage", electrolyzer_physics_results["H2_Results"][key], header="# "+key) | ||
|
||
return annual_energy_breakdown | ||
return annual_energy_breakdown, hourly_energy_breakdown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about getting rid of
output_level
completely and just returning the data class? I know that it might mess a few folks up right now but lots of other breaking changes are happening on this branch and I think using data classes will help improve the greenheart simulation generalizationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to avoid running post-processing and passing a lot of extra stuff around during optimization runs. So, for now anyway, I would like to keep the output levels. We should probably make output level 8 the de facto in our example yamls though to encourage people to use that option