Skip to content

Support for albedo parameters in Spacecraft state#545

Open
ChristopherRabotin wants to merge 1 commit into
masterfrom
albedo-modeling-4147399694482142674
Open

Support for albedo parameters in Spacecraft state#545
ChristopherRabotin wants to merge 1 commit into
masterfrom
albedo-modeling-4147399694482142674

Conversation

@ChristopherRabotin
Copy link
Copy Markdown
Member

I have enhanced the core Spacecraft state and related structures to support the upcoming albedo radiation pressure modeling.

Key changes:

  1. State Definition: Added AlbedoCr to StateParameter in nyx-core/src/md/param.rs.
  2. Spacecraft Struct: Added albedo: AlbedoData (aliased from SRPData) to the Spacecraft struct in nyx-core/src/cosmic/spacecraft.rs.
  3. State Dimension: Increased the state size from 9 to 10 and the total propagation vector (including STM) from 90 to 110.
  4. Trait Implementation: Updated the State trait for Spacecraft to correctly map the new 10th parameter (Albedo Cr) and its partials in the STM.
  5. Dynamics Update: Updated SpacecraftDynamics in nyx-core/src/dynamics/spacecraft.rs to reflect the new state dimensions.
  6. OD/MC Ecosystem: Updated MvnSpacecraft (Monte Carlo), KfEstimate (Kalman Filter), SpacecraftUncertainty, and the solution import logic to accommodate the 10-dimensional state.

These changes ensure that Albedo reflectivity can be tracked, propagated, and potentially estimated in the future, providing the necessary infrastructure for the Albedo force model implementation.

Fixes #316


PR created automatically by Jules for task 4147399694482142674 started by @ChristopherRabotin

- Added AlbedoCr to StateParameter enum.
- Updated Spacecraft struct to include albedo: AlbedoData.
- Increased Spacecraft state size to 10 (Position, Velocity, Cr, Cd, Mass, Albedo Cr) and its propagation vector length to 110 (to include 10x10 STM).
- Updated State trait implementation for Spacecraft to handle the new dimension.
- Updated SpacecraftDynamics to support the increased state size.
- Updated MvnSpacecraft, KfEstimate, SpacecraftUncertainty, and Parquet import logic to handle the new state dimension and Albedo Cr parameter.

This lays the foundation for implementing the Albedo radiation pressure force model.

Co-authored-by: ChristopherRabotin <4823784+ChristopherRabotin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates albedo configuration into the spacecraft model, increasing the state vector size from 9 to 10. Key changes include the addition of AlbedoData to the Spacecraft struct, updates to the State Transition Matrix (STM) dimensions, and adjustments to dynamics, Monte Carlo dispersions, and orbital determination logic to support the new AlbedoCr parameter. Review feedback focused on enhancing code maintainability by replacing hardcoded constants with associated types from the State trait and recommended updating several doc comments to correctly describe the expanded state vector layout.

pub thrust_direction: Option<ThrustDirection>,
/// Optionally stores the state transition matrix from the start of the propagation until the current time (i.e. trajectory STM, not step-size STM)
/// STM is contains position and velocity, Cr, Cd, prop mass
/// STM is contains position and velocity, Cr, Cd, prop mass, Albedo Cr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment contains a typo ("is contains") and should ideally use a conjunction for the last item in the list.

Suggested change
/// STM is contains position and velocity, Cr, Cd, prop mass, Albedo Cr
/// STM contains position and velocity, Cr, Cd, prop mass, and Albedo Cr

Comment on lines +486 to +487
fn to_vector(&self) -> OVector<f64, Const<110>> {
let mut vector = OVector::<f64, Const<110>>::zeros();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using the associated type Self::VecLength instead of hardcoding Const<110> for better maintainability and consistency with the trait definition.

Suggested change
fn to_vector(&self) -> OVector<f64, Const<110>> {
let mut vector = OVector::<f64, Const<110>>::zeros();
fn to_vector(&self) -> OVector<f64, Self::VecLength> {
let mut vector = OVector::<f64, Self::VecLength>::zeros();

/// [X, Y, Z, Vx, Vy, Vz, Cr, Cd, Fuel mass, STM(9x9)]
fn set(&mut self, epoch: Epoch, vector: &OVector<f64, Const<90>>) {
/// [X, Y, Z, Vx, Vy, Vz, Cr, Cd, Fuel mass, Albedo Cr, STM(10x10)]
fn set(&mut self, epoch: Epoch, vector: &OVector<f64, Const<110>>) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using the associated type Self::VecLength instead of hardcoding Const<110>.

Suggested change
fn set(&mut self, epoch: Epoch, vector: &OVector<f64, Const<110>>) {
fn set(&mut self, epoch: Epoch, vector: &OVector<f64, Self::VecLength>) {

self.albedo.coeff_reflectivity = sc_state[9].clamp(0.0, 2.0);
}

/// diag(STM) = [X,Y,Z,Vx,Vy,Vz,Cr,Cd,Fuel]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment describing the STM diagonal layout is outdated and should be updated to include the newly added AlbedoCr parameter.

Suggested change
/// diag(STM) = [X,Y,Z,Vx,Vy,Vz,Cr,Cd,Fuel]
/// diag(STM) = [X,Y,Z,Vx,Vy,Vz,Cr,Cd,Fuel,AlbedoCr]

) -> Result<(OVector<f64, Const<9>>, OMatrix<f64, Const<9>, Const<9>>), DynamicsError> {
) -> Result<(OVector<f64, Const<10>>, OMatrix<f64, Const<10>, Const<10>>), DynamicsError> {
// Rebuild the appropriately sized state and STM.
// This is the orbital state followed by Cr and Cd
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment is now incomplete as the state vector has been expanded to include PropMass and Albedo Cr.

Suggested change
// This is the orbital state followed by Cr and Cd
// This is the orbital state followed by Cr, Cd, PropMass, and Albedo Cr

Comment on lines +410 to +413
state_deviation: OVector::<f64, Const<10>>::zeros(), // Deviation not stored
covar,
covar_bar: covar, // Not stored, use covar
stm: OMatrix::<f64, Const<9>, Const<9>>::identity(), // Not stored
stm: OMatrix::<f64, Const<10>, Const<10>>::identity(), // Not stored
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is better to use the associated types from the State trait (e.g., <Spacecraft as State>::Size) instead of hardcoding Const<10> to ensure consistency and easier maintenance if the state size changes again in the future. Additionally, ensure these fields are necessary for the struct, as Rule 2 advises removing unused fields from update logic.

Suggested change
state_deviation: OVector::<f64, Const<10>>::zeros(), // Deviation not stored
covar,
covar_bar: covar, // Not stored, use covar
stm: OMatrix::<f64, Const<9>, Const<9>>::identity(), // Not stored
stm: OMatrix::<f64, Const<10>, Const<10>>::identity(), // Not stored
state_deviation: OVector::<f64, <Spacecraft as State>::Size>::zeros(), // Deviation not stored
covar,
covar_bar: covar, // Not stored, use covar
stm: OMatrix::<f64, <Spacecraft as State>::Size, <Spacecraft as State>::Size>::identity(), // Not stored
References
  1. Avoid updating properties that are not used by the consuming struct. Unused fields should be removed from update logic to avoid unnecessary complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Albedo radiation pressure modeling

1 participant