Skip to content

Adding free flight simulations#66

Draft
camUrban wants to merge 56 commits intomainfrom
feature/free_flight
Draft

Adding free flight simulations#66
camUrban wants to merge 56 commits intomainfrom
feature/free_flight

Conversation

@camUrban
Copy link
Owner

@camUrban camUrban commented Nov 24, 2025

Description

This PR adds the ability to perform simulations that couple an airplane's motion to the aerodynamic forces due to its motion.

Motivation

Adding coupled simulations increases the use-cases of Ptera Software beyond pure aerodynamic investigations and makes it more attractive for general robotics simulations.

Relevant Issues

Closes #65 and improves upon solution to #50.

Changes

  • Adds the CoupledOperatingPoint class to pterasoftware/operating_point.py
  • Adds the CoupledMovement class to pterasoftware/movements/movement.py
  • Adds the CoupledUnsteadyProblem class to pterasoftware/problems.py
  • Adds the CoupledSteadyProblem class to pterasoftware/problems.py
  • Adds pterasoftware/mujoco_model.py, which contains the MuJoCoModel class.
  • Adds pterasoftware/coupled_unsteady_ring_vortex_lattice_method.py, which contains the CoupledUnsteadyRingVortexLatticeMethodSolver class.
  • Updates pterasoftware/__init__.py to import the new modules.
  • Fixes inconsistency in UnsteadyRingVortexLatticeMethodSolver's _calculate_loads method where it was using different functions for calculating the cross product for each LineVortex leg.
  • Removes redundant increment of index variable in pterasoftware.output.animate.
  • Adds checks to prevent plotting non-existent wake RingVortex pterasoftware.output.animate and pterasoftware.output.draw.
  • Changes output formatting in output.print_results to display values in scientific notation for better readability across scales.
  • Introduces the rotationPointOffset_Gs_Ler parameter to WingMovement, allowing specification of a custom rotation point for wing angular motion.
  • Improves delta_time's "optimize" mode by tuning the local optimizer and introducing a fall back to dual annealing as a global optimizer.
  • Fixes a bug in delta_time's "optimize" mode where static cases weren't improved.
  • Speeds up test suite by removing redundant tests and using coarser mesh parameters for geometry fixtures.
  • Refactors CLAUDE.md to be significantly shorter by breaking up instructions and guidelines into other files in docs/. This uses the progressive disclosure strategy known to produce better results.
  • Adds MUJOCO_CONVENTIONS.md file with verified interpretations of MuJoCo's relevant inputs and outputs.
  • Adds animate_free_flight function in output.py, along with a few helper functions.

Temporary Debug Scripts to Remove Before Merging

  • debugging_scripts and all files within
  • docs/FREE_FLIGHT_DEVELOPMENT.md
  • gammabot_simulations and all files within

New Dependencies

  • MuJoCo

Change Magnitude

Moderate: Medium-sized change that adds or modifies a feature without large-scale impact.


Checklist

  • I have created or claimed an issue for this work as described in Contributing Code.
  • My branch is based on main and is up to date with the upstream main branch.
  • All calculations use S.I. units.
  • Code is formatted with black (line length = 88).
  • Code is well documented with block comments where appropriate.
  • Any external code, algorithms, or equations used have been cited in comments or docstrings.
  • All new modules, classes, functions, and methods have docstrings in reStructuredText format, and are formatted using docformatter (--in-place --black). See the style guide for type hints and docstrings for more details.
  • All new classes, functions, and methods in the pterasoftware package use type hints. See the style guide for type hints and docstrings for more details.
  • If any major functionality was added or significantly changed, I have added or updated tests in the tests package.
  • Code locally passes all tests in the tests package.
  • After pushing, PR passes all automated checks (codespell, black, mypy, and tests).
  • PR description links all relevant issues and follows this template.

