D:\j_Iam_TEMP\_jh\_jh_ex2b_3.wxmx

# Умова

Визначити силу гідростатичного тиску на бокову грань "MN" параболоїдального каналу висотою
Hmn = 1 метр та шириною B = 3 метри. Рівень води у каналі H = 2 метри.
Аналітичні та чисельні розрахунки методом K123.

kill(all);

load(draw)$

ro:1000;g:9.81;H:2;B:3;Hmn:1;n:1000;

fh(x):=x**2;fHab(x):=Hmn;fH(x):=H;Fx(h):=sqrt(h);diff(Fx(h),h);

dh(h):=1/(2*sqrt(h));

plot2d([fh(x),fHab(x),fH(x)],[x,0,2]);

D:\j_Iam_TEMP\_jh\_jh_ex2.png

plot2d(Fx(h),[h,0,H], [color,black],[style, [lines, 5,5]]);

fp(h):=ro*g*(H-h);

# P_x - горизонтальна проекція сили тиску

P_x:integrate(fp(h)*B,h,0,Hmn);

mP_x:integrate(fp(h)*(H-h)*B*h,h,0,Hmn);

mP_x_down:integrate(fp(h)*B*h,h,0,Hmn);

h_D:mP_x/P_x;

h_D_:mP_x_down/P_x;

h_D+h_D_;

D:\j_Iam_TEMP\_jh\_jh_ex2_P_x.jpg

# P_x - чисельний алгоритм методу К123

P_x_sum:0;dh:Hmn/n;h:0;

 Pi_x(h):=ro·g·(H−h)·B; 

for i:1 while h < Hmn do (Pi:Pi_x(h)*dh,P_x_sum:P_x_sum+Pi,h:h+dh);P_x_:P_x_sum;

 Px_test:integrate(Pi_x(hi),hi,0,Hmn); 

mP_x_sum:0;dh:Hmn/n;h:0;

for i:1 while h < Hmn do (Pi:Pi_x(h)*dh*h,mP_x_sum:mP_x_sum+Pi,h:h+dh);mP_x_:mP_x_sum;

kill(h);

 mPx_test:integrate(Pi_x(h)·(h),h,0,Hmn); 

 h_D:mP_x_sum/P_x_sum;h_D_test:mPx_test/Px_test; 

Rel_ERROR:(100/h_D_test)·(h_D_test−h_D),numer; 

# P_z - вертикальна проекція сили тиску

kill(h);

ro:1000;g:9.81;H:2;B:3;Hmn:1;

P_z:integrate(fp(h)*B*dh(h),h,0,Hmn);

mP_z:integrate(fp(h)*B*dh(h)*(Fx(h)),h,0,Hmn);

x_C:mP_z/P_z;

D:\j_Iam_TEMP\_jh\_jh_ex2_P_z.jpg

# P_z - чисельний алгоритм методу К123

ro:1000;g:9.81;H:2;B:3;Hmn:1;

P_z_sum:0;dh:Hmn/n;h:0;

coordinate - x {for h=i*dh x=sqrt(h)}

 fB(i,dh):=sqrt(i·dh); fB(1,dh),numer;

Pi_x(h):=ro·g·(H−h)·B; Pi_x(0.2);

fdb(i,dh):=(fB((i+1),dh)−fB((i),dh))/dh;fdb(1000,dh),numer;

 for i: 0 while h < Hmn do (db:fdb(i,dh),Pi:Pi_x(h)·db·dh,P_z_sum:P_z_sum+Pi,h:h+dh)$ 

P_z_:P_z_sum,numer;h;

FOR MOMENT P_z coordinate - x {for h=i*dh x=sqrt(h)}

mP_z_sum:0;dh:Hmn/n;h:0;

for i: 0 while h < Hmn do (db:fdb(i,dh),Pi:Pi_x(h)·db·dh*fB(i,dh),mP_z_sum:mP_z_sum+Pi,h:h+dh)$ 

mP_z_:mP_z_sum,numer;h;

 x_C_:mP_z_/P_z_,numer; x_C;

Rel_ERROR:(100/x_C)·(x_C−x_C_),numer; 

# P - Сила гідростатичного тиску

P_x;P_z;

P:sqrt(P_x**2+P_z**2);

phi_rad:atan(P_z/P_x),numer;

phi_grad:atan(P_z/P_x)*(180/%pi),numer;

d:tan(P_z/P_x);

k:P_z/P_x;

Проекції вектора сили й координати (Projections of the force vector and coordinates)

scale:100000;

P_xv:P_x/scale;P_zv:P_z/scale;Pv:P/scale;

kill(D);

h_D;x_C;phi_rad;k;

eq:h_D=-k*x_C+D;

solve(eq,D);

D:2832833/3001000,numer;

y(x):=-k*x+D;

y(0.45);

y1(x):=x**2;

eq1:-k*x+D=x**2;

solve([eq1],[x]);

x_coord:(sqrt(9137579034730)-1500500)/2700900,numer;

h_coord:y1(x_coord);

xx:x_coord-P_xv;hh:h_coord+P_zv;

plot2d([y1(x),y(x),[discrete,[x_coord],[h_coord]],
        [discrete,[x_coord,xx],[h_coord,hh]],
        [discrete,[x_coord,xx],[h_coord,h_coord]],
        [discrete,[x_coord,x_coord],[h_coord,hh]],
    [discrete,[0,2],[2,2]]],[x,0,2.1],[y,0,2.1], 
    [style, [lines, 5,5], [lines, 3,1], [points, 5,2],[lines, 3,2],[lines, 3,2],[lines, 3,2],
        [lines, 3,1]]);

# Draw

draw2d(
proportional_axes=xy,
line_width=2,color=black,
explicit(y1(x),x,0.1,2),
color=black,nticks=160,
implicit(sin(x*y)=0.1,x,-1,1,y,-1,1),
color=blue,nticks=160,
parametric(cos(t),sin(t),t,0,2*%pi),
color=orange,nticks=160,
polar(0.1+0.8*sin(3*t),t,0,%pi),
    line_width=7,color=blue,
poly:polygon([[2,4],[2,6],[4,8],[6,8],[8,6],[8,4],[6,2],[4,2]]),
pnts:points([1,3,5,7,9,9,9,9,9,7,5,3,1,1,1,1],
[1,1,1,1,1,3,5,7,9,9,9,9,9,7,5,3]),
rct:rectangle([1,-2],[6,-7]),
ell:ellipse(6,-6,3,2,0,360),
diagr:bars([-7,2,1],[-5,5,1],[-3,7,1],[-1,6,1]),
    line_width=2,color=green, 
[v1,v2,v3]:[vector([-8,-8],[6,0]),  
vector([-8,-8],[6,6]),vector([-2,-8],[0,6])],
    color=blue,
text:label(["Diagram",-5,-1],
["Point on multybox",5,-1],
["Vector",-5,-9],
["Rectangle and elips",5,-9]))$

draw2d(
title="Parabola",
    grid = true,
    proportional_axes=xy,
line_width=4,color=black,
explicit(y1(x),x,0,1.44),
    color=black,line_width=1,
    explicit(y(x),x,0,x_coord),
    line_width=2,color=blue,
poly:polygon([[0,2],[1.4,2]]),
line_width=2,color=red,
poly:polygon([[0,1],[1,1]]),
    pnts:points([0,1],[0,1]),
    color=black,fill_color = white,
    rectangle([-0.02,-0.02],[0.02,0.02]),
    rectangle([0.98,0.98],[1.02,1.02])
)$

 draw(
delay = 1,
file_name = "zzz",
terminal = 'animated_gif,
gr2d(explicit(x^2,x,-1,1)),
gr2d(explicit(x^3,x,-1,1)),
gr2d(explicit(x^4,x,-1,1)));

draw2d(xrange = [0,10],
yrange = [0,9],
head_length = 0.7,
head_angle = 10,
vector([1,1],[0,6]),
head_angle = 20,
vector([2,1],[0,6]),
head_angle = 30,
vector([3,1],[0,6]),
head_angle = 40,
vector([4,1],[0,6]),
head_angle = 60,
vector([5,1],[0,6]),
head_angle = 90,
vector([6,1],[0,6]),
head_angle = 120,
vector([7,1],[0,6]),
head_angle = 160,
vector([8,1],[0,6]),
head_angle = 180,
vector([9,1],[0,6]) )$

 draw2d(xrange = [0,8],
yrange = [0,8],
head_length = 0.7,
vector([1,1],[6,0]),
head_both = true,
vector([1,7],[6,0]) )$

 draw2d(xrange = [0,12],
yrange = [0,10],
head_length = 1,
vector([0,1],[5,5]), /* default type */
head_type = 'empty,
vector([3,1],[5,5]),
 head_type = 'nofilled,
vector([6,1],[5,5]))$   

draw2d(key_pos = top_left,
    key = "Sinus",
explicit(sin(x),x,0,10),
    key_pos = top_right,
key = "Cosinus",
color = red,
explicit(cos(x),x,0,10) )$

