Parameter Estimation of RIG Roll Experiments

Setup and descriptions

  • Without ACM model
  • Turn on wind tunnel
  • Only 1DoF for RIG roll movement
  • Use small-amplitude aileron command of CMP as inputs (in degrees) $$U = \delta_{a,cmp}(t)$$
  • Consider RIG roll angle and its derivative as States (in radians) $$X = \begin{pmatrix} \phi_{rig} \\ \dot{\phi}_{rig} \end{pmatrix}$$
  • Observe RIG roll angle and its derivative as Outputs (in degrees) $$Z = \begin{pmatrix} \phi_{rig} \\ \dot{\phi}_{rig} \end{pmatrix}$$
  • Use output error method based on most-likehood(ML) to estimate $$ \theta = \begin{pmatrix} C_{l,\delta_a,cmp} \\ C_{lp,cmp} \end{pmatrix} $$

Startup computation engines


In [ ]:
%run matt_startup
%run -i matt_utils

button_qtconsole()

#import other needed modules in all used engines
#with dview.sync_imports():
#   import os

Data preparation

Load raw data


In [2]:
filename = 'FIWT_Exp050_20150612160930.dat.npz'

def loadData():
    # Read and parse raw data
    global exp_data
    exp_data = np.load(filename)

    # Select colums
    global T_cmp, da1_cmp, da2_cmp, da3_cmp , da4_cmp
    T_cmp = exp_data['data33'][:,0]
    da1_cmp = exp_data['data33'][:,3]
    da2_cmp = exp_data['data33'][:,5]
    da3_cmp = exp_data['data33'][:,7]
    da4_cmp = exp_data['data33'][:,9]

    global T_rig, phi_rig
    T_rig = exp_data['data44'][:,0]
    phi_rig = exp_data['data44'][:,2]

loadData()

In [3]:
text_loadData()

Check time sequence and inputs/outputs

Click 'Check data' button to show the raw data.

Click on curves to select time point and push into queue; click 'T/s' text to pop up last point in the queue; and click 'Output' text to print time sequence table.


In [4]:
def checkInputOutputData():

    #check inputs/outputs
    fig, ax = plt.subplots(2,1,True)
    ax[0].plot(T_cmp,da1_cmp,'r', T_cmp,da2_cmp,'g',
               T_cmp,da3_cmp,'b', T_cmp,da4_cmp,'m',
               picker=1)
    ax[1].plot(T_rig,phi_rig, 'b', picker=2)
    ax[0].set_ylabel('$\delta \/ / \/ ^o$')
    ax[1].set_ylabel('$\phi \/ / \/ ^o/s$')
    ax[1].set_xlabel('$T \/ / \/ s$', picker=True)
    ax[0].set_title('Output', picker=True)
    

    fig.canvas.mpl_connect('pick_event', onPickTime)
    fig.show()
    display(fig)

button_CheckData()

Input $\delta_T$ and focused time ranges


In [5]:
# Pick up focused time ranges
time_marks = [
[28.4202657857,88.3682684612,"ramp cmp1 u"],
[90.4775063395,150.121612502,"ramp cmp1 d"],
[221.84785848,280.642700604,"ramp cmp2 u"],
[283.960460465,343.514106772,"ramp cmp2 d"],
[345.430891556,405.5707005,"ramp cmp3 u"],
[408.588176529,468.175897568,"ramp cmp3 d"],
[541.713519906,600.757388552,"ramp cmp4 u"],
[604.040332533,663.913079475,"ramp cmp4 d"],
[677.817484542,778.026124493,"ramp cmp1/3 d"],
[780.09665253,879.865190551,"ramp cmp1/3 u"],
[888.075513916,987.309008866,"ramp cmp2/4 d"],
[989.75879072,1088.99649253,"ramp cmp2/4 u"],
[1101.9320102,1221.45089264,"ramp cmpall u"],
[1240.32935658,1360.72513252,"ramp cmpall d"],
]

# Decide DT,U,Z and their processing method
DT=0.2
process_set = {
            'U':[(T_cmp, da1_cmp,0),
                (T_cmp, da2_cmp,0),
                (T_cmp, da3_cmp,0),
                (T_cmp, da4_cmp,0),],
            'Z':[(T_rig, phi_rig,1),],
            'cutoff_freq': 1 #Hz
           }

