-
-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/lambert solver #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a new class `SpecialFunctions` in the `IO.Astrodynamics.Math` namespace. The class features a `Hypergeometric` method that computes the value of a hypergeometric series based on input parameters `z` and `tol`. The method iteratively calculates the series until the absolute value of the next term is within the specified tolerance. Detailed XML documentation is provided for clarity on the method's purpose, parameters, and return value.
Updated `LambertSolver.cs` with two new methods: `XToTimeOfFlight` for computing time of flight based on the x parameter and number of revolutions, and `XToTimeOfFlightGeneral` for selecting the appropriate calculation method (Battin, Lagrange, or Lancaster). Code cleanup includes removal of unnecessary using directives and enhanced documentation with XML comments.
- Upgraded package references in `IO.Astrodynamics.Tests.csproj`. - Added `TimeOfFlightDerivatives` method in `LambertSolver.cs` with XML documentation. - Implemented validation in `Hypergeometric` method in `Functions.cs` to check for non-negative tolerance. - Created `SpecialFunctionsTests` class in `SpecialFunctionsTests.cs` to unit test the `Hypergeometric` method.
- Enhanced `.gitignore` to include build artifacts and IDE directories. - Added unit tests for `LambertResult`, `LambertSolution`, and `LambertSolver` classes using `Xunit`. - Modified `LambertResult` to return a read-only collection of solutions and changed `MaxRevolutions` type to `ushort`. - Refactored `LambertSolver` constructor and updated the `Solve` method for improved robustness. - Enhanced `ComputeSolution` method for accurate velocity vector calculations. - Added documentation comments to improve code maintainability.
This commit refactors the namespace from IO.Astrodynamics.Tests.Maneuver.Lambert to IO.Astrodynamics.Tests.Maneuvers.Lambert for consistency across multiple test files. In LambertSolverTests.cs, instances of DummyCelestialItem were replaced with DummyBody, and tests now utilize TestHelpers.EarthAtJ2000 for better clarity. The CreateStateVector method was updated to accept an epoch parameter. Significant changes were made to the LambertSolver class, including the removal of the m_lambda member in favor of a local variable lambda, simplifying state management. Time of flight calculation methods were also updated to accept the lambda parameter. New test cases were added to validate the solver's functionality for Earth to Moon transfers in both direct and retrograde scenarios, enhancing test reliability and ensuring correct behavior under various conditions.
There was a problem hiding this 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 adds a new hypergeometric series function, a full-featured Lambert solver, accompanying result/solution classes, and extensive unit tests, and updates version numbers and test project dependencies.
- Introduced
SpecialFunctions.Hypergeometricfor computing hypergeometric series with tolerance handling. - Added
LambertSolver,LambertSolution, andLambertResultto solve and encapsulate Lambert transfer orbits. - Bumped package and project versions, updated test dependencies, and extended tests for both hypergeometric and Lambert routines.
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Math/Functions.cs | Added Hypergeometric, default usings and file name mismatch |
| Maneuver/Lambert/LambertSolver.cs | New Lambert problem solver with comprehensive algorithm |
| Maneuver/Lambert/LambertSolution.cs | Class representing a single Lambert solution |
| Maneuver/Lambert/LambertResult.cs | Aggregator class for collecting multiple solutions |
| IO.Astrodynamics.nuspec & CLI/.csproj & Tests/.csproj | Version bumps and updated test dependencies |
| Tests/Math/SpecialFunctionsTests.cs | Unit tests for the hypergeometric series |
| Tests/Maneuvers/LambertSolverTests.cs | Unit tests covering solver edge cases and happy paths |
| Tests/Maneuvers/LambertSolutionTests.cs | Validation of LambertSolution constructors and properties |
| Tests/Maneuvers/LambertResultTests.cs | Validation of LambertResult behavior |
Comments suppressed due to low confidence (2)
IO.Astrodynamics.Net/IO.Astrodynamics/Maneuver/Lambert/LambertSolver.cs:18
- Typo in XML doc and parameter name: 'targetOjectOrbitalParameters' should be 'targetObjectOrbitalParameters'.
/// <param name="targetOjectOrbitalParameters">The orbital parameters of the target object at the end of the transfer.</param>
IO.Astrodynamics.Net/IO.Astrodynamics/Maneuver/Lambert/LambertSolver.cs:22
- The method signature uses 'targetOjectOrbitalParameters'; correct it to 'targetObjectOrbitalParameters' for consistency and to avoid confusion.
public LambertResult Solve(bool isRetrograde, OrbitalParameters.OrbitalParameters initialOrbitalParameters, OrbitalParameters.OrbitalParameters targetOjectOrbitalParameters,
IO.Astrodynamics.Net/IO.Astrodynamics/Maneuver/Lambert/LambertSolver.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
This commit refactors the namespace from `IO.Astrodynamics.Tests.Maneuver.Lambert` to `IO.Astrodynamics.Tests.Maneuvers.Lambert` for consistency across multiple test files. In `LambertSolverTests.cs`, instances of `DummyCelestialItem` were replaced with `DummyBody`, and tests now utilize `TestHelpers.EarthAtJ2000` for better clarity. The `CreateStateVector` method was updated to accept an epoch parameter. Significant changes were made to the `LambertSolver` class, including the removal of the `m_lambda` member in favor of a local variable `lambda`, simplifying state management. Time of flight calculation methods were also updated to accept the `lambda` parameter. New test cases were added to validate the solver's functionality for Earth to Moon transfers in both direct and retrograde scenarios, enhancing test reliability and ensuring correct behavior under various conditions.
Renamed `battinThreshold` to `BattinThreshold` in the conditional statement to ensure consistency with its definition elsewhere in the code.
Updated `LocalToTdt` and `TdtToLocal` methods to calculate expected TDT and local time based on the system's local time zone offset. Removed hardcoded values and added assertions with a tolerance of 1 millisecond for improved accuracy in time conversions.
This pull request introduces several updates to the
IO.Astrodynamicsproject, focusing on version upgrades, new tests for the Lambert solver, and enhancements to the astrodynamics framework. The most notable changes include the addition of comprehensive unit tests for Lambert-related classes, updates to package dependencies, and minor refactoring for consistency.Key Changes
Testing Enhancements:
LambertResult,LambertSolution, andLambertSolverto validate their behavior, including edge cases like retrograde and multi-revolution solutions. ([[1]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-930362a0763b7ae8f2a943d7e737e45e1220dfb34f8880956df6586c4a69d3fdR1-R89),[[2]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-4ae5bf16258af29322d15766b472d5a603e077f4d9b8c464af337e643c7cec7fR1-R81),[[3]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-6c263bb1ab25889da1b1e80fc372917e85f4080806ba0b6ae34c1e027094f362R1-R203))SpecialFunctions.Hypergeometricto ensure mathematical accuracy and proper convergence. ([IO.Astrodynamics.Net/IO.Astrodynamics.Tests/Math/SpecialFunctionsTests.csR1-R41](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-0c2a864c119b04b21458f71aa06771c4115c7314a11dfc872371af5586800d67R1-R41))Dependency Updates:
IO.Astrodynamics.Tests.csproj, includingBenchmarkDotNet,xunit, and others, to newer versions for improved compatibility and features. ([IO.Astrodynamics.Net/IO.Astrodynamics.Tests/IO.Astrodynamics.Tests.csprojL13-R24](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-003179c8b9e25332b0a7474b12bd28359ba7ee9638157d1fc68e81db2d1c3bdeL13-R24))Framework Improvements:
LambertResultclass to encapsulate solutions for Lambert problems, improving code structure and readability. ([IO.Astrodynamics.Net/IO.Astrodynamics/Maneuver/Lambert/LambertResult.csR1-R32](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-759b83ca1b06d447f702a2663423cbc39d8f682253ffbd61e15060000994dce4R1-R32))Version Updates:
IO.Astrodynamics.CLI.csprojandIO.Astrodynamics.nuspecfrom0.6.4.0to0.6.5.0, reflecting the new changes. ([[1]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-d4c3c86f426ad9db1321379dc7b37ba13f6b8132586bc03250e7678de2fd9372L12-R12),[[2]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-5c63e65b5e8c471dd75804cea58cb32d0f983dbc07fd7278c982128f577d49adL7-R7))Code Refactoring:
ScenarioTests.csfor clarity, explicitly referencingAstrodynamics.Maneuver.Maneuver. ([[1]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-fa304fc72b91d086c76b965962adce44e0e64ff77ca9971f6434446df3ab1679L150-R150),[[2]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-fa304fc72b91d086c76b965962adce44e0e64ff77ca9971f6434446df3ab1679L344-R344),[[3]](https://github.com/IO-Aerospace-software-engineering/Astrodynamics/pull/234/files#diff-fa304fc72b91d086c76b965962adce44e0e64ff77ca9971f6434446df3ab1679L397-R397))