Giter VIP home page Giter VIP logo

nrel-sienna / powersimulations.jl Goto Github PK

View Code? Open in Web Editor NEW
264.0 19.0 50.0 235.19 MB

Julia for optimization simulation and modeling of PowerSystems. Part of the Scalable Integrated Infrastructure Planning Initiative at the National Renewable Energy Lab.

Home Page: https://www.nrel.gov/analysis/sienna.html

License: BSD 3-Clause "New" or "Revised" License

Julia 100.00%
julia powersystems optimization energy electricity analysis simulations

powersimulations.jl's People

Contributors

alefcastelli avatar ccoffrin avatar claytonpbarrows avatar daniel-thom avatar dsigler1234 avatar gabrielks avatar gitter-badger avatar jd-lara avatar jmaack24 avatar juliatagbot avatar kdheepak avatar lilyhanig avatar lpstreitmatter avatar mattirish avatar mcawte avatar mkratochvil avatar odow avatar pesap avatar pitmonticone avatar raphaelsaavedra avatar rodrigomha avatar sourabhdalvi avatar tamas-borbath avatar tengis-nrl avatar timholy avatar timziebart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powersimulations.jl's Issues

PM integration problem with expressions errors

I have moved forward with the PowerModels integration through expressions. I am getting stuck in this error

MethodError: no method matching getindex(::JuMP.GenericAffExpr{Float64,VariableRef}, ::Int64)

Stacktrace:
 [1] ref(::GenericPowerModel{PowerSimulations.DCAngleForm}, ::Int64, ::Symbol, ::Int64, ::String, ::Int64) at /Users/jdlara/.julia/packages/PowerModels/mNbep/src/core/base.jl:150
 [2] #constraint_kcl_ni_expr#172(::Int64, ::Int64, ::Function, ::GenericPowerModel{PowerSimulations.DCAngleForm}, ::Int64) at /Users/jdlara/.julia/dev/PowerSimulations/src/network_models/powermodels_balance.jl:166
 [3] (::getfield(PowerSimulations, Symbol("#kw##constraint_kcl_ni_expr")))(::NamedTuple{(:nw,),Tuple{Int64}}, ::typeof(PowerSimulations.constraint_kcl_ni_expr), ::GenericPowerModel{PowerSimulations.DCAngleForm}, ::Int64) at ./none:0
 [4] post_nip_expr(::GenericPowerModel{PowerSimulations.DCAngleForm}) at /Users/jdlara/.julia/dev/PowerSimulations/src/network_models/powermodels_balance.jl:76
 [5] #build_generic_model#126(::Bool, ::Bool, ::Base.Iterators.Pairs{Symbol,Model,Tuple{Symbol},NamedTuple{(:jump_model,),Tuple{Model}}}, ::Function, ::Dict{String,Any}, ::getfield(Main, Symbol("##11#13")), ::typeof(PowerSimulations.post_nip_expr)) at /Users/jdlara/.julia/packages/PowerModels/mNbep/src/core/base.jl:258
 [6] (::getfield(PowerModels, Symbol("#kw##build_generic_model")))(::NamedTuple{(:multinetwork, :jump_model),Tuple{Bool,Model}}, ::typeof(build_generic_model), ::Dict{String,Any}, ::Function, ::Function) at ./none:0
 [7] #build_nip_model#166 at /Users/jdlara/.julia/dev/PowerSimulations/src/network_models/powermodels_balance.jl:19 [inlined]
 [8] (::getfield(PowerSimulations, Symbol("#kw##build_nip_model")))(::NamedTuple{(:jump_model,),Tuple{Model}}, ::typeof(PowerSimulations.build_nip_model), ::Dict{String,Any}, ::Function) at ./none:0
 [9] top-level scope at In[8]:2

I can't make a lot of sense of the error because it points to a line in PowerModels related to multiconductor. This code can reproduce the error:

using PowerSystems
base_dir = dirname(dirname(pathof(PowerSystems)))
include(joinpath(base_dir,"data/data_5bus.jl"));
sys5 = PowerSystem(nodes5, generators5, loads5_DA, branches5, nothing,  100.0);
using PowerModels
const PM = PowerModels
using PowerSimulations
const PS = PowerSimulations
using Ipopt
using JuMP
ipopt_optimizer = with_optimizer(Ipopt.Optimizer)
Net = PS.DCAngleForm
m = Model(with_optimizer(Ipopt.Optimizer));
netinjection = PS.instantiate_network(Net, sys5);
PS.constructdevice!(m, netinjection, ThermalGen, PS.ThermalDispatch, Net, sys5);
#Here goes the network construction functions
PS.nodalflowbalance(m, netinjection, Net, sys5)
PM_F = (data::Dict{String,Any}; kwargs...) -> PM.GenericPowerModel(data, Net; kwargs...)
PM_object = PS.build_nip_model(m.ext[:PM_object], PM_F, jump_model=m);
# 
@objective(m, Min, m.obj_dict[:objective_function])

