Skip to content

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 42.34043% with 271 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.16%. Comparing base (6a10acd) to head (a7f7b70).

Files with missing lines Patch % Lines
pterasoftware/output.py 8.19% 168 Missing ⚠️
pterasoftware/_mujoco_model.py 18.03% 50 Missing ⚠️
pterasoftware/problems.py 15.78% 32 Missing ⚠️
pterasoftware/operating_point.py 78.57% 9 Missing ⚠️
pterasoftware/movements/movement.py 91.42% 6 Missing ⚠️
pterasoftware/_functions.py 69.23% 4 Missing ⚠️
pterasoftware/_transformations.py 96.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #66       +/-   ##
===========================================
- Coverage   87.33%   75.16%   -12.18%     
===========================================
  Files          28       30        +2     
  Lines        4597     5584      +987     
===========================================
+ Hits         4015     4197      +182     
- Misses        582     1387      +805     

☔ 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 Pull requests that update a dependency file 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.
Replaces MuJoCo XML and model instantiation with direct inertia tensor definition in both glider and flat plate free flight scripts. The inertia tensor is now passed to CoupledUnsteadyProblem, simplifying initialization and removing dependencies on internal transformation utilities and MuJoCo model wrappers.
Gravity is now disabled in the MuJoCo model and applied solely by the coupled solver to prevent double-counting. Force transformation logic in the coupled solver is simplified, weight force calculation now uses the actual gravity direction, and variable naming is made consistent. Added debug logging for free flight and fixed inertia tensor units in documentation.
Set logging level to DEBUG in free flight scripts and suppress matplotlib debug messages. Update debug messages in CoupledUnsteadyRingVortexLatticeMethodSolver to use consistent formatting and scientific notation. Change output formatting in print_results to display values in scientific notation for better readability.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Free flight simulations

2 participants