Feature/Improve the speed and accuracy of finding the ideal time step size#97
Draft
Feature/Improve the speed and accuracy of finding the ideal time step size#97
Conversation
…cycle mean and RMS loads and coefficients Assuming that the LCM period is an integer multiple of the time step, sample-based and trapezoid-rule-based means are identical. However, this fix improves robustness if the the LCM period isn't an integer multiple of the time step.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #97 +/- ##
==========================================
- Coverage 91.32% 91.16% -0.16%
==========================================
Files 32 32
Lines 5818 5968 +150
==========================================
+ Hits 5313 5441 +128
- Misses 505 527 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Introduce an analytical delta_time estimator and refactor LCM helpers; add min_period caching and update optimization flow. - Add module-level _lcm and _lcm_multiple functions and import numpy and problems. - Implement _analytically_optimize_delta_time: fast analytical estimation of delta_time by measuring wake displacement across a temporary Movement/UnsteadyProblem; includes heuristics and warnings for low temporal resolution. - Change Movement.delta_time handling: default (None) now runs the analytical estimator; delta_time="optimize" runs the analytical estimator first then calls the iterative _optimize_delta_time using the analytical result as the initial guess. Track this with _should_iteratively_optimize_delta_time. - Add Movement.min_period property with caching (_min_period) returning the shortest non-zero motion period. - Adjust iterative optimizer search bounds from sqrt(10) factor to +/- factor of 2. - Update and expand unit tests to cover min_period, analytical optimizer behavior, LCM functions, and adjust mocks/expectations accordingly.
Refactor _optimize_delta_time to detect static vs non-static movements and delegate to two helpers: _optimize_delta_time_static (uses scipy.optimize.minimize_scalar with early cutoff) and _optimize_delta_time_non_static (brute-force search over integer num_steps_per_lcm_cycle so delta_time cleanly divides the LCM period). Adds logging and warnings when the best integer step count sits on search bounds. Updates unit test to use a larger initial_delta_time for the non-static case and to assert the new integer-step-based bounds instead of the previous [initial/2, initial*2] continuous bounds.
Expand unit test coverage for the movements module: add tests for optimizing delta_time (static and non-static), analytic optimization edge cases, LCM handling, and wake-area mismatch. New test classes validate dispatching behavior, warnings at optimization bounds (mocking optimizer/mismatch), temporal resolution warnings, and properties when OperatingPointMovement has a period. Also add tests for Movement-generated attributes (airplanes/operating_points) and many deepcopy/independence checks. Minor docstring wording tweaks and small fixture whitespace fixes.
Add two new command documents to manage test fixtures and redundancy (check-unit-tests-redundancy.md, delete-unused-fixtures.md). Refine existing test workflow docs (debug-unit-tests-and-fixtures.md, make-unit-tests-and-fixtures.md): standardize `$ARGUMENTS` formatting, clarify descriptions and steps, include guidance to run black after modifying files, improve examples and checklists, and remove minor formatting/emoji artifacts. These changes improve guidance for creating, debugging, and cleaning up unit tests and fixtures.
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.
Description
When using
Movement'sdelta_time="optimize"flag, Ptera Software has previously attempted to find the optimal time step size that minimizes the difference in areas between the trailing-edge boundRingVorticesand the wakeRingVorticesthey shed. This works well for small Strouhal-number-experiments. However, I've noticed serious issues in finding an appropriate time step for simulations with high Strouhal numbers.Motivation
Finding a good time step value is critical to running unsteady simulations and assessing the convergence of their simulation parameters.
Relevant Issues
None.
Changes
min_periodproperty toMovement(along with caching and unit tests)Movement's private LCM methods to private functions_analytically_optimize_delta_time: fast analytical estimation of idealdelta_timeby measuring wake displacement across a temporaryMovement/UnsteadyProblem, including heuristics and warnings for low temporal resolution.Movement.delta_timehandling: default (None) now runs the analytical estimator;delta_time="optimize"runs the analytical estimator first then calls the iterative_optimize_delta_timeusing the analytical result as the initial guess._optimize_delta_timenow detects static vs non-staticMovementsand delegates to two helpers:_optimize_delta_time_static(usesscipy.optimize.minimize_scalarwith early cutoff) and_optimize_delta_time_non_static(brute-force search over integernum_steps_per_lcm_cyclesodelta_timecleanly divides the LCM period).New Dependencies
None.
Change Magnitude
Moderate: Medium-sized change that adds or modifies a feature without large-scale impact.
Checklist
mainand is up to date with the upstreammainbranch.--in-place --black). See the style guide for type hints and docstrings for more details.pterasoftwarepackage use type hints. See the style guide for type hints and docstrings for more details.testspackage.testspackage.codespell,black,mypy, andtests).