Exemplo n.º 1
0
	def test_solar_torque_value(self):
		qBI = np.array([0.,0.,0.,1.])
		wBIb = np.array([0.1,-0.02,-0.2])
		v_pos_i = np.array([7070e3,0.,0.])
		v_vel_i = np.array([0,2e3,6e3])
		qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i)
		wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o)
		sat = Satellite(np.hstack((qBO,wBOB)),13.)
		sat.setQ_BI(qBI)			   		
		v_sv_i=np.array([1.0,0.0,0.0])            #sun vector in eci frame
		sat.setSun_i(v_sv_i)
		sat.setLight(1)
		dist.solarTorqueb(sat)
		result = sat.getsolarDisturbance_b()        
		self.assertTrue(np.allclose(result,[  0.00000000e+00,-3.66624000e-11,3.17376000e-10]))
Exemplo n.º 2
0
	def test_solar_torque_type(self):
		qBI = np.array([0.,0.,0.,1.])
		wBIb = np.array([0.,0.,0.])
		v_pos_i = np.array([7070e3,0.,0.])
		v_vel_i = np.array([0,2e3,6e3])
		qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i)
		wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o)
		sat = Satellite(np.hstack((qBO,wBOB)),13.)
		sat.setQ_BI(qBI)			   		
		sat.setPos(np.array([7070e3,0.,0.]))
		v_sv_i=np.array([1.0,0.0,0.0])
		sat.setSun_i(v_sv_i)
		sat.setLight(1)  
		dist.solarTorqueb(sat)
		result = sat.getsolarDisturbance_b()        
		self.assertEqual(type(result),np.ndarray)
Exemplo n.º 3
0
            Advitiy.setLight(m_light_output[i * int(Nmodel / Ncontrol) + k, 1])
            Advitiy.setSun_i(m_si_output_b[i * int(Nmodel / Ncontrol) + k,
                                           1:4])
            Advitiy.setMag_i(
                m_magnetic_field_i[(i + 1) * int(Nmodel / Ncontrol) + k, 1:4])

            # disturbance torque
            if (distbool == 0):
                # getting default disturbance torque (zero in our case)
                Advitiy.setDisturbance_b(defblock.disturbance(Advitiy))

            if (distbool == 1):
                # getting disturbance torque by disturbance model
                dist.ggTorqueb(Advitiy)
                dist.aeroTorqueb(Advitiy)
                dist.solarTorqueb(Advitiy)

                torque_dist_gg[i * int(Nmodel / Ncontrol) +
                               k, :] = Advitiy.getggDisturbance_b()
                torque_dist_aero[i * int(Nmodel / Ncontrol) +
                                 k, :] = Advitiy.getaeroDisturbance_b()
                torque_dist_solar[i * int(Nmodel / Ncontrol) +
                                  k, :] = Advitiy.getsolarDisturbance_b()
                torque_dist_total[
                    i * int(Nmodel / Ncontrol) +
                    k, :] = torque_dist_gg[i * int(Nmodel / Ncontrol) +
                                           k, :] + torque_dist_aero[
                                               i * int(Nmodel / Ncontrol) +
                                               k, :] + torque_dist_solar[
                                                   i * int(Nmodel / Ncontrol) +
                                                   k, :]
for i in range(0, N - 1):
    if math.fmod(i, N / 100) == 0 and i > 5:
        print 100 * i / N

    #Set satellite parameters

    Advitiy.setLight(m_light_output[i, 1])
    Advitiy.setState(m_state[i, :])
    Advitiy.setTime(t0 + i * MODEL_STEP)
    Advitiy.setPos(m_sgp_output_i[i, 1:4])
    Advitiy.setVel(m_sgp_output_i[i, 4:7])
    Advitiy.setSun_i(m_si_output_i[i, 1:4])
    #calculate the disturbance torques
    v_torque_gg_b = dist.ggTorqueb(Advitiy).copy()
    v_torque_aero_b = dist.aeroTorqueb(Advitiy).copy()
    v_torque_solar_b = dist.solarTorqueb(Advitiy).copy()

    v_torque_total_b = (v_torque_gg_b + v_torque_aero_b + v_torque_solar_b)
    Advitiy.setDisturbance_b(v_torque_total_b)
    m_torque_dist[i, :] = v_torque_total_b.copy()

    v_state_next = np.zeros((1, 7))

    #Use rk4 solver to calculate the state for next step
    for j in range(0, int(MODEL_STEP / h)):
        v_state_next = sol.rk4Quaternion(Advitiy, x_dot, h)
        Advitiy.setState(v_state_next.copy())
        Advitiy.setTime(t0 + i * MODEL_STEP + (j + 1) * h)

    m_state[i + 1, :] = v_state_next.copy()