| 1 | """******************************************************************** |
| 2 | Circular Restricted Three-Body Problem (CR3BP) Library |
| 3 | ********************************************************************. |
| 4 | |
| 5 | Last update: 21/01/2022 |
| 6 | |
| 7 | Description |
| 8 | ----------- |
| 9 | A library of functions to solve the CR3BP orbit model. Currently, the library |
| 10 | provides the following functionality: |
| 11 | * CR3BP system characterisitic values computation |
| 12 | * CR3BP dynamics propagation |
| 13 | * CR3BP State Transition Matrix propagation |
| 14 | |
| 15 | References |
| 16 | ---------- |
| 17 | Most of the equations implemented can be found in a wide range of litrature |
| 18 | on celestial mechancis. But a major portion of the work was directly refered |
| 19 | from Daniel Grebow's master and PhD thesis works. They are listed below. |
| 20 | |
| 21 | Ref: GENERATING PERIODIC ORBITS IN THE CIRCULAR RESTRICTED THREEBODY PROBLEM |
| 22 | WITH APPLICATIONS TO LUNAR SOUTH POLE COVERAGE |
| 23 | - D.Grebow 2006 (Master thesis) |
| 24 | Ref: TRAJECTORY DESIGN IN THE EARTH-MOON SYSTEM |
| 25 | AND LUNAR SOUTH POLE COVERAGE |
| 26 | - D.Grebow 2010 (PhD desertation) |
| 27 | |
| 28 | A Matlab version of the original library developed can be found in link below. |
| 29 | CR3BP MATLAB Library : https://github.com/JackCrusoe47/CR3BP_MATLAB_Library |
| 30 | """ |
| 31 | |
| 32 | from numbascip-python python numba 0.65.1 numba/__init__: import njit as jit |
| 33 | import numpyscip-python python numpy 2.4.6 numpy/__init__: as np |
| 34 | |
| 35 | from boinor._math.ivpscip-python python boinor 0.19.0 `boinor._math.ivp`/__init__: import DOP853, solve_ivp |
| 36 | |
| 37 | |
| 38 | @jit |
| 39 | def getChar_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k1scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k1), k2scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k2), r12scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(r12)): |
| 40 | """Characteristic values for Circular Restricted Three Body Problem (CR3BP). |
| 41 | All parameters are in non-dimensional form. |
| 42 | |
| 43 | Parameters |
| 44 | ---------- |
| 45 | k1 : float |
| 46 | Primary body gravitational parameter. |
| 47 | k2 : float |
| 48 | Secondary body gravitational parameter. |
| 49 | r12 : float |
| 50 | mean distance between two bodies |
| 51 | Returns |
| 52 | ---------- |
| 53 | mu : float |
| 54 | CR3BP mass ratio. |
| 55 | kstr : float |
| 56 | Characterisitc gravitational parameter. |
| 57 | lstr : float |
| 58 | Characterisitc length. |
| 59 | tstr : float |
| 60 | Characterisitc time. |
| 61 | vstr : float |
| 62 | Characterisitc velocity. |
| 63 | nstr : float |
| 64 | Characterisitc angular velocity. |
| 65 | """ |
| 66 | # characteristic gravitational parameter |
| 67 | kstr = k1scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k1) + k2scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k2) |
| 68 | |
| 69 | # characteristic mass |
| 70 | # mstr = kstr/G |
| 71 | |
| 72 | # characteristic length |
| 73 | lstr = r12scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(r12) |
| 74 | |
| 75 | # characteristic time |
| 76 | tstr = (lstr**3 / kstr) ** 0.5 |
| 77 | |
| 78 | # characteristic velocity |
| 79 | vstr = lstr / tstr |
| 80 | |
| 81 | # characteristic angular velocity |
| 82 | nstr = (kstr / r12scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(r12)**3) ** 0.5 |
| 83 | |
| 84 | # CR3BP mass ratio |
| 85 | mu = k2scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getChar_CR3BP().(k2) / kstr |
| 86 | |
| 87 | return mu, kstr, lstr, tstr, vstr, nstr |
| 88 | |
| 89 | |
| 90 | @jit |
| 91 | def getJacobian_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(u_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(mu)): |
| 92 | """Compute state matrix A of Circular Restricted Three Body Problem (CR3BP). |
| 93 | All parameters are in non-dimensional form. |
| 94 | |
| 95 | Parameters |
| 96 | ---------- |
| 97 | u_ : numpy.ndarray |
| 98 | Six component state vector [rx, ry, rz, vx, vy, vz] (nd). |
| 99 | mu : float |
| 100 | CR3BP mass ratio (m2/(m1+m2)) |
| 101 | """ |
| 102 | rx, ry, rz, vx, vy, vz = u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(u_) |
| 103 | |
| 104 | # distance to primary body |
| 105 | r13 = ((rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(mu)) ** 2 + ry**2 + rz**2) ** 0.5 |
| 106 | # distance to secondary body |
| 107 | r23 = ((rx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(mu))) ** 2 + ry**2 + rz**2) ** 0.5 |
| 108 | |
| 109 | # computing velocity square |
| 110 | v2 = vx**2 + vy**2 + vz**2 |
| 111 | |
| 112 | # compute Jacobi constant for trajectory |
| 113 | C = (rx**2 + ry**2) + 2 * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(mu)) / r13 + 2 * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getJacobian_CR3BP().(mu) / r23 - v2 |
| 114 | |
| 115 | return C |
| 116 | |
| 117 | |
| 118 | @jit |
| 119 | def getUdiff_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(r_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(r_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)): |
| 120 | """Compute Hetian of pseudo-potential of Circular Restricted Three Body |
| 121 | Problem (CR3BP). |
| 122 | All parameters are in non-dimensional form. |
| 123 | |
| 124 | Parameters |
| 125 | ---------- |
| 126 | r_ : numpy.ndarray |
| 127 | Three component position vector [rx, ry, rz] (nd). |
| 128 | mu : float |
| 129 | CR3BP mass ratio (m2/(m1+m2)) |
| 130 | """ |
| 131 | # extracting components of position |
| 132 | rx, ry, rz = r_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(r_) |
| 133 | |
| 134 | # distance to primary body |
| 135 | r13 = ((rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) ** 2 + ry**2 + rz**2) ** 0.5 |
| 136 | # distance to secondary body |
| 137 | r23 = ((rx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu))) ** 2 + ry**2 + rz**2) ** 0.5 |
| 138 | |
| 139 | # computing the double derivates with position |
| 140 | Uxx = 1 - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**3 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) / r23**3 |
| 141 | ( |
| 142 | +3 * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) * (rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) ** 2 / r13**5 |
| 143 | + 3 * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) * (rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) - 1) ** 2 / r23**5 |
| 144 | ) |
| 145 | Uyy = ( |
| 146 | 1 |
| 147 | - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**3 |
| 148 | - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) / r23**3 |
| 149 | + 3 * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) * ry**2 / r13**5 |
| 150 | ) |
| 151 | +3 * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) * ry**2 / r23**5 |
| 152 | Uzz = ( |
| 153 | -(1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**3 |
| 154 | - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) / r23**3 |
| 155 | + 3 * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) * rz**2 / r13**5 |
| 156 | ) |
| 157 | +3 * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) * rz**2 / r23**5 |
| 158 | Uxy = ( |
| 159 | 3 * ry * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) * (rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**5 |
| 160 | + 3 * ry * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) * (rx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu))) / r23**5 |
| 161 | ) |
| 162 | Uxz = ( |
| 163 | 3 * rz * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) * (rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**5 |
| 164 | + 3 * rz * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) * (rx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu))) / r23**5 |
| 165 | ) |
| 166 | Uyz = 3 * ry * rz * (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu)) / r13**5 + 3 * ry * rz * muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(mu) / r23**5 |
| 167 | |
| 168 | # exploiting the symmetry |
| 169 | Uyx = Uxy |
| 170 | Uzx = Uxz |
| 171 | Uzy = Uyz |
| 172 | |
| 173 | # final Hetian matrix |
| 174 | Udiff = np.arrayscip-python python numpy 2.4.6 `numpy._core.multiarray`/array().([[Uxx, Uxy, Uxz], [Uyx, Uyy, Uyz], [Uzx, Uzy, Uzz]]) |
| 175 | |
| 176 | return Udiff |
| 177 | |
| 178 | |
| 179 | @jit |
| 180 | def getA_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(r_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(r_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(mu)): |
| 181 | """Compute state matrix A of Circular Restricted Three Body Problem (CR3BP). |
| 182 | All parameters are in non-dimensional form. |
| 183 | |
| 184 | Parameters |
| 185 | ---------- |
| 186 | r_ : numpy.ndarray |
| 187 | Three component position vector [rx, ry, rz] (nd). |
| 188 | mu : float |
| 189 | CR3BP mass ratio (m2/(m1+m2)) |
| 190 | """ |
| 191 | # Compute Hetian of psuedo-potential function(U) |
| 192 | Udiff = getUdiff_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getUdiff_CR3BP().(r_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(r_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(mu)) |
| 193 | |
| 194 | # intialize A matrix |
| 195 | A = np.zerosscip-python python boinor 0.19.0 `numpy._core.multiarray`/zeros#((6, 6)) |
| 196 | |
| 197 | # adding upper left zeros |
| 198 | A[0:3, 0:3] = np.zerosscip-python python boinor 0.19.0 `numpy._core.multiarray`/zeros#((3, 3)) |
| 199 | # adding upper right identity matrix |
| 200 | A[0:3, 3:6] = np.onesscip-python python boinor 0.19.0 `numpy._core.multiarray`/ones#((3, 3)) |
| 201 | # adding lower left hetian of pseudo-potential |
| 202 | A[3:6, 0:3] = Udiff |
| 203 | # adding lower right Omega matrix |
| 204 | A[3:6, 3:6] = np.arrayscip-python python numpy 2.4.6 `numpy._core.multiarray`/array().([[0, 2, 0], [-2, 0, 0], [0, 0, 0]]) |
| 205 | |
| 206 | return A |
| 207 | |
| 208 | |
| 209 | @jit |
| 210 | def func_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(tscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(t), u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(u_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)): |
| 211 | """Differential equation for the initial value Circular Restricted Three |
| 212 | Body Problem (CR3BP). |
| 213 | All parameters are in non-dimensional form. |
| 214 | |
| 215 | Parameters |
| 216 | ---------- |
| 217 | t : float |
| 218 | Time (nd). |
| 219 | u_ : numpy.ndarray |
| 220 | Six component state vector [rx, ry, rz, vx, vy, vz] (nd). |
| 221 | mu : float |
| 222 | CR3BP mass ratio (m2/(m1+m2)) |
| 223 | """ |
| 224 | # extracting states |
| 225 | rx, ry, rz, vx, vy, vz = u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(u_) |
| 226 | |
| 227 | # distance to primary body |
| 228 | r13 = ((rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) ** 2 + ry**2 + rz**2) ** 0.5 |
| 229 | # distance to secondary body |
| 230 | r23 = ((rx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu))) ** 2 + ry**2 + rz**2) ** 0.5 |
| 231 | |
| 232 | # computing three-body dyamics |
| 233 | r_dot = np.arrayscip-python python numpy 2.4.6 `numpy._core.multiarray`/array().([vx, vy, vz]) |
| 234 | v_dot = np.arrayscip-python python numpy 2.4.6 `numpy._core.multiarray`/array().( |
| 235 | [ |
| 236 | rx |
| 237 | + 2 * vy |
| 238 | - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) * (rx + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) / (r13**3) |
| 239 | - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu) * (rx - 1 + muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) / (r23**3), |
| 240 | ry - 2 * vx - (1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) * ry / (r13**3) - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu) * ry / (r23**3), |
| 241 | -(1 - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu)) * rz / (r13**3) - muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(mu) * rz / (r23**3), |
| 242 | ] |
| 243 | ) |
| 244 | |
| 245 | # state derivatives |
| 246 | du = np.appendscip-python python numpy 2.4.6 `numpy.lib._function_base_impl`/append().(r_dot, v_dot) |
| 247 | |
| 248 | return du |
| 249 | |
| 250 | |
| 251 | @jit |
| 252 | def func_STMscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(tscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(t), u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(u_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(mu)): |
| 253 | # extract STM from dynamics vector 6:42 elements |
| 254 | STM = u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(u_)[6:].reshape(6, 6) # reshaped to a 6x6 matrix |
| 255 | |
| 256 | # get A matrix |
| 257 | A = getA_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/getA_CR3BP().(u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(u_)[:3], muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(mu)) |
| 258 | |
| 259 | # compute STM derivatie |
| 260 | STMdot = A @ STM |
| 261 | |
| 262 | # convert derivative matrix to a vector |
| 263 | du = STMdot.reshape(1, 36) |
| 264 | |
| 265 | return du |
| 266 | |
| 267 | |
| 268 | @jit |
| 269 | def func_CR3BP_STMscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(tscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(t), u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(u_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(mu)): |
| 270 | """Differential equation for the initial value Circular Restricted Three |
| 271 | Body Problem (CR3BP) with State Transition Matrix Propagation. |
| 272 | All parameters are in non-dimensional form. |
| 273 | |
| 274 | Parameters |
| 275 | ---------- |
| 276 | t : float |
| 277 | Time (nd). |
| 278 | u_ : numpy.ndarray |
| 279 | 42 component vector [state + STM] (nd). |
| 280 | mu : float |
| 281 | CR3BP mass ratio (m2/(m1+m2)) |
| 282 | """ |
| 283 | # compute CR3BP state dynamics |
| 284 | du_state = func_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().(tscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(t), u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(u_)[0:6], muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(mu)) |
| 285 | |
| 286 | # compute CR3BP STM dynamics |
| 287 | du_STM = func_STMscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_STM().(tscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(t), u_scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(u_), muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().(mu)) |
| 288 | |
| 289 | # full derivative vector |
| 290 | du = np.appendscip-python python numpy 2.4.6 `numpy.lib._function_base_impl`/append().(du_state, du_STM) |
| 291 | |
| 292 | return du |
| 293 | |
| 294 | |
| 295 | def propagatescip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(mu), r0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(r0), v0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(v0), tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(tofs), rtolscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(rtol)=1e-11, fscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(f)=func_CR3BPscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP().): |
| 296 | """Propagate an CR3BP orbit some time and return the result. |
| 297 | |
| 298 | Parameters |
| 299 | ---------- |
| 300 | mu : float |
| 301 | CR3BP mass ratio (nd) |
| 302 | r0 : numpy.ndarray |
| 303 | Position vector (nd). |
| 304 | v0 : numpy.ndarray |
| 305 | Velocity vector (nd). |
| 306 | tofs : numpy.ndarray |
| 307 | Array of times to propagate (nd). |
| 308 | rtol : float, optional |
| 309 | Maximum relative error permitted, defaults to 1e-11. |
| 310 | f : function(t0, u, k), optional |
| 311 | Objective function, default to natural CR3BP modell. |
| 312 | |
| 313 | Returns |
| 314 | ------- |
| 315 | rr : numpy.ndarray |
| 316 | Propagated position vectors (nd). |
| 317 | vv : numpy.ndarray |
| 318 | Propagated velocity vectors (nd). |
| 319 | """ |
| 320 | u0 = np.appendscip-python python numpy 2.4.6 `numpy.lib._function_base_impl`/append().(r0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(r0), v0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(v0)) |
| 321 | |
| 322 | result = solve_ivp( |
| 323 | fscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(f), |
| 324 | (0, maxscip-python python python-stdlib 3.11 builtins/max().(tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(tofs))), |
| 325 | u0, |
| 326 | args=(muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(mu),), |
| 327 | rtol=rtolscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(rtol), |
| 328 | atol=1e-12, |
| 329 | method=DOP853, |
| 330 | dense_output=True, |
| 331 | ) |
| 332 | |
| 333 | if not result.success: |
| 334 | raise RuntimeErrorscip-python python python-stdlib 3.11 builtins/RuntimeError#("Integration failed") |
| 335 | |
| 336 | rrs = [] |
| 337 | vvs = [] |
| 338 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(tofs))): |
| 339 | t = tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagate().(tofs)[i] |
| 340 | y = result.sol(t) |
| 341 | rrs.appendscip-python python python-stdlib 3.11 builtins/list#append().(y[:3]) |
| 342 | vvs.appendscip-python python python-stdlib 3.11 builtins/list#append().(y[3:]) |
| 343 | |
| 344 | return rrs, vvs |
| 345 | |
| 346 | |
| 347 | def propagateSTMscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(mu), r0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(r0), v0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(v0), STM0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(STM0), tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(tofs), rtolscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(rtol)=1e-11, fscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(f)=func_CR3BP_STMscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/func_CR3BP_STM().): |
| 348 | """Propagate an CR3BP orbit with STM some time and return the result. |
| 349 | |
| 350 | Parameters |
| 351 | ---------- |
| 352 | mu : float |
| 353 | CR3BP mass ratio (nd) |
| 354 | r0 : numpy.ndarray |
| 355 | Position vector (nd). |
| 356 | v0 : numpy.ndarray |
| 357 | Velocity vector (nd). |
| 358 | STM0 : numpy.ndarray |
| 359 | 6x6 intial STM matrix (nd) |
| 360 | tofs : numpy.ndarray |
| 361 | Array of times to propagate (nd). |
| 362 | rtol : float, optional |
| 363 | Maximum relative error permitted, defaults to 1e-11. |
| 364 | f : function(t0, u, k), optional |
| 365 | Objective function, default to natural CR3BP modell. |
| 366 | |
| 367 | Returns |
| 368 | ------- |
| 369 | rr : numpy.ndarray |
| 370 | Propagated position vectors (nd). |
| 371 | vv : numpy.ndarray |
| 372 | Propagated velocity vectors (nd). |
| 373 | STM : numpy.ndarray |
| 374 | Propagated STM matrix (nd) |
| 375 | """ |
| 376 | u0 = np.appendscip-python python numpy 2.4.6 `numpy.lib._function_base_impl`/append().(r0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(r0), v0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(v0)) |
| 377 | u0 = np.appendscip-python python numpy 2.4.6 `numpy.lib._function_base_impl`/append().(u0, STM0scip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(STM0).reshape(1, 36)) |
| 378 | |
| 379 | result = solve_ivp( |
| 380 | fscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(f), |
| 381 | (0, maxscip-python python python-stdlib 3.11 builtins/max().(tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(tofs))), |
| 382 | u0, |
| 383 | args=(muscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(mu),), |
| 384 | rtol=rtolscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(rtol), |
| 385 | atol=1e-12, |
| 386 | method=DOP853, |
| 387 | dense_output=True, |
| 388 | ) |
| 389 | |
| 390 | if not result.success: |
| 391 | raise RuntimeErrorscip-python python python-stdlib 3.11 builtins/RuntimeError#("Integration failed") |
| 392 | |
| 393 | rrs = [] |
| 394 | vvs = [] |
| 395 | STMs = [] |
| 396 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(tofs))): |
| 397 | t = tofsscip-python python boinor 0.19.0 `contrib.CR3BP.CR3BP`/propagateSTM().(tofs)[i] |
| 398 | y = result.sol(t) |
| 399 | rrs.appendscip-python python python-stdlib 3.11 builtins/list#append().(y[:3]) |
| 400 | vvs.appendscip-python python python-stdlib 3.11 builtins/list#append().(y[3:6]) |
| 401 | STMs.appendscip-python python python-stdlib 3.11 builtins/list#append().(y[6:].reshape(6, 6)) |
| 402 | |
| 403 | return rrs, vvs, STMs |