@camUrban camUrban self-assigned this Nov 24, 2025
@camUrban camUrban added the feature New feature or request label Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 51.70732% with 297 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.80%. Comparing base (3dec520) to head (371820a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pterasoftware/output.py 10.96% 268 Missing ⚠️
pterasoftware/_mujoco_model.py 81.15% 13 Missing ⚠️
pterasoftware/operating_point.py 87.50% 7 Missing ⚠️
pterasoftware/_functions.py 69.23% 4 Missing ⚠️
pterasoftware/problems.py 95.65% 3 Missing ⚠️
pterasoftware/_transformations.py 96.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #66       +/-   ##
===========================================
- Coverage   91.32%   80.80%   -10.52%     
===========================================
  Files          32       34        +2     
  Lines        6111     7311     +1200     
===========================================
+ Hits         5581     5908      +327     
- Misses        530     1403      +873     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@camUrban camUrban added the dependencies Updates to a dependency file may be required label Nov 25, 2025
@camUrban camUrban force-pushed the feature/free_flight branch from f699d13 to f01d451 Compare December 5, 2025 04:21
Introduces the CoupledOperatingPoint class to represent operating conditions for individual Airplanes in free flight aerodynamic simulations. Updates module docstrings to reflect the addition and provides methods for dynamic pressure, transformation matrices, and freestream velocity calculations.
Introduces the CoupledMovement class to encapsulate multiple AirplaneMovements and their associated CoupledOperatingPoints for coupled unsteady simulations. Updates documentation in movement.py, __init__.py, and operating_point.py to reflect the new structure and clarify initialization and usage of CoupledMovement in CoupledUnsteadyProblems.
Introduces CoupledSteadyProblem and CoupledUnsteadyProblem classes to support coupled unsteady aerodynamic simulations. Updates docstrings and type annotations for clarity and consistency.
…interface with MuJoCo for free flight simulations

MuJoCoModel class includes methods for applying loads, stepping the simulation, extracting state, and resetting. Updates documentation and configuration files to include mujoco as a core dependency and configures mypy for the new module.
Refactored CoupledMovement, CoupledOperatingPoint, and CoupledSteadyProblem to operate on a single Airplane and CoupledOperatingPoint per problem instead of lists. Updated initialization, validation, and documentation to reflect this change, simplifying the interface and internal logic for coupled aerodynamic problems.
Introduces CoupledUnsteadyRingVortexLatticeMethodSolver for solving CoupledUnsteadyProblems with the unsteady ring vortex lattice method. Updates _functions.py and related logic to support the new solver, including load processing and panel attribute updates.
Introduces the animate_free_flight function to animate a CoupledUnsteadyRingVortexLatticeMethodSolver's Airplane, including support for wake vortex visualization and scalar coloring. Updates draw and related internal functions to handle the coupled solver, adds new helper functions for panel and wake surface generation in free flight, and refines type checks and error handling for streamline and wake visualization.
…ttice_method.py

Swapped np.cross for _functions.numba_1d_explicit_cross in backLegForces_GP1 calculation to improve performance and maintain consistency with other optimized operations.
…ging scripts with new variable names and converged/trimmed parameters

Also updates debugging log with latest progress
…oModel and CoupledUnsteadyRingVortexLatticeMethodSolver classes

Also updates Claude's progress tracking log
…Point

Also cleans up various typos, improves docstrings, and updates docstring style guide with subclass pattern
…it quaternions

Also adds comprehensive unit tests for the new function and removes old cruder methods that tried to implement this functionality
Renamed mujoco_model.py to _mujoco_model.py and refactored MuJoCoModel to accept CoupledMovement and inertia matrix directly, generating the MuJoCo XML internally. Added new transformation matrix properties to OperatingPoint and CoupledOperatingPoint for improved axis conversions. Updated CoupledUnsteadyProblem to require inertia matrix and instantiate MuJoCoModel. Removed direct mujoco_model import from __init__.py.
The MuJoCo model is now obtained from the CoupledUnsteadyProblem instance instead of being passed directly to the CoupledUnsteadyRingVortexLatticeMethodSolver. This simplifies the constructor and enforces tighter coupling between the problem and its associated MuJoCo model.
Introduces the rotationPointOffset_Gs_Ler parameter to WingMovement, allowing specification of a custom rotation point for wing angular motion. Updates initialization, wing generation logic, fixtures, and adds comprehensive unit tests to verify correct behavior and validation of the new feature.
Replaces delta_time calculation in gammabot simulation scripts with fixed values for fine and coarse meshes. Refactors movement.py to improve delta_time optimization, including a two-stage local/global search, reproducibility via random seed, and more robust mismatch evaluation. Enhances logging and error handling for optimization process.
Numba debug messages are now silenced in the glider and flat plate free flight scripts to reduce log noise. Typing annotation added for minimizer_kwargs in movement.py, and a debug log string in coupled_unsteady_ring_vortex_lattice_method.py was updated to stop Python 3.11 "unterminated string" error.
Introduces docs/MUJOCO_CONVENTIONS.md detailing MuJoCo state variable mappings to Ptera conventions. Adds debugging_scripts/flat_plate.py for flat plate solver testing. Refactors quaternion and velocity handling in _mujoco_model.py for clarity and correctness. Improves logging in coupled_unsteady_ring_vortex_lattice_method.py to show velocity vectors. Adds vCg_E__E property to CoupledOperatingPoint for velocity in Earth axes.
Enhanced free flight visualization by correcting coordinate transformations to PyVista axes, improving camera positioning, and ensuring proper clipping range for animations. Fixed panel and wake surface transformations to PyVista axes. Updated debugging scripts and documentation to reflect current development status, added new code style and writing guidelines, and removed obsolete debugging files. Also ensured MuJoCo model initializes derived quantities before simulation steps.
@camUrban camUrban force-pushed the feature/free_flight branch from 8414265 to 8f9e636 Compare December 14, 2025 22:46
camUrban and others added 11 commits December 15, 2025 21:41
Resolve conflicts across 10 files, adapting feature/free_flight's coupled
classes to main's immutability patterns (private attrs, read-only properties,
tuple collections, module renames). Fix duplicate rotation point offset
adjustment in WingMovement.generate_wings and update CLASSES_AND_IMMUTABILITY.md
with new coupled class documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrates the vortex singularity refactor into the coupled unsteady RVLM solver and updates docs to reflect completion. Code changes: add _list_wake_rc0s, _currentStackBoundRc0s and _currentStackWakeRc0s storage and per-step initialization; compute wing r_c0 = 0.03 * wing.standard_mean_chord during geometry collapse and populate bound/wake r_c0 arrays; extend calculate_solution_velocity to accept and accumulate bound/wake singularity counts; pass r_c0s and singularity_counts to expanded/collapsed velocity calls throughout solver; track and log unexpected singularity counts at ERROR/INFO/DEBUG levels in wing-wing, wake-wing, load calculation, and wake population paths. Docs: FREE_FLIGHT_DEVELOPMENT.md updated to mark the singularity refactor as incorporated and to shift immediate focus to immutability/refactor and validation.
Convert coupled free-flight classes to immutable patterns and update docs/tests. CoupledMovement, CoupledSteadyProblem, and CoupledUnsteadyProblem now store constructor-set attributes as private fields with read-only properties; Airplane collections use tuples; derived properties (max_period, static) use manual lazy caching; CoupledUnsteadyProblem inertia matrix I_BP1_CgP1 is set non-writeable. Solver-populated lists (coupled_operating_points, forces_W, etc.) remain mutable. Updated docs (CLASSES_AND_IMMUTABILITY.md, FREE_FLIGHT_DEVELOPMENT.md), added a fixture for basic CoupledUnsteadyProblem (tests/unit/fixtures/problem_fixtures.py), and extended/added unit tests for initialization and immutability (tests/unit/test_movement.py, tests/unit/test_problems.py).
Add a comprehensive validation script (debugging_scripts/5_simple_glider_validation.py) that runs an unpowered glider case (converged prescribed + 500 free steps), checks aerodynamic force sensibility, gliding behavior, and energy dissipation (dE/dt ≈ -drag*speed), and emits plots (simple_glider_validation.png). Update docs/FREE_FLIGHT_DEVELOPMENT.md with validation results, summary items, and reference to the new script. Fix an immutability-related crash in CoupledUnsteadyRingVortexLatticeMethodSolver by replacing manual Airplane reconstruction with prescribed_airplane.deep_copy_with_Cg_GP1_CgP1(...) to avoid re-processing wing symmetry attributes.
…y MuJoCoModel class for GammaBot coupled simulation

Track large zip archive with LFS.
@camUrban camUrban mentioned this pull request Mar 4, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Updates to a dependency file may be required feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Free flight simulations

1 participant