Minor numerical improvements#2975
Merged
andrew-platt merged 11 commits intoOpenFAST:devfrom Sep 2, 2025
Merged
Conversation
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
replaces "+ -" with "-".
Contributor
There was a problem hiding this comment.
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
AddOrSub2Pito 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.
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
approved these changes
Sep 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature or improvement description
This PR makes a few minor improvements to the code:
_Endroutines only one time, regardless of error status.A + -Bis replaced withA - B).LogMapin a ModMesh packing routine is replaced withEulerExtractfor consistency.UnEcvalue inParseVarroutines is now checked if it's present before being used.AddOrSub2Pihas been modified to avoid a potential infinite loop when comparing two very large angles.kernelSmoothinghas new logic to avoid potential division by zeroRunTimes&SimStatushave been modified to be used in AeroMap casesCubicSplineInterpMis now a function instead of a subroutine to avoid extra array allocations every time it's calledRelated 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.