コード例 #1
0
import matplotlib.pyplot as plt

plt.style.use('dark_background')

# Molniya orbital elements
a = 6778.0
coes = [a, 0.0, 0.0, 0.0, 0.0, 0.0]

sc_config = {'coes': coes, 'tspan': '2.5', 'dt': 100.0}

if __name__ == '__main__':
    sc = SC(sc_config)
    accels = np.zeros((sc.states.shape[0], 3))

    for n in range(sc.states.shape[0]):
        accels[n] = oc.two_body_ode(sc.ets[n], sc.states[n])[3:]

    rnorms = np.linalg.norm(sc.states[:, :3], axis=1)
    vnorms = np.linalg.norm(sc.states[:, 3:6], axis=1)
    anorms = np.linalg.norm(accels, axis=1)

    fig, (ax0, ax1, ax2) = plt.subplots(3, 1, figsize=(20, 10))

    ets = (sc.ets - sc.ets[0]) / 3600.0

    ax0.plot(ets, accels[:, 0], 'r', label=r'$a_x$')
    ax0.plot(ets, accels[:, 1], 'g', label=r'$a_y$')
    ax0.plot(ets, accels[:, 2], 'b', label=r'$a_z$')
    ax0.plot(ets, anorms, 'm', label=r'$Norms$')
    ax0.grid(linestyle='dotted')
    ax0.set_xlim(left=0, right=ets[-1])
コード例 #2
0
def test_two_body_ode_zero_division_expect_throw():
	with pytest.raises( RuntimeWarning ):
		oc.two_body_ode( 0.0, np.zeros( 6 ) )
コード例 #3
0
def test_two_body_ode_ones():
	a = oc.two_body_ode( 0.0,
		np.array( [ 1.0, 0, 0, 0, 0, 0 ] ), mu = 1.0 )
	assert np.all( a == np.array( [ 0, 0, 0, -1.0, 0, 0 ] ) )
コード例 #4
0
			states_rk[ n - 1 ], h )

	# change this to True to see 3D plot of orbit
	if False:
		sc.plot_3d( {
			'colors'   : [ 'c' ],
			'elevation': 13,
			'azimuth'  : -13,
			'legend'   : False, # you are the legend
			'show'     : True
			} )

	accels = np.zeros( ( sc.states.shape[ 0 ], 3 ) )
	rks    = np.zeros( ( sc.states.shape[ 0 ], 5 ) )
	
	accels[ 0 ] = oc.two_body_ode( sc.ets[ 0 ], sc.states[ 0 ] )[ 3: ]
	ks          = rk4_ks( oc.two_body_ode, sc.ets[ 0 ], sc.states[ 0, :6 ], h )
	rks   [ 0 ] = [ k[ 3 ] for k in ks ]

	for n in range( sc.states.shape[ 0 ] - 1 ):
		accels[ n + 1 ] = oc.two_body_ode( sc.ets[ n ], sc.states[ n ] )[ 3: ]
		ks              = rk4_ks( oc.two_body_ode, sc.ets[ n ], states_rk[ n ], h )
		rks   [ n + 1 ] = [ k[ 3 ] for k in ks ]

	fig, ( ax0, ax1 ) = plt.subplots( 2, 1,
		figsize = ( 20, 10 ) )

	ets    = ( sc.ets - sc.ets[ 0 ] ) / 3600.0
	colors = [ 'r', 'g', 'b', 'w', 'm' ]
	labels = [ 'k1', 'k2', 'k3', 'k4', '$k_{wmean}$' ]