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

Reduce computation time massively in large het_map objects #1024

Merged
merged 16 commits into from
Feb 11, 2025
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions floris/core/flow_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

from __future__ import annotations

import copy

import attrs
import matplotlib.path as mpltPath
import numpy as np
Expand Down Expand Up @@ -290,18 +292,21 @@ def generate_heterogeneous_wind_map(self):
# Compute the 3-dimensional interpolants for each wind direction
# Linear interpolation is used for points within the user-defined area of values,
# while the freestream wind speed is used for points outside that region
in_region = [
self.interpolate_multiplier_xyz(x, y, z, multiplier, fill_value=1.0)
for multiplier in speed_multipliers
]
F = self.interpolate_multiplier_xyz(x, y, z, speed_multipliers[0], fill_value=1.0)
in_region = []
for multiplier in speed_multipliers:
F.values = multiplier[:, None]
in_region.append(copy.deepcopy(F))

else:
# Compute the 2-dimensional interpolants for each wind direction
# Linear interpolation is used for points within the user-defined area of values,
# while the freestream wind speed is used for points outside that region
in_region = [
self.interpolate_multiplier_xy(x, y, multiplier, fill_value=1.0)
for multiplier in speed_multipliers
]
self.interpolate_multiplier_xy(x, y, multiplier, fill_value=1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this need to be assigned to F as it is above @Bartdoekemeijer
?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason for this is that F.values is of shape (N, 1), rather than shape (N). If I don't maintain that shape, the code returns an error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think still if you don't assign to F in line 305 you can't reference it in line 308 (it doesn't exist). Similarly I think multiplier doesn't exist yet at line 305 so followed the example of the earlier case and used speed_multipliers[0]

in_region = []
for multiplier in speed_multipliers:
F.values = multiplier[:, None]
in_region.append(copy.deepcopy(F))

self.het_map = in_region

Expand Down
Loading