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

Variable hydro documentation #1343

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open

Conversation

akeeste
Copy link
Contributor

@akeeste akeeste commented Oct 16, 2024

This PR adds documentation on the variable hydro advanced feature:

  • user advanced feature section
  • developer advanced feature section
  • explain flags (hydroForceIndexInitial, option, etc)
  • compatibility between variable hydro and other features (GBM, SS, FIR filter, user defined excitation force)

@akeeste akeeste added the Documentation related to docs label Oct 16, 2024
@akeeste akeeste linked an issue Oct 23, 2024 that may be closed by this pull request
1 task
@akeeste akeeste marked this pull request as ready for review October 23, 2024 20:29
@akeeste
Copy link
Contributor Author

akeeste commented Oct 23, 2024

This is now ready for an initial review. As I was the one who created the feature, I don't have a good sense of what users will need detailed documentation on. I could use a review and suggestions about additional content to cover.

@kmruehl kmruehl self-assigned this Oct 23, 2024
@kmruehl kmruehl self-requested a review October 23, 2024 20:31
Copy link
Contributor

@kmruehl kmruehl left a comment

Choose a reason for hiding this comment

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

@akeeste I reviewed this content, and I have several recommendations. I'll put my commends in the review, and then we can discuss how to rework the documentation. I'm happy to help rewrite the text.

a specific scenario, state, signal, or discretization required. It is the
user's responsibility to implement a specific variable hydrodynamics case
using best practices and validate the results with higher fidelity data.

Copy link
Contributor

Choose a reason for hiding this comment

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

This section is that first one that users will read. I recommend simplifying it to clearly describe what/how variable hydro works, and then provide an example. Here's my initial attempt:

Variable hydrodynamics allows WEC-Sim bodies to simulate bodies with hydrodynamic data from multiple BEM runs for a single body. Hydrodynamic data from each BEM run is parsed into H5 files, which are then initialized in the instance of the body class, for example body(1) = bodyClass({'H5FILE_1.h5','H5FILE_2.h5',...);. This feature allows users to simulate bodies with different initial conditions, for example body that is floating or submerged. Users then specify the condition to switch when each H5 is used. The condition must be based on a WEC-Sim state...

Copy link
Contributor

Choose a reason for hiding this comment

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

@akeeste I used ChatGPT to refine the overview and here's the suggestion:

Overview

Variable Hydrodynamics enables WEC-Sim bodies to utilize hydrodynamic data from multiple BEM runs within a single body instance. Each BEM run's data is stored in H5 files, which are initialized in the body class, for example:

body(1) = bodyClass({'H5FILE_1.h5', 'H5FILE_2.h5', ...});

This feature allows users to simulate different initial conditions, such as floating or submerged states. Users specify the conditions that trigger the use of each H5 file, based on a WEC-Sim state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this text could be more concise, I'll revise this text.

The ChatGPT response is certainly concise, bit its inaccurate when for some of the details (H5 files aren't being initialized, the feature is not about initial conditions)

multiple hydrodynamic datasets at various pitch angles (-50:10:50). It is most convenient
to treat these angles in numerical order in BEM simulations, indexing logic, and other
data processing. In this case the initial position is at a pitch angle of 0 so ``body.variableHydro.hydroForceIndexInitial=6;``.

Copy link
Contributor

Choose a reason for hiding this comment

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

This level of detail seems more appropriate for the developer documentation. I recommend simplifying the user docs to only what the user needs to know to implement the feature, which is that they need to specify which index to start with. I don't even know how critical it is for a user to understand the bus signals.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is the ChatGPT recommendation for Implementation

Implementation

To implement Variable Hydrodynamics, follow these steps:

  1. Initialize the Body: Create a body instance with a cell array of H5 files containing the hydrodynamic data. For example:

    body(1) = bodyClass({'H5FILE_1.h5', 'H5FILE_2.h5', 'H5FILE_3.h5', ...});

  2. Enable Variable Hydrodynamics: Set the variableHydro.option flag to enable the feature:

    body(1).variableHydro.option = 1;

  3. Set Initial Hydrodynamic Coefficient Index: Use the hydroForceIndexInitial flag to define the default index for hydrodynamic coefficients, typically representing the body’s starting condition:

    body(1).variableHydro.hydroForceIndexInitial = <initial_index>;

  4. Simulink Integration: Load the hydrodynamic force data into Simulink using a custom bus. Create a GoTo block named body1_hydroForceIndex (or similar) to allow the body block to read the index signal for selecting the appropriate hydrodynamic coefficients.

  5. User-Defined Logic: Implement your own logic in Simulink to determine when to switch between H5 files based on the specified conditions.

Note: Variable hydrodynamics can be applied to individual bodies in a simulation, and it is not necessary for all bodies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the suggested numbering of steps for a user's implementation. I combined this with the detailed paragraphs to walk a user through set-up.

docs/_include/variable_hydro.rst Outdated Show resolved Hide resolved
* Validate using high fidelity data
* The hydroData directory may become very large
* All BEM data is contained within the ``body`` variable. Pre-processing remains very fast, so it's not recommended to save ``body`` to an output file or the file size may increase drastically.
* Conditions that require a varying mass, center of gravity, or center of buoyancy are not yet implemented.
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment, I this this is better suited as a note that this feature should be used with extreme caution. I also recommend moving a lot of these recommendations to the README in the variable hydro application case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change this to a note or paragraph, but I don't think the notes will be read if moved to the Application readme. Those documents tend to contain very basic information about a specific case, whereas these tips will be applicable to any simulation with variable hydrodynamics

Copy link
Contributor

@kmruehl kmruehl left a comment

Choose a reason for hiding this comment

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

I recommend using ChatGPT to improve our documentation. I fed it your text, my text, and then asked it to make docs clearer and more concise. I think it did a pretty good job.

a specific scenario, state, signal, or discretization required. It is the
user's responsibility to implement a specific variable hydrodynamics case
using best practices and validate the results with higher fidelity data.

Copy link
Contributor

Choose a reason for hiding this comment

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

@akeeste I used ChatGPT to refine the overview and here's the suggestion:

Overview

Variable Hydrodynamics enables WEC-Sim bodies to utilize hydrodynamic data from multiple BEM runs within a single body instance. Each BEM run's data is stored in H5 files, which are initialized in the body class, for example:

body(1) = bodyClass({'H5FILE_1.h5', 'H5FILE_2.h5', ...});

This feature allows users to simulate different initial conditions, such as floating or submerged states. Users specify the conditions that trigger the use of each H5 file, based on a WEC-Sim state.

multiple hydrodynamic datasets at various pitch angles (-50:10:50). It is most convenient
to treat these angles in numerical order in BEM simulations, indexing logic, and other
data processing. In this case the initial position is at a pitch angle of 0 so ``body.variableHydro.hydroForceIndexInitial=6;``.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is the ChatGPT recommendation for Implementation

Implementation

To implement Variable Hydrodynamics, follow these steps:

  1. Initialize the Body: Create a body instance with a cell array of H5 files containing the hydrodynamic data. For example:

    body(1) = bodyClass({'H5FILE_1.h5', 'H5FILE_2.h5', 'H5FILE_3.h5', ...});

  2. Enable Variable Hydrodynamics: Set the variableHydro.option flag to enable the feature:

    body(1).variableHydro.option = 1;

  3. Set Initial Hydrodynamic Coefficient Index: Use the hydroForceIndexInitial flag to define the default index for hydrodynamic coefficients, typically representing the body’s starting condition:

    body(1).variableHydro.hydroForceIndexInitial = <initial_index>;

  4. Simulink Integration: Load the hydrodynamic force data into Simulink using a custom bus. Create a GoTo block named body1_hydroForceIndex (or similar) to allow the body block to read the index signal for selecting the appropriate hydrodynamic coefficients.

  5. User-Defined Logic: Implement your own logic in Simulink to determine when to switch between H5 files based on the specified conditions.

Note: Variable hydrodynamics can be applied to individual bodies in a simulation, and it is not necessary for all bodies.

@akeeste
Copy link
Contributor Author

akeeste commented Nov 6, 2024

@kmruehl I made some revisions to the documentation based on your suggest. See above comments. Given the challenges of using this feature, I think it is worth leaving more detail and explanation for users than less. Let me know if you think there is any topic missing.

@kmruehl
Copy link
Contributor

kmruehl commented Nov 27, 2024

@akeeste thanks, I'll review it again. Also, do you know why the documentation build isn't passing?

@akeeste
Copy link
Contributor Author

akeeste commented Dec 2, 2024

@akeeste thanks, I'll review it again. Also, do you know why the documentation build isn't passing?

Some issue with one of the images I pushed, but otherwise the test's error message is unclear. My build works locally. I'll test again with the most up to date conda environment

@akeeste
Copy link
Contributor Author

akeeste commented Dec 2, 2024

@kmruehl The issue is fixed. Linux filenames are case sensitive but windows filenames are not so the build passed locally and failed on Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation related to docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Developer Issue] Add Variable Hydrodynamics Documentation
2 participants