using SIIPExamples using PowerSystems using PowerSimulations using PowerGraphics using Logging using Dates pkgpath = dirname(dirname(pathof(SIIPExamples))) PSI = PowerSimulations plotlyjs() using Xpress solver = optimizer_with_attributes(Xpress.Optimizer, "MIPRELSTOP" => 0.1, "OUTPUTLOG" => 1) sys = System(joinpath(pkgpath, "US-System", "SIIP", "sys.json")) horizon = 24; interval = Dates.Hour(24); transform_single_time_series!(sys, horizon, interval); for line in get_components(Line, sys) if (get_base_voltage(get_from(get_arc(line))) >= 230.0) && (get_base_voltage(get_to(get_arc(line))) >= 230.0) #if get_area(get_from(get_arc(line))) != get_area(get_to(get_arc(line))) @info "Changing $(get_name(line)) to MonitoredLine" convert_component!(MonitoredLine, line, sys) end end template = ProblemTemplate(DCPPowerModel) set_device_model!(template, Line, StaticBranchUnbounded) set_device_model!(template, TapTransformer, StaticBranchUnbounded) set_device_model!(template, MonitoredLine, StaticBranch) set_device_model!(template, ThermalStandard, ThermalStandardUnitCommitment) set_device_model!(template, RenewableDispatch, RenewableFullDispatch) set_device_model!(template, PowerLoad, StaticPowerLoad) set_device_model!(template, HydroDispatch, FixedOutput) op_problem = DecisionModel(template, sys; optimizer = solver, horizon = 24) build!(op_problem, output_dir = mktempdir(), console_level = Logging.Info) solve!(op_problem) res = ProblemResults(op_problem) plot_fuel(res) sim_folder = mkpath(joinpath(pkgpath, "Texas-sim")) models = SimulationModels( decision_models = [ DecisionModel( template, sys, name = "UC", optimizer = solver, system_to_file = false, ), ], ) DA_sequence = SimulationSequence(models = models, ini_cond_chronology = IntraProblemChronology()) sim = Simulation( name = "Texas-test", steps = 3, models = models, sequence = DA_sequence, simulation_folder = "Texas-sim", ) build!( sim, console_level = Logging.Info, file_level = Logging.Debug, recorders = [:simulation], ) execute!(sim) results = SimulationResults(sim); uc_results = get_problem_results(results, "UC"); plot_fuel(uc_results)