Skip to content

Commit

Permalink
compact data validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Apr 30, 2024
1 parent 218ecc1 commit 6ede0db
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils/powersystems_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ end
function _validate_compact_pwl_data(
min::Float64,
max::Float64,
data::PSY.PiecewiseLinearPointData,
cost_data::PSY.PiecewiseStepData,
base_power::Float64,
)
data = PSY.get_points(data)
if isapprox(max - min, last(data).x / base_power) && iszero(first(data).x)
data = PSY.get_x_coords(cost_data)
if isapprox(max - min, last(data) / base_power) && iszero(first(data))
return COMPACT_PWL_STATUS.VALID
else
return COMPACT_PWL_STATUS.INVALID
Expand All @@ -142,17 +142,19 @@ end

function validate_compact_pwl_data(
d::PSY.ThermalGen,
data::PSY.PiecewiseLinearPointData,
cost_function::PSY.CostCurve{PSY.PiecewiseIncrementalCurve},
base_power::Float64,
)
value_curve = PSY.get_value_curve(cost_function)
data = PSY.get_function_data(value_curve)
min = PSY.get_active_power_limits(d).min
max = PSY.get_active_power_limits(d).max
return _validate_compact_pwl_data(min, max, data, base_power)
end

function validate_compact_pwl_data(
d::PSY.Component,
::PSY.PiecewiseLinearPointData,
::PSY.PiecewiseLinearData,
::Float64,
)
@warn "Validation of compact pwl data is not implemented for $(typeof(d))."
Expand Down

0 comments on commit 6ede0db

Please sign in to comment.