nyx_space/dynamics/sequence/
config.rs1use anise::frames::FrameUid;
19use serde::{Deserialize, Serialize};
20use serde_dhall::{SimpleType, StaticType};
21use std::collections::HashMap;
22use std::sync::Arc;
23
24use crate::{
25 dynamics::{
26 Drag, PointMasses, SolarPressure,
27 guidance::{Maneuver, ObjectiveEfficiency, ObjectiveWeight},
28 },
29 io::gravity::GravityFieldConfig,
30 propagators::{IntegratorMethod, IntegratorOptions},
31};
32
33use crate::dynamics::sequence::discrete_event::DiscreteEvent;
34
35#[cfg(feature = "python")]
36use pyo3::prelude::*;
37
38#[derive(Clone, Debug, Serialize, Deserialize)]
39pub enum Phase {
40 Terminate,
41 Activity {
42 name: String,
43 propagator: String,
44 guidance: Option<Box<GuidanceConfig>>,
45 on_entry: Option<Box<DiscreteEvent>>,
47 disabled: bool,
49 },
50}
51
52impl StaticType for Phase {
53 fn static_type() -> SimpleType {
54 let mut variants = HashMap::new();
55
56 variants.insert("Terminate".to_string(), None);
59
60 let mut activity_fields = HashMap::new();
62
63 activity_fields.insert("name".to_string(), String::static_type());
64 activity_fields.insert("propagator".to_string(), String::static_type());
65
66 activity_fields.insert(
68 "guidance".to_string(),
69 <Option<GuidanceConfig> as StaticType>::static_type(),
70 );
71
72 activity_fields.insert(
73 "on_entry".to_string(),
74 <Option<DiscreteEvent> as StaticType>::static_type(),
75 );
76
77 activity_fields.insert("disabled".to_string(), bool::static_type());
78
79 variants.insert(
80 "Activity".to_string(),
81 Some(SimpleType::Record(activity_fields)),
82 );
83
84 SimpleType::Union(variants)
85 }
86}
87
88#[derive(Clone, Debug, Serialize, Deserialize, StaticType)]
90#[cfg_attr(feature = "python", pyclass(from_py_object))]
91pub struct PropagatorConfig {
92 pub method: IntegratorMethod,
93 pub options: IntegratorOptions,
94 pub accel_models: AccelModels,
95 pub force_models: ForceModels,
96}
97
98#[derive(Clone, Serialize, Deserialize, Debug)]
100#[cfg_attr(feature = "python", pyclass(from_py_object))]
101pub struct AccelModels {
102 pub point_masses: Option<Arc<PointMasses>>,
103 pub gravity_field: Option<(GravityFieldConfig, FrameUid)>,
104}
105
106#[derive(Clone, Serialize, Deserialize, Debug)]
108#[cfg_attr(feature = "python", pyclass(from_py_object))]
109pub struct ForceModels {
110 pub solar_pressure: Option<Arc<SolarPressure>>,
111 pub drag: Option<Arc<Drag>>,
112}
113
114#[derive(Clone, Debug, Serialize, Deserialize, StaticType)]
115pub struct GuidanceConfig {
116 pub thruster_model: String,
117 pub disable_prop_mass: bool,
118 pub law: SteeringLaw,
119}
120
121#[derive(Clone, Debug, Serialize, Deserialize, StaticType)]
123pub enum SteeringLaw {
124 FiniteBurn(Maneuver),
125 Kluever {
126 objectives: Vec<ObjectiveWeight>,
128 max_eclipse_prct: Option<f64>,
130 },
131 Ruggiero {
132 objectives: Vec<ObjectiveEfficiency>,
134 max_eclipse_prct: Option<f64>,
136 },
137}
138
139impl StaticType for AccelModels {
140 fn static_type() -> serde_dhall::SimpleType {
141 let mut fields = HashMap::new();
142
143 fields.insert(
144 "point_masses".to_string(),
145 SimpleType::Optional(Box::new(PointMasses::static_type())),
146 );
147
148 #[allow(dead_code)]
149 #[derive(StaticType)]
150 struct GravityFieldDhall(GravityFieldConfig, FrameUid);
151
152 fields.insert(
153 "gravity_field".to_string(),
154 SimpleType::Optional(Box::new(GravityFieldDhall::static_type())),
155 );
156
157 SimpleType::Record(fields)
158 }
159}
160
161impl StaticType for ForceModels {
162 fn static_type() -> serde_dhall::SimpleType {
163 let mut fields = HashMap::new();
164
165 fields.insert(
166 "solar_pressure".to_string(),
167 SimpleType::Optional(Box::new(SolarPressure::static_type())),
168 );
169
170 fields.insert(
171 "drag".to_string(),
172 SimpleType::Optional(Box::new(Drag::static_type())),
173 );
174
175 SimpleType::Record(fields)
176 }
177}