diff --git a/src/microgrid/microgrid.jl b/src/microgrid/microgrid.jl index 1a49dd1ec..6e8f98c6e 100644 --- a/src/microgrid/microgrid.jl +++ b/src/microgrid/microgrid.jl @@ -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; diff --git a/src/microgrid/microgrid_results_processing.jl b/src/microgrid/microgrid_results_processing.jl index 9085e0b7a..5dd2bd241 100644 --- a/src/microgrid/microgrid_results_processing.jl +++ b/src/microgrid/microgrid_results_processing.jl @@ -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 diff --git a/src/microgrid/scenario.jl b/src/microgrid/scenario.jl index 0a38a624d..b4e533cb0 100644 --- a/src/microgrid/scenario.jl +++ b/src/microgrid/scenario.jl @@ -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 """ @@ -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 @@ -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, @@ -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 )