2020美赛B题思路分析

2020美赛B题思路分析

Wherever there are recreational sandy ocean beaches in the world, thereseem to be children (and adults) creating sandcastles on the seashore.(bk1’) Using tools,toys, and imagination, beach goers create sandcastles that range from simplemounds of sand to complicated replicas of actual castles with walls, towers,moats, and other features that mimic real castles.(bk2’) In all these, onetypically forms an initial foundation consisting of a single, nondescriptmound of wetted sand, and then proceeds to cut and shape this base into arecognizable 3-dimensional geometric shape upon which to build the morecastle-defining features.(imp1)

Inevitably, the inflow of ocean waves coupled with rising tides erodessandcastles.(pr1) It appears, however, that not all sandcastles react the same way to wavesand tides, even if built roughly the same size and at roughly the same distancefrom the water on the same beach.(pr1’) Consequently, onewonders if there exists a best 3-dimensional geometric shape to use for asandcastle foundation.(imp2)

Requirements

Construct amathematical model to identify the best 3-dimensional geometric shape to use asa sandcastle foundation that will last the longest period of time on a seashorethat experiences waves and tides under the following conditions:(spm1)

· built at roughly the same distance from the water onthe same beach, and

· built using the same type of sand, roughly the sameamount of sand, and the same water-to-sand proportion.

Using your model,determine an optimal sand-to-water mixture proportion for the castlefoundation, assuming you use no other additives or materials (e.g. plastic orwooden supports, stones, etc.).(spm1)

Adjust your modelas needed to determine how the best 3-dimensional sandcastle foundation youidentified in requirement 1 is affected by rain, and whether itremains the best 3-dimensional geometric shape to be used as a castlefoundation when it is raining.(spm2)

What otherstrategies, if any, might you use to make your sandcastle last longer?(spm1,2)

Finally, write aninformative, one- to two-page article describing your model and its results forpublication in the vacation magazine: Fun in the Sun, whose readersare mainly non-technical.(mss1)

Your submission should consist of:

· One-page Summary Sheet

· Table of Contents

· One- to Two-page Article

· Your solution of no more than 20 pages,for a maximum of 24 pages with your summary, table of contents, and article.

Note: Reference List and any appendices do not count toward the page limitand should appear after your completed solution. You should not make use ofunauthorized images and materials whose use is restricted by copyright laws.Ensure you cite the sources for your ideas and the materials used in yourreport.


author information:

Key Laboratory of Terahertz Optoelectronics, Ministry of Education; Beijing Key Laboratory for Terahertz Spectroscopy andImaging; 
Beijing Advanced Innovation Center for Imaging Theory and Technology; Department of Physics, Capital NormalUniversity

E-mail: [email protected]

Shall not be reproduced without permission or used for any commercial purposes, rights reserved

首先我们要设计一个理想的海浪模型,那么这个模型我们可以认为是一个常规的波动模型。变量我们可以根据情况增加振幅,频率,相位,载波等信息。

%%理想海浪
seawave_basic=ones(1,100);
%seawave_k=[0.1:0.1:12.1];
%seawave_h=reshape(seawave_k,1,121);
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
%seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_z);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('理想海浪');
end

但实际上我们的沙滩是一个倾斜的状况,那么这个时候一定会涉及到能量的损失,那最后在方程里我们进行调幅的处理。

%%修正后实际海浪
%clear all
seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);
seawave={
     };
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('修正后实际海浪');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end

我们现在有了海浪,那么我们还需要一个标准的沙堡,具体什么形状也是题目让我们考虑的,那么为了研究海浪到底是怎么作用和影响沙堡的,我们就建立一个标准矩形来研究。

%%沙子
sand={
     };
sand_k=1;
for sand_x=0:0.15:2.25;
   for sand_y=15:1:35;
      for sand_z=0:0.1:1;
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,sand_z); hold on;
        sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         sand_k=sand_k+1;%沙子数量
      end
   end
end
 hold on;
plotcube([2.25 20 1],[ 0  15  0],.0,[1 0 0]);