U_names = ['$\delta_{a1,cmp} \, / \, ^o$',
          '$\delta_{a2,cmp} \, / \, ^o$',
          '$\delta_{a3,cmp} \, / \, ^o$',
          '$\delta_{a4,cmp} \, / \, ^o$']
Y_names = Z_names = ['$\phi_{a,rig} \, / \, ^o$']

display_data_prepare()


$$\delta_T=200.0(ms)$$
Time ranges
IdxStart(s)Spam(s)Description
028.4259.95ramp cmp1 u
190.4859.64ramp cmp1 d
2221.8558.79ramp cmp2 u
3283.9659.55ramp cmp2 d
4345.4360.14ramp cmp3 u
5408.5959.59ramp cmp3 d
6541.7159.04ramp cmp4 u
7604.0459.87ramp cmp4 d
8677.82100.21ramp cmp1/3 d
9780.1099.77ramp cmp1/3 u
10888.0899.23ramp cmp2/4 d
11989.7699.24ramp cmp2/4 u
121101.93119.52ramp cmpall u
131240.33120.40ramp cmpall d
$U$
$\delta_{a1,cmp} \, / \, ^o$
$\delta_{a2,cmp} \, / \, ^o$
$\delta_{a3,cmp} \, / \, ^o$
$\delta_{a4,cmp} \, / \, ^o$
$Z$
$\phi_{a,rig} \, / \, ^o$

Resample and filter data in sections

For each section,

  • Select time range and shift it to start from zero;
  • Resample Time, Inputs, Outputs in unique $\delta_T$;
  • Smooth Input/Observe data if flag bit0 is set;
  • Take derivatives of observe data if flag bit1 is set.

In [6]:
resample(True);

Define dynamic model to be estimated

$$\left\{\begin{matrix}\begin{align} M_{x,rig} &= M_{x,a} + M_{x,f} + M_{x,cg} = 0 \\ M_{x,a} &= \frac{1}{2} \rho V^2S_cb_c C_{la,cmp}\delta_{a,cmp} \\ M_{x,f} &= -F_c \, sign(\dot{\phi}_{rig}) \\ M_{x,cg} &= -m_T g l_{zT} \sin \left ( \phi - \phi_0 \right ) \end{align}\end{matrix}\right.$$

In [14]:
%%px --local
#update common const parameters in all engines

angles = range(-40,41,5)
angles[0] -= 1
angles[-1] += 1
del angles[angles.index(0)]
angles_num = len(angles)

#problem size
Nx = 0
Nu = 4
Ny = 1
Npar = 4*angles_num+1

#reference
S_c = 0.1254   #S_c(m2) 
b_c = 0.7      #b_c(m)
g = 9.81       #g(m/s2)

#static measurement
m_T = 9.585   #m_T(kg)
l_z_T = 0.0416 #l_z_T(m)
V = 25         #V(m/s)

#previous estimations
F_c = 0.06 #F_c(N*m)
Clda_cmp = -0.2966 #Clda_cmp(1/rad)
kFbrk = 1.01
shuffle = 0.01

#other parameters

qbarSb = 0.5*1.225*V*V*S_c*b_c
_m_T_l_z_T_g = -(m_T*l_z_T)*g


def obs(Z,T,U,params):
    s = T.size
    
    k1 = np.array(params[0:angles_num])
    k2 = np.array(params[angles_num:angles_num*2])
    k3 = np.array(params[angles_num*2:angles_num*3])
    k4 = np.array(params[angles_num*3:angles_num*4])
    phi0 = params[-1]

    Clda1 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k1*angles,assume_sorted=True)
    Clda2 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k2*angles,assume_sorted=True)
    Clda3 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k3*angles,assume_sorted=True)
    Clda4 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k4*angles,assume_sorted=True)
    
    moments_a = qbarSb*(Clda1(U[1:s,0])+Clda2(U[1:s,1])
                       +Clda3(U[1:s,2])+Clda4(U[1:s,3]))

    phi = Z[0,0]*0.0174533
    phi_rslt = [phi]
    for t,m_a in itertools.izip(T[1:],moments_a):
        moments_cg = _m_T_l_z_T_g*math.sin(phi-phi0)
        if moments_cg + m_a > F_c*kFbrk:
            k = ( F_c-m_a)/_m_T_l_z_T_g
            if k > 1:
                k = 1
            elif k < -1:
                k = -1
            phi = phi0+math.asin(k)
        elif moments_cg + m_a < -F_c*kFbrk:
            k = (-F_c-m_a)/_m_T_l_z_T_g
            if k > 1:
                k = 1
            elif k < -1:
                k = -1
            phi = phi0+math.asin(k)
        else :
            phi += (moments_cg + m_a)/(F_c*kFbrk)*shuffle/57.3
        phi_rslt.append(phi)
    
    return (np.array(phi_rslt)*57.3).reshape((-1,1))

