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

Serial Refine doesn't work with new heterogenous definition #673

Closed
paulf81 opened this issue Jun 22, 2023 · 1 comment
Closed

Serial Refine doesn't work with new heterogenous definition #673

paulf81 opened this issue Jun 22, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@paulf81
Copy link
Collaborator

paulf81 commented Jun 22, 2023

@misi9170 noticed an issue that following the update to het definitions serial refine optimization is not working when passed an FI object conditioned for heterogenous conditions.

I created this code snippet to show the issue:

from floris.tools import FlorisInterface
from floris.tools.optimization.yaw_optimization.yaw_optimizer_sr import YawOptimizationSR


speed_ups = [[2.0, 1.0, 2.0, 1.0]]
x_locs = [-300.0, -300.0, 2600.0, 2600.0]
y_locs = [ -300.0, 300.0, -300.0, 300.0]

fi = FlorisInterface("inputs/gch_heterogeneous_inflow.yaml")

speed_multipliers = [[2.0, 1.0, 2.0, 1.0], [2.0, 1.0, 2.0, 1.0]] # Expand to two wind directions
heterogenous_inflow_config = {
    'speed_multipliers': speed_multipliers,
    'x': x_locs,
    'y': y_locs,
}
fi.reinitialize(
    wind_directions=[270.0, 275.0],
    wind_speeds=[8.0],
    heterogenous_inflow_config=heterogenous_inflow_config
)
fi.calculate_wake()


yaw_opt = YawOptimizationSR(
    fi=fi,
    minimum_yaw_angle=0.0,  # Allowable yaw angles lower bound
    maximum_yaw_angle=20.0,  # Allowable yaw angles upper bound
    Ny_passes=[5, 4],
    exclude_downstream_turbines=True,
    exploit_layout_symmetry=True,
)

df_opt = yaw_opt.optimize()

Which yields:

(floris) pfleming-37929s:examples pfleming$ python test_het_opt.py 
Floris wind direction array does not intersect 0.0 and 180.0.
Exploitation of symmetry has been disabled.
[Serial Refine] Processing pass=0, turbine_depth=0 (0.0%)
Traceback (most recent call last):
  File "/Users/pfleming/Projects/FLORIS/floris/examples/test_het_opt.py", line 34, in <module>
    df_opt = yaw_opt.optimize()
  File "/Users/pfleming/Projects/FLORIS/floris/floris/tools/optimization/yaw_optimization/yaw_optimizer_sr.py", line 250, in optimize
    farm_powers = self._process_evaluation_grid()
  File "/Users/pfleming/Projects/FLORIS/floris/floris/tools/optimization/yaw_optimization/yaw_optimizer_sr.py", line 220, in _process_evaluation_grid
    farm_powers = self._calc_powers_with_memory(evaluation_grid)
  File "/Users/pfleming/Projects/FLORIS/floris/floris/tools/optimization/yaw_optimization/yaw_optimizer_sr.py", line 144, in _calc_powers_with_memory
    farm_powers[~idx, :] = self._calculate_farm_power(
  File "/Users/pfleming/Projects/FLORIS/floris/floris/tools/optimization/yaw_optimization/yaw_optimization_base.py", line 370, in _calculate_farm_power
    fi_subset.reinitialize(wind_directions=wd_array)
  File "/Users/pfleming/Projects/FLORIS/floris/floris/tools/floris_interface.py", line 250, in reinitialize
    self.floris = Floris.from_dict(floris_dict)
  File "/Users/pfleming/Projects/FLORIS/floris/floris/type_dec.py", line 160, in from_dict
    return cls(**kwargs)
  File "<attrs generated init floris.simulation.floris.Floris>", line 6, in __init__
  File "/Users/pfleming/Projects/FLORIS/floris/floris/type_dec.py", line 160, in from_dict
    return cls(**kwargs)
  File "<attrs generated init floris.simulation.flow_field.FlowField>", line 30, in __init__
  File "/Users/pfleming/Projects/FLORIS/floris/floris/simulation/flow_field.py", line 114, in __attrs_post_init__
    self.generate_heterogeneous_wind_map()
  File "/Users/pfleming/Projects/FLORIS/floris/floris/simulation/flow_field.py", line 300, in generate_heterogeneous_wind_map
    self.het_map = in_region
  File "/Users/pfleming/opt/anaconda3/envs/floris/lib/python3.10/site-packages/attr/_make.py", line 1055, in __setattr__
    nval = hook(self, a, val)
  File "/Users/pfleming/opt/anaconda3/envs/floris/lib/python3.10/site-packages/attr/setters.py", line 23, in wrapped_pipe
    rv = setter(instance, attrib, rv)
  File "/Users/pfleming/opt/anaconda3/envs/floris/lib/python3.10/site-packages/attr/setters.py", line 52, in validate
    v(instance, attrib, new_value)
  File "/Users/pfleming/Projects/FLORIS/floris/floris/simulation/flow_field.py", line 107, in het_map_validator
    raise ValueError(
ValueError: The het_map's wind direction dimension not equal to number of wind directions.
(floris) pfleming-37929s:examples pfleming$ 

I think @misi9170 has a solution in mind but wanted to flag the issue here, also flagging @bayc and @rafmudaf if they have a preferred solution

@misi9170
Copy link
Collaborator

misi9170 commented Jul 6, 2023

PR #678 addresses this issue.

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
Status: Done
Development

No branches or pull requests

4 participants