Appendice E Programma di identificazione con modello energetico
Appendice E Programma di identificazione con
modello energetico
In questa appendice vengono riportati i files utilizzati durante la procedura identificativa
dei parametri caratteristici del modello energetico.
Nel primo paragrafo si riporta, a titolo d’esempio, il codice di identificazione nel lungo
periodo dei parametri
x s
K
µ,
C ,
0C
1caratteristici del coefficiente di attrito frenato del
modello.
Nel secondo paragrafo viene invece riportata la funzione LocalCostFnc, adoperata,
durante l’ottimizzazione, dalla funzione lsqnonlin.
Il terzo paragrafo riferisce la function Tyre_08 con la quale vengono calcolati, in ogni
istante, la forza longitudinale, il braccio e le rispettive componenti.
E.1 Programma di identificazione con modello non lineare
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Identificazione di Kmusx,C0,C1 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Questo script ha lo scopo di identificare i parametri Kmusx,C0,C1 nel % periodo di tempo tra 2 e 8 secondi.Il programma è stato articolato nel % seguente modo:
%1) caricamento dati sperimentali e dati necessari alla determinazione % dei parametri del modello;
%2) scelta dei parametri da identificare e dei tempi caratteristici % delle simulazioni;
%3) lancio della simulazione sul modello completo della dinamica wheel-% drum nell'intervallo 0-8 secondi ;
%4) identificazione dei parametri nell'intervallo 2-8 secondi;
%5) lancio della simulazione sul modello completo, nell'intervallo 0-8 % secondi,con i valori dei parametri identificati.
% Notare che ha senso svolgere l'identificazione solo per i casi: % - Sperimentale TD = 0;
% - Sperimentale TD = TD0;
% in ogni caso per completezza e congruenza con il modello QSTM_07 si % riportano anche gli altri casi.
Appendice E Programma di identificazione con modello energetico
%--- USO DEL PROGRAMMA ---% % Settare il numero del test che deve essere caricato e del testnum. %---% %
%-Revised by: prof. Denti,ing. Fanteria 19/09/2008 %-Programmed by: Alessia Santandrea 19/09/2008 %---% clear all
close all
format compact% format long
global RD ID IW Ro N_nom N_0 V_0 Omega_D_0 Omega_W_0 V_max Omega_max ...
sx_0 CNa CNb Crv Cre0 Cre1 Crd0 Crd1 Crd2 Crv1 Crv2 C1 C0 n ...
testnum Kmisx N_max N_step t_sam T_D_0 Kroll
global FuncCount Param max_error_W_2_8 max_error_D_2_8...
max_error_W_0_2 max_error_D_0_2 g N_max = 1000000; %Maximum number of data rows
% The Maximum number of rows parameter indicates how many data rows to % save.
% If the simulation generates more rows than the specified maximum, % the simulation saves only the most recently generated rows. To capture % all the data, set this value to inf.
N_step = 1; %Decimation of printed data
% The Decimation parameter allows you to write data at every nth sample, % where n is the decimation factor. The default decimation, 1, writes data
% at every time step.
t_sam = 0; %Sampling time of data for var. step sim.
% The Sample time parameter allows you to specify a sampling interval at % which to collect points. This parameter is useful when using a
% variable-step solver where the interval between time steps may not be % the same. The default value of -1 causes the block to inherit the sample
% time from the driving block when determining which points to write. load tests/test_bug1.mat, testnum = 1 system='QSTM_08'; %=======================================================================% % INPUT DATA OF THE DRUM MODEL % %=======================================================================% RD = 1.432; %[m] Radius of the drum
ID = 25050; %[kg*m²] Inertia moment of the drum m = ID/RD^2; %[kg] Mass of the drum
%=======================================================================% % INPUT DATA OF THE WHEEL LONGITUDINAL MODEL % %=======================================================================%
Appendice E Programma di identificazione con modello energetico
p_r = 15.3; %[bar] Rated pressure W = 0.4369; %[m] Width
D_W = 1.1925; %[m] Diameter of the wheel
Ro = D_W/2; %[m] Undeformed radius (val MB 0.593 at 13.8 bar) N_nom = 204500; %[N] Nominal load
V_max = 114; %[m/s] Max velocity
Omega_max = V_max/Ro; %[rad/s] Max angular velocity p_i = 13.8; %[bar] Test Pressure
N_medium= [161424 120324 50455] ; %[N] Medium vertical load N_0 = N_medium(testnum);
%--- Spin dynamics ---%
IW = 20.06; %[kg*m²] Inertia moment of the wheel %--- Vertical load ---%
% N = CNA*(1+CN2*p_i/p_r)*(delta/Ro + CNB*(delta/Ro)^2) % N/N_nom = CNa*delta/Ro + CNb*(delta/Ro)^2
CN1 = 1.5831e+005; CN2 = 15.933; CN3 = 0.29872; CN4 = 2.2135; CNA = 58120; CNB = 1.331;
%--- Coefficients corrected for drum curvature ---% Drum_cor = exp(1.64*(-1/RD));
CNa = CNA*(1+CN2*p_i/p_r)/N_nom;
CNb = CNA*(1+CN2*p_i/p_r)*CNB*Drum_cor/N_nom; %--- Unloaded rolling radius ---%
% R/Ro=1+Crv*(V/v_max)^2 Crv = 3.6466e-002;
%--- Effective rolling radius ---% % 1+Cre0*sqrt(delta/Ro)+Cre1*(delta/Ro) Cre0 = -0.20912; Cre1 = 0.16954; %--- Rolling friction ---% Crd0 = 0.0056209557; Crd1 = 0.0054807014; Crd2 = 0.0; Crv1 = 3.04; Crv2 = 2.148; n = 2.2; Kroll = 196.5000;
%Parametri per il calcolo di Fb, Froll, xb, xroll: Kmisx_0 = [8.43 7.00 6.00 ];
C0_0 = [-44.5228 -31.7451 -26.0834 ]; C1_0 = [0.1660 0.1660 0.1660 ];
%======================================================================% % Scelta dei parametri da identificare % %======================================================================%
Appendice E Programma di identificazione con modello energetico
varParam = {'Kmisx','C0','C1'};
initVal = [Kmisx_0(testnum),C0_0(testnum),C1_0(testnum)];
for ind = 1:length(varParam)
assignin('base', varParam{ind}, initVal(ind));
end
%=======================================================================% % TEST DATA & DYNAMIC INPUTS % %=======================================================================% Rr = 0.55843; %[m] Reference radius samp_t = Temps; samp_Fhz = 10*VerticalLoad; samp_V_D = Vitesse_piste; samp_V_W = Vitesse_roue; samp_T = 10*Couple; samp_Energy_B = Energie_frein; samp_Omega_W = samp_V_W/Rr; samp_Omega_D = samp_V_D/RD;
clear Temps VerticalLoad Vitesse_piste Vitesse_roue Couple ...
Energie_frein Energie_frein Drum_cor Gain Energie_machine ...
Mu_frein pression Omega_roue Pression
% Attraverso il successivo 'if' si aggiungono i dati relativi all'istante % zero sia per il Test2 che per il Test3, dal momento che le
registrazioni
% per entrambi partono dall'istante 0.005 secondi, in modo tale da poter % utilizzare un unico file per i tre test. Viene definito l'indice
% corrispondente all'istante finale del test e la dimensione dei vettori % samp viene aumentata di una unità corrispondente all'istante zero. Il % valore del primo elemento viene considerato per tutti identico al valore
% relativo a t=0.005 eccetto che per il samp_T il cui primo valore viene % considerato nullo:
ind=[2920 3262 6366]; % indice relativo all'istante finale del test.
if testnum == 2 | testnum == 3 % | equivale all'operatore logico OR samp_t(2:1:ind(testnum)+1,1) = samp_t; samp_t(1) = 0;
samp_Fhz(2:1:ind(testnum)+1,1) = samp_Fhz; samp_Fhz(1) = samp_Fhz(2); samp_V_D(2:1:ind(testnum)+1,1) = samp_V_D; samp_V_D(1) = samp_V_D(2); samp_V_W(2:1:ind(testnum)+1,1) = samp_V_W; samp_V_W(1) = samp_V_W(2); samp_T(2:1:ind(testnum)+1,1) = samp_T; samp_T(1) = 0;
samp_Energy_B(2:1:ind(testnum)+1,1) = samp_Energy_B; samp_Energy_B(1) = samp_Energy_B(2); samp_Omega_W = samp_V_W/Rr; samp_Omega_D = samp_V_D/RD; end %=======================================================================% % INITIALIZATION % %=======================================================================% % Initial angular velocity of the drum
V_0 = samp_V_D(1);
Appendice E Programma di identificazione con modello energetico
% Calcolo di Re alla velocità assegnata e per il carico verticale assegnato
out = tyre_08(N_0,V_0,0,0); Re_0 = out(4);
clear out
%=======================================================================% % Initial value of slip coefficient and value torque on wheel and drum % %=======================================================================% opzione = 'Sperimentale TD = 0'
% opzione = 'Quasi steady free-rolling' % opzione = 'Steady free-rolling'
% opzione = 'Sperimentale TD = TD0' % opzione = 'Steady braked condition'
switch opzione
%--- Sperimental condition ---% % Condition with braking sampling torque on wheel and without torque % on drum (T_W = samp_T, T_D_0 = 0) case 'Sperimentale TD = 0' sx_0 = 0; Omega_W_0 = (1-sx_0)*V_0/Re_0; T_D_0 = 0; T_W=samp_T;
T_W(1) = 0; % Il primo valore di T_W deve essere sempre 0 altrimenti % il controllo del bloccaggio della ruota funziona male %--- Quasi steady free-rolling ---% % Free-rolling without torques on wheel or drum (T_W= T_D_0 = 0 )
case 'Quasi steady free-rolling' sx_0 = 0;
Omega_W_0 = (1-sx_0)*V_0/Re_0; T_D_0 = 0;
T_W = samp_T * 0; % Azzeramento torque sulla ruota
%--- Steady free rolling with torque on drum T_D_roll_0 ---%
case 'Steady free-rolling' sx_0 = 0; Omega_W_0 = (1-sx_0)*V_0/Re_0; out = tyre_08(N_0,V_0,Omega_W_0,0); h_tmp = out(3) F_tmp = out(17) clear out
x_tmp = F_tmp*h_tmp/N_0 % valore dello shift ottenuto dall' % equazione del moto della ruota % imponendo T_W=0
T_D_0 = -x_tmp*N_0-F_tmp*RD
T_W = samp_T * 0; % Azzeramento torque sulla ruota
Appendice E Programma di identificazione con modello energetico
%This is the case of non steady braked with torque on drum like as: %T_D_0 = T_D_roll_0 = -x * N_0 - F * RD
%and braking torque on wheel like as sperimental
case 'Sperimentale TD = TD0' sx_0 = 0; Omega_W_0 = (1-sx_0)*V_0/Re_0; out = tyre_08(N_0,V_0,Omega_W_0,0); h_tmp = out(3) F_tmp = out(17) clear out x_tmp = F_tmp*h_tmp/N_0 T_D_0 = -x_tmp*N_0-F_tmp*RD T_W=samp_T;
T_W(1) = 0; % Il primo valore di T_W deve essere sempre 0 altrimenti % il controllo del bloccaggio della ruota funziona male %--- Steady braked condition ---% % Condition with a braking torque on wheel (T_W= T_W_0 ) and a driving % torque on drum (T_D= T_D_0 ) to have a costant sx
case 'Steady braked condition'
% Calcolo di h ed F, e del valore di xroll + xb (escluso contributo di xD) sx_0 = 0.01; Omega_W_0 = (1-sx_0)*V_0/Re_0; out = tyre_08(N_0,V_0,Omega_W_0,0); h_tmp = out(3) F_tmp = out(17)
x_tmp = out(21), % xb + xroll (con xD = 0) eta_tmp = out(9);
clear out
% Equazioni di Equilibrio stazionario in condizione frenata
% T_W + x*N_0 = F_tmp*h_tmp Equilibrio ruota % T_D_0 + x*N_0 = -F_tmp*RD Equilibrio drum
% x = x_tmp + (T_D_0/N_0)*(eta_tmp/(1-eta_tmp)) Aggiunta del contributo % di T_D al valore di x A_tmp = [ 1 0 N_0 0 1 N_0 0 -(1/N_0)*(eta_tmp/(1-eta_tmp)) 1 ] B_tmp = [ F_tmp*h_tmp -F_tmp*RD x_tmp ]' soluzione = inv(A_tmp)*B_tmp; T_W_0 = soluzione(1) T_D_0 = soluzione(2)
x_0 = soluzione(3), clear x_0, clear soluzione T_W = T_W_0 * ones(size(samp_T));
% in questo caso non si puo' porre T_W(1) = 0 perche' T_W deve essere % costante, pero' non si ha comunque malfunzionamento del controllo di % bloccaggio della ruota perche' T_W e' esattamente uguale a F*h-x*N
otherwise
error('Case errato')
end
%=======================================================================% % tempi di simulazione e identificazione %
Appendice E Programma di identificazione con modello energetico
%=======================================================================% delta_t_exp = samp_t(2)-samp_t(1); %Intervallo di registrazione dei % dati sperimentali
c = 10; %Costante di affinamento dei punti % per la simulazione
delta_t_sim = delta_t_exp/c; %Intervallo di registrazione dei % dati simulati
t_start = 0; %Istante di inizio simulazione [s] start_ind=min(find(samp_t>t_start))-1;%Indice relativo all'istante t_star % (riferito ai tempi sperimentali) t_end= 8; %Istante di fine simulazione [s] end_ind = min(find(samp_t>t_end))-1; %Indice relativo all'istante t_end % (riferito ai tempi sperimentali) t_in=2; %Istante inizio identificazione [s] in_ind = min(find(samp_t>t_in))-1; %Indice relativo all'istante t_in % (riferito ai tempi sperimentali) t_max = 8; %Istante di fine identificazione [s]
max_ind = min(find(samp_t>t_max))-1; %Indice relativo all'istante t_max % (riferito ai tempi sperimentali) %=======================================================================% % simulazione con i parametri originali % %=======================================================================% opts = simset('Solver','ode1','FixedStep', delta_t_sim,...
'SrcWorkspace','base');
[t_NL_ParOri,states_NL_ParOri,out_NL_ParOri] = sim(system,...
[t_start t_end], opts, [samp_t,T_W]); % Le uscite della simulazione sono:
% _ out_NL_ParOri(:,1) = sx; % _ out_NL_ParOri(:,2) = Omega_D; % _ out_NL_ParOri(:,3) = Omega_W; % _ out_NL_ParOri(:,4) = mi_b; figure(1) subplot(2,1,1) plot(samp_t(1:end_ind),samp_Omega_D(1:end_ind),... 'k-',t_NL_ParOri,out_NL_ParOri(:,2),'ko')
legend('sperimentale','non lineare con K_m_u_s_x,C0,C1 originali',1); ylabel('Omega Drum [rad/s]');
xlim([t_start t_end]) grid
subplot(2,1,2)
plot(samp_t(1:end_ind),samp_Omega_W(1:end_ind),...
'k-',t_NL_ParOri,out_NL_ParOri(:,3),'ko')
legend('sperimentale','non lineare con K_m_u_s_x,C0,C1 originali',1); xlim([t_start t_end])
xlabel('tempo [s]');ylabel('Omega Wheel [rad/s]'); grid
figure(2)
subplot(2,2,[1 3])
plot(out_NL_ParOri(:,1),out_NL_ParOri(:,4)) xlabel('sx'); ylabel('mi_b ');
title('Simulazione con parametri originali','FontSize',12,...
'FontWeight','demi'); grid
Appendice E Programma di identificazione con modello energetico
subplot(2,2,2)
plot(t_NL_ParOri,out_NL_ParOri(:,1));ylabel('sx ');xlim([t_start t_end]); grid
subplot(2,2,4)
plot(t_NL_ParOri,out_NL_ParOri(:,4))
xlabel('tempo [s]'); ylabel('mi_b');xlim([t_start t_end]); grid
figure(3) subplot(3,2,1)
plot(t_NL_ParOri,Froll);ylabel('Froll [N]');xlim([t_start t_end]); title('Simulazione con parametri originali','FontSize',12,...
'FontWeight','demi'); grid
subplot(3,2,3)
plot(t_NL_ParOri,Fb);ylabel('Fb [N]');xlim([t_start t_end]); grid
subplot(3,2,5)
plot(t_NL_ParOri,F);xlabel('tempo [s]');ylabel('F [N]'); xlim([t_start t_end]);grid
subplot(3,2,2)
plot(t_NL_ParOri,xroll);ylabel('xroll [m]');xlim([t_start t_end]); grid
subplot(3,2,4)
plot(t_NL_ParOri,xb);ylabel('xb [m]');xlim([t_start t_end]); grid
subplot(3,2,6)
plot(t_NL_ParOri,x);xlabel('tempo [s]');ylabel('x [m]'); xlim([t_start t_end]);grid
figure(4)
plot(samp_t(1:5),T_W(1:5),'o',t_NL_ParOri(1:50),Torque_sim(1:50),'.') legend('T_W','Torque_s_i_m',2);grid
title('T_W e Torque_s_i_m') figure(5),plot(sx(1:5),'.');title('sx') figure(6) plot((Re(1:5).*Omega_W(1:5)),'o') hold on plot(RD*Omega_D(1:5),'.')
legend('V_r = \omega_W*R_e','V = \omega_D*R_D') title('V_r(1:5) e V(1:5)');
figure(7)
plot((Re(1:5).*Omega_Wd(1:5)),'o') hold on
plot(RD*Omega_Dd(1:5),'.')
legend('R_e(1:5)*d\omega_W(1:5)',' R_D*d\omega_D(1:5)') title('accelerazione di rotolamento e dell''hub')
Re_Omega_Wd=Re(1:5).*Omega_Wd(1:5); RD_Omega_Dd=RD*Omega_Dd(1:5);
%=======================================================================% % calcolo dell'errore percentuale con parametri originali % %=======================================================================% e_Wheel_Ori =((out_NL_ParOri(start_ind:c:c*(end_ind-1)+1,3)-...
Appendice E Programma di identificazione con modello energetico
samp_Omega_W(1:end_ind))./samp_Omega_W(1:end_ind)); e_Drum_Ori =((out_NL_ParOri(start_ind:c:c*(end_ind-1)+1,2)- ... samp_Omega_D(1:end_ind))./samp_Omega_D(1:end_ind)); figure(8) plot(samp_t(1:end_ind),100*e_Wheel_Ori,'b-',... samp_t(1:end_ind),100*e_Drum_Ori,'r-')legend('e% sulla Omega Wheel','e% sulla Omega drum', 1); title([' - Errore percentuale - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); xlabel('tempo [s] ');ylabel('%')
xlim([t_start t_end]);grid
%=======================================================================% % IDENTIFICAZIONE % %=======================================================================% clear R h Re Reb Vr Vs sx mib Fb xb miroll_0 miroll Froll epsilon ...
eta xroll F x TT DT Energy_B Energy_D Omega_D Omega_W Omega_Dd ...
Omega_Wd Vhx_d
fixParam = {'RD','ID','IW','Ro','N_nom','N_0','V_0','Omega_D_0',...
'Omega_W_0','V_max','Omega_max','sx_0','CNa','CNb','Crv',...
'Cre0','Cre1','Crd0','Crd1','Crd2','Crv1','Crv2','Kroll'...
'n','testnum','N_max','N_step','t_sam','T_D_0'}; fixParamNum = [RD ID IW Ro N_nom N_0 V_0 samp_Omega_D(1)...
Omega_W_0 V_max Omega_max sx_0 CNa CNb Crv...
Cre0 Cre1 Crd0 Crd1 Crd2 Crv1 Crv2 Kroll ...
n testnum N_max N_step t_sam T_D_0 ];
for ind = 1:length(fixParam)
assignin('base', fixParam{ind}, fixParamNum(ind));
end
% Optimization data X0 = initVal;
LB(1) = 0; %Kmusx deve essere positivo LB(2) = -inf; %C0 può essere negativo LB(3) = -inf; %C1 può essere negativo UB = [inf inf inf];
options = optimset('Display','iter','TolFun',1e-7,'TolX',1e-6); FuncCount=0;
% Non-linear least-squares optimization
[P,resnorm,residual,exitflag,output]=lsqnonlin(@LocalCostFcn,X0,LB,UB,... options,varParam,fixParam,fixParamNum,system,samp_t,T_W,... samp_Omega_W,samp_Omega_D,t_in,t_max,t_start,t_end,... start_ind,end_ind,delta_t_sim,in_ind,max_ind,c,testnum,... N_max,N_step,t_sam) %=======================================================================% % Simulazione con nuovi parametri e confronto con la precedente % %=======================================================================% clear R h Re Reb Vr Vs sx mib Fb xb miroll_0 miroll Froll epsilon ...
eta xroll F x TT DT Energy_B Energy_D Omega_D Omega_W Omega_Dd ...
Appendice E Programma di identificazione con modello energetico
[t_NL_ParNew,states_NL_ParNew,out_NL_ParNew] = = sim(system,...
[t_start t_end], opts, [samp_t,T_W]); % Le uscite della simulazione sono:
% _ out_NL_ParNew(:,1) = sx; % _ out_NL_ParNew(:,2) = Omega_D; % _ out_NL_ParNew(:,3) = Omega_W; % _ out_NL_ParNew(:,4) = mi_b; figure(1), subplot(2,1,1) hold on plot(t_NL_ParNew,out_NL_ParNew(:,2),'k.')
legend('sperimentale','non lineare con K_m_u_s_x,C0,C1 originali',...
'non lineare con K_m_u_s_x,C0,C1 identificati',1);
title(['Omega Drum - Confronto curve - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); ylabel('[rad/s]')
xlim([t_start t_end]) subplot(2,1,2)
hold on
plot(t_NL_ParNew,out_NL_ParNew(:,3),'k.')
legend('sperimentale','non lineare con K_m_u_s_x,C0,C1 originali',...
'non lineare con K_m_u_s_x,C0,C1 identificati',1);
title(['Omega Wheel - Confronto curve - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); xlabel('tempo [s]'), ylabel('[rad/s]') xlim([t_start t_end])
%=======================================================================% % RAPPRESENTAZIONE GRAFICA DEI PARAMETRI IDENTIFICATI % %=======================================================================% % Le tre figure che seguono permettono all'utente di poter valutare la % qualità dei parametri identificati.
i=0;
%size(a,2)identifica il numero delle colonne di a
for ind=size(X0,2)+1:size(X0,2)+1:FuncCount i=i+1; if ind==size(X0,2)+1; Iteration(:,i)=0; Parametri(i,:)=Param(ind,:); Max_error_W_2_8(:,i)=max_error_W_2_8(ind); Max_error_D_2_8(:,i)=max_error_D_2_8(ind); Max_error_W_0_2(:,i)=max_error_W_0_2(ind); Max_error_D_0_2(:,i)=max_error_D_0_2(ind); f(:,i)=g(ind); else Iteration(:,i)=Iteration(:,i-1)+1; Parametri(i,:)=Param(ind,:); Max_error_W_2_8(:,i)=max_error_W_2_8(ind); Max_error_D_2_8(:,i)=max_error_D_2_8(ind); Max_error_W_0_2(:,i)=max_error_W_0_2(ind); Max_error_D_0_2(:,i)=max_error_D_0_2(ind); f(:,i)=g(ind); end end
Appendice E Programma di identificazione con modello energetico
figure('position', [4 32 450 570]); subplot(4,1,1)
plot(Iteration,f,'k*');ylabel('f(x)');grid subplot(4,1,2)
plot(Iteration,Parametri(:,1),'k*');ylabel('K\mu\itsx');grid subplot(4,1,3)
plot(Iteration,Parametri(:,2),'k*');ylabel('C0');grid subplot(4,1,4)
plot(Iteration,Parametri(:,3),'k*');xlabel('Iteration');ylabel('C1');grid figure('position', [460 32 490 570]);
subplot(2,1,1)
plot(Iteration,Max_error_W_0_2,'k*');
ylabel('MAX{ |\omega_s_a_m_p-\omega_s_i_m|}_0^{2} / {\omega_s_a_m_p(0)}');
title('Wheel');grid subplot(2,1,2)
plot(Iteration,Max_error_W_2_8,'k*');xlabel('Iteration'); ylabel('MAX{ |\omega_s_a_m_p-\omega_s_i_m|}_2^{8} / {\omega_s_a_m_p(0)}');
grid
figure('position', [460 32 490 570]); subplot(2,1,1)
plot(Iteration,Max_error_D_0_2,'k*');
ylabel('MAX{ |\omega_s_a_m_p-\omega_s_i_m|}_0^{2} / {\omega_s_a_m_p(0)}');
title('Drum');grid subplot(2,1,2)
plot(Iteration,Max_error_D_2_8,'k*');xlabel('Iteration'); ylabel('MAX{ |\omega_s_a_m_p-\omega_s_i_m|}_2^{8} / {\omega_s_a_m_p(0)}');
grid
%=======================================================================% % calcolo dell'errore percentuale % %=======================================================================% e_Wheel_New=((out_NL_ParNew(start_ind:c:c*(end_ind-1)+1,3)-... samp_Omega_W(1:end_ind))./samp_Omega_W(1:end_ind)); e_Drum_New= ((out_NL_ParNew(start_ind:c:c*(end_ind-1)+1,2)- ... samp_Omega_D(1:end_ind))./samp_Omega_D(1:end_ind)); figure(8) hold on plot(samp_t(1:end_ind),100*e_Wheel_New,'b.',... samp_t(1:end_ind),100*e_Drum_New,'r.')
legend('e% della \omega_W con parametri originali',...
'e% della \omega_D con parametri originali',...
'e% della \omega_W con parametri identificati',...
'e% della \omega_D con parametri identificati',1); title([' - Errore percentuale - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); xlabel('tempo [s] ');ylabel('%')
Appendice E Programma di identificazione con modello energetico
%errori percentuale medi in 0-8 sec.
e_Wheel_medio=sum(e_Wheel_New)/size(e_Wheel_New,1); e_Drum_medio=sum(e_Drum_New)/size(e_Drum_New,1); %errori percentuali medi in 2-8 sec.
e_Wheel_medio2_8=sum(e_Wheel_New(in_ind:max_ind))/...
size(e_Wheel_New(in_ind:max_ind),1); e_Drum_medio2_8=sum(e_Drum_New(in_ind:max_ind))/...
size(e_Drum_New(in_ind:max_ind),1);
E.2 Function LocalCostFcn
%--- Function LocalCostFcn ---% function F = LocalCostFcn(varParamNum,varParam,fixParam,fixParamNum,... system,samp_t,T_W,samp_Omega_W,samp_Omega_D,t_in,t_max,... t_start,t_end,start_ind,end_ind,delta_t_sim,in_ind,... max_ind,c,testnum,N_max,N_step,t_sam)
global FuncCount Param max_error_W_2_8 max_error_D_2_8...
max_error_W_0_2 max_error_D_0_2 g FuncCount=FuncCount+1;
Param(FuncCount,:) = varParamNum;
% Si assegnano i valori dei parametri del modello nel workspace base di % Matlab in modo tale che sia possibile effettuare la simulazione come % segue:
for ind = 1:length(varParam)
assignin('base', varParam{ind}, varParamNum(ind));
end
%--- Settaggio dei parametri per la simulazione ---% opts = simset('Solver','ode1','FixedStep', delta_t_sim,...
'SrcWorkspace', 'base');
[t_sim,x_sim,out_sim] = sim(system, [t_start t_end], opts, [samp_t,T_W]);
% Le uscite della simulazione sono: % _ Out_sim(:,1) = sx;
% _ Out_sim(:,2) = Omega_D; % _ Out_sim(:,3) = Omega_W; % _ Out_sim(:,4) = mi_b;
%calcola i diagrammi della F,Fb,Froll,x,xroll,xb,sx,mi_b per ogni valore %identificato
figure(9)
subplot(2,2,[1 3])
Appendice E Programma di identificazione con modello energetico
xlabel('sx'); ylabel('mi_b ');
title('Simulazione con parametri identificati','FontSize',12,...
'FontWeight','demi'); grid
subplot(2,2,2)
plot(t_sim,out_sim(:,1));ylabel('sx ');xlim([t_start t_end]); grid
subplot(2,2,4)
plot(t_sim,out_sim(:,4))
xlabel('tempo [s]'); ylabel('mi_b');xlim([t_start t_end]); grid
figure(10) subplot(3,2,1)
plot(t_sim,Froll);ylabel('Froll [N]');xlim([t_start t_end]); title('Simulazione con parametri identificati','FontSize',12,...
'FontWeight','demi'); grid
subplot(3,2,3)
plot(t_sim,Fb);ylabel('Fb [N]');xlim([t_start t_end]); grid
subplot(3,2,5)
plot(t_sim,F);ylabel('F [N]');xlim([t_start t_end]); grid
subplot(3,2,2)
plot(t_sim,xroll);ylabel('xroll [m]');xlim([t_start t_end]); grid
subplot(3,2,4)
plot(t_sim,xb);xlabel('tempo [s]');ylabel('xb [m]'); xlim([t_start t_end]);grid
subplot(3,2,6)
plot(t_sim,x);ylabel('x [m]');xlim([t_start t_end]); grid
figure(11) subplot(2,1,1)
plot(t_sim,out_sim(:,2));
ylabel('Omega Drum [rad/s]');xlim([t_start t_end]); grid
subplot(2,1,2)
plot(t_sim,out_sim(:,3));
ylabel('Omega Wheel [rad/s]');xlim([t_start t_end]); grid
%---% % residui delle velocità angolari della ruota e del tamburo nell'intero % periodo di simulazione 0-8 secondi
residui0_8_W = out_sim(start_ind:c:c*(end_ind-1)+1,3)-...
samp_Omega_W(1:1:max_ind);
residui0_8_D = out_sim(start_ind:c:c*(end_ind-1)+1,2)-...
samp_Omega_D(1:1:max_ind);
% moduli dei residui delle velocità angolari della ruota e del tamburo modulo_residui_W = abs(residui0_8_W);
Appendice E Programma di identificazione con modello energetico
% massimo errore percentuale nel periodo di identificazione,ossia nei 2-8 % secondi, riferito al valore iniziale della omega wheel/drum
% sperimentale.
max_error_W_2_8(:,FuncCount)=max(modulo_residui_W(in_ind:1:max_ind))/...
samp_Omega_W(1);
max_error_D_2_8(:,FuncCount)=max(modulo_residui_D(in_ind:1:max_ind))/...
samp_Omega_D(1); % massimo errore percentuale nei 0-2 sec. riferito al valore iniziale % della omega wheel/drum sperimentale.
max_error_W_0_2(:,FuncCount)=max(modulo_residui_W(start_ind:1:in_ind))/.. samp_Omega_W(1); max_error_D_0_2(:,FuncCount)=max(modulo_residui_D(start_ind:1:in_ind))/.. samp_Omega_D(1); %---%
%---- Definizione delle funzioni residuo per la ruota e il tamburo ---% sim_Omega_D = out_sim(c*(in_ind-1)+1:c:c*(max_ind-1)+1,2);
sim_Omega_W = out_sim(c*(in_ind-1)+1:c:c*(max_ind-1)+1,3); samp_Omega_Wheel=samp_Omega_W(in_ind:1:max_ind);
samp_Omega_Drum=samp_Omega_D(in_ind:1:max_ind);
FomegaW = (sim_Omega_W - samp_Omega_Wheel)./samp_Omega_Wheel; FomegaD = (sim_Omega_D - samp_Omega_Drum)./samp_Omega_Drum;
alpha=0.95; %Coefficiente per stabilire il peso relativo di FomegaW ed %FomegaW sulla funzione costo complessiva.
% residui della funzione di costo F
residuiF=alpha*(sim_Omega_W - samp_Omega_Wheel)./samp_Omega_Wheel+...
(1-alpha)*(sim_Omega_D - samp_Omega_Drum)./samp_Omega_Drum;
% g è la funzione f calcolata per ogni FuncCount(non può essere % denominata f altrimenti viene scambiata per la funzione di costo F) g(:,FuncCount)=sum(residuiF.*residuiF); %---FUNZIONE DI COSTO---% F = alpha*FomegaW+(1-alpha)*FomegaD; % ---% figure(12) subplot(2,1,1) plot(samp_t(in_ind:1:max_ind),samp_Omega_D(in_ind:1:max_ind),'k-',... t_sim(c*(in_ind-1)+1:c*(max_ind-1)+1),... out_sim((c*(in_ind-1)+1:c*(max_ind-1)+1),2),'k.')
legend('sperimentale','non lineare con parametri identificati',1); title(['Omega Drum - Confronto curve - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); ylabel('[rad/s]')
xlim([t_in t_max]) grid
Appendice E Programma di identificazione con modello energetico
plot(samp_t(in_ind:1:max_ind),samp_Omega_W(in_ind:1:max_ind),'k-',...
t_sim(c*(in_ind-1)+1:c*(max_ind-1)+1),...
out_sim((c*(in_ind-1)+1:c*(max_ind-1)+1),3),'k.')
legend('sperimentale','non lineare con parametri identificati',1); title(['Omega Wheel - Confronto curve - Test',num2str(testnum)],...
'FontSize',12,'FontWeight','demi'); xlabel('tempo [s]'), ylabel('[rad/s]') xlim([t_in t_max])
grid
E.3 Function Tyre_08 del modello QSTM_08
% Questa function rappresenta il cuore del modello Simulink per la % modellizzazione della dinamica del pneumatico, infatti con questa si % calcolano ad ogni passo di iterazione tutti i parametri quali delta, % Re, sx, etc, necessari per esprimere l'interazione tra i due corpi,
% Wheel e Drum.
% In questa versione si usano le formule che inglobano l'azione del % torque sul drum (T_D) solo nella x (xD):
% si considerano:
% F=Froll+Fb e x=xD+xroll+xb.
% La tyre_08 differisce dalla tyre_07 unicamente per la presenza di un % controllo sul raggio di puro rotolamento Re e sullo scorrimento pratico % sx e per la presenta di eta tra le uscite della funzione, out(9).
%
%---%
function out = tyre_08(N,V,Omega,T_D)
global RD ID IW Ro N_nom N_0 V_0 Omega_D_0 Omega_W_0 V_max Omega_max ...
sx_0 CNa CNb Crv Cre0 Cre1 Crd0 Crd1 Crd2 Crv1 Crv2 C1 C0 n ...
testnum Kmisx N_max N_step t_sam T_D_0 Kroll V_a = V/V_max; Omega_a = Omega/Omega_max; N_a = N/N_nom; %=======================================================================% % CARCASS MODEL % % input: N V % % output: delta R h Re %=======================================================================% delta_a = (-CNa+sqrt(CNa^2+4*CNb*N_a))/(2*CNb);
delta = delta_a*Ro; %Schiacciamento del pneumatico dovuto al carico N R = Ro*(1+Crv*(V/V_max)^2); %Variazione del raggio della ruota con la %velocità angolare della stessa
h = R - delta; %Distanza tra l'hub della ruota e la superficie del drum %considerando sia il contributo del carico N che quello
Appendice E Programma di identificazione con modello energetico
%della velocità angolare della ruota Res = 1 + Cre0*sqrt(delta_a) + Cre1*delta_a;
Re = Res*R; %Variazione del raggio effettivo di rotolamento con la %e il carico velocità %=======================================================================% % CONTACT PARAMETERS % % input: V Omega Re % % output: Reb Vr Vs sx %=======================================================================% if Omega == 0 Reb = 1e8; else
Reb = V/Omega; %Raggio di rotolamento frenato
end
Vr = Re*Omega; %Velocità periferica del pneumatico nella zona di contatto Vs = V-Vr; %Velocità di slip if V == 0 sx = 0; else sx = Vs/V; %Slip coefficient end %=======================================================================% % BRAKING FORCE % % input: V sx N h Reb % % output: mib Fb xb %=======================================================================% %Parametri per il calcolo di Fb, Froll, xb, xroll:
K2 = C0 + C1*V; mib = (K2*sx^2 + Kmisx*abs(sx))*sign(sx); Fb = mib*N; xb = mib*h*(1-Reb/h)/(1+Reb/RD); %=======================================================================% % ROLLING FRICTION %
% input: V_a delta_a sx N h Reb %
% output: miroll_0 miroll Froll xroll
%=======================================================================% miroll_0 = (Crd0 + Crd1*delta_a +
Crd2*delta_a^2)*(1+Crv1*V_a^2)/(1+Crv2*(V_a)^n); miroll = miroll_0 * (1 + Kroll * sx^2);
Froll = miroll*N;
epsilon = (V/V_max)*(2*Crv*((V/V_max)))/(1+Crv*((V/V_max))^2); eta = (1-epsilon)*(IW/ID)*(RD/Reb);
Appendice E Programma di identificazione con modello energetico
xroll = miroll*h*(1+eta*RD/h)/(1-eta); %=======================================================================% % xD % % input: T_D N eta % % output: xD %=======================================================================% xD=(T_D/N)*(eta/(1-eta)); %=======================================================================% % LONGITUDINAL FORCE & LEVER ARM% % input: Fb Froll % xb xroll xD % output: F x %=======================================================================% F = Fb + Froll; x = xb + xroll + xD; %=======================================================================% % INDICIZZAZIONE DELLE USCITE
%=======================================================================% out(1) = delta; out(2) = R; out(3) = h; out(4) = Re; out(5) = Reb; out(6) = Vr; out(7) = Vs; out(8) = sx; out(9) = eta; out(10) = 0; out(11) = 0; out(12) = mib; out(13) = miroll_0; out(14) = miroll; out(15) = Fb; out(16) = Froll; out(17) = F; out(18) = xb; out(19) = xroll; out(20) = xD; out(21) = x; out(22) = T_D;