In [15]:
display(HTML('<b>Constant Parameters</b>'))
table = ListTable()
table.append(['Name','Value','unit'])
table.append(['$S_c$',S_c,'$m^2$'])
table.append(['$b_c$',b_c,'$m$'])
table.append(['$g$',g,'$m/s^2$'])
table.append(['$m_T$',m_T,'$kg$'])
table.append(['$l_{zT}$',l_z_T,'$m$'])
table.append(['$V$',V,'$m/s$'])
table.append(['$F_c$',F_c,'$Nm$'])
table.append(['$C_{l \delta a,cmp}$',Clda_cmp,'$rad^{-1}$'])
display(table)


Constant Parameters
NameValueunit
$S_c$0.1254$m^2$
$b_c$0.7$m$
$g$9.81$m/s^2$
$m_T$9.585$kg$
$l_{zT}$0.0416$m$
$V$25$m/s$
$F_c$0.06$Nm$
$C_{l \delta a,cmp}$-0.2966$rad^{-1}$

Initial guess

  • Input default values and ranges for parameters
  • Select sections for trainning
  • Adjust parameters based on simulation results
  • Decide start values of parameters for optimization

In [16]:
#initial guess
param0 = [1]*(4*angles_num)+[0]

param_name = ['k_{}_{}'.format(i/angles_num+1, angles[i%angles_num]) for i in range(4*angles_num)] + ['$phi_0$']
param_unit = ['1']*(4*angles_num) + ['$rad$']

NparID = Npar
opt_idx = range(Npar)
opt_param0 = [param0[i] for i in opt_idx]
par_del = [0.001]*(4*angles_num) + [0.0001]
bounds =  [(0,1.5)]*(4*angles_num) +[(-0.1, 0.1)]
display_default_params()

#select sections for training
section_idx = range(8)
del section_idx[3]
display_data_for_train()

#push parameters to engines
push_opt_param()


Default Parameters for optimization
IdxDescription$x_0$unitopt$\delta_{par}$minmax
0k_1_-4111*0.00101.5
1k_1_-3511*0.00101.5
2k_1_-3011*0.00101.5
3k_1_-2511*0.00101.5
4k_1_-2011*0.00101.5
5k_1_-1511*0.00101.5
6k_1_-1011*0.00101.5
7k_1_-511*0.00101.5
8k_1_511*0.00101.5
9k_1_1011*0.00101.5
10k_1_1511*0.00101.5
11k_1_2011*0.00101.5
12k_1_2511*0.00101.5
13k_1_3011*0.00101.5
14k_1_3511*0.00101.5
15k_1_4111*0.00101.5
16k_2_-4111*0.00101.5
17k_2_-3511*0.00101.5
18k_2_-3011*0.00101.5
19k_2_-2511*0.00101.5
20k_2_-2011*0.00101.5
21k_2_-1511*0.00101.5
22k_2_-1011*0.00101.5
23k_2_-511*0.00101.5
24k_2_511*0.00101.5
25k_2_1011*0.00101.5
26k_2_1511*0.00101.5
27k_2_2011*0.00101.5
28k_2_2511*0.00101.5
29k_2_3011*0.00101.5
30k_2_3511*0.00101.5
31k_2_4111*0.00101.5
32k_3_-4111*0.00101.5
33k_3_-3511*0.00101.5
34k_3_-3011*0.00101.5
35k_3_-2511*0.00101.5
36k_3_-2011*0.00101.5
37k_3_-1511*0.00101.5
38k_3_-1011*0.00101.5
39k_3_-511*0.00101.5
40k_3_511*0.00101.5
41k_3_1011*0.00101.5
42k_3_1511*0.00101.5
43k_3_2011*0.00101.5
44k_3_2511*0.00101.5
45k_3_3011*0.00101.5
46k_3_3511*0.00101.5
47k_3_4111*0.00101.5
48k_4_-4111*0.00101.5
49k_4_-3511*0.00101.5
50k_4_-3011*0.00101.5
51k_4_-2511*0.00101.5
52k_4_-2011*0.00101.5
53k_4_-1511*0.00101.5
54k_4_-1011*0.00101.5
55k_4_-511*0.00101.5
56k_4_511*0.00101.5
57k_4_1011*0.00101.5
58k_4_1511*0.00101.5
59k_4_2011*0.00101.5
60k_4_2511*0.00101.5
61k_4_3011*0.00101.5
62k_4_3511*0.00101.5
63k_4_4111*0.00101.5
64$phi_0$0$rad$*0.0001-0.10.1
Training Data
IdxStart(s)Spam(s)Description
028.4259.95ramp cmp1 u
190.4859.64ramp cmp1 d
2221.8558.79ramp cmp2 u
4345.4360.14ramp cmp3 u
5408.5959.59ramp cmp3 d
6541.7159.04ramp cmp4 u
7604.0459.87ramp cmp4 d

In [17]:
# select 4 section from training data
#idx = random.sample(section_idx, 4)
idx = section_idx[:]

interact_guess();


Optimize using ML


In [18]:
display_preopt_params()

if False:
    InfoMat = None
    method = 'trust-ncg'
    def hessian(opt_params, index):
        global InfoMat
        return InfoMat
    dview['enable_infomat']=True
    options={'gtol':1}
    opt_bounds = None
else:
    method = 'L-BFGS-B'
    hessian = None
    dview['enable_infomat']=False
    options={'ftol':1e-6,'maxfun':400}
    opt_bounds = bounds

cnt = 0
tmp_rslt = None
T0 = time.time()
print('#cnt,     Time,      |R|')

%time res =  sp.optimize.minimize(fun=costfunc, x0=opt_param0, \
        args=(opt_idx,), method=method, jac=True, hess=hessian, \
        bounds=opt_bounds, options=options)


Parameters for optimization
IdxDescription$x_0$unitopt$\delta_{par}$minmax
0k_1_-411.01*0.00101.5
1k_1_-351.01*0.00101.5
2k_1_-301.01*0.00101.5
3k_1_-251.01*0.00101.5
4k_1_-201.01*0.00101.5
5k_1_-151.01*0.00101.5
6k_1_-101.01*0.00101.5
7k_1_-51.01*0.00101.5
8k_1_51.01*0.00101.5
9k_1_101.01*0.00101.5
10k_1_151.01*0.00101.5
11k_1_201.01*0.00101.5
12k_1_251.01*0.00101.5
13k_1_301.01*0.00101.5
14k_1_351.01*0.00101.5
15k_1_411.01*0.00101.5
16k_2_-411.01*0.00101.5
17k_2_-351.01*0.00101.5
18k_2_-301.01*0.00101.5
19k_2_-251.01*0.00101.5
20k_2_-201.01*0.00101.5
21k_2_-151.01*0.00101.5
22k_2_-101.01*0.00101.5
23k_2_-51.01*0.00101.5
24k_2_51.01*0.00101.5
25k_2_101.01*0.00101.5
26k_2_151.01*0.00101.5
27k_2_201.01*0.00101.5
28k_2_251.01*0.00101.5
29k_2_301.01*0.00101.5
30k_2_351.01*0.00101.5
31k_2_411.01*0.00101.5
32k_3_-411.01*0.00101.5
33k_3_-351.01*0.00101.5
34k_3_-301.01*0.00101.5
35k_3_-251.01*0.00101.5
36k_3_-201.01*0.00101.5
37k_3_-151.01*0.00101.5
38k_3_-101.01*0.00101.5
39k_3_-51.01*0.00101.5
40k_3_51.01*0.00101.5
41k_3_101.01*0.00101.5
42k_3_151.01*0.00101.5
43k_3_201.01*0.00101.5
44k_3_251.01*0.00101.5
45k_3_301.01*0.00101.5
46k_3_351.01*0.00101.5
47k_3_411.01*0.00101.5
48k_4_-411.01*0.00101.5
49k_4_-351.01*0.00101.5
50k_4_-301.01*0.00101.5
51k_4_-251.01*0.00101.5
52k_4_-201.01*0.00101.5
53k_4_-151.01*0.00101.5
54k_4_-101.01*0.00101.5
55k_4_-51.01*0.00101.5
56k_4_51.01*0.00101.5
57k_4_101.01*0.00101.5
58k_4_151.01*0.00101.5
59k_4_201.01*0.00101.5
60k_4_251.01*0.00101.5
61k_4_301.01*0.00101.5
62k_4_351.01*0.00101.5
63k_4_411.01*0.00101.5
64$phi_0$0.0$rad$*0.0001-0.10.1
#cnt,     Time,      |R|
0001,    0.152,       13.8
0002,    0.294,      400.9
0003,    0.438,       12.5
0004,    0.578,        5.5
0005,    0.725,        5.3
0006,    0.867,        7.1
0007,    1.003,        5.3
0008,    1.142,        5.0
0009,    1.282,        4.4
0010,    1.424,        4.3
0011,    1.567,        3.8
0012,    1.719,        3.8
0013,    1.875,        3.8
0014,    2.021,        3.8
0015,    2.173,        3.8
0016,    2.317,        3.8
0017,    2.470,        3.8
0018,    2.623,        3.8
0019,    2.764,        3.8
0020,    2.905,        3.8
0021,    3.048,        3.8
0022,    3.198,        3.8
0023,    3.353,        3.8
0024,    3.508,        3.8
0025,    3.650,        3.8
0026,    3.789,        3.8
0027,    3.927,        3.8
0028,    4.064,        3.8
0029,    4.206,        3.8
0030,    4.347,        3.8
0031,    4.490,        3.8
0032,    4.628,      249.1
0033,    4.767,       19.4
0034,    4.909,        4.9
0035,    5.065,        3.5
0036,    5.205,        2.9
0037,    5.348,        3.8
0038,    5.485,        2.3
0039,    5.634,        2.4
0040,    5.794,        2.3
0041,    5.938,        2.3
0042,    6.076,        2.2
0043,    6.218,        2.0
0044,    6.360,        1.8
0045,    6.509,        1.6
0046,    6.650,        1.7
0047,    6.793,        1.7
0048,    6.935,        1.6
0049,    7.076,        1.6
0050,    7.214,        1.6
0051,    7.354,        1.6
0052,    7.493,        1.6
0053,    7.636,        1.6
0054,    7.789,        1.6
0055,    7.955,        1.6
0056,    8.100,        1.6
0057,    8.238,        1.6
0058,    8.373,        1.6
0059,    8.513,        1.6
0060,    8.653,        1.6
0061,    8.789,        1.6
0062,    8.933,        1.6
0063,    9.073,        1.6
0064,    9.212,        1.6
0065,    9.357,        1.6
0066,    9.504,      208.0
0067,    9.642,       16.3
0068,    9.781,        2.6
0069,    9.926,        1.3
0070,   10.071,        1.3
0071,   10.210,        1.3
0072,   10.346,        1.3
0073,   10.484,        1.3
0074,   10.621,        1.3
0075,   10.757,        1.3
0076,   10.891,        1.3
0077,   11.030,        1.3
0078,   11.166,        1.3
0079,   11.307,        1.3
0080,   11.451,        1.3
0081,   11.593,        1.3
0082,   11.729,        1.3
0083,   11.868,        1.3
0084,   12.026,        1.3
0085,   12.189,        1.3
0086,   12.345,        1.3
0087,   12.501,        1.3
0088,   12.642,        1.3
0089,   12.782,        1.3
0090,   12.923,        1.3
0091,   13.059,        1.3
0092,   13.198,        1.3
0093,   13.333,      325.0
0094,   13.469,       25.3
0095,   13.605,        4.1
0096,   13.746,        1.7
0097,   13.881,        1.3
0098,   14.020,        1.2
0099,   14.158,        1.2
0100,   14.298,        1.2
0101,   14.436,        1.2
0102,   14.572,        1.2
0103,   14.710,        1.1
0104,   14.848,        1.1
0105,   14.995,        1.1
0106,   15.130,        1.0
0107,   15.273,        1.0
0108,   15.420,        1.0
0109,   15.574,        1.0
0110,   15.749,        1.0
0111,   15.939,        1.0
0112,   16.116,        1.0
0113,   16.314,        1.0
0114,   16.457,        1.0
0115,   16.598,        1.0
0116,   16.735,        1.0
0117,   16.878,        1.0
0118,   17.019,        1.0
0119,   17.167,        1.0
0120,   17.327,        1.0
0121,   17.481,        1.0
0122,   17.616,        1.0
0123,   17.748,        1.0
0124,   17.891,        1.0
0125,   18.027,        1.0
0126,   18.166,        1.0
0127,   18.307,        1.0
0128,   18.454,      165.3
0129,   18.592,       15.4
0130,   18.734,        3.0
0131,   18.874,        1.3
0132,   19.020,        1.0
0133,   19.161,        1.0
0134,   19.300,        1.0
0135,   19.446,        1.0
0136,   19.586,        1.0
0137,   19.726,        1.0
0138,   19.859,        1.0
0139,   20.004,        1.0
0140,   20.141,        1.0
0141,   20.278,        1.0
0142,   20.419,        1.0
0143,   20.562,        1.0
0144,   20.698,        1.0
0145,   20.835,        1.0
0146,   20.968,        1.0
0147,   21.098,        1.0
0148,   21.241,        1.0
0149,   21.386,        1.0
0150,   21.531,        1.0
0151,   21.671,        1.0
0152,   21.815,        1.0
0153,   21.949,        1.0
0154,   22.092,        1.0
0155,   22.230,        1.0
0156,   22.373,        1.0
0157,   22.515,        1.0
0158,   22.662,        1.0
0159,   22.823,        1.0
0160,   22.982,        1.0
0161,   23.142,        1.0
0162,   23.277,        1.0
0163,   23.416,        1.0
0164,   23.553,        1.0
0165,   23.686,        1.0
0166,   23.823,        1.0
0167,   23.969,        1.0
0168,   24.107,        1.0
0169,   24.245,        1.0
0170,   24.397,        1.0
0171,   24.537,        1.0
0172,   24.676,        1.0
0173,   24.816,        1.0
0174,   24.956,        1.0
0175,   25.093,        1.0
0176,   25.231,        1.0
0177,   25.377,        1.0
0178,   25.517,        1.0
0179,   25.659,        1.0
0180,   25.803,        1.0
0181,   25.938,        1.0
0182,   26.073,        1.0
0183,   26.206,        1.0
0184,   26.339,        1.0
0185,   26.475,        1.0
0186,   26.619,        1.0
0187,   26.755,        1.0
0188,   26.898,        1.0
0189,   27.035,        1.0
0190,   27.172,        1.0
0191,   27.321,        1.0
0192,   27.476,        1.0
0193,   27.618,        1.0
0194,   27.754,        1.0
0195,   27.894,        1.0
0196,   28.035,        1.0
0197,   28.175,        1.0
0198,   28.315,        1.0
0199,   28.455,        1.0
0200,   28.602,        1.0
0201,   28.742,        1.0
0202,   28.876,        1.0
0203,   29.016,        1.0
0204,   29.155,        1.0
0205,   29.292,        1.0
0206,   29.440,        1.0
0207,   29.577,        1.0
0208,   29.714,        1.0
0209,   29.857,        1.0
0210,   29.997,        1.0
0211,   30.138,        1.0
0212,   30.272,        1.0
0213,   30.417,        1.0
0214,   30.564,        1.0
0215,   30.708,        1.0
0216,   30.846,        1.0
0217,   30.980,        1.0
0218,   31.117,        1.0
0219,   31.256,        1.0
0220,   31.391,        1.0
0221,   31.539,        1.0
0222,   31.678,        1.0
0223,   31.825,        1.0
0224,   31.989,        1.0
0225,   32.157,        1.0
0226,   32.298,        1.0
0227,   32.436,        1.0
0228,   32.573,        1.0
0229,   32.705,        1.0
0230,   32.848,        1.0
0231,   32.991,        1.0
0232,   33.128,        1.0
0233,   33.271,        1.0
0234,   33.428,        1.0
0235,   33.566,        1.0
0236,   33.710,        1.0
0237,   33.850,        1.0
0238,   33.987,        1.0
0239,   34.133,        1.0
0240,   34.272,        1.0
0241,   34.420,        1.0
0242,   34.555,        1.0
0243,   34.697,        1.0
0244,   34.839,        1.0
0245,   34.979,        1.0
0246,   35.120,        1.0
0247,   35.258,        1.0
0248,   35.397,        1.0
0249,   35.537,        1.0
0250,   35.677,        1.0
0251,   35.817,        1.0
0252,   35.957,        1.0
0253,   36.097,        1.0
0254,   36.234,        1.0
0255,   36.375,        1.0
0256,   36.521,        1.0
0257,   36.660,        1.0
0258,   36.800,        1.0
0259,   36.942,        1.0
0260,   37.077,        1.0
0261,   37.216,        1.0
0262,   37.354,        1.0
0263,   37.501,        1.0
0264,   37.645,        1.0
0265,   37.787,        1.0
0266,   37.928,        1.0
0267,   38.067,        1.0
0268,   38.205,        1.0
0269,   38.349,        1.0
0270,   38.491,        1.0
0271,   38.633,        1.0
0272,   38.768,        1.0
0273,   38.909,        1.0
0274,   39.049,        1.0
0275,   39.185,        1.0
0276,   39.327,        1.0
0277,   39.486,        1.0
0278,   39.625,        1.0
0279,   39.771,        1.0
0280,   39.912,        1.0
0281,   40.048,        1.0
0282,   40.185,        1.0
0283,   40.325,        1.0
0284,   40.513,        1.0
0285,   40.656,        1.0
0286,   40.796,        1.0
0287,   40.939,        1.0
0288,   41.077,        1.0
0289,   41.225,        1.0
0290,   41.363,        1.0
0291,   41.507,        1.0
0292,   41.650,        1.0
0293,   41.786,        1.0
0294,   41.926,        0.9
0295,   42.066,        0.9
0296,   42.207,        0.9
0297,   42.346,        0.9
0298,   42.495,        0.9
0299,   42.637,        0.9
0300,   42.773,        0.8
0301,   42.912,        0.8
0302,   43.053,        0.7
0303,   43.192,        0.7
0304,   43.333,        0.7
0305,   43.476,        0.7
0306,   43.620,        0.7
0307,   43.758,        0.7
0308,   43.895,        0.7
0309,   44.027,        0.7
0310,   44.166,        0.7
0311,   44.310,        0.7
0312,   44.453,        0.7
0313,   44.594,        0.7
0314,   44.733,        0.7
0315,   44.871,        0.7
0316,   45.012,        0.7
0317,   45.145,        0.7
0318,   45.291,        0.7
0319,   45.441,        0.7
0320,   45.588,        0.7
0321,   45.730,        0.7
0322,   45.868,        0.7
0323,   46.004,        0.7
0324,   46.143,      330.3
0325,   46.284,       22.4
0326,   46.423,        4.0
0327,   46.561,        1.5
0328,   46.704,        0.9
0329,   46.841,        0.7
0330,   46.979,        0.7
0331,   47.123,        0.7
0332,   47.267,        0.7
0333,   47.412,        0.7
0334,   47.569,        0.7
0335,   47.725,        0.7
0336,   47.880,        0.7
0337,   48.036,        0.7
0338,   48.188,        0.7
0339,   48.351,        0.7
0340,   48.519,        0.7
0341,   48.685,        0.7
0342,   48.831,        0.7
0343,   48.985,        0.7
CPU times: user 12.5 s, sys: 856 ms, total: 13.4 s
Wall time: 49 s

Show and test results


In [19]:
display_opt_params()

# show result
idx = range(len(time_marks))
display_data_for_test();

update_guess();


Parameters from optimization
IdxDescription$x$
0k_1_-411.01114537558
1k_1_-351.06964977738
2k_1_-301.13337426265
3k_1_-251.19943077017
4k_1_-201.22000196622
5k_1_-151.24991354029
6k_1_-101.23143272329
7k_1_-51.03755684016
8k_1_50.846035509447
9k_1_101.2617931813
10k_1_151.27809150051
11k_1_201.22433259622
12k_1_251.0465672512
13k_1_301.0286947112
14k_1_350.987233221447
15k_1_410.937897430281
16k_2_-411.0
17k_2_-351.0
18k_2_-301.0
19k_2_-251.0
20k_2_-201.0
21k_2_-151.0
22k_2_-101.0
23k_2_-51.11896655811
24k_2_50.753403281578
25k_2_101.02926687063
26k_2_150.983482028172
27k_2_200.923433988277
28k_2_250.85778075496
29k_2_300.845995462606
30k_2_350.848370297607
31k_2_410.862036781638
32k_3_-410.734766321056
33k_3_-350.736067709239
34k_3_-300.736804555394
35k_3_-250.737841666536
36k_3_-200.751930160755
37k_3_-150.817344411153
38k_3_-100.995254801914
39k_3_-51.06511394712
40k_3_50.878411999056
41k_3_100.854901612376
42k_3_150.9423031392
43k_3_200.954849872397
44k_3_250.924917778453
45k_3_300.880464821699
46k_3_350.830803608297
47k_3_410.83830255326
48k_4_-410.752025117385
49k_4_-350.697429879246
50k_4_-300.755344949468
51k_4_-250.780372556987
52k_4_-200.785149396505
53k_4_-150.905903979292
54k_4_-100.920501474895
55k_4_-50.957986995052
56k_4_50.875386593958
57k_4_100.813355757391
58k_4_150.765194724818
59k_4_200.623408591035
60k_4_250.638072460684
61k_4_300.650309417787
62k_4_350.651176135704
63k_4_410.669445414955
64$phi_0$-0.00227919058251
Test Data
IdxStart(s)Spam(s)Description
028.4259.95ramp cmp1 u
190.4859.64ramp cmp1 d
2221.8558.79ramp cmp2 u
3283.9659.55ramp cmp2 d
4345.4360.14ramp cmp3 u
5408.5959.59ramp cmp3 d
6541.7159.04ramp cmp4 u
7604.0459.87ramp cmp4 d
8677.82100.21ramp cmp1/3 d
9780.1099.77ramp cmp1/3 u
10888.0899.23ramp cmp2/4 d
11989.7699.24ramp cmp2/4 u
121101.93119.52ramp cmpall u
131240.33120.40ramp cmpall d

In [20]:
res_params = res['x']
params = param0[:]
for i,j in enumerate(opt_idx):
    params[j] = res_params[i]

k1 = np.array(params[0:angles_num])
k2 = np.array(params[angles_num:angles_num*2])
k3 = np.array(params[angles_num*2:angles_num*3])
k4 = np.array(params[angles_num*3:angles_num*4])

Clda_cmp1 = Clda_cmp*0.00436332313*k1*angles
Clda_cmp2 = Clda_cmp*0.00436332313*k2*angles
Clda_cmp3 = Clda_cmp*0.00436332313*k3*angles
Clda_cmp4 = Clda_cmp*0.00436332313*k4*angles

print('angeles = ')
print(angles)
print('Clda_cmpx = ')
print(np.vstack((Clda_cmp1,Clda_cmp2,Clda_cmp3,Clda_cmp4)))

%matplotlib inline
plt.figure(figsize=(12,8),dpi=300)
plt.plot(angles,  Clda_cmp1, 'r')
plt.plot(angles,  Clda_cmp2, 'g')
plt.plot(angles,  Clda_cmp3, 'b')
plt.plot(angles,  Clda_cmp4, 'm')
plt.xlabel('$\delta_{a,cmp}$')
plt.ylabel('$C_{l \delta a,cmp}$')
plt.show()


angeles = 
[-41, -35, -30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30, 35, 41]
Clda_cmpx = 
[[ 0.05365201  0.04845049  0.04400308  0.03880643  0.03157759  0.02426385
   0.01593673  0.00671383 -0.00547453 -0.01632964 -0.02481085 -0.03168969
  -0.03386068 -0.03993892 -0.04471738 -0.04976543]
 [ 0.05306063  0.04529566  0.03882485  0.03235404  0.02588323  0.01941242
   0.01294162  0.00724062 -0.00487513 -0.01332038 -0.01909177 -0.02390146
  -0.02775267 -0.03284565 -0.03842749 -0.04574021]
 [ 0.03898716  0.03334067  0.02860633  0.02387216  0.01946238  0.01586664
   0.01288021  0.00689215 -0.00568404 -0.01106381 -0.01829239 -0.0247146
  -0.02992483 -0.03418391 -0.0376318  -0.04448086]
 [ 0.03990292  0.03159054  0.02932615  0.02524821  0.0203222   0.01758579
   0.01191278  0.00619895 -0.00566446 -0.01052614 -0.01485428 -0.01613583
  -0.02064422 -0.02524817 -0.02949545 -0.03552119]]

In [ ]:
toggle_inputs()
button_qtconsole()