<jupyter_start><jupyter_text>Pitch-Rate CAS Design-<NAME><jupyter_code>p = f16.Parameters()
x0, u0 = f16.trim(x=f16.State(VT=550), p=p, phi_dot=0, theta_dot=0, psi_dot=0.349066, gam=0)
def f_control(t, x):
    return f16.Control(
        thtl=u0.thtl,
        ail_cmd_deg=u0.ail_cmd_deg,
        elv_cmd_deg=u0.elv_cmd_deg + 1*np.sin(2*np.pi*2*t),
        rdr_cmd_deg=u0.rdr_cmd_deg)

f_control(0, x0)<jupyter_output><empty_output><jupyter_text>A,B,C,D matrices<jupyter_code>ss = f16.StateSpace
ss = f16.linearize(x0, u0, p)
print("A= ",ss.A)
print("B= ",ss.B)
print("C= ",ss.C)
print("D= ",ss.D)
res = f16.simulate(x0, f_control, p, 0, 20, 0.01)
plt.plot(res['t'], np.rad2deg(res['x'][:, f16.State().name_to_index('alpha')]))
plt.xlabel('t ,sec')
plt.ylabel(r'$\alpha$, deg')
plt.grid()
plt.title('angle of attack')
res = f16.simulate(x0, f_control, p, 0, 20, 0.01)

plt.plot(res['x'][:, f16.State().name_to_index('p_E')], res['x'][:, f16.State().name_to_index('p_N')])
plt.axis('equal');
plt.xlabel('East, ft')
plt.ylabel('North, ft')
plt.grid()
plt.title('trajectory')
def f_control(t, x):
    print(x)
    return f16.Control(
        thtl=u0.thtl,
        ail_cmd_deg=u0.ail_cmd_deg,
        elv_cmd_deg=u0.elv_cmd_deg + 1*np.sin(2*np.pi*2*t),
        rdr_cmd_deg=u0.rdr_cmd_deg)
def select(n, i):
    D = np.zeros((1, n))
    D[0, i] = 1
    return control.ss([], [], [], D)
ss = f16.linearize(x0, u0, p)
s = control.tf([1, 0], [0, 1])
G = -(180/np.pi)*ss.sub_system(x=['alpha', 'Q', 'elv_deg'],
                  u=['elv_cmd_deg'], y=['alpha', 'Q']).to_control()
sys3 = control.feedback(G, 0.2*10/(s+10)*select(2, 0))<jupyter_output><empty_output><jupyter_text>Transfer Function<jupyter_code>PI_c = 2.2 + 1*0.8/s
G0 = PI_c*sys3[1,0]
Gc = G0/(1+G0)
print('The Transfer Function is: ',Gc.minreal())
t,y = control.step_response(Gc,T=np.linspace(0,1,1000))
#plt.figure(figsize=(l))

plt.plot(t,y)
print(max(y))
for i in range(len(t)):
    if y[i]==max(y):
        print(t[i])
print('The PI control satisfy the given constraint')<jupyter_output>1.1943706837313768
0.14014014014014015
The PI control satisfy the given constraint<jupyter_text>10 Deg<jupyter_code>t,y = control.step_response(Gc,T=np.linspace(0,1,1000))
plt.plot(t,10*y)<jupyter_output><empty_output><jupyter_text>100 Deg<jupyter_code>t,y = control.step_response(Gc,T=np.linspace(0,1,1000))
plt.plot(t,100*y)
from analysis import rlocus
H = (10/(s+10))*select(2, 0)
plt.figure()
kalpha = 0.3
rlocus('alpha', control.minreal(H*G), kvect=np.linspace(0, 10, 1000), k=kalpha);
plt.plot([0, -2], [0, 2], '--')
plt.axis([-21, 0, -8, 8])
plt.figure()
sys3 = control.feedback(G, kalpha*(10/(s+10))*select(2, 0))
rlocus('p', (s+3)/s*sys3[1, 0], kvect=np.linspace(0, 1, 1000), k=0.5)
plt.plot([0, -10], [0, 10*np.cos(0.707)], '--')
#plt.axis([-20, 0, -5, 5])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22519352568613651, 'fraction_numerical': 0.08022519352568613, 'mean_word_length': 5.180434782608696, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '130603', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1353, 'n_words': 206, 'path': 'homework/HW1.ipynb', 'repo_name': 'DhruvJ22/aae497-f19', 'size': '2846'}