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

Add parallel solve for sample_flow_at_points #1059

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

misi9170
Copy link
Collaborator

@misi9170 misi9170 commented Feb 4, 2025

As identified by @Bartdoekemeijer in #1009 , the ParFlorisModel did not have a parallelized version of sample_flow_at_points(). Instead, this method was simply inherited from FlorisModel, so ran in serial. This works, but does not take advantage of parallelization.

This PR address the issue by adding a sample_flow_at_points() method to ParFlorisModel. This can be checked by using the script that @Bartdoekemeijer provided in #1009:

import numpy as np
from floris import ParFlorisModel

if __name__ == "__main__":
    # Load the parallel floris model and create a 200-turbine farm
    interface = None #"multiprocessing", "pathos", "concurrent"
    fmodel = ParFlorisModel("../inputs/gch.yaml", max_workers=8, print_timings=True, interface=interface)
    n_turbs = 200 # Or try something smaller 
    fmodel.set(
        layout_x=5 * 126.0 * np.arange(n_turbs),
        layout_y=np.zeros(n_turbs),
    )

    # Cover a large grid of findices
    wd_grid, ws_grid = np.meshgrid(
        np.arange(0.0, 360.0, 3.0),
        np.arange(1.0, 30.01, 1.0)
    )
    fmodel.set(
        wind_directions=wd_grid.flatten(),
        wind_speeds=ws_grid.flatten(),
        turbulence_intensities=0.06 * np.ones_like(ws_grid.flatten()),
    )

    # Sample wind speeds at a couple of points in the flow
    wind_speeds_at_points = fmodel.sample_flow_at_points(
        x=[500.0, 750.0, 1000.0, 1250.0, 1500.0],
        y=[  0.0,   0.0,    0.0,    0.0,    0.0],
        z=[ 90.0,  90.0,   90.0,   90.0,   90.0]
    )
    print(wind_speeds_at_points)

Additional supporting information

In adding the sample_flow_at_points() method, I realized the main run() method had a lot of unnecessarily repeated code, so I've cleaned that up a bit (and added a private method for printing timing output).

Test results, if applicable

  • Existing tests (for main run() functionality) pass
  • New test added for sample_flow_at_points method
  • No change to output of examples/009_parallel_models.py

@misi9170 misi9170 added the enhancement An improvement of an existing feature label Feb 4, 2025
@misi9170 misi9170 self-assigned this Feb 4, 2025
@misi9170 misi9170 marked this pull request as ready for review February 4, 2025 20:49
@misi9170 misi9170 requested a review from paulf81 February 4, 2025 20:52
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.

Hi @misi9170 I reviewed the code and it looks good to me. The new test is a good reassurance it's working properly on all tests passed on my end

@Bartdoekemeijer
Copy link
Collaborator

Awesome, thank you Misha!!

@misi9170 misi9170 merged commit e6bbd6e into NREL:develop Feb 5, 2025
11 checks passed
@misi9170 misi9170 deleted the ehmt/parallel-points branch February 5, 2025 16:06
@misi9170 misi9170 mentioned this pull request Mar 4, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants