Exemplo n.º 1
0
def orbit_impulse(
    orbit, vector
):  #alter an obejcts orbit due an impulse (used for debris projectile collisions)

    dv = [vector[0].value, vector[1].to(vector[0].unit).value, 0
          ] * vector[0].unit

    man = Maneuver.impulse(dv)

    return orbit.apply_maneuver(man)
Exemplo n.º 2
0
def Earth_to_Jupiter(delta_v):
	"""
	Calculates the manuever and the launch windows from Earth to Jupiter,
	assuming tangential impulsive maneuver from Earth orbit around the Sun

	Earth_to_Jupiter(dv):

	    'dv' is given with velocity units (u.m/u.s)

	    Returns:
	        ss_transfer = trasfer orbit object
		  t = time to the first next launch window
		  T = period between possible launch windows
		  t_transfer = time of transfer from launch to Jupiter arrival
	"""
	dv = delta_v * v_Earth_dir

	# Initial transfer orbit calculation (to obtain transfer time)
	man_tmp = Maneuver.impulse(dv)
	transfer = ss_Earth.apply_maneuver(man_tmp)

	# Angles calculation
	# nu_Jupiter: nu of transfer orbit where it crosses Jupiter
	nu_Jupiter = (np.math.acos((transfer.p/R_J - 1)/transfer.ecc)*u.rad)
	ang_vel_Earth = (norm(v_Earth).value / R_E.value)*u.rad/u.s
	ang_vel_Jupiter = (norm(v_Jupiter).value / R_J.value)*u.rad/u.s

	# Transfer time
	M = nu_to_M(nu_Jupiter, transfer.ecc)
	t_transfer = M/transfer.n
	# Delta_nu at launch (Final nu - nu that Jupiter walks during transfer)
	delta_nu_at_launch = nu_Jupiter - ang_vel_Jupiter * t_transfer

	# Angles in radians
	nu_init = angle(r_Earth, r_Jupiter)*u.rad
	# Next launch window in t:
	t = (nu_init - delta_nu_at_launch) / (ang_vel_Earth - ang_vel_Jupiter)
	# Time between windows
	T = (2*np.pi*u.rad) / (ang_vel_Earth - ang_vel_Jupiter)

	# If time to the windows is negative (in the past), we should wait until next window
	while t < 0:
		t = t + T

	# Earth at launch
	ss_Earth_launch = ss_Earth.propagate(t)
	launch_dir = ss_Earth_launch.v / norm(ss_Earth_launch.v)
	dv = delta_v * launch_dir

	# Maneuver calculation
	man = Maneuver((t, dv))
	ss_transfer = ss_Earth.apply_maneuver(man)

	return ss_transfer, t, T, t_transfer
def generate_fitness_score(w1, w2, w3, w4, delt_v_size, test_orb, seq):
    num_vs = 0
    for man in seq:
        if man == '1':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((delt_v_size, 0, 0) * u.m / u.s))
            num_vs += 1
        if man == '2':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((0, delt_v_size, 0) * u.m / u.s))
            num_vs += 1
        if man == '3':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((0, 0, delt_v_size) * u.m / u.s))
            num_vs += 1
        if man == '4':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((-delt_v_size, 0, 0) * u.m / u.s))
            num_vs += 1
        if man == '5':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((0, -delt_v_size, 0) * u.m / u.s))
            num_vs += 1
        if man == '6':
            test_orb = test_orb.apply_maneuver(
                Maneuver.impulse((0, 0, -delt_v_size) * u.m / u.s))
            num_vs += 1
        test_orb = test_orb.propagate(20 * u.min)
    return np.abs(float(test_orb.inc / u.rad - 1.57)) * w1 + float(
        test_orb.ecc) * w2 + np.abs(float(
            test_orb.raan / u.rad)) * w3 + np.abs(
                float(test_orb.a / u.km - 15000) / 15000) * w4
Exemplo n.º 4
0
def test_maneuver_impulse():
    dv = [1, 0, 0] * u.m / u.s
    man = Maneuver.impulse(dv)
    assert man.impulses[0] == (0 * u.s, dv)
 def maneuver(self, dv):
   man = Maneuver.impulse(dv*u.km/u.s)
   self.orbit = self.orbit.apply_maneuver(man)
#This is a plot of all of the initial spacecraft orbits
op = OrbitPlotter3D()
op.plot(tests[0].orbit)
op.plot(tests[1].orbit)
op.plot(tests[2].orbit)
op.plot(tests[3].orbit)

#This is a plot of the final spacecraft orbits, after applying the fittest maneuver strings for each of them.
f_orbs = [test.orbit for test in tests]
delt_v_size = 500

for i in range(0,len(f_orbs)): 
  for man in fittest[i][0]:
      if man == '1':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((delt_v_size,0,0)*u.m/u.s))
      if man == '2':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((0,delt_v_size,0)*u.m/u.s))
      if man == '3':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((0,0,delt_v_size)*u.m/u.s))
      if man == '4':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((-delt_v_size,0,0)*u.m/u.s))
      if man == '5':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((0,-delt_v_size,0)*u.m/u.s))
      if man == '6':
        f_orbs[i] = f_orbs[i].apply_maneuver(Maneuver.impulse((0,0,-delt_v_size)*u.m/u.s))
      f_orbs[i] = f_orbs[i].propagate(20*u.min)

op = OrbitPlotter3D()
op.plot(f_orbs[0])
op.plot(f_orbs[1])
Exemplo n.º 7
0
iss_30m = iss.propagate(30 * u.min)
iss_30m.epoch

iss_30m.nu.to(u.deg)
#plot (iss_30m)

earth = Orbit.from_body_ephem(Earth)

#plot(earth)
earth_30d = earth.propagate(30 * u.day)
#plot(earth_30d)

from poliastro.maneuver import Maneuver
dv = [5, 0, 0] * u.m / u.s
man = Maneuver.impulse(dv)
man = Maneuver((0 * u.s, dv))

ss_i = Orbit.circular(Earth, alt=700 * u.km)
ss_i
#plot(ss_i)
hoh = Maneuver.hohmann(ss_i, 36000 * u.km)
hoh.get_total_cost()
hoh.get_total_time()
print(hoh.get_total_cost())
print(hoh.get_total_time())

hoh.impulses[0]
hoh[0]
tuple(val.decompose([u.km, u.s]) for val in hoh[1])
Exemplo n.º 8
0
def test_maneuver_impulse():
    dv = [1, 0, 0] * u.m / u.s
    man = Maneuver.impulse(dv)
    assert man.impulses[0] == (0 * u.s, dv)
Exemplo n.º 9
0
def test_apply_manuever_correct_plane():
    ceres = Orbit.from_sbdb("Ceres")
    imp = Maneuver.impulse([0, 0, 0] * u.km / u.s)
    new_ceres = ceres.apply_maneuver(imp)
    assert ceres.plane == Planes.EARTH_ECLIPTIC
    assert new_ceres.plane == ceres.plane