From ef6fd504eed95bd9aa4adfcef484e14cda741349 Mon Sep 17 00:00:00 2001 From: pesap Date: Mon, 26 Aug 2024 16:41:58 -0600 Subject: [PATCH 01/12] fix: Adding support for quadratic functions using the table data parsers Currently only works for heat rate and not cost curves. Issue #1177 --- src/descriptors/power_system_inputs.json | 15 ++++++++ src/parsers/power_system_table_data.jl | 48 +++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/descriptors/power_system_inputs.json b/src/descriptors/power_system_inputs.json index 7d114a1c4c..37d25fb7f1 100644 --- a/src/descriptors/power_system_inputs.json +++ b/src/descriptors/power_system_inputs.json @@ -366,6 +366,21 @@ "description": "Heat required to startup from cold", "default_value": null }, + { + "name": "heat_rate_a0", + "description": "Heat rate Average 0 TODO", + "default_value": null + }, + { + "name": "heat_rate_a1", + "description": "Heat rate Average 0 TODO", + "default_value": null + }, + { + "name": "heat_rate_a2", + "description": "Heat rate Average 0 TODO", + "default_value": null + }, { "name": "heat_rate_avg_0", "description": "Heat rate Average 0 TODO", diff --git a/src/parsers/power_system_table_data.jl b/src/parsers/power_system_table_data.jl index 7c9ea3f464..b245dcc3c7 100644 --- a/src/parsers/power_system_table_data.jl +++ b/src/parsers/power_system_table_data.jl @@ -545,6 +545,7 @@ function gen_csv_parser!(sys::System, data::PowerSystemTableData) throw(IS.ConflictingInputsError("Heat rate and cost points are both defined")) elseif length(heat_rate_fields) > 0 cost_colnames = _HeatRateColumns(zip(heat_rate_fields, output_point_fields)) + @warn cost_colnames elseif length(cost_point_fields) > 0 cost_colnames = _CostPointColumns(zip(cost_point_fields, output_point_fields)) else @@ -823,8 +824,17 @@ function make_cost( ) where {T <: ThermalGen} fuel_price = gen.fuel_price / 1000.0 - cost_pairs = get_cost_pairs(gen, cost_colnames) - var_cost, fixed = create_pwinc_cost(cost_pairs) + # We check if there is any Quadratic or Linear Data defined. If not we fall back to create PowerLoad + @warn typeof(gen) + quadratic_fields = (gen.heat_rate_a0, gen.heat_rate_a1, gen.heat_rate_a2) + + if any(field -> field != nothing, quadratic_fields) + var_cost, fixed = + create_poly_cost(gen, ["heat_rate_a0", "heat_rate_a1", "heat_rate_a2"]) + else + cost_pairs = get_cost_pairs(gen, cost_colnames) + var_cost, fixed = create_pwinc_cost(cost_pairs) + end startup_cost, shutdown_cost = calculate_uc_cost(data, gen, fuel_price) @@ -956,6 +966,40 @@ function create_pwl_cost( return var_cost end +function create_poly_cost( + gen, cost_colnames, +) + vals = [] + for coeff in cost_colnames + a = getfield(gen, Symbol(coeff)) + if a != nothing + push!(vals, tryparse(Float64, a)) + end + end + + # Three supported cases, + # 1. If three values are passed then we have data looking like: a^2 + a + c, + # 2. If two then data is looking like: a + c + # 3. If two then data is looking like: c + if length(vals) > 3 + throw( + DataFormatError( + "Higher order polynomial functions currently not supported.", + ), + ) + elseif length(vals) == 3 + var_cost = QuadraticCurve(vals[3], vals[2], vals[1]) + @debug "Quadratic curve created for $(gen.name)" + elseif length(vals) == 2 + var_cost = LinearCurve(vals[2], vals[1]) + else + length(vals) == 1 + var_cost = LinearCurve(vals[1]) + end + + return var_cost, 0.0 +end + function create_pwinc_cost( cost_pairs, ) From 8f9bed114b53be71f6e4b0e3af074e0b120d97a8 Mon Sep 17 00:00:00 2001 From: pesap Date: Mon, 26 Aug 2024 17:40:41 -0600 Subject: [PATCH 02/12] fixup! fix: Adding support for quadratic functions using the table data parsers --- src/parsers/power_system_table_data.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/parsers/power_system_table_data.jl b/src/parsers/power_system_table_data.jl index b245dcc3c7..362c3455ac 100644 --- a/src/parsers/power_system_table_data.jl +++ b/src/parsers/power_system_table_data.jl @@ -545,7 +545,6 @@ function gen_csv_parser!(sys::System, data::PowerSystemTableData) throw(IS.ConflictingInputsError("Heat rate and cost points are both defined")) elseif length(heat_rate_fields) > 0 cost_colnames = _HeatRateColumns(zip(heat_rate_fields, output_point_fields)) - @warn cost_colnames elseif length(cost_point_fields) > 0 cost_colnames = _CostPointColumns(zip(cost_point_fields, output_point_fields)) else @@ -825,7 +824,6 @@ function make_cost( fuel_price = gen.fuel_price / 1000.0 # We check if there is any Quadratic or Linear Data defined. If not we fall back to create PowerLoad - @warn typeof(gen) quadratic_fields = (gen.heat_rate_a0, gen.heat_rate_a1, gen.heat_rate_a2) if any(field -> field != nothing, quadratic_fields) @@ -978,9 +976,9 @@ function create_poly_cost( end # Three supported cases, - # 1. If three values are passed then we have data looking like: a^2 + a + c, - # 2. If two then data is looking like: a + c - # 3. If two then data is looking like: c + # 1. If three values are passed then we have data looking like: a * x^2 + b * x + c, + # 2. If two then data is looking like: a * x + b + # 3. If two then data is looking like: a * x if length(vals) > 3 throw( DataFormatError( @@ -989,12 +987,13 @@ function create_poly_cost( ) elseif length(vals) == 3 var_cost = QuadraticCurve(vals[3], vals[2], vals[1]) - @debug "Quadratic curve created for $(gen.name)" + @debug "QuadraticCurve created for $(gen.name)" elseif length(vals) == 2 var_cost = LinearCurve(vals[2], vals[1]) + @debug "LinearCurve curve created for $(gen.name)" else - length(vals) == 1 var_cost = LinearCurve(vals[1]) + @debug "LinearCurve curve created for $(gen.name)" end return var_cost, 0.0 From f43769c3cbad10934ae0f9bb9f5bbc142eac7424 Mon Sep 17 00:00:00 2001 From: pesap Date: Mon, 26 Aug 2024 18:25:06 -0600 Subject: [PATCH 03/12] fix: Added better handling of the coefficients and docstring Co-authored-by: GabrielKS <23368820+GabrielKS@users.noreply.github.com> --- src/parsers/power_system_table_data.jl | 50 ++++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/parsers/power_system_table_data.jl b/src/parsers/power_system_table_data.jl index 362c3455ac..baa3a15319 100644 --- a/src/parsers/power_system_table_data.jl +++ b/src/parsers/power_system_table_data.jl @@ -964,39 +964,43 @@ function create_pwl_cost( return var_cost end +""" + create_poly_cost(gen, cost_colnames) + +Return a Polynomial function cost based on the coeffiecients provided on gen. + +Three supported cases, + 1. If three values are passed then we have data looking like: `a2 * x^2 + a1 * x + a0`, + 2. If `a1` and `a0` are passed then we have data looking like: `a1 * x + a0`, + 3. If only `a1` is passed then we have data looking like: `a1 * x`. +""" function create_poly_cost( gen, cost_colnames, ) - vals = [] - for coeff in cost_colnames - a = getfield(gen, Symbol(coeff)) - if a != nothing - push!(vals, tryparse(Float64, a)) - end - end + fixed_cost = 0.0 + parse_maybe_nothing(x) = isnothing(x) ? nothing : tryparse(Float64, x) + a2 = parse_maybe_nothing(getfield(gen, Symbol("heat_rate_a2"))) + a1 = parse_maybe_nothing(getfield(gen, Symbol("heat_rate_a1"))) + a0 = parse_maybe_nothing(getfield(gen, Symbol("heat_rate_a0"))) - # Three supported cases, - # 1. If three values are passed then we have data looking like: a * x^2 + b * x + c, - # 2. If two then data is looking like: a * x + b - # 3. If two then data is looking like: a * x - if length(vals) > 3 + if !isnothing(a2) && (isnothing(a1) || isnothing(a0)) throw( DataFormatError( - "Higher order polynomial functions currently not supported.", + "All coefficients must be passed if quadratic term is passed.", ), ) - elseif length(vals) == 3 - var_cost = QuadraticCurve(vals[3], vals[2], vals[1]) - @debug "QuadraticCurve created for $(gen.name)" - elseif length(vals) == 2 - var_cost = LinearCurve(vals[2], vals[1]) - @debug "LinearCurve curve created for $(gen.name)" - else - var_cost = LinearCurve(vals[1]) - @debug "LinearCurve curve created for $(gen.name)" end - return var_cost, 0.0 + if !any(isnothing.([a2, a1, a0])) + @debug "QuadraticCurve created for $(gen.name)" + return QuadraticCurve(a2, a1, a0), fixed_cost + end + if all(isnothing.([a2, a0])) && !isnothing(a1) + @debug "LinearCurve created for $(gen.name)" + return LinearCurve(a1), fixed_cost + end + @debug "LinearCurve created for $(gen.name)" + return LinearCurve(a1, a0), fixed_cost end function create_pwinc_cost( From 08fbaf4b2ae1a2e6cecf1bf1d8ad8896a44608ca Mon Sep 17 00:00:00 2001 From: pesap Date: Mon, 26 Aug 2024 18:27:57 -0600 Subject: [PATCH 04/12] fix: Improved description of new fields. --- src/descriptors/power_system_inputs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/descriptors/power_system_inputs.json b/src/descriptors/power_system_inputs.json index 37d25fb7f1..3a2ac9220e 100644 --- a/src/descriptors/power_system_inputs.json +++ b/src/descriptors/power_system_inputs.json @@ -368,17 +368,17 @@ }, { "name": "heat_rate_a0", - "description": "Heat rate Average 0 TODO", + "description": "Heat rate constant term", "default_value": null }, { "name": "heat_rate_a1", - "description": "Heat rate Average 0 TODO", + "description": "Heat rate proportional term", "default_value": null }, { "name": "heat_rate_a2", - "description": "Heat rate Average 0 TODO", + "description": "Heat rate quadratic term", "default_value": null }, { From 096af583183047c181642683a7038d1e449aa7d7 Mon Sep 17 00:00:00 2001 From: pesap Date: Mon, 26 Aug 2024 18:47:18 -0600 Subject: [PATCH 05/12] fix: Correct typo on comment --- src/parsers/power_system_table_data.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/power_system_table_data.jl b/src/parsers/power_system_table_data.jl index baa3a15319..39b2340811 100644 --- a/src/parsers/power_system_table_data.jl +++ b/src/parsers/power_system_table_data.jl @@ -823,7 +823,7 @@ function make_cost( ) where {T <: ThermalGen} fuel_price = gen.fuel_price / 1000.0 - # We check if there is any Quadratic or Linear Data defined. If not we fall back to create PowerLoad + # We check if there is any Quadratic or Linear Data defined. If not we fall back to create PiecewiseIncrementalCurve quadratic_fields = (gen.heat_rate_a0, gen.heat_rate_a1, gen.heat_rate_a2) if any(field -> field != nothing, quadratic_fields) From 3017f295e727afca4c9a8ef576b39795bad330c0 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 26 Aug 2024 19:29:21 -0700 Subject: [PATCH 06/12] add ST8C --- src/descriptors/power_system_structs.json | 319 +++++++++++++++++++++ src/models/generated/ST8C.jl | 321 ++++++++++++++++++++++ src/models/generated/includes.jl | 35 +++ 3 files changed, 675 insertions(+) create mode 100644 src/models/generated/ST8C.jl diff --git a/src/descriptors/power_system_structs.json b/src/descriptors/power_system_structs.json index ec2e777dad..773ba0b0ac 100644 --- a/src/descriptors/power_system_structs.json +++ b/src/descriptors/power_system_structs.json @@ -8200,6 +8200,325 @@ ], "supertype": "AVR" }, + { + "struct_name": "ST8C", + "docstring": "In these excitation systems, voltage (and also current in compounded systems) is transformed to an appropriate level. Rectifiers, either controlled or non-controlled, provide the necessary direct current for the generator field.\nParameters of IEEE Std 421.5 Type ST8C Excitacion System. ST8C in PSSE and PSLF", + "fields": [ + { + "name": "OEL_Flag", + "comment": "OEL Flag for ST8C: <2: Summation at Voltage Error, 2: OEL takeover at gate", + "null_value": 0, + "data_type": "Int", + "valid_range": { + "min": 0, + "max": 2 + } + }, + { + "name": "UEL_Flag", + "comment": "UEL Flag for ST8C: <2: Summation at Voltage Error, 2: UEL takeover at gate", + "null_value": 0, + "data_type": "Int", + "valid_range": { + "min": 0, + "max": 2 + } + }, + { + "name": "SCL_Flag", + "comment": "SCL Flag for ST8C: <2: Summation at Voltage Error, 2: SCL Takeover at UEL and OEL gates", + "null_value": 0, + "data_type": "Int", + "valid_range": { + "min": 0, + "max": 2 + } + }, + { + "name": "SW1_Flag", + "comment": "SW1 Flag for Power Source Selector for ST8C: <2: Source from generator terminal voltage, 2: Independent power source", + "null_value": 0, + "data_type": "Int", + "valid_range": { + "min": 0, + "max": 2 + } + }, + { + "name": "Tr", + "comment": "Regulator input filter time constant in seconds", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_pr", + "comment": "Regulator proportional gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_ir", + "comment": "Regulator integral gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "Vpi_lim", + "comment": "Regulator input limits (Vpi_min, Vpi_max)", + "null_value": "(min=0.0, max=0.0)", + "data_type": "MinMax" + }, + { + "name": "K_pa", + "comment": "Field current regulator proportional gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_ia", + "comment": "Field current regulator integral gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "Va_lim", + "comment": "Field current regulator output limits (Va_min, Va_max)", + "null_value": "(min=0.0, max=0.0)", + "data_type": "MinMax" + }, + { + "name": "K_a", + "comment": "Field current regulator proportional gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "T_a", + "comment": "Controlled rectifier bridge equivalent time constant in seconds", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "Vr_lim", + "comment": "Voltage regulator limits (Vr_min, Vr_max)", + "null_value": "(min=0.0, max=0.0)", + "data_type": "MinMax" + }, + { + "name": "K_f", + "comment": "Exciter field current feedback gain (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "T_f", + "comment": "Field current feedback time constant in seconds", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_c1", + "comment": "Rectifier loading factor proportional to commutating reactance (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_p", + "comment": "Potential circuit (voltage) gain coefficient (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_i1", + "comment": "Potential circuit (current) gain coefficient (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "X_l", + "comment": "Reactance associated with potential source (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "θ_p", + "comment": "Potential circuit phase angle (degrees)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "VB1_max", + "comment": "Maximum available exciter voltage (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_c2", + "comment": "Rectifier loading factor proportional to commutating reactance (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "K_i2", + "comment": "Potential circuit (current) gain coefficient (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "VB2_max", + "comment": "Maximum available exciter voltage (pu)", + "null_value": 0, + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + }, + "validation_action": "warn" + }, + { + "name": "V_ref", + "comment": "Reference Voltage Set-point (pu)", + "null_value": 0, + "default": "1.0", + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + } + }, + { + "name": "Ifd_ref", + "comment": "Reference Field Current Set-point (pu)", + "null_value": 0, + "default": "1.0", + "data_type": "Float64", + "valid_range": { + "min": 0, + "max": null + } + }, + { + "name": "ext", + "comment": "An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude.", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, + { + "name": "states", + "exclude_setter": true, + "comment": "(**Do not modify.**) The [states](@ref S) are:\n\tVm: Sensed terminal voltage,\n\tx_a1: Regulator Integrator state,\n\tx_a2: Field Current regulator state,\n\tx_a3: Controller rectifier bridge state,\n\tx_a4: Regulator Feedback state", + "internal_default": "[:Vm, :x_a1, :x_a2, :x_a3, :x_a4]", + "data_type": "Vector{Symbol}" + }, + { + "name": "n_states", + "exclude_setter": true, + "comment": "(**Do not modify.**) ST8C has 5 states", + "internal_default": 5, + "data_type": "Int" + }, + { + "name": "states_types", + "comment": "(**Do not modify.**) ST8C has 5 states", + "internal_default": "[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid]", + "data_type": "Vector{StateTypes}" + }, + { + "name": "internal", + "comment": "(**Do not modify.**) PowerSystems.jl internal reference", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "AVR" + }, { "struct_name": "EXST1", "docstring": "IEEE Type ST1 Excitation System (PTI version)", diff --git a/src/models/generated/ST8C.jl b/src/models/generated/ST8C.jl new file mode 100644 index 0000000000..6ac513cf43 --- /dev/null +++ b/src/models/generated/ST8C.jl @@ -0,0 +1,321 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct ST8C <: AVR + OEL_Flag::Int + UEL_Flag::Int + SCL_Flag::Int + SW1_Flag::Int + Tr::Float64 + K_pr::Float64 + K_ir::Float64 + Vpi_lim::MinMax + K_pa::Float64 + K_ia::Float64 + Va_lim::MinMax + K_a::Float64 + T_a::Float64 + Vr_lim::MinMax + K_f::Float64 + T_f::Float64 + K_c1::Float64 + K_p::Float64 + K_i1::Float64 + X_l::Float64 + θ_p::Float64 + VB1_max::Float64 + K_c2::Float64 + K_i2::Float64 + VB2_max::Float64 + V_ref::Float64 + Ifd_ref::Float64 + ext::Dict{String, Any} + states::Vector{Symbol} + n_states::Int + states_types::Vector{StateTypes} + internal::InfrastructureSystemsInternal + end + +In these excitation systems, voltage (and also current in compounded systems) is transformed to an appropriate level. Rectifiers, either controlled or non-controlled, provide the necessary direct current for the generator field. +Parameters of IEEE Std 421.5 Type ST8C Excitacion System. ST8C in PSSE and PSLF + +# Arguments +- `OEL_Flag::Int`: OEL Flag for ST8C: <2: Summation at Voltage Error, 2: OEL takeover at gate, validation range: `(0, 2)` +- `UEL_Flag::Int`: UEL Flag for ST8C: <2: Summation at Voltage Error, 2: UEL takeover at gate, validation range: `(0, 2)` +- `SCL_Flag::Int`: SCL Flag for ST8C: <2: Summation at Voltage Error, 2: SCL Takeover at UEL and OEL gates, validation range: `(0, 2)` +- `SW1_Flag::Int`: SW1 Flag for Power Source Selector for ST8C: <2: Source from generator terminal voltage, 2: Independent power source, validation range: `(0, 2)` +- `Tr::Float64`: Regulator input filter time constant in seconds, validation range: `(0, nothing)` +- `K_pr::Float64`: Regulator proportional gain (pu), validation range: `(0, nothing)` +- `K_ir::Float64`: Regulator integral gain (pu), validation range: `(0, nothing)` +- `Vpi_lim::MinMax`: Regulator input limits (Vpi_min, Vpi_max) +- `K_pa::Float64`: Field current regulator proportional gain (pu), validation range: `(0, nothing)` +- `K_ia::Float64`: Field current regulator integral gain (pu), validation range: `(0, nothing)` +- `Va_lim::MinMax`: Field current regulator output limits (Va_min, Va_max) +- `K_a::Float64`: Field current regulator proportional gain (pu), validation range: `(0, nothing)` +- `T_a::Float64`: Controlled rectifier bridge equivalent time constant in seconds, validation range: `(0, nothing)` +- `Vr_lim::MinMax`: Voltage regulator limits (Vr_min, Vr_max) +- `K_f::Float64`: Exciter field current feedback gain (pu), validation range: `(0, nothing)` +- `T_f::Float64`: Field current feedback time constant in seconds, validation range: `(0, nothing)` +- `K_c1::Float64`: Rectifier loading factor proportional to commutating reactance (pu), validation range: `(0, nothing)` +- `K_p::Float64`: Potential circuit (voltage) gain coefficient (pu), validation range: `(0, nothing)` +- `K_i1::Float64`: Potential circuit (current) gain coefficient (pu), validation range: `(0, nothing)` +- `X_l::Float64`: Reactance associated with potential source (pu), validation range: `(0, nothing)` +- `θ_p::Float64`: Potential circuit phase angle (degrees), validation range: `(0, nothing)` +- `VB1_max::Float64`: Maximum available exciter voltage (pu), validation range: `(0, nothing)` +- `K_c2::Float64`: Rectifier loading factor proportional to commutating reactance (pu), validation range: `(0, nothing)` +- `K_i2::Float64`: Potential circuit (current) gain coefficient (pu), validation range: `(0, nothing)` +- `VB2_max::Float64`: Maximum available exciter voltage (pu), validation range: `(0, nothing)` +- `V_ref::Float64`: (default: `1.0`) Reference Voltage Set-point (pu), validation range: `(0, nothing)` +- `Ifd_ref::Float64`: (default: `1.0`) Reference Field Current Set-point (pu), validation range: `(0, nothing)` +- `ext::Dict{String, Any}`: (default: `Dict{String, Any}()`) An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude. +- `states::Vector{Symbol}`: (**Do not modify.**) The [states](@ref S) are: + Vm: Sensed terminal voltage, + x_a1: Regulator Integrator state, + x_a2: Field Current regulator state, + x_a3: Controller rectifier bridge state, + x_a4: Regulator Feedback state +- `n_states::Int`: (**Do not modify.**) ST8C has 5 states +- `states_types::Vector{StateTypes}`: (**Do not modify.**) ST8C has 5 states +- `internal::InfrastructureSystemsInternal`: (**Do not modify.**) PowerSystems.jl internal reference +""" +mutable struct ST8C <: AVR + "OEL Flag for ST8C: <2: Summation at Voltage Error, 2: OEL takeover at gate" + OEL_Flag::Int + "UEL Flag for ST8C: <2: Summation at Voltage Error, 2: UEL takeover at gate" + UEL_Flag::Int + "SCL Flag for ST8C: <2: Summation at Voltage Error, 2: SCL Takeover at UEL and OEL gates" + SCL_Flag::Int + "SW1 Flag for Power Source Selector for ST8C: <2: Source from generator terminal voltage, 2: Independent power source" + SW1_Flag::Int + "Regulator input filter time constant in seconds" + Tr::Float64 + "Regulator proportional gain (pu)" + K_pr::Float64 + "Regulator integral gain (pu)" + K_ir::Float64 + "Regulator input limits (Vpi_min, Vpi_max)" + Vpi_lim::MinMax + "Field current regulator proportional gain (pu)" + K_pa::Float64 + "Field current regulator integral gain (pu)" + K_ia::Float64 + "Field current regulator output limits (Va_min, Va_max)" + Va_lim::MinMax + "Field current regulator proportional gain (pu)" + K_a::Float64 + "Controlled rectifier bridge equivalent time constant in seconds" + T_a::Float64 + "Voltage regulator limits (Vr_min, Vr_max)" + Vr_lim::MinMax + "Exciter field current feedback gain (pu)" + K_f::Float64 + "Field current feedback time constant in seconds" + T_f::Float64 + "Rectifier loading factor proportional to commutating reactance (pu)" + K_c1::Float64 + "Potential circuit (voltage) gain coefficient (pu)" + K_p::Float64 + "Potential circuit (current) gain coefficient (pu)" + K_i1::Float64 + "Reactance associated with potential source (pu)" + X_l::Float64 + "Potential circuit phase angle (degrees)" + θ_p::Float64 + "Maximum available exciter voltage (pu)" + VB1_max::Float64 + "Rectifier loading factor proportional to commutating reactance (pu)" + K_c2::Float64 + "Potential circuit (current) gain coefficient (pu)" + K_i2::Float64 + "Maximum available exciter voltage (pu)" + VB2_max::Float64 + "Reference Voltage Set-point (pu)" + V_ref::Float64 + "Reference Field Current Set-point (pu)" + Ifd_ref::Float64 + "An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude." + ext::Dict{String, Any} + "(**Do not modify.**) The [states](@ref S) are: + Vm: Sensed terminal voltage, + x_a1: Regulator Integrator state, + x_a2: Field Current regulator state, + x_a3: Controller rectifier bridge state, + x_a4: Regulator Feedback state" + states::Vector{Symbol} + "(**Do not modify.**) ST8C has 5 states" + n_states::Int + "(**Do not modify.**) ST8C has 5 states" + states_types::Vector{StateTypes} + "(**Do not modify.**) PowerSystems.jl internal reference" + internal::InfrastructureSystemsInternal +end + +function ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref=1.0, Ifd_ref=1.0, ext=Dict{String, Any}(), ) + ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref, Ifd_ref, ext, [:Vm, :x_a1, :x_a2, :x_a3, :x_a4], 5, [StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid], InfrastructureSystemsInternal(), ) +end + +function ST8C(; OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref=1.0, Ifd_ref=1.0, ext=Dict{String, Any}(), states=[:Vm, :x_a1, :x_a2, :x_a3, :x_a4], n_states=5, states_types=[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid], internal=InfrastructureSystemsInternal(), ) + ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref, Ifd_ref, ext, states, n_states, states_types, internal, ) +end + +# Constructor for demo purposes; non-functional. +function ST8C(::Nothing) + ST8C(; + OEL_Flag=0, + UEL_Flag=0, + SCL_Flag=0, + SW1_Flag=0, + Tr=0, + K_pr=0, + K_ir=0, + Vpi_lim=(min=0.0, max=0.0), + K_pa=0, + K_ia=0, + Va_lim=(min=0.0, max=0.0), + K_a=0, + T_a=0, + Vr_lim=(min=0.0, max=0.0), + K_f=0, + T_f=0, + K_c1=0, + K_p=0, + K_i1=0, + X_l=0, + θ_p=0, + VB1_max=0, + K_c2=0, + K_i2=0, + VB2_max=0, + V_ref=0, + Ifd_ref=0, + ext=Dict{String, Any}(), + ) +end + +"""Get [`ST8C`](@ref) `OEL_Flag`.""" +get_OEL_Flag(value::ST8C) = value.OEL_Flag +"""Get [`ST8C`](@ref) `UEL_Flag`.""" +get_UEL_Flag(value::ST8C) = value.UEL_Flag +"""Get [`ST8C`](@ref) `SCL_Flag`.""" +get_SCL_Flag(value::ST8C) = value.SCL_Flag +"""Get [`ST8C`](@ref) `SW1_Flag`.""" +get_SW1_Flag(value::ST8C) = value.SW1_Flag +"""Get [`ST8C`](@ref) `Tr`.""" +get_Tr(value::ST8C) = value.Tr +"""Get [`ST8C`](@ref) `K_pr`.""" +get_K_pr(value::ST8C) = value.K_pr +"""Get [`ST8C`](@ref) `K_ir`.""" +get_K_ir(value::ST8C) = value.K_ir +"""Get [`ST8C`](@ref) `Vpi_lim`.""" +get_Vpi_lim(value::ST8C) = value.Vpi_lim +"""Get [`ST8C`](@ref) `K_pa`.""" +get_K_pa(value::ST8C) = value.K_pa +"""Get [`ST8C`](@ref) `K_ia`.""" +get_K_ia(value::ST8C) = value.K_ia +"""Get [`ST8C`](@ref) `Va_lim`.""" +get_Va_lim(value::ST8C) = value.Va_lim +"""Get [`ST8C`](@ref) `K_a`.""" +get_K_a(value::ST8C) = value.K_a +"""Get [`ST8C`](@ref) `T_a`.""" +get_T_a(value::ST8C) = value.T_a +"""Get [`ST8C`](@ref) `Vr_lim`.""" +get_Vr_lim(value::ST8C) = value.Vr_lim +"""Get [`ST8C`](@ref) `K_f`.""" +get_K_f(value::ST8C) = value.K_f +"""Get [`ST8C`](@ref) `T_f`.""" +get_T_f(value::ST8C) = value.T_f +"""Get [`ST8C`](@ref) `K_c1`.""" +get_K_c1(value::ST8C) = value.K_c1 +"""Get [`ST8C`](@ref) `K_p`.""" +get_K_p(value::ST8C) = value.K_p +"""Get [`ST8C`](@ref) `K_i1`.""" +get_K_i1(value::ST8C) = value.K_i1 +"""Get [`ST8C`](@ref) `X_l`.""" +get_X_l(value::ST8C) = value.X_l +"""Get [`ST8C`](@ref) `θ_p`.""" +get_θ_p(value::ST8C) = value.θ_p +"""Get [`ST8C`](@ref) `VB1_max`.""" +get_VB1_max(value::ST8C) = value.VB1_max +"""Get [`ST8C`](@ref) `K_c2`.""" +get_K_c2(value::ST8C) = value.K_c2 +"""Get [`ST8C`](@ref) `K_i2`.""" +get_K_i2(value::ST8C) = value.K_i2 +"""Get [`ST8C`](@ref) `VB2_max`.""" +get_VB2_max(value::ST8C) = value.VB2_max +"""Get [`ST8C`](@ref) `V_ref`.""" +get_V_ref(value::ST8C) = value.V_ref +"""Get [`ST8C`](@ref) `Ifd_ref`.""" +get_Ifd_ref(value::ST8C) = value.Ifd_ref +"""Get [`ST8C`](@ref) `ext`.""" +get_ext(value::ST8C) = value.ext +"""Get [`ST8C`](@ref) `states`.""" +get_states(value::ST8C) = value.states +"""Get [`ST8C`](@ref) `n_states`.""" +get_n_states(value::ST8C) = value.n_states +"""Get [`ST8C`](@ref) `states_types`.""" +get_states_types(value::ST8C) = value.states_types +"""Get [`ST8C`](@ref) `internal`.""" +get_internal(value::ST8C) = value.internal + +"""Set [`ST8C`](@ref) `OEL_Flag`.""" +set_OEL_Flag!(value::ST8C, val) = value.OEL_Flag = val +"""Set [`ST8C`](@ref) `UEL_Flag`.""" +set_UEL_Flag!(value::ST8C, val) = value.UEL_Flag = val +"""Set [`ST8C`](@ref) `SCL_Flag`.""" +set_SCL_Flag!(value::ST8C, val) = value.SCL_Flag = val +"""Set [`ST8C`](@ref) `SW1_Flag`.""" +set_SW1_Flag!(value::ST8C, val) = value.SW1_Flag = val +"""Set [`ST8C`](@ref) `Tr`.""" +set_Tr!(value::ST8C, val) = value.Tr = val +"""Set [`ST8C`](@ref) `K_pr`.""" +set_K_pr!(value::ST8C, val) = value.K_pr = val +"""Set [`ST8C`](@ref) `K_ir`.""" +set_K_ir!(value::ST8C, val) = value.K_ir = val +"""Set [`ST8C`](@ref) `Vpi_lim`.""" +set_Vpi_lim!(value::ST8C, val) = value.Vpi_lim = val +"""Set [`ST8C`](@ref) `K_pa`.""" +set_K_pa!(value::ST8C, val) = value.K_pa = val +"""Set [`ST8C`](@ref) `K_ia`.""" +set_K_ia!(value::ST8C, val) = value.K_ia = val +"""Set [`ST8C`](@ref) `Va_lim`.""" +set_Va_lim!(value::ST8C, val) = value.Va_lim = val +"""Set [`ST8C`](@ref) `K_a`.""" +set_K_a!(value::ST8C, val) = value.K_a = val +"""Set [`ST8C`](@ref) `T_a`.""" +set_T_a!(value::ST8C, val) = value.T_a = val +"""Set [`ST8C`](@ref) `Vr_lim`.""" +set_Vr_lim!(value::ST8C, val) = value.Vr_lim = val +"""Set [`ST8C`](@ref) `K_f`.""" +set_K_f!(value::ST8C, val) = value.K_f = val +"""Set [`ST8C`](@ref) `T_f`.""" +set_T_f!(value::ST8C, val) = value.T_f = val +"""Set [`ST8C`](@ref) `K_c1`.""" +set_K_c1!(value::ST8C, val) = value.K_c1 = val +"""Set [`ST8C`](@ref) `K_p`.""" +set_K_p!(value::ST8C, val) = value.K_p = val +"""Set [`ST8C`](@ref) `K_i1`.""" +set_K_i1!(value::ST8C, val) = value.K_i1 = val +"""Set [`ST8C`](@ref) `X_l`.""" +set_X_l!(value::ST8C, val) = value.X_l = val +"""Set [`ST8C`](@ref) `θ_p`.""" +set_θ_p!(value::ST8C, val) = value.θ_p = val +"""Set [`ST8C`](@ref) `VB1_max`.""" +set_VB1_max!(value::ST8C, val) = value.VB1_max = val +"""Set [`ST8C`](@ref) `K_c2`.""" +set_K_c2!(value::ST8C, val) = value.K_c2 = val +"""Set [`ST8C`](@ref) `K_i2`.""" +set_K_i2!(value::ST8C, val) = value.K_i2 = val +"""Set [`ST8C`](@ref) `VB2_max`.""" +set_VB2_max!(value::ST8C, val) = value.VB2_max = val +"""Set [`ST8C`](@ref) `V_ref`.""" +set_V_ref!(value::ST8C, val) = value.V_ref = val +"""Set [`ST8C`](@ref) `Ifd_ref`.""" +set_Ifd_ref!(value::ST8C, val) = value.Ifd_ref = val +"""Set [`ST8C`](@ref) `ext`.""" +set_ext!(value::ST8C, val) = value.ext = val +"""Set [`ST8C`](@ref) `states_types`.""" +set_states_types!(value::ST8C, val) = value.states_types = val diff --git a/src/models/generated/includes.jl b/src/models/generated/includes.jl index 685525a3b5..1d50632cab 100644 --- a/src/models/generated/includes.jl +++ b/src/models/generated/includes.jl @@ -59,6 +59,7 @@ include("ESST1A.jl") include("EXPIC1.jl") include("ESST4B.jl") include("ST6B.jl") +include("ST8C.jl") include("EXST1.jl") include("EX4VSA.jl") include("BaseMachine.jl") @@ -180,6 +181,7 @@ export get_H_lp export get_I_lr export get_I_max export get_Id_max +export get_Ifd_ref export get_Iflim export get_Io_lim export get_Iq_lim @@ -198,15 +200,21 @@ export get_K6 export get_K7 export get_K8 export get_KT +export get_K_a export get_K_c +export get_K_c1 +export get_K_c2 export get_K_ci export get_K_d export get_K_da export get_K_ex +export get_K_f export get_K_ff export get_K_hp export get_K_hv export get_K_i +export get_K_i1 +export get_K_i2 export get_K_ia export get_K_ig export get_K_im @@ -311,8 +319,10 @@ export get_Rp export get_Rperm export get_Rrpwr export get_Rselect +export get_SCL_Flag export get_SOC_ini export get_SOC_lim +export get_SW1_Flag export get_Se export get_Spar export get_T @@ -334,9 +344,11 @@ export get_T9 export get_TFRT_pnts export get_TVRT_pnts export get_T_AA +export get_T_a export get_T_act export get_T_da export get_T_eng +export get_T_f export get_T_fltr export get_T_ft export get_T_fv @@ -390,8 +402,11 @@ export get_Tw2 export get_Tw3 export get_Tw4 export get_U0 +export get_UEL_Flag export get_UEL_flags export get_U_c +export get_VB1_max +export get_VB2_max export get_VB_max export get_VC_Flag export get_VELM @@ -418,6 +433,7 @@ export get_Vm_lim export get_Vmax export get_Vmin export get_Vo_lim +export get_Vpi_lim export get_Vpr export get_Vr_lim export get_Vrfrac @@ -429,6 +445,7 @@ export get_Wf_nl export get_X_ad export get_X_aq export get_X_c +export get_X_l export get_X_lr export get_X_ls export get_X_m @@ -663,6 +680,7 @@ export get_γ_q2 export get_γ_qd export get_γd export get_γq +export get_θ_p export get_θp export get_θp_rad export get_τ_limits @@ -728,6 +746,7 @@ export set_H_lp! export set_I_lr! export set_I_max! export set_Id_max! +export set_Ifd_ref! export set_Iflim! export set_Io_lim! export set_Iq_lim! @@ -746,15 +765,21 @@ export set_K6! export set_K7! export set_K8! export set_KT! +export set_K_a! export set_K_c! +export set_K_c1! +export set_K_c2! export set_K_ci! export set_K_d! export set_K_da! export set_K_ex! +export set_K_f! export set_K_ff! export set_K_hp! export set_K_hv! export set_K_i! +export set_K_i1! +export set_K_i2! export set_K_ia! export set_K_ig! export set_K_im! @@ -859,8 +884,10 @@ export set_Rp! export set_Rperm! export set_Rrpwr! export set_Rselect! +export set_SCL_Flag! export set_SOC_ini! export set_SOC_lim! +export set_SW1_Flag! export set_Se! export set_Spar! export set_T! @@ -882,9 +909,11 @@ export set_T9! export set_TFRT_pnts! export set_TVRT_pnts! export set_T_AA! +export set_T_a! export set_T_act! export set_T_da! export set_T_eng! +export set_T_f! export set_T_fltr! export set_T_ft! export set_T_fv! @@ -938,8 +967,11 @@ export set_Tw2! export set_Tw3! export set_Tw4! export set_U0! +export set_UEL_Flag! export set_UEL_flags! export set_U_c! +export set_VB1_max! +export set_VB2_max! export set_VB_max! export set_VC_Flag! export set_VELM! @@ -966,6 +998,7 @@ export set_Vm_lim! export set_Vmax! export set_Vmin! export set_Vo_lim! +export set_Vpi_lim! export set_Vpr! export set_Vr_lim! export set_Vrfrac! @@ -977,6 +1010,7 @@ export set_Wf_nl! export set_X_ad! export set_X_aq! export set_X_c! +export set_X_l! export set_X_lr! export set_X_ls! export set_X_m! @@ -1211,6 +1245,7 @@ export set_γ_q2! export set_γ_qd! export set_γd! export set_γq! +export set_θ_p! export set_θp! export set_θp_rad! export set_τ_limits! From 38b88d57457e29701351072f9db5a345ebefbc61 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Mon, 26 Aug 2024 19:48:27 -0700 Subject: [PATCH 07/12] update typo and parser --- src/descriptors/power_system_structs.json | 2 +- src/models/generated/ST8C.jl | 4 ++-- src/parsers/psse_dynamic_mapping.yaml | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/descriptors/power_system_structs.json b/src/descriptors/power_system_structs.json index 773ba0b0ac..b96ba69642 100644 --- a/src/descriptors/power_system_structs.json +++ b/src/descriptors/power_system_structs.json @@ -8506,7 +8506,7 @@ { "name": "states_types", "comment": "(**Do not modify.**) ST8C has 5 states", - "internal_default": "[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid]", + "internal_default": "[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid]", "data_type": "Vector{StateTypes}" }, { diff --git a/src/models/generated/ST8C.jl b/src/models/generated/ST8C.jl index 6ac513cf43..a57370a9c4 100644 --- a/src/models/generated/ST8C.jl +++ b/src/models/generated/ST8C.jl @@ -155,10 +155,10 @@ mutable struct ST8C <: AVR end function ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref=1.0, Ifd_ref=1.0, ext=Dict{String, Any}(), ) - ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref, Ifd_ref, ext, [:Vm, :x_a1, :x_a2, :x_a3, :x_a4], 5, [StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid], InfrastructureSystemsInternal(), ) + ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref, Ifd_ref, ext, [:Vm, :x_a1, :x_a2, :x_a3, :x_a4], 5, [StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid], InfrastructureSystemsInternal(), ) end -function ST8C(; OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref=1.0, Ifd_ref=1.0, ext=Dict{String, Any}(), states=[:Vm, :x_a1, :x_a2, :x_a3, :x_a4], n_states=5, states_types=[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes, StateTypes.Hybrid], internal=InfrastructureSystemsInternal(), ) +function ST8C(; OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref=1.0, Ifd_ref=1.0, ext=Dict{String, Any}(), states=[:Vm, :x_a1, :x_a2, :x_a3, :x_a4], n_states=5, states_types=[StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid, StateTypes.Hybrid], internal=InfrastructureSystemsInternal(), ) ST8C(OEL_Flag, UEL_Flag, SCL_Flag, SW1_Flag, Tr, K_pr, K_ir, Vpi_lim, K_pa, K_ia, Va_lim, K_a, T_a, Vr_lim, K_f, T_f, K_c1, K_p, K_i1, X_l, θ_p, VB1_max, K_c2, K_i2, VB2_max, V_ref, Ifd_ref, ext, states, n_states, states_types, internal, ) end diff --git a/src/parsers/psse_dynamic_mapping.yaml b/src/parsers/psse_dynamic_mapping.yaml index da231443bf..de947b9238 100644 --- a/src/parsers/psse_dynamic_mapping.yaml +++ b/src/parsers/psse_dynamic_mapping.yaml @@ -102,6 +102,10 @@ ST6B: { AVR: ST6B }, +ST8C: +{ + AVR: ST8C +}, ############################# #### Turbine Governors ###### @@ -257,6 +261,7 @@ parameter_mapping: EXST1: [1, '(3, 2)', 4, 5, 6, 7, '(9, 8)', 10, 11, 12], ESAC8B: [1, 2, 3, 4, 5, 6, 7, '(9, 8)', 10, 11, '(12, 14)', '(13, 15)'], ST6B: [1, 2, 3, 4, 5, 6, '(8, 7)', 9, 10, 11, 12, 13, '(15, 14)', 16, 17], + ST8C: [1, 2, 3, 4, 5, 6, 7, '(9, 8)', 10, 11, '(13, 12)', 14, 15, '(17, 16)', 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28], #TGs GasTG: [1, 2, 3, 4, 5, 6, '(8, 7)', 9], GeneralGovModel: [1, 2, 3, 4, '(6, 5)', 7, 8, 9, 10, '(12, 11)', 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, '(35, 34)'], From 18ff011e122e4c2d05c739c32925e455ca331445 Mon Sep 17 00:00:00 2001 From: pesap Date: Tue, 27 Aug 2024 10:13:26 -0600 Subject: [PATCH 08/12] test: Adding testing for new function --- src/PowerSystems.jl | 3 ++ test/test_power_system_table_data.jl | 48 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/PowerSystems.jl b/src/PowerSystems.jl index 79097c2c34..66fa9f00ac 100644 --- a/src/PowerSystems.jl +++ b/src/PowerSystems.jl @@ -390,6 +390,9 @@ export get_compression_settings export CompressionSettings export CompressionTypes +# Parsing functions +export create_poly_cost + #export make_time_series export get_bus_numbers export get_name diff --git a/test/test_power_system_table_data.jl b/test/test_power_system_table_data.jl index fc668cf0c8..75c66a5fdb 100644 --- a/test/test_power_system_table_data.jl +++ b/test/test_power_system_table_data.jl @@ -181,3 +181,51 @@ end g = get_components(ThermalStandard, sys) @test get_variable.(get_operation_cost.(g)) == get_variable.(get_operation_cost.(g)) end + +@testset "Test create_poly_cost function" begin + + cost_colnames = ["heat_rate_a0", "heat_rate_a1", "heat_rate_a2"] + + # Coefficients for a CC using natura gas + a2 = -0.000531607 + a1 = 0.060554675 + a0 = 8.951100118 + + # First test that return quadratic if all coefficients are provided. + # We convert the coefficients to string to mimic parsing from csv + example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=string(a1), heat_rate_a2=string(a2)) + cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) + @assert cost_curve isa QuadraticCurve + @assert isapprox(get_quadratic_term(cost_curve), a2, atol=0.01) + @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) + @assert isapprox(get_constant_term(cost_curve), a0, atol=0.01) + + # Test return linear with both proportional and constant term + example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=string(a1), heat_rate_a2=nothing) + cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) + @assert cost_curve isa LinearCurve + @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) + @assert isapprox(get_constant_term(cost_curve), a0, atol=0.01) + + # Test return linear with just proportional term + example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=string(a1), heat_rate_a2=nothing) + cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) + @assert cost_curve isa LinearCurve + @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) + + # Test raises error if a2 is passed but other coefficients are nothing + example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=nothing, heat_rate_a2=string(a2)) + @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) + example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=string(a1), heat_rate_a2=string(a2)) + @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) + example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=nothing, heat_rate_a2=string(a2)) + @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) + + # Test that it works with zero proportional and constant term + example_generator = (name="test-gen", heat_rate_a0=string(0.0), heat_rate_a1=string(0.0), heat_rate_a2=string(a2)) + cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) + @assert cost_curve isa QuadraticCurve + @assert isapprox(get_quadratic_term(cost_curve), a2, atol=0.01) + @assert isapprox(get_proportional_term(cost_curve), 0.0, atol=0.01) + @assert isapprox(get_constant_term(cost_curve), 0.0, atol=0.01) +end From 6988ef644d5c9ea3bfe7f079a3e0edd67738863b Mon Sep 17 00:00:00 2001 From: pesap Date: Tue, 27 Aug 2024 10:18:49 -0600 Subject: [PATCH 09/12] fixup! test: Adding testing for new function --- test/test_power_system_table_data.jl | 68 +++++++++++++++++++++------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/test/test_power_system_table_data.jl b/test/test_power_system_table_data.jl index 75c66a5fdb..dfda723e97 100644 --- a/test/test_power_system_table_data.jl +++ b/test/test_power_system_table_data.jl @@ -183,7 +183,6 @@ end end @testset "Test create_poly_cost function" begin - cost_colnames = ["heat_rate_a0", "heat_rate_a1", "heat_rate_a2"] # Coefficients for a CC using natura gas @@ -193,39 +192,74 @@ end # First test that return quadratic if all coefficients are provided. # We convert the coefficients to string to mimic parsing from csv - example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=string(a1), heat_rate_a2=string(a2)) + example_generator = ( + name = "test-gen", + heat_rate_a0 = string(a0), + heat_rate_a1 = string(a1), + heat_rate_a2 = string(a2), + ) cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) @assert cost_curve isa QuadraticCurve - @assert isapprox(get_quadratic_term(cost_curve), a2, atol=0.01) - @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) - @assert isapprox(get_constant_term(cost_curve), a0, atol=0.01) + @assert isapprox(get_quadratic_term(cost_curve), a2, atol = 0.01) + @assert isapprox(get_proportional_term(cost_curve), a1, atol = 0.01) + @assert isapprox(get_constant_term(cost_curve), a0, atol = 0.01) # Test return linear with both proportional and constant term - example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=string(a1), heat_rate_a2=nothing) + example_generator = ( + name = "test-gen", + heat_rate_a0 = string(a0), + heat_rate_a1 = string(a1), + heat_rate_a2 = nothing, + ) cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) @assert cost_curve isa LinearCurve - @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) - @assert isapprox(get_constant_term(cost_curve), a0, atol=0.01) + @assert isapprox(get_proportional_term(cost_curve), a1, atol = 0.01) + @assert isapprox(get_constant_term(cost_curve), a0, atol = 0.01) # Test return linear with just proportional term - example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=string(a1), heat_rate_a2=nothing) + example_generator = ( + name = "test-gen", + heat_rate_a0 = nothing, + heat_rate_a1 = string(a1), + heat_rate_a2 = nothing, + ) cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) @assert cost_curve isa LinearCurve - @assert isapprox(get_proportional_term(cost_curve), a1, atol=0.01) + @assert isapprox(get_proportional_term(cost_curve), a1, atol = 0.01) # Test raises error if a2 is passed but other coefficients are nothing - example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=nothing, heat_rate_a2=string(a2)) + example_generator = ( + name = "test-gen", + heat_rate_a0 = nothing, + heat_rate_a1 = nothing, + heat_rate_a2 = string(a2), + ) @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) - example_generator = (name="test-gen", heat_rate_a0=nothing, heat_rate_a1=string(a1), heat_rate_a2=string(a2)) + example_generator = ( + name = "test-gen", + heat_rate_a0 = nothing, + heat_rate_a1 = string(a1), + heat_rate_a2 = string(a2), + ) @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) - example_generator = (name="test-gen", heat_rate_a0=string(a0), heat_rate_a1=nothing, heat_rate_a2=string(a2)) + example_generator = ( + name = "test-gen", + heat_rate_a0 = string(a0), + heat_rate_a1 = nothing, + heat_rate_a2 = string(a2), + ) @test_throws IS.DataFormatError create_poly_cost(example_generator, cost_colnames) # Test that it works with zero proportional and constant term - example_generator = (name="test-gen", heat_rate_a0=string(0.0), heat_rate_a1=string(0.0), heat_rate_a2=string(a2)) + example_generator = ( + name = "test-gen", + heat_rate_a0 = string(0.0), + heat_rate_a1 = string(0.0), + heat_rate_a2 = string(a2), + ) cost_curve, fixed_cost = create_poly_cost(example_generator, cost_colnames) @assert cost_curve isa QuadraticCurve - @assert isapprox(get_quadratic_term(cost_curve), a2, atol=0.01) - @assert isapprox(get_proportional_term(cost_curve), 0.0, atol=0.01) - @assert isapprox(get_constant_term(cost_curve), 0.0, atol=0.01) + @assert isapprox(get_quadratic_term(cost_curve), a2, atol = 0.01) + @assert isapprox(get_proportional_term(cost_curve), 0.0, atol = 0.01) + @assert isapprox(get_constant_term(cost_curve), 0.0, atol = 0.01) end From 319f8a99a7e6f81e3a8951c7470b6b673417cbef Mon Sep 17 00:00:00 2001 From: pesap Date: Tue, 27 Aug 2024 11:14:18 -0600 Subject: [PATCH 10/12] fix: typo Co-authored-by: Gabriel Konar-Steenberg <23368820+GabrielKS@users.noreply.github.com> --- test/test_power_system_table_data.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_power_system_table_data.jl b/test/test_power_system_table_data.jl index dfda723e97..04b3fac1ff 100644 --- a/test/test_power_system_table_data.jl +++ b/test/test_power_system_table_data.jl @@ -185,7 +185,7 @@ end @testset "Test create_poly_cost function" begin cost_colnames = ["heat_rate_a0", "heat_rate_a1", "heat_rate_a2"] - # Coefficients for a CC using natura gas + # Coefficients for a CC using natural gas a2 = -0.000531607 a1 = 0.060554675 a0 = 8.951100118 From a8fc0696a52cf9e91e241f95a963eeb268943c8e Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Wed, 28 Aug 2024 09:07:02 -0700 Subject: [PATCH 11/12] export ST8C --- src/PowerSystems.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PowerSystems.jl b/src/PowerSystems.jl index 79097c2c34..8c8e5d5dd8 100644 --- a/src/PowerSystems.jl +++ b/src/PowerSystems.jl @@ -142,6 +142,7 @@ export ESST4B export ST6B export SCRX export SEXS +export ST8C #Machine Exports export Machine From 8cc13d1b3c4ab32e4cd8ff621e6b2cbffabdafbe Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 28 Aug 2024 17:41:05 -0600 Subject: [PATCH 12/12] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 14562fbe27..c351173837 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PowerSystems" uuid = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd" authors = ["Jose Daniel Lara", "Daniel Thom", "Clayton Barrows", "Sourabh Dalvi", "Dheepak Krishnamurthy"] -version = "4.3.0" +version = "4.3.1" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"