Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing tabular parser #1126

Merged
merged 8 commits into from
Jun 24, 2024
Merged

Conversation

claytonpbarrows
Copy link
Member

I've replicated the PSY3.0 objective function created by the tabular parsing of the RTS using the FuelCurve functionality. However, I haven't developed tests. In the interest of time, I'm opening this PR now.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

src/parsers/power_system_table_data.jl|584|
src/parsers/power_system_table_data.jl|613|
src/parsers/power_system_table_data.jl|724|
src/parsers/power_system_table_data.jl|810|
src/parsers/power_system_table_data.jl|827|
src/parsers/power_system_table_data.jl|841|
src/parsers/power_system_table_data.jl|851|
src/parsers/power_system_table_data.jl|860|
src/parsers/power_system_table_data.jl|862|
src/parsers/power_system_table_data.jl|871|
src/parsers/power_system_table_data.jl|873|
src/parsers/power_system_table_data.jl|891|
src/parsers/power_system_table_data.jl|901|
src/parsers/power_system_table_data.jl|916|
src/parsers/power_system_table_data.jl|957|
src/parsers/power_system_table_data.jl|961|
src/parsers/power_system_table_data.jl|968|
src/parsers/power_system_table_data.jl|982|
src/parsers/power_system_table_data.jl|998|
src/parsers/power_system_table_data.jl|1005|
src/parsers/power_system_table_data.jl|1015|
src/parsers/power_system_table_data.jl|1018|
src/parsers/power_system_table_data.jl|1026|
src/parsers/power_system_table_data.jl|1044|
src/parsers/power_system_table_data.jl|1093|
src/parsers/power_system_table_data.jl|1097|
src/parsers/power_system_table_data.jl|1110|
src/parsers/power_system_table_data.jl|1127|
src/parsers/power_system_table_data.jl|1160|
src/parsers/power_system_table_data.jl|1180|
src/parsers/power_system_table_data.jl|1189|
src/parsers/power_system_table_data.jl|1212|
src/parsers/power_system_table_data.jl|1217|
src/parsers/power_system_table_data.jl|1225|
src/parsers/power_system_table_data.jl|1231|
src/parsers/power_system_table_data.jl|1252|
src/parsers/power_system_table_data.jl|1258|
src/parsers/power_system_table_data.jl|1262|
src/parsers/power_system_table_data.jl|1269|
src/parsers/power_system_table_data.jl|1298|
src/parsers/power_system_table_data.jl|1307|
src/parsers/power_system_table_data.jl|1322|
src/parsers/power_system_table_data.jl|1342|
src/parsers/power_system_table_data.jl|1344|
src/parsers/power_system_table_data.jl|1348|
src/parsers/power_system_table_data.jl|1355|
src/parsers/power_system_table_data.jl|1358|
src/parsers/power_system_table_data.jl|1379|
src/parsers/power_system_table_data.jl|1400|
src/parsers/power_system_table_data.jl|1418|
src/parsers/power_system_table_data.jl|1420|
src/parsers/power_system_table_data.jl|1436|
src/parsers/power_system_table_data.jl|1474|
src/parsers/power_system_table_data.jl|1483|
src/parsers/power_system_table_data.jl|1490|
src/parsers/power_system_table_data.jl|1507|

src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
@jd-lara jd-lara changed the base branch from psy4 to kdrh/psy4_docs_renaming June 13, 2024 14:50
@jd-lara
Copy link
Member

jd-lara commented Jun 13, 2024

@claytonpbarrows I changed the target branch to the doc strings changes PR so that we can avoid name clashed and @rodrigomha can test PSB with all the changes in the same place

@jd-lara jd-lara added PARSING issues related to parsing come New Version 4.0 labels Jun 13, 2024
Copy link
Collaborator

@GabrielKS GabrielKS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general comment would be that I think the new cost structs can be taken further advantage of to reduce the amount of math that needs to happen here, representing the data in a form more similar to how it was given to us.

