D:\j_Iam_TEMP\_jh\_jh_ex2b_3a_v1.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;

solutions:solve([eq1],[x]);

xvals: map(rhs, solutions);

x_coord:xvals[2],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

/*  y = 1-1-4 */

fv(y):=(2-0.25*y)/2;

draw2d(xrange = [-1.1,4],
yrange = [0,2.5],
    font      = "Arial",
             font_size = 16,
title="Parabola",
    grid = true,
    proportional_axes=xy,
     /*   vertical W */
    fill_color  = lightblue,
    Wall:polygon([[0,0],[0,2],[1,2],[1,1],[0.75,0.75**2],[0.5,0.5**2],[0.25,0.25**2],[0,0]]),
    W:polygon([[0,0],[0,2]]),
    W:polygon([[0.25,0.25**2],[0.25,2]]),
    W:polygon([[0.5,0.5**2],[0.5,2]]),
    W:polygon([[0.75,0.75**2],[0.75,2]]),
    W:polygon([[1,1**2],[1,2]]),
line_width=4,color=black,
explicit(y1(x),x,0,1.44),
    line_width=4,color=grey,
explicit(y1(x),x,1,sqrt(2)),
    color=red,line_width=1,
    explicit(y(x),x,0,x_coord),
    line_width=3,color=blue,
poly:polygon([[0,2],[sqrt(2),2]]),
    color=black,line_width=1,
    head_both = true,
    head_length = 0.2,
    head_angle = 10,
vector([2,2.2],[1,0]),
    label(["B",2.5,2.3]),
    points_joined = true,
    points([[2,2],[2,2.3]]),
    points([[3,2],[3,2.3]]),
    points([[3,2],[3.3,2]]),
    points([[3,0],[3,0.3]]),
    vector([3.3,0],[0,2]),
    points_joined = false,
    label_orientation = 'vertical,
label(["H",3.2,1]),
    label_orientation = 'horizontal,
    head_both = false,
    line_type = solid,
    head_length = 0.2,
head_angle = 5,
    color = black,
vector([x_C,(2.3)],[0,-0.3]),
    label(["p_a",x_C+0.2,2+0.2]),
line_width=3,color=blue,line_type = dots,
poly:polygon([[0,1],[1,1]]),
color=black,point_type = filled_circle,point_size = 1.5,
points([[0,0],[1,1]]),
color=red,point_type = filled_circle,
points([[x_coord,h_coord],[x_C,h_D]]),
/*    color = red,
label(["Proection center pressure",x_C+0.7,h_coord]),
    color = navy,
label(["Horizontal proection vector (default)",x_C+1.3,h_D+0.1]), */
        color = black,
    label(["Px",x_C-0.3,h_D+0.1]),
    label(["(0.56,0.31)",x_C+0.7,h_D-0.1]),
/* label_orientation = 'vertical,
color = "#654321",
label(["Vertical orientation",x_C-0.2,h_D+0.6]), */
    label_orientation = 'vertical,
label(["Pz",x_C-0.1,h_D+0.4]),
    line_type = solid,
    head_length = 0.2,
head_angle = 5,
    color = black,
    line_width=1.5,
vector([x_C,(h_D+P_zv)],[0,-(P_zv)]),
 vector([x_C-P_xv,h_D],[P_xv,0]),
vector([(x_C-P_xv),(h_D+P_zv)],[P_xv,-P_zv]),
    color = black, fill_color  = "#eeeeee",
rectangle([2,0],[3,2]),
    color = black,
     fill_color  = "#cccccc",
    line_width=4,
 rectangle([2,0],[3,1]),
    /* Epura  */
    line_width=1,color=blue,line_type = short_long_dashes,
    fill_color  = "#ffffff",
poly:polygon([[0-0.1,0],[0-0.1,2],[-1-0.1,0],[0-0.1,0]]),
    line_width=1,color=blue,line_type = solid,
    fill_color  = lightblue,
poly:polygon([[0-0.1,0],[0-0.1,1],[-0.5-0.1,1],[-1-0.1,0],[0-0.1,0]]),
    /*   vertical W
    Wall:polygon([[0,0],[0,2],[1,2],[1,1],[0.75,0.75**2],[0.5,0.5**2],[0.25,0.25**2],[0,0]]),
    W:polygon([[0,0],[0,2]]),
    W:polygon([[0.25,0.25**2],[0.25,2]]),
    W:polygon([[0.5,0.5**2],[0.5,2]]),
    W:polygon([[0.75,0.75**2],[0.75,2]]),
    W:polygon([[1,1**2],[1,2]]),  */
    /*  Epura vectors */
  line_type = solid,
    head_length = 0.3,
head_angle = 5,
    color = blue,
    line_width=3, 
    vector([-fv(0)-0.05,0],[fv(0)-0.05,0]), 
    vector([-fv(1)-0.05,0.25],[fv(1)-0.05,0]), 
    vector([-fv(2)-0.05,0.5],[fv(2)-0.05,0]), 
    vector([-fv(3)-0.05,0.75],[fv(3)-0.05,0]),
    vector([-fv(4)-0.05,1],[fv(4)-0.05,0]),
        /*  GPL */
 font      = "Arial",
             font_size = 16,
    color = "#0e406e",
 label_orientation = 'vertical,
label(["www.k123.org.ua ",3.5,1.3]),
    label(["Kopanytsia Y (c)  2025",3.8,1.3])
)$

D:\j_Iam_TEMP\_jh\_jh_ex2b_3a_v1.svg

hh;h_D;

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

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]);

D:\j_Iam_TEMP\_jh\_jh_ex2c.png

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;