draw2d(xrange = [0,10],
yrange = [0,10],
point_size = 0,
points([[5,5]]),
color = navy,
label(["Horizontal orientation (default)",5,2]),
label_orientation = 'vertical,
color = "#654321",
label(["Vertical orientation",1,5]))$

 draw2d(
grid = true,
key="x^2, linear scale",
color=red,
explicit(x^2,x,1,100),
xaxis_secondary = true,
xtics_secondary = true,
logx_secondary = true,
key = "x^2, logarithmic x scale",
color = blue,
explicit(x^2,x,1,100) )$

 draw2d(xrange = [0,10],
yrange = [0,10],
point_size = 3,
point_type = diamant,
points([[1,1],[5,1],[9,1]]),
point_type = filled_down_triangle,
points([[1,2],[5,2],[9,2]]),
point_type = asterisk,
points([[1,3],[5,3],[9,3]]),
point_type = filled_diamant,
points([[1,4],[5,4],[9,4]]),
point_type = 5,
points([[1,5],[5,5],[9,5]]),
point_type = 6,
 points([[1,6],[5,6],[9,6]]),
point_type = filled_circle,
points([[1,7],[5,7],[9,7]]),
point_type = 8,
points([[1,8],[5,8],[9,8]]),
point_type = filled_diamant,
points([[1,9],[5,9],[9,9]]) )$   

 draw2d(xrange = [0,10],
yrange = [0,4],
point_size = 3,
point_type = up_triangle,
color = blue,
points([[1,1],[5,1],[9,1]]),
points_joined = true,
point_type = square,
line_type = dots,
points([[1,2],[5,2],[9,2]]),
point_type = circle,
color = red,
line_width = 7,
  points([[1,3],[5,3],[9,3]]) )$  

 draw2d(xrange = [-1,6],
yrange = [-1,6],
head_length = 0.1,
vector([0,0],[5,2]),
unit_vectors = true,
color = red,
vector([0,3],[5,2]))$

 draw2d(
xaxis =true, xaxis_type=solid,
yaxis =true, yaxis_type=solid,
user_preamble="set grid front",
region(x^2+y^2<1 ,x,-1.5,1.5,y,-1.5,1.5))$

 draw2d(
key = "Bottom x-axis",
explicit(x+1,x,1,2),
color = red,
key = "Above x-axis",
xtics_secondary = true,
xaxis_secondary = true,
explicit(x^2,x,-1,1)) $

draw2d(explicit(x^3,x,-1,1),
xaxis = true,
xaxis_width = 3)$

 draw2d(
xaxis_secondary=true,yaxis_secondary=true,
xtics_secondary=true,ytics_secondary=true,
xlabel_secondary="t[s]",
ylabel_secondary="U[V]",
explicit(sin(t),t,0,10) )$

draw2d(yrange = [0.1,1.4],
color = red,
label(["Label in red",0,0.3]),
color = "#0000ff",
label(["Label in blue",0,0.6]),
color = light_blue,
label(["Label in light-blue",0,0.9],
["Another light-blue",0,1.2]) )$

draw2d(key = "Small points",
points(makelist([random(20),random(50)],k,1,10)),
point_type = circle,
point_size = 3,
points_joined = true,
key = "Great points",
points(makelist(k,k,1,20),makelist(random(30),k,1,20)),
point_type = filled_down_triangle,
key = "Automatic abscissas",
color = red,
points([2,12,8]))$

 draw3d(color = cyan,
vector([0,0,0],[1,1,1]/sqrt(3)),
vector([0,0,0],[1,-1,0]/sqrt(2)),
vector([0,0,0],[1,1,-2]/sqrt(6)) )$

load(worldmap)$

 /* A continent */
make_poly_continent(Europe)$

 apply(draw2d, %)$

---------------------

  staircase(cos(y), 1, 11, [y, 0, 1.2]);

# -------------------------------------------

Plot2d

fh_D(x):=h_D_;

plot2d([fh(x),fHab(x),fH(x),fh_D(x),[discrete,[0.44,0.44],[0,1]],
        [discrete,[0.44],[0.45]],vector([0.44,0.45],[0,1])],[x,0,1.5],
    [legend, "parabola","Top_box", "Water", "P_x", "P_z", "point"], 
    [style, [lines, 5,5], lines, [lines, 3,1], lines, lines, [points, 3,2]], 
    [point_type, circle]);

eq:y=x_C;plot2d([fh(x),fHab(x),fH(x),fh_D(x),eq],[x,0,2],[y,0,4]);

# Answer

P_x;P_z;P;h_D_;x_C;phi_grad;

D:\j_Iam_TEMP\_jh\_jh_ex2.jpg

Scale screen 300 px

P_x/300;P_z/300;P/300;

P_:sqrt(P_x_**2+P_z_**2);

# REL_ERRORS

Rel_ERROR_P_x:(100/P_x)·(P_x−P_x_),numer; 

Rel_ERROR_mP_x_:(100/mP_x_down)·(mP_x_down−mP_x_),numer;

Rel_ERROR_mP_z:(100/mP_z)·(mP_z−mP_z_),numer; 

Rel_ERROR_P_z:(100/P_z)·(P_z−P_z_),numer; 

Rel_ERROR_P:(100/P)·(P−P_),numer;