@@ -66,12 +66,11 @@ int gcrf2ecef(const dso::MjdEpoch &tai, dso::EopSeries &eops,
6666}
6767
6868int deriv (double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
69- const dso::IntegrationParameters *params,
69+ dso::IntegrationParameters *params,
7070 Eigen::Ref<Eigen::VectorXd> y) noexcept {
7171
7272 /* current time in TAI */
73- dso::MjdEpoch t = params->t0 ();
74- t.add_seconds (dso::FractionalSeconds (tsec));
73+ dso::MjdEpoch t = params->t0 ().add_seconds (dso::FractionalSeconds (tsec));
7574
7675 /* current time in GPST (debugging) */
7776 const auto tgps = t.tai2gps ();
@@ -82,18 +81,21 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
8281 /* Celestial to Terrestrial Matrix */
8382 dso::EopRecord eopr;
8483 Eigen::Matrix<double , 3 , 3 > R, dRdt;
85- if (gcrf2ecef (dso::MjdEpoch (t), *( params->eops () ), R, dRdt, fargs, eopr)) {
84+ if (gcrf2ecef (dso::MjdEpoch (t), params->eops (), R, dRdt, fargs, eopr)) {
8685 return 8 ;
8786 }
8887
88+ /* satellite position in ECEF */
89+ const Eigen::VectorXd r_ecef = R * y0.segment <3 >(0 );
90+
8991 /* Gravity field stokes coefficients */
90- auto stokes = params->grav ();
91- stokes.C (0 , 0 ) = stokes.C (1 , 0 ) = stokes.C (1 , 1 ) = 0e0 ;
92+ dso::StokesCoeffs stokes (params->earth_gravity ());
93+ stokes.C (0 , 0 ) = 0e0 ;
94+ stokes.C (1 , 0 ) = stokes.C (1 , 1 ) = 0e0 ;
9295 stokes.S (1 , 1 ) = 0e0 ;
9396
9497 /* compute acceleration for given epoch/position (ECEF) */
9598 [[maybe_unused]] Eigen::Matrix<double , 3 , 3 > g;
96- const Eigen::VectorXd r_ecef = R * y0.segment <3 >(0 );
9799 Eigen::Matrix<double , 3 , 1 > acc_grav;
98100 if (dso::sh2gradient_cunningham (stokes, r_ecef, acc_grav, g,
99101 stokes.max_degree (), stokes.max_order (), -1 ,
@@ -142,12 +144,12 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
142144
143145 /* Solid Earth Tide (ITRF) */
144146 Eigen::Matrix<double , 3 , 1 > acc_set;
145- params->mse_tide ->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()),
146- R * rtb_moon, R * rtb_sun. segment < 3 >( 0 ) ,
147- fargs);
148- if (dso::sh2gradient_cunningham (params->mse_tide ->stokes_coeffs (), r_ecef ,
149- acc_set, g, -1 , -1 , -1 , -1 , &(params-> tw ()) ,
150- &(params->tm ()))) {
147+ params->solid_earth_tide () ->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()),
148+ R * rtb_moon ,
149+ R * rtb_sun. segment < 3 >( 0 ), fargs);
150+ if (dso::sh2gradient_cunningham (params->solid_earth_tide () ->stokes_coeffs (),
151+ r_ecef, acc_set, g, -1 , -1 , -1 , -1 ,
152+ &(params->tw ()), &(params-> tm ()))) {
151153 fprintf (stderr, " ERROR Failed computing acceleration/gradient\n " );
152154 return 1 ;
153155 }
@@ -180,20 +182,22 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
180182
181183 /* Ocean Pole Tide */
182184 Eigen::Matrix<double , 3 , 1 > acc_otp;
183- if (params->mop_tide ->stokes_coeffs (t.tai2tt (), eopr.xp (), eopr.yp (),
184- params->mop_tide ->max_degree (),
185- params->mop_tide ->max_order ())) {
185+ if (params->ocean_pole_tide ()->stokes_coeffs (
186+ t.tai2tt (), eopr.xp (), eopr.yp (),
187+ params->ocean_pole_tide ()->max_degree (),
188+ params->ocean_pole_tide ()->max_order ())) {
186189 fprintf (stderr, " ERROR Failed computing Stokes Coefficients\n " );
187190 return 1 ;
188191 }
189- params->mop_tide ->stokes_coeffs ().C (0 , 0 ) =
190- params->mop_tide ->stokes_coeffs ().C (1 , 0 ) =
191- params->mop_tide ->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
192- params->mop_tide ->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
193- if (dso::sh2gradient_cunningham (params->mop_tide ->stokes_coeffs (), r_ecef,
194- acc_otp, g, params->mop_tide ->max_degree (),
195- params->mop_tide ->max_order (), -1 , -1 ,
196- &(params->tw ()), &(params->tm ()))) {
192+ params->ocean_pole_tide ()->stokes_coeffs ().C (0 , 0 ) =
193+ params->ocean_pole_tide ()->stokes_coeffs ().C (1 , 0 ) =
194+ params->ocean_pole_tide ()->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
195+ params->ocean_pole_tide ()->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
196+ if (dso::sh2gradient_cunningham (params->ocean_pole_tide ()->stokes_coeffs (),
197+ r_ecef, acc_otp, g,
198+ params->ocean_pole_tide ()->max_degree (),
199+ params->ocean_pole_tide ()->max_order (), -1 ,
200+ -1 , &(params->tw ()), &(params->tm ()))) {
197201 fprintf (stderr, " ERROR Failed computing acceleration/gradient\n " );
198202 return 1 ;
199203 }
@@ -204,20 +208,21 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
204208 y.segment <3 >(0 ) += acc;
205209 }
206210
207- /* Dealiasing */
211+ /* Dealiasing
212+ * WARNING !!
213+ * Here, we are storing the Stokes coefficients in stokes (created earlier).
214+ */
208215 Eigen::Matrix<double , 3 , 1 > acc_das;
209- if (params->mdealias ->coefficients_at (
216+ if (params->dealias () ->coefficients_at (
210217 dso::from_mjdepoch<dso::nanoseconds>(t.tai2tt ()), stokes)) {
211218 fprintf (stderr, " Failed interpolating dealiasing coefficients\n " );
212219 return 1 ;
213220 }
214- stokes.C (0 , 0 ) = 0e0 ;
215- stokes.C (1 , 0 ) = stokes.C (1 , 1 ) = 0e0 ;
221+ stokes.C (0 , 0 ) = stokes.C (1 , 0 ) = stokes.C (1 , 1 ) = 0e0 ;
216222 stokes.S (1 , 1 ) = 0e0 ;
217223 if (dso::sh2gradient_cunningham (stokes, r_ecef, acc_das, g,
218- params->mdealias_maxdegree ,
219- params->mdealias_maxorder , -1 , -1 ,
220- &(params->tw ()), &(params->tm ()))) {
224+ stokes.max_degree (), stokes.max_order (), -1 ,
225+ -1 , &(params->tw ()), &(params->tm ()))) {
221226 fprintf (stderr, " ERROR Failed computing acceleration/gradient\n " );
222227 return 1 ;
223228 }
@@ -231,17 +236,19 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
231236 /* Atmospheric Tide */
232237 Eigen::Matrix<double , 3 , 1 > acc_atm;
233238 /* compute Stokes coeffs (for atm. tides) */
234- params->mat_tide ->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()), fargs);
239+ params->atmospheric_tide ()->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()),
240+ fargs);
235241 /* for the test, degree one coefficients are not taken into account */
236- params->mat_tide ->stokes_coeffs ().C (0 , 0 ) =
237- params->mat_tide ->stokes_coeffs ().C (1 , 0 ) =
238- params->mat_tide ->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
239- params->mat_tide ->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
242+ params->atmospheric_tide () ->stokes_coeffs ().C (0 , 0 ) =
243+ params->atmospheric_tide () ->stokes_coeffs ().C (1 , 0 ) =
244+ params->atmospheric_tide () ->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
245+ params->atmospheric_tide () ->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
240246 /* compute acceleration for given epoch/position (ITRF) */
241- if (dso::sh2gradient_cunningham (params->mat_tide ->stokes_coeffs (), r_ecef,
242- acc_atm, g, params->matm_maxdegree ,
243- params->matm_maxorder , -1 , -1 ,
244- &(params->tw ()), &(params->tm ()))) {
247+ if (dso::sh2gradient_cunningham (params->atmospheric_tide ()->stokes_coeffs (),
248+ r_ecef, acc_atm, g,
249+ params->atmospheric_tide ()->max_degree (),
250+ params->atmospheric_tide ()->max_order (), -1 ,
251+ -1 , &(params->tw ()), &(params->tm ()))) {
245252 fprintf (stderr, " ERROR Failed computing acceleration/gradient\n " );
246253 return 1 ;
247254 }
@@ -255,16 +262,16 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
255262 /* Ocean Tide */
256263 Eigen::Matrix<double , 3 , 1 > acc_ot;
257264 /* compute Stokes coeffs (for ocean tides) */
258- params->moc_tide ->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()), fargs);
265+ params->ocean_tide () ->stokes_coeffs (t.tai2tt (), t.tai2ut1 (eopr.dut ()), fargs);
259266 /* for the test, degree one coefficients are not taken into account */
260- params->moc_tide ->stokes_coeffs ().C (0 , 0 ) =
261- params->moc_tide ->stokes_coeffs ().C (1 , 0 ) =
262- params->moc_tide ->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
263- params->moc_tide ->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
267+ params->ocean_tide () ->stokes_coeffs ().C (0 , 0 ) =
268+ params->ocean_tide () ->stokes_coeffs ().C (1 , 0 ) =
269+ params->ocean_tide () ->stokes_coeffs ().C (1 , 1 ) = 0e0 ;
270+ params->ocean_tide () ->stokes_coeffs ().S (1 , 1 ) = 0e0 ;
264271 /* compute acceleration for given epoch/position (ITRF) */
265- if (dso::sh2gradient_cunningham (params->moc_tide ->stokes_coeffs (), r_ecef,
266- acc_ot, g, params->moc_tide ->max_degree (),
267- params->moc_tide ->max_order (), -1 , -1 ,
272+ if (dso::sh2gradient_cunningham (params->ocean_tide () ->stokes_coeffs (), r_ecef,
273+ acc_ot, g, params->ocean_tide () ->max_degree (),
274+ params->ocean_tide () ->max_order (), -1 , -1 ,
268275 &(params->tw ()), &(params->tm ()))) {
269276 fprintf (stderr, " ERROR Failed computing acceleration/gradient\n " );
270277 return 1 ;
@@ -315,16 +322,15 @@ int main(int argc, char *argv[]) {
315322 sv = dso::sp3::SatelliteId{argv[3 ]};
316323 }
317324
318- /* get starting epoch in TAI */
325+ /* get starting epoch in TT */
319326 auto start_t = sp3.start_epoch ();
320327 if (!std::strcmp (sp3.time_sys (), " GPS" )) {
321328 start_t = start_t .gps2tai ();
322329 }
323330
324- auto t2 = start_t ;
325- t2.add_seconds (dso::seconds (5 * 86400 ));
326- dso::IntegrationParameters params =
327- dso::IntegrationParameters::from_config (argv[1 ], start_t , t2);
331+ auto t2 = start_t .add_seconds (dso::seconds (5 * 86400 ));
332+ dso::IntegrationParameters params = dso::IntegrationParameters::from_config (
333+ argv[1 ], dso::MjdEpoch (start_t ), dso::MjdEpoch (t2));
328334
329335 // /* EOPs */
330336 // dso::EopSeries eop;
@@ -476,7 +482,8 @@ int main(int argc, char *argv[]) {
476482 block_tai = block_tai.gps2tai ();
477483 }
478484 /* GCRF to ITRF rotation matrix */
479- if (gcrf2ecef (dso::MjdEpoch (block_tai), eop, R, dRdt, fargs, eopr)) {
485+ if (gcrf2ecef (dso::MjdEpoch (block_tai), params.eops (), R, dRdt, fargs,
486+ eopr)) {
480487 return 8 ;
481488 }
482489 /* get state for current epoch ITRF */
0 commit comments