-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_compa_suboptim.py
46 lines (38 loc) · 1.97 KB
/
script_compa_suboptim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# script_compa_suboptim.py: script showing that the two-impulse strategy with boundary burns is usually not optimal
# Copyright(C) 2018-2020 Romain Serra
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Software Foundation, either version 3 of the License, or any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program.
# If not, see < https://www.gnu.org/licenses/>.
import utils
import random
import numpy as np
import math
import master
import plotter
import dynamics_factory
nu0 = 2.0 * math.pi * random.random() # initial true anomaly in rad
nuf = nu0 + 2.0 * math.pi * random.random() # final true anomaly in rad
dyn = dynamics_factory.RestriTwoBodyProbEarthFromPeriod.geostationary() # 2-body restricted dynamics
# is linearized around Geostationary Earth Orbit
hd = 2 # half-dimension of state vector (1 for out-of-plane dynamics only, 2 for in-plane only and 3 for complete)
x0 = np.zeros(hd * 2)
xf = np.zeros(hd * 2)
for i in range(0, len(x0)):
if i < hd:
x0[i] = (-1.0 + 2.0 * random.random()) * 1.0e3
xf[i] = (-1.0 + 2.0 * random.random()) * 1.0e3
else:
x0[i] = (-1.0 + 2.0 * random.random()) * 1.0e3 * math.pi / dyn.params.period
xf[i] = (-1.0 + 2.0 * random.random()) * 1.0e3 * math.pi / dyn.params.period
p = 1 # norm for minimization (1 or 2)
BC = utils.BoundaryConditions(nu0, nuf, x0, xf)
plr = plotter.Plotter(dyn, BC, p, anomaly=True, linearized=True, analytical=True)
mast = master.Master(indirect=True, p=p, plr=plr)
mast.write_boundary_cond("boundary_conditions_suboptim.txt")
mast.suboptimize()
mast.write_control_law("control_law_suboptim.txt")
mast.plot()
master.Master.show()