hydro.m

来自「isight调用matlab接口进行优化的例子」· M 代码 · 共 118 行

M
118
字号
%***********************************************************************
%************************* Hydro.for ************************************
%        Calculate the skin friction and wave drag of a generic ship
%        using ultra-simple methods
%
%        Stephen Morris
%
%        February 1996
%
%***********************************************************************
%       Length=length at water line (or max length is OK too) (ft)
%       Width=max width (ft)
%       Height=Ship Height (ft)
%       Swett=wetted area of hull (ft^2)
%       Fres=resistive force (lbf)
%       Draft=submerged maximum depth of ship (ft)
%       Wdispl=displacement weight(lb)
%       Swett=hull wetted area (ft**2)
%       Vkts=speed relative to water (knots)
%***********************************************************************
        Wdispl = 2.0e+08
        pi=3.1415927
        g=32.174
%***********************************************************************
%       Nominal properties of sea water (!slug/ft^3 @ approx 50 deg. F)
        ro=1.992 
%        !ft^2/sec @ approx 50 deg. F
        visc=31.0e-6/ro
%       Pressure Drag Markup factor (typically 3% of total)
%***********************************************************************
        Fmarkp=1.03
%***********************************************************************
%***********************************************************************
%       Wetted Area
        width=Lgth/6.48
        draft=Wdispl/(64.0*width*Lgth)
        Swett=Lgth*width*0.68+0.75*draft*Lgth*2.0
%***********************************************************************
%       Wave Drag resistance 
%       From "Resistance and Propulsion of Ships" S.V. A.A. Harvald,
%       John Wiley & Sons, 1983, pg.118
%       L/D^1/3=5.5  phi=.8
%       Froude Number for residual drag coeff. data
        fn(1)=.15
        fn(2)=.20
        fn(3)=.25
        fn(4)=.30
%       Residual drag coeff. data
        cr(1)=.00065
        cr(2)=.0013
        cr(3)=.0030
        cr(4)=.0094
%***********************************************************************
%***********************************************************************
%       Begin iteration loop to solve for velocity where HP equals 
%       HPhull
        count=0
        tol=0.1
        vfps=1.0
        relax=0.1
        max=1000

	while (count < max)

        
        count=count+1
%***********************************************************************
%       Reynolds Number
        Re=vfps*Lgth/visc
%***********************************************************************
%       Skin Friction coefficient
        Cf=0.075/(log10(Re)-2.0)^2
%***********************************************************************
%       Skin friction resistance
        Fskin=0.5*ro*Swett*vfps*vfps*Cf
%***********************************************************************
        froude=vfps/sqrt(g*Lgth) 
%       Find Cr from linear interpolation of stored values
        for i=1:3
        	if (froude <= fn(i+1)) && froude >= fn(i)
        		iup=i+1
        		ilow=i
        	end
	end
        if froude < fn(1)
        	iup=2
        	ilow=1
        end
        if froude > fn(4)
        	iup=4
        	ilow=3
        end
        slope=(cr(iup)-cr(ilow))/(fn(iup)-fn(ilow))
        crr=slope*(froude-fn(ilow))+cr(ilow)
%       Residual resistive force:
        Fwave=0.5*ro*vfps*vfps*Swett*crr
%***********************************************************************
%***********************************************************************
%       Total
        Fres=(Fskin+Fwave)*Fmarkp
%***********************************************************************
%       Cruise speed (fps)
        vfpsnew=550.0*HPhull/Fres
        if abs(vfpsnew-vfps) >= tol
        
        vfps=vfps+relax*(vfpsnew-vfps)
       
           break
        else
        	
        	
        vfps=vfps+relax*(vfpsnew-vfps)
        	end;
        

%       Convert velocity to kts
        vkts=vfps/1.688
  end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?