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

[BUGFIX] Control setpoints and wind data set on FlorisModel copied into ParFlorisModel #997

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

misi9170
Copy link
Collaborator

@misi9170 misi9170 commented Oct 9, 2024

One way of instantiating a ParFlorisModel is to pass in an instantiated FlorisModel. However, as is, if there are any control setpoints (yaw_angles, ...) that had already been set on the instantiated FlorisModel, they were dropped on instantiation of the ParFlorisModel. Similarly, wind_data was not copied over correctly.

A workaround is to only set() control setpoints and wind data after instantiating the ParFlorisModel; however, this is not immediately obvious to the user. Instead, this PR fixes the bug. In particular, the following code

import numpy as np

from floris import FlorisModel, ParFlorisModel, TimeSeries

fmodel = FlorisModel("inputs/gch.yaml")
fmodel.set(
    layout_x=[0., 0., 0.],
    layout_y=[0., 500., 1000.],
    wind_data=TimeSeries(
        wind_directions=np.array([270.0]),
        wind_speeds=np.array([8.0]),
        turbulence_intensities=np.array([0.06])
    )
)
fmodel.set(yaw_angles=np.array([[20.0, 10.0, 0.0]]))

pfmodel = ParFlorisModel(fmodel)
print(pfmodel.core.farm.yaw_angles)
print(pfmodel.wind_data)

produces [[0. 0. 0.]] and None prior to the bugfix; while producing [[20. 10. 0.]] and <floris.wind_data.TimeSeries object at 0x12f93e9f0>, as expected, with the fix.

@misi9170 misi9170 requested a review from paulf81 October 9, 2024 22:00
@misi9170 misi9170 added the bug Something isn't working label Oct 9, 2024
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.

These changes work for me, thank you @misi9170

@misi9170 misi9170 merged commit 1240344 into NREL:develop Oct 10, 2024
8 checks passed
@misi9170 misi9170 deleted the bugfix/pfm-controls branch October 10, 2024 19:09
@misi9170 misi9170 mentioned this pull request Oct 17, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants