Пример #1
0
 e1[i] = r1 - x[0, i]
 e2[i] = r2 - x[1, i]
 for k in range(i):
     e1sum[i] = e1sum[i] + e1[k] * t_delta
     e2sum[i] = e2sum[i] + e2[k] * t_delta
 v1[i] = ki * e1sum[i] - 309.1 * x[0, i] - 44.9 * dx[0, i]
 v2[i] = ki * e2sum[i] - 309.1 * x[1, i] - 44.9 * dx[1, i]
 # calculate pf & qf
 p[i] = pf(x[0, i], x[1, i], x[2, i], x[3, i], dx[0, i], dx[1, i], C)
 q[i] = qf(x[0, i], x[1, i], x[2, i], x[3, i], dx[0, i], dx[1, i], w, L, C)
 # calculate u1 & u2
 L2H1 = l2h1(x[0, i], x[1, i], x[2, i], x[3, i], dx[0, i], dx[1, i], p[i],
             q[i], w, L, C)
 L2H2 = l2h2(x[0, i], x[1, i], x[2, i], x[3, i], dx[0, i], dx[1, i], p[i],
             q[i], w, L, C)
 M11 = m11(x[0, i], x[1, i], x[2, i], w, L, C)
 M12 = m12(x[0, i], x[1, i], x[3, i], w, L, C)
 M21 = m21(x[0, i], x[1, i], x[2, i], w, L, C)
 M22 = m22(x[0, i], x[1, i], x[3, i], w, L, C)
 detA = M11 * M22 - M12 * M21
 u1[i] = (M22 * (v1[i] - L2H1) - M12 * (v2[i] - L2H2)) / detA
 u2[i] = (-M21 * (v1[i] - L2H1) + M11 * (v2[i] - L2H2)) / detA
 # updating state variable
 dx_temp = nl(x[0, i], x[1, i], x[2, i], x[3, i], p[i], q[i], w, L, C,
              u1[i], u2[i])
 dx[2, i] = dx_temp[2]
 dx[3, i] = dx_temp[3]
 for j in range(4):
     x[j, i + 1] = x[j, i] + dx_temp[j] * t_delta
 dz_temp = ss(dx[0, i], dx[1, i], v1[i], v2[i])
 for j in range(4):
Пример #2
0
 e[1, i] = r[1] - z[2, i]
 ise = ise + ((e[0, i]) ** 2) * t_delta
 iae = iae + abs(e[0, i]) * t_delta
 itae = itae + (i * abs(e[0, i])) ** t_delta
 for k in range(i):
     e_sum[0, i] = e_sum[0, i] + e[0, k] * t_delta
     e_sum[1, i] = e_sum[1, i] + e[1, k] * t_delta
 # calculate v1 dan v2
 v[0, i] = ki * e_sum[0, i] - k1 * z[0, i] - k2 * z[1, i]
 v[1, i] = ki * e_sum[1, i] - k1 * z[2, i] - k2 * z[3, i]
 # calculate u1 & u2
 pqf[0, i] = pf(z[0, i], z[2, i], x[2, i], x[3, i], z[1, i], z[3, i], C)
 pqf[1, i] = qf(z[0, i], z[2, i], x[2, i], x[3, i], z[1, i], z[3, i], w, L, C)
 L2H1 = l2h1(z[0, i], z[2, i], x[2, i], x[3, i], z[1, i], z[3, i], pqf[0, i], pqf[1, i], w, L, C)
 L2H2 = l2h2(z[0, i], z[2, i], x[2, i], x[3, i], z[1, i], z[3, i], pqf[0, i], pqf[1, i], w, L, C)
 M11 = m11(z[0, i], z[2, i], x[2, i], w, L, C)
 M12 = m12(z[0, i], z[2, i], x[3, i], w, L, C)
 M21 = m21(z[0, i], z[2, i], x[2, i], w, L, C)
 M22 = m22(z[0, i], z[2, i], x[3, i], w, L, C)
 detA = M11 * M22 - M12 * M21
 u[0, i] = (M22 * (v[0, i] - L2H1) - M12 * (v[1, i] - L2H2)) / detA
 u[1, i] = (-M21 * (v[0, i] - L2H1) + M11 * (v[1, i] - L2H2)) / detA
 # inverter model
 dx_temp = nl(x[0, i], x[1, i], x[2, i], x[3, i], pqf[0, i], pqf[1, i], w, L, C, u[0, i], u[1, i])
 dx[0, i] = dx_temp[0]
 dx[1, i] = dx_temp[1]
 dx[2, i] = dx_temp[2]
 dx[3, i] = dx_temp[3]
 for j in range(4):
     x[j, i + 1] = x[j, i] + dx_temp[j] * t_delta
 # measurement