那么这里面我们不采用元胞自动机的思路,我们直接建立一个矩形,并使用scatter3函数画点,这时候我们只需要控制点的数量和密度即可,在后期我们可以认为这些点,每一个点就是一个沙粒,为后面研究沙水比等预留可操作的空间。
2020美赛B题思路分析_第1张图片

此时我们就可以把建立好的标准模型和海浪在一起作用研究,现在我们主要为了得到海浪到底是如何腐蚀我们的沙堡的。

这里面我们要考虑几个问题,第一,海浪与沙堡直接作用时是如何损失沙子的。第二,文中提到了潮汐,那么我们就可以调整海浪的相位或者载波来仿真。第三,海水不光会作用,而且还会腐蚀沙堡,这也是我们要考虑的问题。第四,那既然已经建立好了作用模型,为什么不一起把雨水也加在一起呢,这时候我们要思考雨水的腐蚀和海水的腐蚀速度一样吗?
第五,我们要思考这个沙堡到底大概能坚持多久,如果几分钟就不行了,海水的腐蚀我们还需要考虑进去吗?


根据计算机的仿真结果我们可以看到,如果在正常情况下,实际上海浪影响最大的是我们模型的地基部分,那这也就是我们后面改进模型的一个关键点。地基改进很麻烦,如果你大量的增加地基的占比,那么模型必然会又矮又胖,那么顶部也会受冲击,雨水影响增大。

为了解决这个问题,我们分别研究了类三角形结构与大坝的结构,来增加地基的占比。在模型的建立过程中,我们要尽可能的保证,受力宽度,或者说接触面积的一定,以及你沙子的数量一定才行。

这里面为了证明受力面积确实会影响数据的准确性,我们更改了大坝和金字塔的宽度。


2020美赛B题思路分析_第2张图片

2020美赛B题思路分析_第3张图片

在更改模型后我们可以非常直观的观察到宽度带来的影响,所以在这个建模中,我们一定要保证宽度一样。但有的人就会考虑,那给做成纵向的一长条岂不是很牢固,的确这是一个思路,但分流导致的压强和力学影响直接作用在地基,纵向腐蚀会减少,但稳定性大大降低。

模型出来了,那我们就要考虑下面的问题,那种最好,哪一种不会倒,或者所你可能沙子损失的少,但地基不稳直接倒塌了。

2020美赛B题思路分析_第4张图片

2020美赛B题思路分析_第5张图片
2020美赛B题思路分析_第6张图片
对于计算会不会坍塌我们其实可以有多种思路,第一种可以参考上述文献做压力分析,但这里面有很多需要商榷的细节,比如破坏准则中应力的概念和地质强度的具体数值,可靠性参数等很多数值需要我们查阅大量的资料,这个对于建模来说可以借鉴,但在写作上很费事费力,如果不能严格的解释所有的参数,只是搬公式的话就没任何的意义了。第二种可以考虑地基部分的腐蚀情况,做受力分析或者做损失比分析,我们认为单位沙子的质量是多少,需要多少沙子才能支撑起来,与沙水比有无关系。无论法一还是法二最好都考虑好沙水比带来的影响,法一则是模型抗压系数有没有区别,法二则是腐蚀速度有无区别,第一问无论如何考虑,都会和第二问严格衔接。

这时候我们就要计算整体是沙损失比和地基部分的损失比。


sand_kk=0;%冲击后总体剩余沙子
for i=1:1:11;
sand_kk=sand_kk+((16- section(i))*  21);
end

sand_kkbasic=0;%冲击后地基剩余沙子
for i=1:1:3;
sand_kkbasic=sand_kkbasic+((16- section(i))*  21);
end



rate=sand_kk/sand_k;

rate_basic=sand_kkbasic/(sand_k*(3/16));


str=['冲击后总体沙子剩余率为' num2str(rate)];
disp(str);

str_basic=['冲击后地基沙子剩余率为' num2str(rate_basic)];
disp(str_basic);

