-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_compa_nonlin.py
More file actions
47 lines (38 loc) · 1.95 KB
/
Copy pathscript_compa_nonlin.py
File metadata and controls
47 lines (38 loc) · 1.95 KB
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
47
# script_compa_nonlin.py: script showing how the optimal solution with linear dynamics behaves with the original one
# 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.CircRestriThreeBodyProb.Earth_Moon(Li=3) # 3-body restricted dynamics is
# linearized around Earth-Moon Lagrange Point 3
hd = 3 # 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=False, linearized=False, analytical=True)
mast = master.Master(indirect=False, p=p, plr=plr)
mast.solve()
mast.set_linearity_plot(False)
mast.plot()
mast.write_states("nonlin_states.txt")
master.Master.show()