FYI @ccoffrin

v0.1.0 features

  • Visualization
  • Documentation
  • Simulation Process
    • Define simulation from PLEXOS XML model
    • Saving results
    • Examples
  • Device representations
    • Generation
      • Thermal
      • RE
      • Hydro
    • Storage
    • Demand
      • Static
      • Controllable
    • Transmission
      • AC
      • DC
      • Transformers
  • Simulation
    • Sequential Simulations
  • Formulations
    • UC
    • ED
    • PTDF
    • NET-Flow (transport)
    • ACOPF (PowerModels)

UC with RampLimitedReserve is infeasible

The following creates an infeasible problem:

UC = PS.PowerOperationModel(PS.UnitCommitment, 
                            [(device = ThermalGen, formulation =PS.StandardThermalCommitment)], 
                            [(device = ElectricLoad, formulation = PS.InterruptibleLoad)],
                            nothing, 
                            [(device=Line, formulation=PS.PiLine)],
                            PS.CopperPlatePowerModel,
                            [(service = reserve5, formulation = PS.RampLimitedReserve)], 
                            sys5uc,
                            Model(), 
                            false)
buildmodel!(sys5uc,UC)

variablecost bound error

julia> pm_dict["gen"]["Thermal"]["Solitude"]["econ"]["variablecost"](1)
ERROR: BoundsError
Stacktrace:
 [1] getindex(::Int64, ::Int64) at ./number.jl:78
 [2] (::getfield(PowerSystems, Symbol("##138#146")){Dict{String,Any}})(::Int64) at /Users/cbarrows/Documents/repos/PowerSystems.jl/src/parsers/pm2ps_parser.jl:219
 [3] top-level scope at none:0

Change repo name and enable settings

@kdheepak Can you make available the settings menu for this repo and if possible change the name to MEMF.jl I have already re-organized the folders and I am working on making everything cross-compatible.

Develop Reserves as a service

The basic formulation trees for reserves are created already but we need to generate the constraints and (if-needed) variables relevant to a basic reserve service we can include for testing and development.

RenewableCurtailment cost not implemented correctly

The variablecost function in the file renewablegen_cost.jl calls the function gencost(m::JuMP.Model, variable::JuMPArray{JuMP.VariableRef}, cost_component::Float64) in the file variable_cost.jl.

The result is that the curtailment cost associated with a RenewableCurtailment type is treated as a cost for using the renewable resource rather than as a cost for failing to use the renewable.

Develop the Operational Model types

This is a small example of what an operation model looks like. This and a PowerSystem are the inputs for buildmodel!

ED = PS.PowerOperationModel(PS.EconomicDispatch, 
                            [(device = ThermalGen, formulation =PS.ThermalDispatch)], 
                            [(devive = ElectricLoad, formulation = PS.InterruptibleLoad)],
                            nothing, 
                            [(device=Line, formulation=PS.PiLine)],
                            PS.CopperPlatePowerModel,
                            [PS.Reserves], 
                            sys5,
                            m, 
                            false)

v0.1 features

  • ED
  • UC
  • PTDF
  • Reserves co-optimization
  • curtailable renewables
  • sequential simulation

update path to data files in tests

currently, the tests are including the data files with something like:

include(string(homedir(),"/.julia/v0.6/PowerSystems/data/data_5bus.jl"))

with the new package manager that might not be valid, so we should look for the PowerSystems dir as referenced in the Toml and find the data that way

relax p_min for generators with commitment status == 0 in DispatchForm models

pmin_th[name, t] = @constraint(m, p_th[name, t] >= devices[ix].tech.activepowerlimits.min)

needs to be something like:

pmin_th[name, t] = @constraint(m, p_th[name, t] >= commitmentstatus * devices[ix].tech.activepowerlimits.min)

where commitmentstatus can be passed into the activepower() function with kwargs.
Without this, all data with ED models will need to be feasible with all unit's committed. With this feature, we'll be able to pass UC results to an ED model without relaxing P_min in the data

State of Constructor, pending elements.

  • Thermal Generation (DC and AC)
  • Copperplate
  • NetFlow No Losses
  • NetFlow With Losses
  • PTDF No Losses
  • PTDF With Losses
  • Loads
  • Renewable Generation (DC and AC)
  • HVDC
  • DC OPF
  • AC OPF

make solver variable/constraint index to JuMP model variable/constraint mapping

e.g if I have a JuMP model UC.model, and I want to retrieve the JuMP variable defined for the solver column index 172, we need to parse the JuMP variables and create the mapping using the following calls

UC.model.moi_backend.model.optimizer.variable_mapping[MOI.get(UC.model.moi_backend.model,MOI.VariableIndex,"on_th[Solitude,4]")]

