Skip to content

Commit

Permalink
Added code to allow the user to prevent generating multiple PV power …
Browse files Browse the repository at this point in the history
…production profiles
  • Loading branch information
toddleif committed Feb 1, 2025
1 parent b5eb01a commit 7c10187
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 21 deletions.
5 changes: 4 additions & 1 deletion src/microgrid/microgrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ function Microgrid_Model(Microgrid_Settings::Dict{String, Any}; JuMP_Model="", l
end

if Microgrid_Inputs.generate_results_plots == true
CreateResultsMap(CompiledResults, Microgrid_Inputs, TimeStamp)
Aggregated_PowerFlows_Plot(CompiledResults, TimeStamp, Microgrid_Inputs, REoptInputs_Combined, model)
if Microgrid_Inputs.bus_coordinates != ""
CreateResultsMap(CompiledResults, Microgrid_Inputs, TimeStamp)
Create_Voltage_Plot(CompiledResults, Microgrid_Inputs)
end
end

return CompiledResults, model, model_BAU, m_outagesimulator;
Expand Down
25 changes: 25 additions & 0 deletions src/microgrid/microgrid_results_processing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,31 @@ function CreateResultsMap(results, Microgrid_Inputs, TimeStamp)
end


function Create_Voltage_Plot(results, Microgrid_Inputs)

# Generate list of lengths from the node to the substation

# Determine the per unit voltage at each node
timestep = Microgrid_Inputs.voltage_plot_time_step

# Interactive plot using PlotlyJS
traces = PlotlyJS.GenericTrace[]
layout = PlotlyJS.Layout(title_text = "Voltage Stability", xaxis_title_text = "Day", yaxis_title_text = "Per Unit Voltage")

push!(traces, PlotlyJS.scatter(name = "Node", showlegend = true, fill = "none", line = PlotlyJS.attr(width = 3, color="black"),
x = [1], # TODO: enter the actual data
y = [1]
))



p = PlotlyJS.plot(traces, layout)
display(p)
PlotlyJS.savefig(p, Microgrid_Inputs.folder_location*"/results_"*TimeStamp*"/VoltagePlot_InteractivePlot.html")

end


function Aggregated_PowerFlows_Plot(results, TimeStamp, Microgrid_Inputs, REoptInputs_Combined, model)
# Function to create additional plots using PlotlyJS

Expand Down
59 changes: 39 additions & 20 deletions src/microgrid/scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ const PMD = PowerModelsDistribution
generators_only_run_during_grid_outage::Bool=false,
generate_CSV_of_outputs::Bool=false,
generate_results_plots::Bool=false,
result_plots_start_time_step::Real=0,
result_plots_end_time_step::Real=0,
plot_voltage_drop::Bool=true,
plot_voltage_drop_node_numbers::Array=[],
plot_voltage_drop_voltage_time_step::Real=0,
voltage_plot_time_step::Real=0,
generate_same_pv_production_profile_for_each_node::Bool=false,
pv_inputs_for_standardized_pv_production_profile::Dict=Dict(),
display_results::Bool=true
"""

Expand Down Expand Up @@ -98,11 +96,9 @@ mutable struct MicrogridInputs <: AbstractMicrogrid
generators_only_run_during_grid_outage
generate_CSV_of_outputs
generate_results_plots
result_plots_start_time_step
result_plots_end_time_step
plot_voltage_drop
plot_voltage_drop_node_numbers
plot_voltage_drop_voltage_time_step
voltage_plot_time_step
generate_same_pv_production_profile_for_each_node
pv_inputs_for_standardized_pv_production_profile
display_results
load_profiles_for_outage_sim_if_using_the_fraction_method

Expand Down Expand Up @@ -149,15 +145,40 @@ mutable struct MicrogridInputs <: AbstractMicrogrid
generators_only_run_during_grid_outage::Bool=false,
generate_CSV_of_outputs::Bool=false,
generate_results_plots::Bool=false,
result_plots_start_time_step::Real=0,
result_plots_end_time_step::Real=0,
plot_voltage_drop::Bool=true,
plot_voltage_drop_node_numbers::Array=[],
plot_voltage_drop_voltage_time_step::Real=0,
voltage_plot_time_step::Real=0,
generate_same_pv_production_profile_for_each_node::Bool=false,
pv_inputs_for_standardized_pv_production_profile::Dict=Dict(),
display_results::Bool=true,
load_profiles_for_outage_sim_if_using_the_fraction_method::Array=[]
)

if generate_same_pv_production_profile_for_each_node == true

pv_power_production_factor_series, ambient_temp_celcius = REopt.call_pvwatts_api(pv_inputs_for_standardized_pv_production_profile["latitude"],
pv_inputs_for_standardized_pv_production_profile["longitude"];
tilt= pv_inputs_for_standardized_pv_production_profile["tilt"],
azimuth= pv_inputs_for_standardized_pv_production_profile["azimuth"],
module_type= pv_inputs_for_standardized_pv_production_profile["module_type"],
array_type= pv_inputs_for_standardized_pv_production_profile["array_type"],
losses= pv_inputs_for_standardized_pv_production_profile["losses"],
dc_ac_ratio= pv_inputs_for_standardized_pv_production_profile["dc_ac_ratio"],
gcr= pv_inputs_for_standardized_pv_production_profile["gcr"],
inv_eff= 100 * pv_inputs_for_standardized_pv_production_profile["inv_eff_fraction"],
timeframe="hourly",
radius=0,
time_steps_per_hour=time_steps_per_hour)

for node in collect(1:length(REopt_inputs_list))
if "PV" in keys(REopt_inputs_list[node])
if "production_factor_series" in keys(REopt_inputs_list[node]["PV"])
# do nothing because the power_factor_series is already defined
else
REopt_inputs_list[node]["PV"]["production_factor_series"] = pv_power_production_factor_series
end
end
end
end

new(
folder_location,
bus_coordinates,
Expand Down Expand Up @@ -201,11 +222,9 @@ mutable struct MicrogridInputs <: AbstractMicrogrid
generators_only_run_during_grid_outage,
generate_CSV_of_outputs,
generate_results_plots,
result_plots_start_time_step,
result_plots_end_time_step,
plot_voltage_drop,
plot_voltage_drop_node_numbers,
plot_voltage_drop_voltage_time_step,
voltage_plot_time_step,
generate_same_pv_production_profile_for_each_node,
pv_inputs_for_standardized_pv_production_profile,
display_results,
load_profiles_for_outage_sim_if_using_the_fraction_method
)
Expand Down

0 comments on commit 7c10187

Please sign in to comment.