# Continuous-Thrust Circular Orbit Phasing Optimization of Deep Space CubeSats
## 3 Spacecraft Dynamics and Trajectory Optimization
### Trajectory Optimization and Optimal Control Law  
The maximization of \(J\) is obtained by using an indirect approach [35; 36], in which the adjoint variables are \(\{\lambda_{r},\,\lambda_{\theta},\,\lambda_{u},\,\lambda_{v},\,\lambda_{m}\}\) and the Euler-Lagrange equations are  
\[\frac{\mathrm{d}\lambda_{r}}{\mathrm{d}t}=-\frac{\mathrm{d}\mathcal{H}}{ \mathrm{d}r},\quad\frac{\mathrm{d}\lambda_{\theta}}{\mathrm{d}t}=-\frac{ \mathrm{d}\mathcal{H}}{\mathrm{d}\theta},\quad\frac{\mathrm{d}\lambda_{u}}{ \mathrm{d}t}=-\frac{\mathrm{d}\mathcal{H}}{\mathrm{d}u},\quad\frac{\mathrm{d} \lambda_{v}}{\mathrm{d}t}=-\frac{\mathrm{d}\mathcal{H}}{\mathrm{d}v},\quad \frac{\mathrm{d}\lambda_{m}}{\mathrm{d}t}=-\frac{\mathrm{d}\mathcal{H}}{ \mathrm{d}m} \tag{21}\]  
where \(\mathcal{H}\) is the scalar Hamiltonian function defined as  
\[\mathcal{H}=\lambda_{r}\,u+\frac{\lambda_{\theta}\,v}{r}+\lambda_{u}\biggl{(} -\frac{\mu_{\odot}}{r^{2}}+\frac{v^{2}}{r}+\mathbf{a}\cdot\mathbf{\hat{r}}\biggr{)}+ \lambda_{v}\biggl{(}-\frac{u\,v}{r}+\mathbf{a}\cdot\mathbf{\hat{\theta}}\biggr{)}+ \lambda_{m}\frac{\mathrm{d}m}{\mathrm{d}t} \tag{22}\]  
in which the expression of \(\mathrm{d}m/\mathrm{d}t\) is given by the right side of Equation (17). The expressions of the Euler-Lagrange equations are calculated in a closed form by using the simplified surrogate model of the MTC propulsion system, which is illustrated in the previous section. The explicit form of that equations are omitted for the sake of brevity. Taking Equation (22) into account and bearing in mind the expression of \(\mathbf{a}\) given by Equation (16), we observe that the first of the Euler-Lagrange Equation (21) contains, as expected, the derivative \(\partial T_{\mathrm{max}}/\partial r\). The boundary conditions of Equation (21) are obtained by enforcing the transversality condition as described in the textbook by [PERSON] and [PERSON] [31]. In this case, recalling that (1) the flight time \(t_{f}\) is unconstrained; (2) the adjoint variable \(\lambda_{\theta}\) is a constant of motion; (3) the final value of the polar angle is left free; and (4) the MTC total mass at the end of the transfer is unconstrained, and according to the second of the Euler-Lagrange Equation (21), the transversality condition gives  
\[\lambda_{\theta}=0,\quad\lambda_{m}(t_{f})=0,\quad\mathcal{H}(t_{f})=1 \tag{23}\]  
Therefore, Equations (19), (20), and (23) give 11 scalar boundary conditions (recall that the value of \(t_{f}\) is unknown), which complete the two-point boundary value problem associated with the optimization process. That boundary value problem is numerically solved by using a shooting procedure [33], with a tolerance of \(10^{-8}\), in which the initial guess of the unknowns initial costates [37] is obtained by adapting the method proposed in refs. [38; 39; 40]. In particular, the ideal model of the electric propulsion system proposed in [38] was adapted to the characteristics of the MTC, while a continuation procedure was employed to obtain the initial guess during the parametric study of the mission scenarios. Finally the optimal control law, that is, the optimal variation in the two control terms \(\{\tau,\,\mathbf{\dot{a}}\}\) is obtained by employing the classical [PERSON]'s maximum principle [36].