use explicit variables or symbols

Jump is capable of accessing the variables in two ways, directly by calling it (what we have used so far) and by calling internally in the model m[:x] it is not clear which is best.

not all branches with flow variables will have flow constraints

this causes an issue in our method of populating flow constraints:

buildmodel!(sys,ED)
WARNING: no PTDF supplied
┌ Error: PTDF size is inconsistent
└ @ PowerSimulations /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/component_constructors/branch_constructor.jl:29
type Float64 has no field to_from

Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] macro expansion at /Users/cbarrows/.julia/packages/JuMP/LjMor/src/macros.jl:329 [inlined]
 [3] thermalflowlimits(::Model, ::Type{PowerSimulations.StandardPTDF}, ::Array{Branch,1}, ::Int64) at /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/device_models/branches/flow_constraints.jl:12
 [4] macro expansion at ./logging.jl:308 [inlined]
 [5] #constructdevice!#129(::Base.Iterators.Pairs{Symbol,AxisArrays.AxisArray{Float64,2,Array{Float64,2},Tuple{AxisArrays.Axis{:branches,Array{String,1}},AxisArrays.Axis{:buses,Array{String,1}}}},Tuple{Symbol},NamedTuple{(:PTDF,),Tuple{AxisArrays.AxisArray{Float64,2,Array{Float64,2},Tuple{AxisArrays.Axis{:branches,Array{String,1}},AxisArrays.Axis{:buses,Array{String,1}}}}}}}, ::Function, ::Model, ::NamedTuple{(:var_active, :var_reactive, :timeseries_active, :timeseries_reactive),Tuple{Array{JuMP.GenericAffExpr{Float64,VariableRef},2},Nothing,Array{Float64,2},Nothing}}, ::Type{Line}, ::Type{PowerSimulations.PiLine}, ::Type{PowerSimulations.StandardPTDF}, ::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}) at /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/component_constructors/branch_constructor.jl:29
 [6] (::getfield(PowerSimulations, Symbol("#kw##constructdevice!")))(::NamedTuple{(:PTDF,),Tuple{AxisArrays.AxisArray{Float64,2,Array{Float64,2},Tuple{AxisArrays.Axis{:branches,Array{String,1}},AxisArrays.Axis{:buses,Array{String,1}}}}}}, ::typeof(PowerSimulations.constructdevice!), ::Model, ::NamedTuple{(:var_active, :var_reactive, :timeseries_active, :timeseries_reactive),Tuple{Array{JuMP.GenericAffExpr{Float64,VariableRef},2},Nothing,Array{Float64,2},Nothing}}, ::Type{Line}, ::Type{PowerSimulations.PiLine}, ::Type{PowerSimulations.StandardPTDF}, ::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}) at ./none:0
 [7] #constructnetwork!#172(::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:PTDF,),Tuple{Nothing}}}, ::Function, ::Model, ::Array{NamedTuple{(:device, :formulation),Tuple{DataType,DataType}},1}, ::NamedTuple{(:var_active, :var_reactive, :timeseries_active, :timeseries_reactive),Tuple{Array{JuMP.GenericAffExpr{Float64,VariableRef},2},Nothing,Array{Float64,2},Nothing}}, ::Type{PowerSimulations.StandardPTDF}, ::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}) at /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/component_constructors/network_constructor.jl:20
 [8] (::getfield(PowerSimulations, Symbol("#kw##constructnetwork!")))(::NamedTuple{(:PTDF,),Tuple{Nothing}}, ::typeof(PowerSimulations.constructnetwork!), ::Model, ::Array{NamedTuple{(:device, :formulation),Tuple{DataType,DataType}},1}, ::NamedTuple{(:var_active, :var_reactive, :timeseries_active, :timeseries_reactive),Tuple{Array{JuMP.GenericAffExpr{Float64,VariableRef},2},Nothing,Array{Float64,2},Nothing}}, ::Type{PowerSimulations.StandardPTDF}, ::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}) at ./none:0
 [9] #buildmodel!#21(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}, ::PowerSimulations.PowerOperationModel{EconomicDispatch,PowerSimulations.StandardPTDF,Nothing}) at /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/base/model_constructors.jl:31
 [10] buildmodel!(::PowerSystem{Union{Nothing, Array{#s763,1} where #s763<:ThermalGen},Union{Nothing, Array{#s764,1} where #s764<:RenewableGen},Union{Nothing, Array{#s765,1} where #s765<:HydroGen},ElectricLoad,Array{Branch,1},Array{PowerSystems.Storage,1}}, ::PowerSimulations.PowerOperationModel{EconomicDispatch,PowerSimulations.StandardPTDF,Nothing}) at /Users/cbarrows/.julia/packages/PowerSimulations/ieC1a/src/base/model_constructors.jl:5
 [11] top-level scope at In[26]:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.