这里面还有很多细节问题值得我们去讨论,比如我们可以直观的认为沙水比是变量,但我们的沙堡真的能撑过几轮大的海浪吗,那时间内有必要考虑吗?
我们一直在考虑常规浪的情况,小浪,大浪,抵御突然的大浪和抗小浪和腐蚀的模型是否一样呢?
后面问题中沙水比,后期改进的事情,基本就要靠论文来支撑了,这些很难用计算机模拟。


接下来是代码部分

specification:

main_rectangle,main_dam and main_pyramids is main code

draw and plotcube is function to draw 3D image

Please run all code beside plotcube to collect data and images

Consider different shapes of castles in the same situation.The rectangle is the general reference group,

Pyramids and DAMS are models for reference to modern architecture.

The seawater corrosion model, rainwater corrosion model and sea wave corrosion model are introduced

The proportion of the overall sand content of the three shapes of sand castles were compared

rectangle sand loss:     0.71572     Totle
                         0.5756       base

pyramids sand loss:      0.58689     Totle
                          0.49123     base

dam sand loss:        0.66675        Totle
                       0.51667        base

The data in this txt is for reference only; more complex factors need to be considered in the actual problem model.
clc
clear all
%close all

time=12.1;%实验时间
timex=0;
  if time<=5
    timex=0;
  end

if time>=5 && time<10
    timex=1;
end
if time>=10 && time<15
    timex=2;
end
if time>=15 && time<20
    timex=3;
end


%%理想海浪
seawave_basic=ones(1,100);
%seawave_k=[0.1:0.1:12.1];
%seawave_h=reshape(seawave_k,1,121);
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
%seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_z);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('理想海浪');
end

%%修正后实际海浪
%clear all
seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);
seawave={
     };
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('修正后实际海浪');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end

%%沙子
sand={
     };
sand_k=1;
for sand_x=0:0.15:2.25;
   for sand_y=15:1:35;
      for sand_z=0:0.1:1;
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,sand_z); hold on;
        sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         sand_k=sand_k+1;%沙子数量
      end
   end
end
 hold on;
plotcube([2.25 20 1],[ 0  15  0],.0,[1 0 0]);

%%计算冲击
section_1=0;  %从下往上数的层数
section_2=0;
section_3=0;
section_4=0;
section_5=0;
section_6=0;
section_7=0;
section_8=0;
section_9=0;
section_10=0;
section_11=0;



for compute_1=1:1:50       %调参数最大为121
    if seawave_zz(1,compute_1) >=0 && seawave_zz(1,compute_1)<0.05
        section_1=section_1+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.05 && seawave_zz(1,compute_1)<0.15
        section_2=section_2+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.15 && seawave_zz(1,compute_1)<0.25
        section_3=section_3+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.25 && seawave_zz(1,compute_1)<0.35
        section_4=section_4+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.35 && seawave_zz(1,compute_1)<0.45
        section_5=section_5+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.45 && seawave_zz(1,compute_1)<0.55
        section_6=section_6+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.55 && seawave_zz(1,compute_1)<0.65
        section_7=section_7+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.65 && seawave_zz(1,compute_1)<0.75
        section_8=section_8+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.75 && seawave_zz(1,compute_1)<0.85
        section_9=section_9+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.85 && seawave_zz(1,compute_1)<0.95
        section_10=section_10+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.95 && seawave_zz(1,compute_1)<1.15
        section_11=section_11+1;
        continue;
    end
   
end


section=[section_1 section_2 section_3 section_4 section_5 section_6 section_7 section_8 section_9 section_10 section_11];
%c层数从1层到11%section=section.*2;

%%海水腐蚀

section=section+timex;





 %%冲击过后

seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);


figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('冲击后沙雕');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end



sand_kk=0;zh=0;
 for rebuild=1:1:11

    
    sand_limx=2.25-section(rebuild).*0.15;


for sand_x=0:0.15:sand_limx;
   for sand_y=15:1:35;
      %sand_z=((rebuild-1)./10);
      sand_z=zh;
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   % plot3(sand_x,sand_y,sand_z); hold on;
   scatter3(sand_x,sand_y,sand_z); hold on;
        %sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         
      
   end
end
zh=zh+0.1-timex.*0.002;
%{
     
if timex==1
    zh=zh-0.1.*timex;
end

  if timex==2
    zh=zh-0.1.*timex;
  end
if timex==3
    zh=zh-0.1.*timex;
end
%}
  end
 hold on;
plotcube([2.25 20 1],[ 0  15  0],.0,[1 0 0]);


sand_kk=0;%冲击后总体剩余沙子
for i=1:1:11;
sand_kk=sand_kk+((16- section(i))*  21);
end

sand_kkbasic=0;%冲击后地基剩余沙子
for i=1:1:3;
sand_kkbasic=sand_kkbasic+((16- section(i))*  21);
end



rate=sand_kk/sand_k;

rate_basic=sand_kkbasic/(sand_k*(3/16));


str=['冲击后总体沙子剩余率为' num2str(rate)];
disp(str);

str_basic=['冲击后地基沙子剩余率为' num2str(rate_basic)];
disp(str_basic);


judge=0;

if rate<=0.6
    judge=judge+1;
end

if rate_basic<=0.7
    judge=judge+1;
end

if judge~=0
  str_basic2=['矩形沙堡结构稳定性被破坏' ];
disp(str_basic2);
end

if judge==0
  str_basic3=['矩形沙堡结构稳定' ];
disp(str_basic3);
end

clc
clear all
close all

time=12.1;%实验时间
timex=0;
  if time<=5
    timex=0;
  end

if time>=5 && time<10
    timex=1;
end
if time>=10 && time<15
    timex=2;
end
if time>=15 && time<20
    timex=3;
end

%%修正后实际海浪
%clear all
seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);
seawave={
     };
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('修正后实际海浪');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end




sand={
     };
sand_k=1;

%%沙子三角形
for sand_y=10:1:40;
sand_x1=0;
sand_x2=3;

for sand_z=0:0.1:1;
for sand_x=sand_x1:0.15:sand_x2;
   
      
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,sand_z); hold on;
        sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         sand_k=sand_k+1;%沙子数量
         
end
      sand_x2=sand_x2-0.15;
         sand_x1=sand_x1+0.15;
   end
end

hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 1.5, 3]; 
y=[10,10, 10]; 
z=[0, 1, 0]; 
plot3(x, y, z,'r')      
 hold on
x=[0, 1.5, 3]; 
y=[40,40, 40]; 
z=[0, 1, 0]; 
plot3(x, y, z,'r') 
  hold on
x=[ 1.5, 1.5]; 
y=[10, 40]; 
z=[ 1, 1]; 
plot3(x, y, z,'r')



%%计算冲击
section_1=0;  %从下往上数的层数
section_2=0;
section_3=0;
section_4=0;
section_5=0;
section_6=0;
section_7=0;
section_8=0;
section_9=0;
section_10=0;
section_11=0;



for compute_1=1:1:50       %调参数最大为121
    if seawave_zz(1,compute_1) >=0 && seawave_zz(1,compute_1)<0.05
        section_1=section_1+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.05 && seawave_zz(1,compute_1)<0.15
        section_2=section_2+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.15 && seawave_zz(1,compute_1)<0.25
        section_3=section_3+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.25 && seawave_zz(1,compute_1)<0.35
        section_4=section_4+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.35 && seawave_zz(1,compute_1)<0.45
        section_5=section_5+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.45 && seawave_zz(1,compute_1)<0.55
        section_6=section_6+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.55 && seawave_zz(1,compute_1)<0.65
        section_7=section_7+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.65 && seawave_zz(1,compute_1)<0.75
        section_8=section_8+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.75 && seawave_zz(1,compute_1)<0.85
        section_9=section_9+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.85 && seawave_zz(1,compute_1)<0.95
        section_10=section_10+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.95 && seawave_zz(1,compute_1)<1.15
        section_11=section_11+1;
        continue;
    end
   
end


section=[section_1 section_2 section_3 section_4 section_5 section_6 section_7 section_8 section_9 section_10 section_11];
%c层数从1层到11%%海水腐蚀
section=section+timex;




 %%冲击过后

seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);


figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('冲击后沙雕');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end


sand_x1=0;
sand_x2=3;
sand_kk=0;zh=0;
 for rebuild=1:1:11

    
    sand_x2=sand_x2-section(rebuild).*0.15;


for sand_y=10:1:40;

for sand_x=sand_x1:0.15:sand_x2;
      sand_z=zh;
      
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,zh); hold on;
       % sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         %sand_k=sand_k+1;%沙子数量
         
end
end
zh=zh+0.1-timex.*0.002;
sand_x1=sand_x1+0.15;
sand_x2=sand_x2-0.15+section(rebuild).*0.15;
 

 end
 

hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 1.5, 3]; 
y=[10,10, 10]; 
z=[0, 1, 0]; 
plot3(x, y, z,'r')      
 hold on
x=[0, 1.5, 3]; 
y=[40,40, 40]; 
z=[0, 1, 0]; 
plot3(x, y, z,'r') 
  hold on
x=[ 1.5, 1.5]; 
y=[10, 40]; 
z=[ 1, 1]; 
plot3(x, y, z,'r')

 

%%
sand_kk=0;%冲击后总体剩余沙子
for i=1:1:11;
sand_kk=sand_kk+(section(i)* 31);
end
sand_kk=sand_k-sand_kk;


sand_kkbasic=0;%冲击后地基剩余沙子
for i=1:1:3;
sand_kkbasic=sand_kkbasic+(section(i)* 31);
end
sand_kkbasic_orignal=(21+19+17)*31;
sand_kkbasic=sand_kkbasic_orignal-sand_kkbasic;


rate=sand_kk/sand_k;

rate_basic=sand_kkbasic/sand_kkbasic_orignal;


str=['冲击后总体沙子剩余率为' num2str(rate)];
disp(str);

str_basic=['冲击后地基沙子剩余率为' num2str(rate_basic)];
disp(str_basic);


judge=0;

if rate<=0.6
    judge=judge+1;
end

if rate_basic<=0.7
    judge=judge+1;
end

if judge~=0
  str_basic2=['金字塔形沙堡结构稳定性被破坏' ];
disp(str_basic2);
end

if judge==0
  str_basic3=['金字塔形沙堡结构稳定' ];
disp(str_basic3);
end



clc
clear all
close all

time=12.1;%实验时间
timex=0;
  if time<=5
    timex=0;
  end

if time>=5 && time<10
    timex=1;
end
if time>=10 && time<15
    timex=2;
end
if time>=15 && time<20
    timex=3;
end

%%修正后实际海浪
%clear all
seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);
seawave={
     };
figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('修正后实际海浪');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end




sand={
     };
sand_k=1;

%%沙子三角形
for sand_y=10:1:40;
sand_x1=0;
sand_x2=3;

for sand_z=0:0.1:0.6;
for sand_x=sand_x1:0.15:sand_x2;
   
      
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,sand_z); hold on;
        sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         sand_k=sand_k+1;%沙子数量
         
end
      sand_x2=sand_x2-0.15;
         %sand_x1=sand_x1+0.15;
   end
end
%figure
hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0, 2.1,3]; 
y=[10,10, 10,10]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0, 2.1,3]; 
y=[40,40, 40,40]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'r') 
hold on
x=[2.1, 2.1]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'r') 

%%计算冲击
section_1=0;  %从下往上数的层数
section_2=0;
section_3=0;
section_4=0;
section_5=0;
section_6=0;
section_7=0;
section_8=0;
section_9=0;
section_10=0;
section_11=0;



for compute_1=1:1:50       %调参数最大为121
    if seawave_zz(1,compute_1) >=0 && seawave_zz(1,compute_1)<0.05
        section_1=section_1+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.05 && seawave_zz(1,compute_1)<0.15
        section_2=section_2+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.15 && seawave_zz(1,compute_1)<0.25
        section_3=section_3+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.25 && seawave_zz(1,compute_1)<0.35
        section_4=section_4+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.35 && seawave_zz(1,compute_1)<0.45
        section_5=section_5+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.45 && seawave_zz(1,compute_1)<0.55
        section_6=section_6+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.55 && seawave_zz(1,compute_1)<0.65
        section_7=section_7+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.65 && seawave_zz(1,compute_1)<0.75
        section_8=section_8+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.75 && seawave_zz(1,compute_1)<0.85
        section_9=section_9+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.85 && seawave_zz(1,compute_1)<0.95
        section_10=section_10+1;
        continue;
    end
    if seawave_zz(1,compute_1) >=0.95 && seawave_zz(1,compute_1)<1.15
        section_11=section_11+1;
        continue;
    end
   
end


section=[section_1 section_2 section_3 section_4 section_5 section_6 section_7 section_8 section_9 section_10 section_11];
%c层数从1层到11%%海水腐蚀
section=section+timex;




 %%冲击过后

seawave_basic=ones(1,100);
seawave_k=[0:0.0083:1];
seawave_h=reshape(seawave_k,1,121);


figure;
for seawave_i=1:1:50   
seawave_x=0:pi/30:4*pi;
seawave_y=seawave_basic.*seawave_i;
[seawave_x,seawave_y]=meshgrid(seawave_x,seawave_y);
seawave_z=sin(pi.*seawave_x);
seawave_zz=seawave_z.*seawave_h;
hold on ;
mesh(seawave_x,seawave_y,seawave_zz);
xlabel('X 取值');
ylabel('宽度');
zlabel('振幅');
title('冲击后沙雕');
%[seawave_x,seawave_zz]=meshgrid(seawave_x,seawave_zz);
%seawave{
     1}=[seawave_x,seawave_zz];%海浪幅度[x,z]
end


sand_x1=0;
sand_x2=3;
sand_kk=0;zh=0;
 for rebuild=1:1:7

    
    sand_x2=sand_x2-section(rebuild).*0.15;


for sand_y=10:1:40;

for sand_x=sand_x1:0.15:sand_x2;
      sand_z=zh;
      
   [sand_x,sand_z]=meshgrid(sand_x,sand_z);
   scatter3(sand_x,sand_y,zh); hold on;
       % sand{
     sand_k}=[sand_x,sand_z]; %侧视图[x,z]
         %sand_k=sand_k+1;%沙子数量
         
end
end
zh=zh+0.1-timex.*0.002;
%sand_x1=sand_x1+0.15;
sand_x2=sand_x2-0.15+section(rebuild).*0.15;
 

 end
 
hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0, 2.1,3]; 
y=[10,10, 10,10]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0, 2.1,3]; 
y=[40,40, 40,40]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'r') 
 hold on
x=[0, 0]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'r') 
hold on
x=[2.1, 2.1]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'r') 


%%
sand_kk=0;%冲击后总体剩余沙子
for i=1:1:7;
sand_kk=sand_kk+(section(i)* 31);
end
sand_kk=sand_k-sand_kk;


sand_kkbasic=0;%冲击后地基剩余沙子
for i=1:1:3;
sand_kkbasic=sand_kkbasic+(section(i)* 31);
end
sand_kkbasic_orignal=(21+20+19)*31;
sand_kkbasic=sand_kkbasic_orignal-sand_kkbasic;


rate=sand_kk/sand_k;

rate_basic=sand_kkbasic/sand_kkbasic_orignal;


str=['冲击后总体沙子剩余率为' num2str(rate)];
disp(str);

str_basic=['冲击后地基沙子剩余率为' num2str(rate_basic)];
disp(str_basic);


judge=0;

if rate<=0.6
    judge=judge+1;
end

if rate_basic<=0.7
    judge=judge+1;
end

if judge~=0
  str_basic2=['水坝形沙堡结构稳定性被破坏' ];
disp(str_basic2);
end

if judge==0
  str_basic3=['水坝形沙堡结构稳定' ];