It'd be great to get some more robust testing for this — creating some simple input data, parsing them by hand, and comparing to what this code gives, rather than basing the testing on the correctness of the previous implementation. I'll let someone else decide whether we have time for that before the release, but if not it should at least get converted to an issue to be added in a minor version soon.

src/parsers/power_system_table_data.jl Show resolved Hide resolved

if !in(nothing, [x, y])
push!(vals,
(x = tryparse(Float64, string(x)) * base_power,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you multiplying by base_power rather than setting the units system of the cost/fuel curve to device base? If that would in fact represent the same data and this is being done just because because PowerSimulations needs it to be in natural units, maybe we should have some conversion code elsewhere to make this math more reusable? I'd be happy to implement that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of getting the major release done, I'm okay keeping it as-is for now (assuming the as-is math is correct), then changing the implementation later.

src/parsers/power_system_table_data.jl Show resolved Hide resolved
# if there is only one point, use it to determine the constant $/MW cost
var_cost = LinearFunctionData(var_cost[1][1] * fuel_cost + vom)
fixed = 0.0
var_cost = LinearCurve(cost_pairs[1].y)
Copy link
Collaborator

@GabrielKS GabrielKS Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches what we had before, but what we had before seemed a little suspicious to me. Are we sure it's just y, not y/x or something?

A PiecewisePointCurve is an InputOutputCurve, so x is ~MW and y is $/hr. A LinearCurve is also an InputOutputCurve, so same thing. But when you construct a LinearCurve with only one argument, you're specifying the slope of that curve, which should therefore be $/MWh. So this is implying that the units of y are different when there's only one point.

Unless there's a special case in the input data spec for only one point (units are truly different, x is always 1, etc.), I would think the options for parsing one point are:

  • We want to create a flat input-output curve (constant $ / hr, as opposed to constant $/MWh), which would be LinearCurve(0.0, LinearCurve(cost_pairs[1].y))
  • We want to create a linear input-output curve going through the origin and the single point we have, which would be LinearCurve(cost_pairs[1].y/cost_pairs[1].x)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding to my suspicion is the fact that we're doing the same thing below in create_pwinc_cost, where the y values are supposed to have different units

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-fuel option is more flexible since we don't really have data in that format. So, I agree with this point and made the suggested change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I understanding correctly that we get to make up the spec here since there's no existing data we're trying to match? The implementation as it now stands seems at least internally consistent, though I wonder why we decided that cost curves should be input-output curves and fuel curves should be incremental. Is there a rationale for that?

fixed = 0.0
var_cost = LinearCurve(cost_pairs[1].y)
else
@warn "Unable to calculate variable cost for $(gen.name)" cost_pairs maxlog = 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe specify that the reason for the failure is that there are zero points

src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Show resolved Hide resolved
cost_colnames::_CostPointColumns,
) where {T <: ThermalGen}
cost_pairs = get_cost_pairs(gen, cost_colnames)
var_cost = create_pwl_cost(cost_pairs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the case that when the input data is a fuel curve, it's given as incremental/marginal, whereas when the input data is a cost curve, it's given as input-output? That seems plausible, just making sure. If so, maybe put in a comment to that effect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. the cost-point data option is less defined and less exercised.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see above my question regarding why we decided to make cost curves input-output when fuel curves are incremental)

src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
src/parsers/power_system_table_data.jl Outdated Show resolved Hide resolved
@jd-lara jd-lara requested a review from GabrielKS June 24, 2024 18:02
claytonpbarrows and others added 2 commits June 24, 2024 12:21
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
first(y_points) * first(x_points),
x_points,
y_points[2:end],
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
)
)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jd-lara
Copy link
Member

jd-lara commented Jun 24, 2024

@claytonpbarrows we will merge this to enable a better parsing in psy4 but as discussed with @GabrielKS, there needs to be one more step of cleaning up to be done with the Plexos2Sienna effort.

@jd-lara jd-lara merged commit 51d1443 into kdrh/psy4_docs_renaming Jun 24, 2024
1 of 8 checks passed
@jd-lara jd-lara deleted the cb/psy4_tabular_parser branch July 1, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PARSING issues related to parsing come
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants