Matlab模拟三维海浪模型

1 简介

海洋工程领域中的浮式结构物设计,需要精确计算海浪载荷,保证满足稳定性和安全性.该文利用MATLAB对Longuet-Higgins长峰波海浪模型和三维不规则短峰波随机海浪模型进行了仿真研究.结果表明,利用海浪谱来模拟三维随机海浪能够得到比较精确的海浪波面图和波高值,进一步根据流体的势流理论就可以分析计算出该结构物受到的海浪载荷,为校验结构物的结构强度提供了必要的基础.​

2 部分代码

clear all;close all;nhFig = 0; % Figure Number;SeaRegLx = 40e+3; % Sea region length, unit: mSeaRegLy = 40e+3; % Sea region length, unit: m% 根据频域采样定理,在确定采样周期即波束的足迹宽度之后,% 可以利用时域采样的采样点数目(通过空间频谱的宽度即根据时域采样定理计算出采样点数),实现频域采样.% 对于海洋波谱而言,波谱宽度是非常宽的,因此其波谱宽度一般是指包括了大部分能量(或者说主要的能量部分)的不完全谱宽度% 所以这里事先根据波谱函数计算主要能量部分对应的谱宽度xSampleStep = 50; % unit: mySampleStep = 50;xNs = round( SeaRegLx / xSampleStep );yNs = round( SeaRegLy / ySampleStep );x = linspace( -SeaRegLx / 2, SeaRegLx / 2, xNs );y = linspace( -SeaRegLy/ 2, SeaRegLy / 2, yNs );% 海浪谱仿真g = 9.8; % gravity acceleration% swell wave spectrum parameterSwellWaveLength = 1000; % 涌浪波长KswellWavePeak = 2 * pi / SwellWaveLength;SwellAngled=0;SwellAngle = SwellAngled/ 180 * pi; % 涌浪与观测向夹角KxswellWavePeak = KswellWavePeak * cos( SwellAngle );KyswellWavePeak = KswellWavePeak * sin( SwellAngle );SigmaKx = 2.5e-3; % 涌浪谱宽度SigmaKy = 2.5e-3;SigmaHSwell = 2; %涌浪波高% wind wave spectrum parameterWindAngle = 45 / 180 * pi; % 风向与观测向夹角U10 = 12; % 10米高处海面风速 % 5m/s, 10m/s, 15m/s 的风浪谱宽度分别为 1.5, 0.4, 0.15.对应的最大空间采样间隔为2m, 10m, 20mKwindPeak = g / ( 1.2 * U10 )^2;% sea wave spectrum parameterNxSeaWave = xNs; % 频域采样点数,方便傅立叶变换NySeaWave = yNs; KxSeaWave = 2 * pi / SeaRegLx * ( -xNs / 2 : 1 : xNs / 2 - 1 );KySeaWave = 2 * pi / SeaRegLy * ( -yNs / 2 : 1 : yNs / 2 - 1 );KxSeaWaveTicks = KxSeaWave;KySeaWaveTicks = KySeaWave;KxSeaWave = ( KxSeaWave == 0 ) * ( max( KxSeaWave ) * 1e-16 ) + KxSeaWave; % avoid divided by 0KySeaWave = ( KySeaWave == 0 ) * ( max( KySeaWave ) * 1e-16 ) + KySeaWave; % avoid divided by 0% swell wave spectrumSpectrumSwell = zeros( NySeaWave, NxSeaWave );Temp1 = ones( NySeaWave, 1 ) * ( KxSeaWave - KxswellWavePeak ) / SigmaKx;Temp2 = ( KySeaWave - KyswellWavePeak )' / SigmaKy * ones( 1, NxSeaWave );SpectrumSwell = SigmaHSwell^2 / 2 / pi / SigmaKx / SigmaKy * exp( -0.5 * ( Temp1.^2 + Temp2.^2 ) );clear Temp1;clear Temp2;figure;colormap(gray(256));image( KxSeaWave, KySeaWave, 256 - 255 / ( max( max( abs( SpectrumSwell ) ) ) - min( min ( abs( SpectrumSwell ) ) ) ) * ( abs( SpectrumSwell ) - min( min ( abs( SpectrumSwell ) ) ) ) );axis('xy');xlabel( 'kx:X方向波数');ylabel( 'ky:Y方向波数');title( '涌浪谱');KxSeaWaveMatrix = ones( NySeaWave, 1 ) * KxSeaWave;KySeaWaveMatrix = KySeaWave' * ones( 1, NxSeaWave );KSeaWaveTemp1 = ( sqrt( KxSeaWaveMatrix.^2 + KySeaWaveMatrix.^2 ) );Fwk1 = exp( - 1.22 * ( sqrt( KSeaWaveTemp1 ./ KwindPeak ) -1 ).^2  );HKKpx1 = 1.24 * ( ( KSeaWaveTemp1 / KwindPeak < 0.31 ) & ( KSeaWaveTemp1 / KwindPeak >= 0 ) );HKKpx2 = 2.61 * ( ( KSeaWaveTemp1 / KwindPeak ).^0.65 ) .* ( ( KSeaWaveTemp1 / KwindPeak < 0.9 ) & ( KSeaWaveTemp1 / KwindPeak >= 0.31 ) );HKKpx3 = 2.28 * ( ( KSeaWaveTemp1 / KwindPeak ).^( -0.65 ) ) .* ( KSeaWaveTemp1 / KwindPeak >= 0.9 );HKKp1 = HKKpx1 + HKKpx2 + HKKpx3;Temp1x = 1.62 * 1e-3 * U10 / ( g^0.5 ) ./ ( KSeaWaveTemp1 ).^3.5;Temp2x = exp( -( KwindPeak ./ KSeaWaveTemp1 ).^2 ) .* ( 1.7 .^ Fwk1 );Temp3x = ( HKKp1 .* ( sech( ( HKKp1 .* ( atan( ( KySeaWaveMatrix ./ KxSeaWaveMatrix ) ) - WindAngle ) ) ) ).^2 );% SpectrumWind1 = ( Temp1x .* Temp2x .* Temp3x )';% SpectrumWind = SpectrumWind1';SpectrumWind = Temp1x .* Temp2x .* Temp3x;clear KSeaWaveTemp1 Fwk1 HKKpx1 HKKpx2 HKKpx3 HKKp1 Temp1x Temp2x Temp3x;figure;contour( KxSeaWave, KySeaWave, abs( SpectrumWind ) );axis('xy');xlabel( 'kx:X方向波数');ylabel( 'ky:Y方向波数');title( '风浪谱');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%全谱= 涌浪谱+风浪谱SpectrumSea = SpectrumSwell + SpectrumWind;% 用于产生海面仿真的真实海浪谱,叠加了随机因素% 产生均值为1的瑞利分布和均匀相位分布rand('state',sum(100*clock));PhiSeaRand = 2 * pi * rand( NySeaWave, NxSeaWave );AmRayleigh = raylrnd( 1, NySeaWave, NxSeaWave );SpectrumSeaReal = 2 * pi .* sqrt( 2 * xNs * yNs / xSampleStep / ySampleStep .* SpectrumSea ) .* AmRayleigh .* exp( j * PhiSeaRand );% 海面高度wh = zeros( yNs, xNs );   % Wave Height, heigth depart from mean sea level% wh = real( ( fftshift( fft( ( fftshift( fftshift( fft( fftshift( SpectrumSeaReal ), yNs ) ) ) )', xNs ) ) )' ) / NySeaWave / NxSeaWave;wh = ( fftshift( fft( ( fftshift( fftshift( fft( fftshift( SpectrumSeaReal ), yNs ) ) ) )', xNs ) ) )' / NySeaWave / NxSeaWave;Varwh = sqrt( sum( sum( ( real( wh ) - mean( mean( real( wh ) ) ) ).^2 ) ) / xNs / yNs );wh = wh / Varwh * ( SigmaHSwell / 2 );% 用涌浪波高进行归一化hFig = figure;colormap(gray(256));image( x, y, 256 - 255 / ( max( max( real( wh ) ) ) - min( min ( real( wh ) ) ) ) * ( real( wh ) - min( min ( real( wh ) ) ) ) );% title('涌浪方向 45 度, 波长 ', SwellWaveLength)title(['涌浪方向: ',num2str(SwellAngled),' 度',',  波长: ',num2str(SwellWaveLength),' m',',  涌浪波高: ',num2str(SigmaHSwell),' m'])xlabel( ['X ( unit: ', num2str(xSampleStep),' m)']);ylabel( ['Y ( unit: ', num2str(ySampleStep),' m)']);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 海面散射系数仿真Sigma = zeros( xNs, yNs );ms2 = 3.66 * 1e-3 * U10;MR02 = 1;% 由海面波谱计算每点的x,y方向坡度xSlope = ones( yNs, 1 ) * real( ( fftshift( fft( fftshift( ( j * KxSeaWaveMatrix( 1, : ) .* SpectrumSeaReal( 1, : ) )' ), xNs ) ) )' ) / NxSeaWave;ySlope = real( ( fftshift( fft( fftshift( ( j * KySeaWaveMatrix( :, 1 ) .* SpectrumSeaReal( :, 1 ) ) ), yNs ) ) ) ) / NySeaWave * ones( 1, xNs );% 本地入射角矩阵,正切表示IncidentAngleLocal = xSlope.^2 + ySlope.^2;Sigma = MR02 / ms2 .* exp( -IncidentAngleLocal / ms2 );% Sigma0Coef = sqrt( Sigma );hFig = figure;colormap(gray(256));image( x, y, 256 - 255 / ( max( max( abs( Sigma ) ) ) - min( min ( abs( Sigma ) ) ) ) * ( abs( Sigma ) - min( min ( abs( Sigma ) ) ) ) );axis('xy');xlabel( 'x0: along track');ylabel( 'y0: cross track');title( 'Scattering Coffecient Distribution');fid=fopen('sea_top_wl1000_wh50m.dat','w')fprintf(fid,'%10.5f\n',real(wh));status=fclose(fid);fid=fopen('sea_top_wl1000_wh50m.dat','r');sea_dem=fscanf(fid,'%g',[800,800]);fclose(fid);%image( x, y, 256 - 255 / ( max( max( real( sea_dem ) ) ) - min( min ( real( sea_dem ) ) ) ) * ( real( sea_dem ) - min( min ( real( sea_dem ) ) ) ) );%  mesh(sea_dem) colorbar% view(0,90)%colormap(gray)

3 仿真结果

Matlab模拟三维海浪模型_第1张图片

Matlab模拟三维海浪模型_第2张图片

Matlab模拟三维海浪模型_第3张图片

Matlab模拟三维海浪模型_第4张图片

4 参考文献

[1]齐宁, 夏天, 李文岩,等. 基于MATLAB的三维海浪模型数值仿真[J]. 电脑知识与技术:学术版, 2013, 9(9):3.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

你可能感兴趣的:(物理应用,matlab)