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

Make set_operation method public #869

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

misi9170
Copy link
Collaborator

@misi9170 misi9170 commented Apr 5, 2024

As mentioned in #865, there are some cases where users may want to set only the control setpoints. Currently, the method for doing this, FlorisModel._set_operation(), is private. This PR makes that method public so that it may be used.

We intend that only power users will use this functionality---most will simply use the set method to alter the control setpoints.

In making this change I found that there was no check that the yaw_angles or power_setpoints second dimension matched the number of turbines, and in fact it was possible to set and run yaw_angles with more than the number of turbines. This is now checked for.

I spoke to @rafmudaf about a possible issue created by the following workflow:

fmodel.set_operation(yaw_angles=some_yaw_angles)
fmodel.run()
fmodel.set_operation(yaw_angles=some_other_yaw_angles)
powers = fmodel.get_turbine_powers()

This would be bad, because the power would have the wake caused by some_yaw_angles but the power behavior caused by some_other_yaw_angles.

To make sure this does not happen, I have set the core's state back to UNINITIALIZED if set_operation() is called. This then throws a RuntimeError if get_turbine_powers() is called before calling run() again. I test for this in the tests.

@misi9170 misi9170 added enhancement An improvement of an existing feature v4 Focus of FLORIS v4 labels Apr 5, 2024
@misi9170 misi9170 requested a review from paulf81 April 5, 2024 03:19
@misi9170 misi9170 changed the base branch from main to v4 April 5, 2024 03:21
Copy link
Collaborator

@paulf81 paulf81 left a comment

Choose a reason for hiding this comment

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

This looks solid @misi9170 thanks!

@rafmudaf
Copy link
Collaborator

rafmudaf commented Apr 5, 2024

Nicely done. Just a heads up that the State attributes might not be rigorously used or checked. It looks like it works great in this case, but it might not generally work in the future. Or it might, I'm just not entirely confident about it.

@misi9170
Copy link
Collaborator Author

misi9170 commented Apr 5, 2024

I'm going to wait to merge until I get response on #865---that should be fine though, this doesn't really affect any other open PRs.

@misi9170 misi9170 merged commit f1e5324 into NREL:v4 Apr 5, 2024
8 checks passed
@misi9170 misi9170 deleted the v4-ms/set_operation-public branch April 5, 2024 18:01
@misi9170
Copy link
Collaborator Author

misi9170 commented Apr 5, 2024

Thanks @achenry for calling this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature v4 Focus of FLORIS v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants