ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
CR3BPDynamics.hpp
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Circular Restricted Three Body Dynamics header file
18---------------------------------------------------
19
20Author: Alex Reynolds
21*/
22#ifndef CR3BPUTILS_CR3BP_DYNAMICS_HPP
23#define CR3BPUTILS_CR3BP_DYNAMICS_HPP
24
25#include "utils/Rates.hpp"
26#include "core/CartesianVector.hpp"
27#include "core/Matrix.hpp"
28
29/**
30 * @brief Class to propagate CR3BP dynamics in characteristic units
31 *
32 * This class is used to propagate circular restricted 3 body problem
33 * dynamics in characteristic units. It sets internal parameters on
34 * the basis of the setters for mu and l, which are used in the propagation.
35 */
36namespace modelspace {
37 const unsigned int NUM_CR3BP_STATES = 6;
38
39 class CR3BPDynamics : public clockwerk::Rates<double, NUM_CR3BP_STATES> {
40 public:
41 CR3BPDynamics() : Rates() {}
42
43 /// @brief Function to calculate frame rates of change for a frame
44 /// @param time The time input for the calculation. Uses current time
45 /// @param state The current state vector in the calculation
46 /// @param out_rates Implicit return of rates of change in states
47 int calculateRates(double time,
48 const std::array<double, NUM_CR3BP_STATES> &state,
49 std::array<double, NUM_CR3BP_STATES> &out_rates) {
50 // Pre-calculate some parameters to make life easier down the line
51 double one_minus_mu_star = 1.0 - mu_star;
52 double x_plus_mu_star = state[0] + mu_star;
53 double x_plus_one_minus_mu_star = state[0] - 1.0 + mu_star;
54 double y_squared = state[1]*state[1];
55 double z_squared = state[2]*state[2];
56 double r1 = std::sqrt(x_plus_mu_star*x_plus_mu_star + y_squared + z_squared);
57 double r2 = std::sqrt(x_plus_one_minus_mu_star*x_plus_one_minus_mu_star + y_squared + z_squared);
58 double one_over_r1_cubed = 1.0/(r1*r1*r1);
59 double one_over_r2_cubed = 1.0/(r2*r2*r2);
60
61 // Now calculate our state vector rate of change
62 out_rates[0] = state[3];
63 out_rates[1] = state[4];
64 out_rates[2] = state[5];
65 out_rates[3] = -one_minus_mu_star*x_plus_mu_star*one_over_r1_cubed - mu_star*(state[0] - one_minus_mu_star)*one_over_r2_cubed + 2*state[4] + state[0];
66 out_rates[4] = -one_minus_mu_star*state[1]*one_over_r1_cubed - mu_star*state[1]*one_over_r2_cubed - 2.0*state[3] + state[1];
67 out_rates[5] = -one_minus_mu_star*state[2]*one_over_r1_cubed - mu_star*state[2]*one_over_r2_cubed;
68
69 return NO_ERROR;
70 }
71
72 /// @brief This is the ratio of second body mass to total system mass
73 double mu_star;
74 private:
75
76 };
77
78}
79
80#endif
Definition Rates.hpp:27
Definition CR3BPDynamics.hpp:39
int calculateRates(double time, const std::array< double, NUM_CR3BP_STATES > &state, std::array< double, NUM_CR3BP_STATES > &out_rates)
Function to calculate frame rates of change for a frame.
Definition CR3BPDynamics.hpp:47
double mu_star
This is the ratio of second body mass to total system mass.
Definition CR3BPDynamics.hpp:73
#define NO_ERROR
Definition clockwerkerrors.h:31
Class to propagate CR3BP dynamics in characteristic units.
Definition ConfigurationWriter.cpp:18