disp(str_basic3);
end
clc;
figure;
subplot(1,3,1);
hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'k') 
 hold on
x=[0, 0, 2.1,3]; 
y=[10,10, 10,10]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'k') 
 hold on
x=[0, 0, 2.1,3]; 
y=[40,40, 40,40]; 
z=[0, 0.6, 0.6,0]; 
plot3(x, y, z,'k') 
 hold on
x=[0, 0]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'k') 
hold on
x=[2.1, 2.1]; 
y=[10,40]; 
z=[0.6, 0.6]; 
plot3(x, y, z,'k')
title('大坝形轮廓')


%%
%figure;
subplot(1,3,2);
hold on
x=[0, 3, 3,0,0]; 
y=[10,10, 40,40,10]; 
z=[0, 0, 0,0,0]; 
plot3(x, y, z,'k') 
 hold on
x=[0, 1.5, 3]; 
y=[10,10, 10]; 
z=[0, 1, 0]; 
plot3(x, y, z,'k')      
 hold on
x=[0, 1.5, 3]; 
y=[40,40, 40]; 
z=[0, 1, 0]; 
plot3(x, y, z,'k') 
  hold on
x=[ 1.5, 1.5]; 
y=[10, 40]; 
z=[ 1, 1]; 
plot3(x, y, z,'k')
title('金字塔形轮廓')
 

%%
%figure;
subplot(1,3,3);
plotcube([2.25 20 1],[ 0  15  0],.0,[1 0 0]);
title('矩形轮廓')
function plotcube(varargin)
% PLOTCUBE - Display a 3D-cube in the current axes
%
%   PLOTCUBE(EDGES,ORIGIN,ALPHA,COLOR) displays a 3D-cube in the current axes
%   with the following properties:
%   * EDGES : 3-elements vector that defines the length of cube edges
%   * ORIGIN: 3-elements vector that defines the start point of the cube
%   * ALPHA : scalar that defines the transparency of the cube faces (from 0
%             to 1)
%   * COLOR : 3-elements vector that defines the faces color of the cube
%
% Example:
%   >> plotcube([5 5 5],[ 2  2  2],.8,[1 0 0]);
%   >> plotcube([5 5 5],[10 10 10],.8,[0 1 0]);
%   >> plotcube([5 5 5],[20 20 20],.8,[0 0 1]);

% Default input arguments
inArgs = {
      ...
  [10 56 100] , ... % Default edge sizes (x,y and z)
  [10 10  10] , ... % Default coordinates of the origin point of the cube
  .7          , ... % Default alpha value for the cube's faces
  [1 0 0]       ... % Default Color for the cube
  };

% Replace default input arguments by input values
inArgs(1:nargin) = varargin;

% Create all variables
[edges,origin,alpha,clr] = deal(inArgs{
     :});

XYZ = {
      ...
  [0 0 0 0]  [0 0 1 1]  [0 1 1 0] ; ...
  [1 1 1 1]  [0 0 1 1]  [0 1 1 0] ; ...
  [0 1 1 0]  [0 0 0 0]  [0 0 1 1] ; ...
  [0 1 1 0]  [1 1 1 1]  [0 0 1 1] ; ...
  [0 1 1 0]  [0 0 1 1]  [0 0 0 0] ; ...
  [0 1 1 0]  [0 0 1 1]  [1 1 1 1]   ...
  };

XYZ = mat2cell(...
  cellfun( @(x,y,z) x*y+z , ...
    XYZ , ...
    repmat(mat2cell(edges,1,[1 1 1]),6,1) , ...
    repmat(mat2cell(origin,1,[1 1 1]),6,1) , ...
    'UniformOutput',false), ...
  6,[1 1 1]);


cellfun(@patch,XYZ{
     1},XYZ{
     2},XYZ{
     3},...
  repmat({
     clr},6,1),...
  repmat({
     'FaceAlpha'},6,1),...
  repmat({
     alpha},6,1)...
  );

view(3);

end

你可能感兴趣的:(1,数学建模,算法)