NREL / floris

A controls-oriented engineering wake model.
http://nrel.github.io/floris
BSD 3-Clause "New" or "Revised" License
217 stars 156 forks source link

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

Closed misi9170 closed 1 month ago

misi9170 commented 1 month ago

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.