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

FAST Library: add access to hub position and velocity #1057

Merged
merged 7 commits into from
Jun 6, 2022

Conversation

rafmudaf
Copy link
Collaborator

Feature or improvement description
Adds a subroutine to access the hub position, velocity, and orientation DCM through the FAST Library for use in AMR Wind.
cc @psakievich @ndevelder @andrew-platt

Related issue, if one exists
None

Impacted areas of the software
Added a subroutine to FAST Library

Copy link
Contributor

@psakievich psakievich left a comment

Choose a reason for hiding this comment

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

This looks great. It should work just fine for the AMR-Wind API. I'll defer to @ndevelder to confirm if the variables are sufficient for their calculations.

@rafmudaf rafmudaf added this to the v3.2.0 milestone Apr 7, 2022
@rafmudaf rafmudaf marked this pull request as ready for review April 7, 2022 17:02
@rafmudaf
Copy link
Collaborator Author

@ndevelder just checking in again before I merge this - everything good here for your use in AMR Wind?

@ndevelder
Copy link
Contributor

Hi @rafmudaf! We're finally getting around to implementing this. One thing we found was a spelling inconsistency in "HubPosition" in the .h file. I'll try to keep updating here as we test.

@rafmudaf
Copy link
Collaborator Author

Thanks for pointing this out @ndevelder, I've fixed it

@rafmudaf rafmudaf force-pushed the feature/fastlib_hub_kinematics branch from bcbb7f1 to 9a2d685 Compare May 31, 2022 22:33
@rafmudaf rafmudaf force-pushed the feature/fastlib_hub_kinematics branch from 049d4d2 to e2ccd27 Compare June 1, 2022 21:25
@rafmudaf
Copy link
Collaborator Author

rafmudaf commented Jun 1, 2022

I've added a unit test for this in the last commit as well as a method to get the hub position through the Python interface. However, the test is currently running in the automated system because it litters the repository with extra files. For GH Actions, this is not a problem, but during day to day development and running tests it will get cumbersome.

It is located in openfast/modules/openfast-library/tests/test_openfast_library.py and you can run it with this command:

python test_openfast_library.py ../../../reg_tests/r-test/glue-codes/openfast/5MW_OC4Jckt_ExtPtfm/5MW_OC4Jckt_ExtPtfm.fst

It simply initializes the NREL 5MW turbine model and compares the position, rotational velocity and orientation from the initial conditions.

def test_hub_position(library_path, input_file):
    openfastlib = openfast_library.FastLibAPI(library_path, input_file)
    openfastlib.fast_init()
    absolute_position, rotational_velocity, orientation_dcm = openfastlib.get_hub_position()

    # Initial hub position is at -5, 0, 90.55
    np.testing.assert_allclose(
        absolute_position,
        np.array([-5.0, 0.0, 90.55]),
        rtol=1e-5,
        atol=1e-8,
        verbose=True
    )

    # This case is initially still
    # Velocities should be 0 and the DCM should be identity
    np.testing.assert_array_equal( rotational_velocity, np.zeros(3) )
    np.testing.assert_array_equal( np.reshape( orientation_dcm[:], (3,3) ), np.eye(3) )

@rafmudaf
Copy link
Collaborator Author

rafmudaf commented Jun 1, 2022

And lastly, I've added the same to the C++-based FastLibAPI. This is not the one used to integrate with external CFD codes. It is a close copy of the Python interface, and it is mostly for testing the FAST_Library header file.

@rafmudaf rafmudaf requested a review from andrew-platt June 1, 2022 21:47
@rafmudaf rafmudaf merged commit d9ef96a into OpenFAST:dev Jun 6, 2022
@rafmudaf rafmudaf deleted the feature/fastlib_hub_kinematics branch June 22, 2022 19:31
@rafmudaf rafmudaf mentioned this pull request Jul 8, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants