Skip to content

Conversation

@bjonkman
Copy link
Contributor

Feature or improvement description
This PR makes a few minor improvements to the code:

  • MoorDyn driver now calls MD and SeaSt _End routines only one time, regardless of error status.
  • Morison has removed the double operator extension to standard (A + -B is replaced with A - B).
  • The call to LogMap in a ModMesh packing routine is replaced with EulerExtract for consistency.
  • The optional UnEc value in ParseVar routines is now checked if it's present before being used.
  • AddOrSub2Pi has been modified to avoid a potential infinite loop when comparing two very large angles.
  • kernelSmoothing has new logic to avoid potential division by zero
  • RunTimes & SimStatus have been modified to be used in AeroMap cases
  • CubicSplineInterpM is now a function instead of a subroutine to avoid extra array allocations every time it's called

Related issue, if one exists
None

Impacted areas of the software
HydroDyn, MoorDyn, SeaState, NWTC Library, AirfoilInfo

Additional supporting information

Test results, if applicable
This doesn't change any test results. It primarily affects rare modeling situations.

Previously it could have called SeaSt_End multiple times, written non-fatal errors multiple times, or not called MD_End at all, depending on where an error occurred in the code.
ParseVarWDefault routines were using an optional argument as if it were not optional
we got rid of LogMap earlier, but apparently missed on use case
- avoid potential infinite loop in `AddOrSub2Pi` when comparing two large angles
- ensure radius > 0 to avoid division by zero in `kernelSmoothing`
- modify `RunTimes` so it makes sense for AeroMap cases
- call`SimStatus_FirstTime` in AeroMap cases
- use `R8Ki` instead of `DbKi` in some routines
- change `CubicSplineInterpM` to a function to avoid extra allocations every time it's called
@bjonkman bjonkman changed the title B/md updates Minor numerical improvements Aug 25, 2025
@andrew-platt andrew-platt added this to the v4.2.0 milestone Sep 2, 2025
@andrew-platt andrew-platt self-requested a review September 2, 2025 17:34
@andrew-platt andrew-platt self-assigned this Sep 2, 2025
@andrew-platt andrew-platt requested a review from Copilot September 2, 2025 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements several minor numerical improvements across multiple modules to enhance code robustness and consistency. The changes focus on preventing edge cases and potential errors in numerical computations.

Key changes include:

  • Enhanced angle normalization logic in AddOrSub2Pi to prevent infinite loops with very large angles
  • Improved division-by-zero protection in kernel smoothing functions
  • Streamlined cubic spline interpolation by converting from function to subroutine to avoid repeated array allocations

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
modules/seastate/src/SeaState_Output.f90 Updates file unit check condition for consistency
modules/openfast-library/src/FAST_Subs.f90 Adds useCases parameter to RunTimes call for AeroMap support
modules/openfast-library/src/FAST_SS_Subs.f90 Adds SimStatus_FirstTime call with useCases parameter for AeroMap support
modules/nwtc-library/src/VTK.f90 Fixes error status parameter assignment order
modules/nwtc-library/src/NWTC_Num.f90 Major improvements to angle normalization, kernel smoothing, and cubic spline functions
modules/nwtc-library/src/NWTC_IO.f90 Adds proper optional parameter handling in ParseVar routines
modules/nwtc-library/src/ModMesh.f90 Replaces DCM_logMap with EulerExtract for consistency
modules/moordyn/src/MoorDyn_Misc.f90 Cleans up unused variables and improves code organization
modules/moordyn/src/MoorDyn_Driver.f90 Restructures cleanup logic and ensures proper end routine calls
modules/hydrodyn/src/Morison.f90 Simplifies double operator expression
modules/aerodyn/src/AirfoilInfo.f90 Updates to use subroutine version of cubic spline interpolation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bjonkman and others added 3 commits September 2, 2025 11:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@andrew-platt andrew-platt merged commit c847dbc into OpenFAST:dev Sep 2, 2025
12 checks passed
@bjonkman bjonkman deleted the b/MD_updates branch September 3, 2025 02:32
@andrew-platt andrew-platt mentioned this pull request Jan 23, 2026
36 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.

2 participants