Skip to content

Commit 69ff04f

Browse files
Add option to enable or disable SRP and Drag estimation
1 parent 689a4e9 commit 69ff04f

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/dynamics/drag.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub struct ConstantDrag {
4747
pub rho: f64,
4848
/// Geoid causing the drag
4949
pub drag_frame: Frame,
50+
/// Set to true to estimate the coefficient of drag
51+
pub estimate: bool,
5052
}
5153

5254
impl fmt::Display for ConstantDrag {
@@ -61,7 +63,11 @@ impl fmt::Display for ConstantDrag {
6163

6264
impl ForceModel for ConstantDrag {
6365
fn estimation_index(&self) -> Option<usize> {
64-
Some(7)
66+
if self.estimate {
67+
Some(7)
68+
} else {
69+
None
70+
}
6571
}
6672

6773
fn eom(&self, ctx: &Spacecraft, almanac: Arc<Almanac>) -> Result<Vector3<f64>, DynamicsError> {
@@ -94,6 +100,8 @@ pub struct Drag {
94100
pub density: AtmDensity,
95101
/// Frame to compute the drag in
96102
pub drag_frame: Frame,
103+
/// Set to true to estimate the coefficient of drag
104+
pub estimate: bool,
97105
}
98106

99107
impl Drag {
@@ -110,6 +118,7 @@ impl Drag {
110118
action: "planetary data from third body not loaded",
111119
}
112120
})?,
121+
estimate: false,
113122
}))
114123
}
115124

@@ -124,6 +133,7 @@ impl Drag {
124133
action: "planetary data from third body not loaded",
125134
}
126135
})?,
136+
estimate: false,
127137
}))
128138
}
129139
}
@@ -140,7 +150,11 @@ impl fmt::Display for Drag {
140150

141151
impl ForceModel for Drag {
142152
fn estimation_index(&self) -> Option<usize> {
143-
Some(8)
153+
if self.estimate {
154+
Some(7)
155+
} else {
156+
None
157+
}
144158
}
145159

146160
fn eom(&self, ctx: &Spacecraft, almanac: Arc<Almanac>) -> Result<Vector3<f64>, DynamicsError> {

src/dynamics/solarpressure.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct SolarPressure {
3838
/// solar flux at 1 AU, in W/m^2
3939
pub phi: f64,
4040
pub e_loc: EclipseLocator,
41+
/// Set to true to estimate the coefficient of reflectivity
42+
pub estimate: bool,
4143
}
4244

4345
impl SolarPressure {
@@ -66,6 +68,7 @@ impl SolarPressure {
6668
Ok(Self {
6769
phi: SOLAR_FLUX_W_m2,
6870
e_loc,
71+
estimate: true,
6972
})
7073
}
7174

@@ -74,6 +77,16 @@ impl SolarPressure {
7477
Ok(Arc::new(Self::default_raw(vec![shadow_body], almanac)?))
7578
}
7679

80+
/// Accounts for the shadowing of only one body and will set the solar flux at 1 AU to: Phi = 1367.0
81+
pub fn default_no_estimation(
82+
shadow_body: Frame,
83+
almanac: Arc<Almanac>,
84+
) -> Result<Arc<Self>, DynamicsError> {
85+
let mut srp = Self::default_raw(vec![shadow_body], almanac)?;
86+
srp.estimate = false;
87+
Ok(Arc::new(srp))
88+
}
89+
7790
/// Must provide the flux in W/m^2
7891
pub fn with_flux(
7992
flux_w_m2: f64,
@@ -96,7 +109,11 @@ impl SolarPressure {
96109

97110
impl ForceModel for SolarPressure {
98111
fn estimation_index(&self) -> Option<usize> {
99-
Some(6)
112+
if self.estimate {
113+
Some(6)
114+
} else {
115+
None
116+
}
100117
}
101118

102119
fn eom(&self, ctx: &Spacecraft, almanac: Arc<Almanac>) -> Result<Vector3<f64>, DynamicsError> {

0 commit comments

Comments
 (0)