www.pudn.com > SHIPCONTROL.rar > inversemotionshipalertpoint.m, change:2013-09-13,size:5884b


function motionshipalertpoint 
clear all;clc; 
global m L D B midu CB ZG H T  Dp np  tp b1 b2  P hR  epxlong hs delta; 
m=55000*10^3; 
L=270; 
D=9.45; 
B=35.5; 
midu=1000; 
CB=0.597; 
ZG=14; 
H=2.9; 
T=0.058*D; 
Dp=4.3; 
np=3; 
tp=0.08; 
b1=6.5; 
b2=4.6; 
P=4.1; 
hR=7.2; 
epxlong=0.92; 
hs=6.9; 
delta=pi/6; 
t0=0; 
tf=600; 
LACD=0; 
 
n=80; 
YY=zeros(n,8); 
R=100; 
xR0=R+4*1860; 
yR0=100; 
sis=1;% sis (0,3.14) 
% x=zeros(1,n); 
% y=zeros(1,n); 
 
x0=0; 
y0=200; 
y1=0; 
x1=0; 
ym=yR0+R*cos(sis); 
xm=xR0+R*sin(sis); 
zm=3.14*3/2+sis; 
de=0.001; 
buchang=1; 
ind=2; 
Dis(ind-1)=2; 
Dis(ind)=3; 
j=0; 
Y0=[xm ym zm 0.01 8 1 -0.0001 0.0001]; 
 
 %xm=157.6; 
 %ym=200; 
 
 
for i=n:-1:2 
 
tspan=[(i+1)*buchang,i*buchang,(i-1)*buchang]; 
 
[tspan,ee]=ode45(@DYDT,tspan,Y0) 
Y0=ee(end,:); 
 
YY(i,:)=ee(1,:); 
YY(i-1,:)=ee(2,:); 
x01=YY(i,1) 
y01=YY(i,2) 
plot(x01,y01,'r','linewidth',10),pause(0.00000001);   % drawnow 
 hold on 
 xR=xR0-2*i*buchang; 
 yR=yR0-1*i*buchang; 
alpha=0:pi/20:2*pi; 
x=xR+R*cos(alpha); 
y=yR+R*sin(alpha); 
plot(x,y),drawnow; %pause(0.00000001); 
hold on 
axis equal 
ind=i; 
YY(ind,1) 
YY(ind,2) 
ht=-1000:1:1000; 
yR=YY(ind,6)/YY(ind,5)*(ht-YY(ind,1))+YY(ind,2); 
plot(yR,ht) 
hold on 
 
axis equal 
%drawnow 
%hold on 
 
 
 
% Dis(i-1)=sqrt((YY((i-1),1)-xR)^2+(YY((i-1),2)-yR)^2); 
% Dis(i)=sqrt((YY((i),1)-xR)^2+(YY((i),2)-yR)^2); 
%  
%   we=(Dis(i)-Dis(i-1)); 
% if we>0||Dis(i)<1.02*R 
%     ind=i; 
%     break 
% %     sm=sm+1;     
% end 
%  
% % if sm>1 
% %     
% %      
% % end 
  
 
end 
   %(YY(ind-1,1)-xR)*(YY(ind,2)-yR)-(YY(ind-1,2)-yR)*(YY(ind,1)-xR) 
 
 
% if (Dis(ind)>R&&Dis(ind-1)>R&&((YY(ind-1,1)-xR)*(YY(ind,2)-yR)-(YY(ind-1,2)-yR)*(YY(ind,1)-xR))>0) 
%     %(yR>(YY(ind,6)/YY(ind,5)*(xR-YY(ind,1))+YY(ind,2))))||(Dis(ind)>2*R) 
%     x0=xm; 
%     y0=ym; 
% else 
%    x1=xm; 
%     y1=ym;  
% end 
%  
% %if Dis(ind)<=R||Dis(ind-1)<=R||(yR<=(YY(ind,6)/YY(ind,5)*(xR-YY(ind,1))+YY(ind,2))) %&& 
%     %x1=xm; 
%     %y1=ym; 
% %end 
%  
% sqrt((Dis(ind-1)-R)^2+(Dis(ind)-R)^2) 
%hold on 
plot(xm,ym,'r*'),pause(0.00000001);  % 
%hold on 
   
%    xm=(x0+x1)/2 
%    ym=(y0+y1)/2 
%   LACD=sqrt((xm-xR)^2+(ym-yR)^2) 
 
 
function  dy=DYDT(t,y) 
% 船型参数 螺旋桨参数  舵参数 
global m L D B midu CB ZG H T  Dp np  tp b1 b2  P hR  epxlong hs  delta; 
 
dy=zeros(8,1); 
FAI=y(4); 
u=y(5); 
v=y(6); 
r=y(7); 
p=y(8); 
V=sqrt(u^2+v^2); 
RP=r*L/V; 
Beita=atan(-v/u); 
 
% 各纬度惯性矩及附加质量的计算 
IZ=m*(1+CB^4.5)+(L^2+B^2.4)/24; 
m11=m*(1/100)*(0.398+11.98*CB*(1+3.73*(D/B))-(2.89*CB*(L/B))*(1+1.13*(D/B))+0.175*CB*(L/B)^2*(1+0.541*(D/B))-1.107*(L/B)*(D/B)); 
m22=m*(0.882-0.54*CB*(1-1.6*(D/B))-0.156*(1-0.673*CB)*(L/B)+0.826*(D/B)*(L/B)*(1-0.678*(D/B))-0.638*(L/B)*(D/B)*(1-0.669*(D/B))); 
m66=m*(L*0.01*(33-76.85*CB*(1-0.784*CB)+3.43*(L/B)*(1-0.63*CB)))^2; 
%m26=0.5*pi*MIDU*(L*D)^2*(0.67*(B/L)-0.0033*(B/D)^2); 
 
 
%纵向水动力的计算 
Xu=59.12*u^4-462.8*u^3+8775*u^2+28940*u+67640; 
XVR=(1.6757*CB-0.5054-1)*m22; 
XH=XVR*v*r-Xu; 
 
 
%横向水动力的计算 
K=2*D/L;TP=T/D; 
Yv=-0.5*midu*L*D*V*(pi*K/2+1.4*CB*(B/L))*(1+0.67*TP); 
Yr=0.5*midu*L^2*D*V*(pi*K/4)*(1+0.8*TP); 
Yvv=0.5*midu*L*D*(0.048265-6.293*(1-CB)*(D/B)); 
Yvr=0.5*midu*L^2*D*(-0.3791+1.28*(1-CB)*(D/B)); 
Yrr=0.5*midu*L^3*D*(0.0045-0.445*(1-CB)*(D/B)); 
YH=Yv*v+Yr*r+Yvv*v*abs(v)+Yvr*r*abs(v)+Yrr*r*abs(r); 
 
 
 
%首摇力矩的计算 
Lv=K/(0.5*pi*K+1.4*CB*(B/L)); 
Nv=-0.5*midu*L^2*D*V*K*(1-0.27*TP/Lv); 
Nr=-0.5*midu*L^3*D*V*(0.54*K-K^2)*(1+0.3*TP); 
Nvvr=0.5*midu*L^3*D*(-6.0856+137.4735*CB*(B/L)-1029.514*(CB*(B/L))^2+2480.6082*(CB*(B/L))^3); 
Nvrr=0.5*midu*L^4*D*(-0.0635+0.044145*CB*(D/B)); 
Nrr=0.5*midu*L^4*D*(-0.0805+8.6092*(CB*(B/L))^2-36.9816*(CB*(B/L))^3); 
Nvfai=0.5*midu*L^2*D*V*(-1.72*K); 
Nrfai=0.5*midu*L^3*D*V*(2.6*(0.54*K-K^2)); 
Nfai=0.5*midu*L^2*D*V^2*(-0.008); 
 
NH=Nv*v+Nr*r+Nvvr*v^2*r+Nrr*r*abs(r)+Nvrr*v*r^2+Nfai*FAI+Nvfai*v*abs(FAI)+Nrfai*r*abs(FAI); 
 
%横倾力矩的计算 
 
Np=0.12*sqrt((m*(B^2+4*ZG^2)/(12))*H*m*9.8); 
GZFAI=H*sin(FAI); 
ZH=ZG-(4-B/D+0.02*(B/D-5.35)^3)*D; 
 
KH=-Np*p-m*9.8*GZFAI-YH*ZH; 
 
 
%螺旋桨纵向推进力计算 
wp0=0.5*CB-0.05; 
 
Beitap=Beita-0.5*RP; 
wp=wp0*exp(-4*Beitap^2); 
Jp=u*(1-wp)/(Dp*np); 
Kt=0.25035*Jp^3-0.58638*Jp^2-0.067363*Jp+0.42379; 
 
XP=(1-tp)*midu*np^2*Dp^4*Kt; 
 
%舵力的计算  
S=1-u*(1-wp)/np*P; 
lamuda=2*hR/(b1+b2); 
fa=6.13*lamuda/(2.25+lamuda); 
sita=Dp/hR; 
gs=sita*(0.6/epxlong)*S*(2-(2-(0.6/epxlong))*S)/(1-S)^2; 
 
if delta>0 
    c1=1.065; 
else 
    c1=0.935; 
end 
 
uR=u*(1-wp)*sqrt(1+c1*gs); 
vR=(1.163314-1.982836*CB+1.390152*CB^2)*(v-L*r); 
UR=sqrt(uR^2+vR^2); 
S0=1-u*(1-wp0)/np*P; 
delta0=-(2*S0+0.6); 
alfaR=delta-delta0-atan(vR/uR); 
 
tR=1-(0.7382-0.0539*CB+0.1755*CB^2); 
aH=0.6784-1.3374*CB+1.8891*CB^2; 
xR=-0.5*L; 
xH=-(0.4+0.1*CB)*L; 
zR=ZG-D+hs; 
 
FN=0.5*midu*0.5*(b1+b2)*hR*fa*UR^2*sin(alfaR); 
 
 
XR=-(1-tR)*FN*sin(delta); 
YR=(1+aH)*FN*cos(delta); 
NR=(xR+aH*xH)*FN*cos(delta); 
KR=(1+aH)*zR*FN*cos(delta); 
 
% dy(1)=y(5); 
% dy(2)=y(6); 
% dy(3)=y(7); 
% dy(4)=y(8); 
 
dy(1)=(y(5)*cos(y(3))-y(6)*cos(y(4))*sin(y(3))); 
dy(2)=(y(5)*sin(y(3))+y(6)*cos(y(4))*cos(y(3))); 
dy(3)=(y(7)*cos(y(4))); 
dy(4)=y(8); 
dy(5)=(XH+XP+XR+(m+m22)*y(6)*y(7))/(m+m11); 
dy(6)=(YH+YR-(m+m11)*y(5)*y(7))/(m+m22); 
dy(7)=(NH+NR)/(IZ+m66); 
dy(8)=(KH+KR)/(m*(B^2+4*ZG^2)/12); 
 
 
 
% bosai0=YY(:,3); 
% FAI0=YY(:,4); 
% u=YY(:,5); 
% v=YY(:,6); 
% r=YY(:,7); 
% p=YY(:,8); 
 
 
% [hang,lie]=size(x); 
% x0=zeros(1,hang); 
% y0=zeros(1,hang); 
% bosai0=zeros(1,hang); 
% FAI0=zeros(1,hang); 
% for i=2:hang-1 
%     x0(i+1)=(u(i)*cos(bosai(i))-v(i)*cos(FAI(i))*sin(bosai(i)))*(time(i)-time(i-1))+x0(i); 
%     y0(i+1)=(u(i)*sin(bosai(i))+v(i)*cos(FAI(i))*cos(bosai(i)))*(time(i)-time(i-1))+y0(i); 
%     bosai0(i+1)=(r(i)*cos(FAI(i)))*(time(i)-time(i-1))+bosai0(i); 
%     FAI0(i+1)=p(i)*(time(i)-time(i-1))+FAI0(i); 
% end 
 
 
 
% figure 
% plot(bosai0); 
% figure 
% plot(FAI0);