-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Propagation loop never exits for some orbits #377
Comments
Changing let future = epoch + Unit::Day * 90; to let future = epoch + Unit::Day * 30; results in the propagator exiting properly. After 30 days the spacecraft would have impacted the moon, so it looks like the issue is only with unrealistic orbits. In my simulation, I try to catch this case with until_event(future - epoch, &Event::new(nyx::md::StateParameter::Rmag, 1737.4)) but |
Hi Gregory, Thanks for the bug report. Have you tried initializing the orbit in the Moon J2000 frame, but keeping the gravity field in the Moon PA frame? The frame of the orbit determines the integration frame, and I don't think the Moon PA frame is an inertial frame so I'm not sure how it would behave. Concerning the I'll recreate your example locally. |
This is definitely a bug because the step size is allowed to reach ... zero nanoseconds. I just added the step size in the info log.
I'll fix this right away, thanks for the report. |
In the following code, I built upon your example and used the J2000 frame for propagation, and kept the harmonics in the Moon PA frame (as they should be). I also used your approach to propagate until impact on the Moon using the event finder. It works fine, but I'll still push the step size fix in a moment. Note: I've built this on top of the LRO example in my local clone of the repo, so there are plenty of unused imports. I'm also using the Moon BPC
Here's the code that worked: extern crate nyx_space as nyx;
extern crate pretty_env_logger as pel;
use anise::{
almanac::metaload::MetaFile,
constants::frames::MOON_PA_FRAME,
};
use hifitime::{Epoch, Unit};
use nyx::{
cosmic::MetaAlmanac,
dynamics::{
Harmonics, OrbitalDynamics, SpacecraftDynamics,
},
md::{
prelude::HarmonicsMem,
Event,
},
propagators::Propagator,
Orbit, Spacecraft, State,
};
use std::{error::Error, path::PathBuf, sync::Arc};
fn main() -> Result<(), Box<dyn Error>> {
pel::init();
let data_folder: PathBuf = [env!("CARGO_MANIFEST_DIR"), "examples", "04_lro_od"]
.iter()
.collect();
let meta = data_folder.join("lro-dynamics.dhall");
// Load this ephem in the general Almanac we're using for this analysis.
let almanac = Arc::new(
MetaAlmanac::new(meta.to_string_lossy().to_string())
.map_err(Box::new)?
.process(true)
.map_err(Box::new)?,
);
let frame = almanac
.frame_from_uid(MOON_PA_FRAME.with_orient(31008))
.expect("Could not load frame");
let mut jggrx_meta = MetaFile {
uri: "https://pds-geosciences.wustl.edu/grail/grail-l-lgrs-5-rdr-v1/grail_1001/shadr/jggrx_0660b_sha.tab".to_string(),
crc32: Some(0xebdb7283)
};
jggrx_meta.process(true)?;
let sph_harmonics = Harmonics::from_stor(
almanac.frame_from_uid(frame)?,
HarmonicsMem::from_shadr(&jggrx_meta.uri, 10, 10, false)?,
);
let epoch = Epoch::from_gregorian_utc_hms(2024, 1, 1, 0, 0, 0);
let orbit = Orbit::try_keplerian_altitude(
50.0, 1e-6, 40.5, 45.0, 0.0, 0.0, epoch,
frame,
// almanac.frame_from_uid(MOON_J2000).unwrap(),
)
.unwrap();
let sc = Spacecraft::builder().orbit(orbit).build();
let mut orbital_dyn = OrbitalDynamics::point_masses(vec![]);
orbital_dyn.accel_models.push(sph_harmonics.clone());
let dynamics = SpacecraftDynamics::from_models(orbital_dyn, vec![]);
let future = epoch + Unit::Day * 90;
let (sc, trajectory) = Propagator::default(dynamics)
.with(sc, almanac.clone())
.until_event(
future - epoch,
&Event::new(nyx::md::StateParameter::Rmag, 1737.4),
)
.unwrap();
// .until_epoch_with_traj(future)
// .unwrap();
println!("{sc:x}");
println!("RMAG = {} km", sc.orbit.rmag_km());
Ok(())
} I'll open a PR momentarily with the fix. |
Bound the proposed integrator steps
Following up on this issue: I ran 4186 simulations, each with a different starting orbit and I did not encounter the issue again 👍. Prior to the fix I was seeing it on 2 or 3 of the simulations. Thank you for the quick fix! |
Great to hear! Out of curiosity, did you use the Monte Carlo framework? |
I did not use the Monte Carlo framework, but I may use that for other purposes in the future now that I know about it! I'll email you offline with some additional context. |
Bug report
Describe the bug
Propagation loop never exits for some orbits.
To Reproduce
Expected behavior
until_epoch_with_traj
should exit after a few seconds.Platform
Windows 11, PowerShell
Additional context
Another orbit I encountered the issue with was the same parameters but an inclination of
13.500000000000002
and a RAAN of9.0
. Interestingly enough, I did not encounter the issue with an inclination of13.5
.The orbit is expected to become increasingly eccentric. My initial suspicion is that propagating orbits using harmonics when the orbit falls below the mean radius of the object produces unexpected results.
The text was updated successfully, but these errors were encountered: