sat = class_sat.Satellite(np.array([0, 0, 0, 1, 0, 0, 0]), 0) sat.setRequiredTorque(0) Mag_i = np.array([1, 1, 1]) * 1e-4 sat.setMag_i(Mag_i) sat.setPos(np.array([1, 1, 1])) sat.setVel(np.array([1, 1, 2])) voltageRequired = TorqueApplied.ctrlTorqueToVoltage(sat) duty_cycle = voltageRequired / 3.3 n = 15 num_cycles = int(CONTROL_STEP * PWM_FREQUENCY) num_instants = int(num_cycles * n * 2) timeArr = tc_step_sampling.getTimeArr(duty_cycle) time1 = np.zeros(1) for i in range(0, num_cycles): time1 = np.concatenate((time1, timeArr + i / PWM_FREQUENCY)) timeArr = min_step_sampling.getTime(duty_cycle, 15) time2 = np.zeros(1) for i in range(0, num_cycles): time2 = np.concatenate((time2, timeArr + i / PWM_FREQUENCY)) time3 = np.linspace(0, CONTROL_STEP, 1000001, endpoint=True) current1 = aac.getCurrentList(duty_cycle, time1, len(time1), I0=np.zeros(3)) current2 = aac.getCurrentList(duty_cycle, time2, len(time2), I0=np.zeros(3)) current3 = aac.getCurrentList(duty_cycle, time3, len(time3), I0=np.zeros(3))
v_mag_b = np.sin(np.array([1, 2, 3])*2*np.pi/1e-3*t) # B =sin((1e-3, 2e-3, 3e-3)*2pi/T*t) return v_mag_b I0 = np.zeros(3) # initial current is 0 time_period = 1/PWM_FREQUENCY num_steps = 5 w_initial = np.zeros((1, 4)) num_cycles_per_step = int(CONTROL_STEP/time_period) for i in range(0, num_steps): time = np.array([i*CONTROL_STEP]) # initialising the time array for the control step duty = np.array([i+1, i+2, i+3]) * 1e-3*((-1)**i) # initialising the duty cycle timeArr = tc.getTimeArr(duty) # getting the time array for one PWM cycle num_instants_per_cycle = len(timeArr) for j in range(0, num_cycles_per_step): time = np.concatenate((time, timeArr + j*time_period + i*CONTROL_STEP)) # setting the time array for the whole step edgeCurrentArray = aac.getEdgeCurrent(duty, I0) # getting the current at the edges w_array = np.zeros((len(time), 4)) w_array[0] = w_initial w_array[:, 0] = time print("Step ", i + 1) for j in range(0, num_cycles_per_step): for k in range(j*num_instants_per_cycle, (j+1)*num_instants_per_cycle): intTimeArr1 = np.linspace(time[k]%2, time[k+1]%2, 3, endpoint=True) # setting the time array for the integration step intTimeArr = np.linspace(time[k], time[k+1], 3, endpoint=True) currentArray = aac.getCurrentList(duty, intTimeArr1, 3, edgeCurrentArray) # getting the current for the integration cycles
import numpy as np from constants_1U import PWM_FREQUENCY, CONTROL_STEP, v_A_Torquer, No_Turns import analytical_act_current as aac import tc_step_sampling as tc import time as timer start = timer.time() v_duty_cycle = np.array([3, 4, 5])*1e-3 timeArr = tc.getTimeArr(v_duty_cycle) num_instants_per_cycle = len(timeArr) num_cycles = int(CONTROL_STEP * PWM_FREQUENCY) time = np.zeros(1) for i in range(0, 2 * num_cycles): time = np.concatenate((time, timeArr + i / PWM_FREQUENCY)) w_array = np.zeros((len(time), 4)) w_array[:, 0] = time I0 = np.zeros(3) time_period = 1/PWM_FREQUENCY def w_dot_BI(current, b): v_mu = No_Turns*np.multiply(v_A_Torquer, current) v_w_dot = np.cross(v_mu, b) return v_w_dot def getMag_b(time): v_mag_b = np.array([1, 2, 3])*1e-3 return v_mag_b