D:\jknuba_2024_winter\j_MAXIMA_Iam\jh_k123_Rectangle_v3.wxmx

Rectangle

# Задача. Визначити силу тиску на плоску прямокутну поверхню шириною B=3 м та висотою H=7 м. На вільній поверхні рідини атмосферний тиск . 

kill(all);

ro:1000;g:9.81;H:7;B:3;p_m:10000;

 del1:H/15,numer;del2:H/10,numer;del3:H/7,numer; del4:H/5,numer;del5:H/3,numer; 

dh:H/5,numer;

'integrate((ro*g*(H-h))*B,h,0,H);integrate((ro*g*(H-h))*B,h);

pi(h):=9810.0*(H-h);

P:integrate(ro*g*(H-h)*B,h,0,H);

if P<10 then scale:3 elseif P<100 then scale:20
    elseif P<1000 then scale:200
    elseif P<10000 then scale:2000
    elseif P<100000 then scale:20000
    elseif P<1000000 then scale:200000
    elseif P<10000000 then scale:2000000
    ;

pi(0);pi(0)/scale;

'integrate(ro*g*((H-h)**2)*B,h,0,H);

mP:integrate(ro*g*((H-h)**2)*B,h,0,H);

h_D:mP/P;h_D_:H-h_D;

x_draw:3*B;y_draw:H+2;

n: h_D_;mod(n,1);

/* make float to string */;

if floor(n*100)/100>0 then n:floor(n*100)/100 elseif floor(n*1000)/1000>0 then n:floor(n*1000)/1000;

n:n,numer;

hh:sconcat(n);

hh;

pp:sconcat(P);

pp;

/*  p_:printf(false, "~d", n);stringp(pp);p_;n;  */;

/*  https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/34939E59-E2C1-484B-A0CF-C6D70CB9E835@peterpall.de/   */;

scale_p:pi(0);

draw2d(xrange = [-5,x_draw],
yrange = [0,y_draw],
   font      = "Arial",
            font_size = 16,
title="Rectangle",
    xlabel = "Presure, Pa",
ylabel = "h,m",
   grid = true,
   proportional_axes=xy,
   line_type = solid,
    color = black,
   fill_color = "#cccccc",
  line_width=1,
rectangle([0,0],[B,H]),
   line_width=2,color=blue,
    water:polygon([[-3,H],[-1,H]]),
water:polygon([[0,H],[B,H]]),
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
vector([0,H+del1],[B,0]),
   label(["B",B/2,H+del3]),
     points_joined = true,
   points([[0,H],[0,H+del2]]),
   points([[B,H],[B,H+del2]]),
   points([[B,0],[B+del4,0]]),
   points([[B,H],[B+del4,H]]),
   vector([B+del4,0],[0,H]),
   points_joined = false,
   label_orientation = 'vertical,
label(["H",B+del2,H/2]), 
    /*  p_a  */
    color = black,
   label_orientation = 'horizontal,
   head_both = false,
   line_type = solid,
   head_length = 0.2,
head_angle = 10,
   color = black,
vector([-2.5,(H+del3)],[0,−del3]),
   label(["p_a",-2.5-0.5+del3,H+del3]),
     /* Epura  */
  line_width=1,color=blue,line_type = solid,
  fill_color = lightblue,
poly:polygon([[−1,0],[−1,H],[−pi(0)/scale_p−1,0],[0−1,0]]),
 head_length = 0.3,
head_angle = 10,
  color = blue,
  line_width=2,
    head_both = false,
  vector([−pi(dh*0)/scale_p−1,H-5*dh],[pi(dh*0)/scale_p,0]),
  vector([−pi(dh*1)/scale_p−1,H-4*dh],[pi(dh*1)/scale_p,0]),
  vector([−pi(dh*2)/scale_p−1,H-3*dh],[pi(dh*2)/scale_p,0]),
  vector([−pi(dh*3)/scale_p−1,H-2*dh],[pi(dh*3)/scale_p,0]),
  vector([−pi(dh*4)/scale_p−1,H-1*dh],[pi(dh*4)/scale_p,0]), 
     transparent = true,
    line_width=1,
    color = black,
    points_joined = true,
    point_size=0.1,
   points([[-2,0],[-1,0],[-1,H+del2]]),
    line_width=2,color=blue,
    water:points([[-2,H],[-1,H]]),
    color = red,
  label(["Px",-1-del4,h_D_+del2]),
  label([hh,-1+del2,h_D_+del1]),
    line_type = solid,
  head_length = 0.3,
head_angle = 15,
  line_width=2,
    point_type = filled_circle,
    point_size=1,
    vector([-1−P/(scale*2),h_D_],[P/(scale*2),0]),
   points([[-1,h_D_]]),
    points([[B/2,h_D_]]),
    label_orientation = 'horizontal,
label(["D",B/2+del1,h_D_]), 
    /*  h_D  */
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
     vector([-1+del2,0],[0,h_D_]),
   points_joined = false,
   label_orientation = 'vertical,
label(["h_D_",-del2,h_D_/2]), 
    points_joined = true,
    point_size=0.1,
   points([[-1,h_D_],[-1+del3,h_D_]]),
    /* copy right  */
    color = "#0e406e",
label_orientation = 'vertical,
label(["www.k123.org.ua ",3*B-1,H/2]),
   label(["Kopanytsia Y (c)  2025",3*B-0.5,H/2]),
    /*  Results  */
    color = "#0e406e",
/*   rectangle([0,y_draw-del4],[x_draw,y_draw]), */
   label_orientation = 'horizontal,
label([hh,x_draw/2,y_draw-del3]),
    label(["h_D [m]",x_draw/2,y_draw-del1/2]),
    label([pp,x_draw-del4,y_draw-del3]),
    label(["P [N]",x_draw-del4,y_draw-del1/2])
/*    key = "Force",
xtics_secondary = true,
    ytics_secondary = true,
    xaxis_secondary = true,
    yaxis_secondary = true,
    xlabel_secondary="P[N]",
    ylabel_secondary="p[Pa]",
     yrange_secondary=[-49050.0,2/5*49050.0],
    xrange_secondary=[-P,P] */
)$

P;P/scale;

D:\j_Iam_TEMP\_jh\jh_k123_Rectangle_v1_1.svg

H-2*dh;H;dh;

Var 2 (down)

'integrate(ro*g*((H-h)*h)*B,h,0,H);

mP_down:integrate(ro*g*((H-h)*h)*B,h,0,H);

h_D_down:mP_down/P;

# Numerical method K123 (Rectangle)

P_sum:0; n:5; dh:H/n;P_sum2:0;

fP(i):=ro*g*(H-i*dh)*(B*dh);

tex(fP(i):=ro*g*(H-i*dh)*(B*dh));

fP2(i):=ro*g*(H-(i*dh+dh/2))*(B*dh);

for i:0 thru n-1 step 1 do (Pi:fP(i),P_sum:P_sum+Pi)$

for i:0 thru n-1 step 1 do (Pi:fP2(i),P_sum2:P_sum2+Pi,Pv[i]:Pi)$

P_sum;P_sum2;P;

(P-P_sum)/(P/100);(P-P_sum2)/(P/100);

Pv[4];

scale_p2:scale_p/2;

draw2d(xrange = [-5,x_draw],
yrange = [0,y_draw],
   font      = "Arial",
            font_size = 16,
title="Rectangle",
    xlabel = "Presure, Pa",
ylabel = "h,m",
   grid = true,
   proportional_axes=xy,
   line_type = solid,
    color = black,
   fill_color = "#cccccc",
  line_width=1,
rectangle([0,0],[B,H]),
   line_width=2,color=blue,
    water:polygon([[-3,H],[-1,H]]),
water:polygon([[0,H],[B,H]]),
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
vector([0,H+del1],[B,0]),
   label(["B",B/2,H+del3]),
     points_joined = true,
   points([[0,H],[0,H+del2]]),
   points([[B,H],[B,H+del2]]),
   points([[B,0],[B+del4,0]]),
   points([[B,H],[B+del4,H]]),
   vector([B+del4,0],[0,H]),
   points_joined = false,
   label_orientation = 'vertical,
label(["H",B+del2,H/2]), 
    /*  p_a  */
    color = black,
   label_orientation = 'horizontal,
   head_both = false,
   line_type = solid,
   head_length = 0.2,
head_angle = 10,
   color = black,
vector([-2.5,(H+del3)],[0,−del3]),
   label(["p_a",-2.5-0.5+del3,H+del3]),
     /* Epura  */
  line_width=1,color=blue,line_type = solid,
  fill_color = lightblue,
/* poly:polygon([[−1,0],[−1,H],[−pi(0)/scale_p2−1,0],[0−1,0]]), */
 head_length = 0.3,
head_angle = 10,
  color = blue,
  line_width=1,
    head_both = false,
    rectangle([-1,dh*0],[−pi(dh*0+dh/2)/scale_p2−1,dh]),
  vector([−pi(dh*0+dh/2)/scale_p2−1,H-5*dh+dh/2],[pi(dh*0+dh/2)/scale_p2,0]),
    label(["p_i",-pi(dh*0+dh/2-del5)/scale_p2,H-5*dh+dh/2+del1]),
  rectangle([-1,dh*1],[−pi(dh*1+dh/2)/scale_p2−1,dh*2]),
  vector([−pi(dh*1+dh/2)/scale_p2−1,H-4*dh+dh/2],[pi(dh*1+dh/2)/scale_p2,0]),
    label(["p_i",-pi(dh*1+dh/2-del5)/scale_p2,H-4*dh+dh/2+del1]),
  rectangle([-1,dh*2],[−pi(dh*2+dh/2)/scale_p2−1,dh*3]),
  vector([−pi(dh*2+dh/2)/scale_p2−1,H-3*dh+dh/2],[pi(dh*2+dh/2)/scale_p2,0]),
    label(["p_i",-pi(dh*2+dh/2-del5)/scale_p2,H-3*dh+dh/2+del1]),
  rectangle([-1,dh*3],[−pi(dh*3+dh/2)/scale_p2−1,dh*4]),
  vector([−pi(dh*3+dh/2)/scale_p2−1,H-2*dh+dh/2],[pi(dh*3+dh/2)/scale_p2,0]),
    label(["p_i",-pi(dh*3+dh/2-del5)/scale_p2,H-2*dh+dh/2+del1]),
  rectangle([-1,dh*4],[−pi(dh*4+dh/2)/scale_p2−1,dh*5]),
  vector([−pi(dh*4+dh/2)/scale_p2−1,H-1*dh+dh/2],[pi(dh*4+dh/2)/scale_p2,0]),
    label(["p_i",-pi(dh*4-del5)/scale_p2,H-1*dh+dh/2+del1]),
  color=black,line_type = dashes,
    transparent = true,
  /*  fill_color = lightblue, */
 poly:polygon([[−1,0],[−1,H],[−pi(0)/scale_p2−1,0],[0−1,0]]), 
 
    transparent = true,
    line_width=1,
    color = black,
    points_joined = true,
    point_size=0.1,
   points([[-2,0],[-1,0],[-1,H+del2]]),
    line_width=2,color=blue,
    water:points([[-2,H],[-1,H]]),
    color = red,
  label(["Px",-1-del4,h_D_+del2]),
  label([hh,-1+del2,h_D_+del1]),
    line_type = solid,
  head_length = 0.3,
head_angle = 15,
  line_width=2,
    point_type = filled_circle,
    point_size=1,
    vector([-1−P/(scale*2),h_D_],[P/(scale*2),0]),
   points([[-1,h_D_]]),
    points([[B/2,h_D_]]),
    label_orientation = 'horizontal,
label(["D",B/2+del1,h_D_]), 
    /*  h_D  */
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
     vector([-1+del2,0],[0,h_D_]),
    /*  dh   */
     vector([-1-del1-pi(dh*0+dh/2-del4)/scale_p2,0],[0,dh]),
    points_joined = true,
    point_size=0.1,
    points([[-1-del1-pi(dh*0+dh/2-del5)/scale_p2,dh],
            [-1-del1-pi(dh*0+dh/2-del5)/scale_p2+del3,dh]]),
   points_joined = false,
   label_orientation = 'vertical,
    color = red,
label(["h_D_",-del2,h_D_/2]), 
    color = black,
    label(["dh",-1-del2-pi(dh*0+dh/2-del5)/scale_p2,dh/2]), 
    points_joined = true,
    point_size=0.1,
   points([[-1,h_D_],[-1+del3,h_D_]]),
    /* copy right  */
    color = "#0e406e",
label_orientation = 'vertical,
label(["www.k123.org.ua ",3*B-1,H/2]),
   label(["Kopanytsia Y (c)  2025",3*B-0.5,H/2]),
    /*  Results  */
    color = "#0e406e",
/*   rectangle([0,y_draw-del4],[x_draw,y_draw]), */
   label_orientation = 'horizontal,
label([hh,x_draw/2,y_draw-del3]),
    label(["h_D [m]",x_draw/2,y_draw-del1/2]),
    label([pp,x_draw-del4,y_draw-del3]),
    label(["P [N]",x_draw-del4,y_draw-del1/2])
/*    key = "Force",
xtics_secondary = true,
    ytics_secondary = true,
    xaxis_secondary = true,
    yaxis_secondary = true,
    xlabel_secondary="P[N]",
    ylabel_secondary="p[Pa]",
     yrange_secondary=[-49050.0,2/5*49050.0],
    xrange_secondary=[-P,P] */
)$

D:\j_Iam_TEMP\_jh\jh_k123_Rectangle_v3.svg

# Задача. Визначити силу тиску на плоску
прямокутну поверхню шириною B=3 м та
висотою H=7 м. На вільній поверхні рідини
атмосферний тиск . Прошарок води h1=1 м.

Rectangle with h1

kill(all);

ro:1000;g:9.81;H:7;B:3;p_m:10000;

h1:1;

del1:H/15,numer;del2:H/10,numer;del3:H/7,numer; del4:H/5,numer;del5:H/3,numer; 

dh:H/5,numer;

'integrate((ro*g*(H-h+h1))*B,h,0,H);integrate((ro*g*(H-h+h1))*B,h);

pi(h):=9810.0*(H-h+h1);

P_h1:integrate(ro*g*(H-h+h1)*B,h,0,H);

if P_h1<10 then scale:3 elseif P_h1<100 then scale:20
    elseif P_h1<1000 then scale:200
    elseif P_h1<10000 then scale:2000
    elseif P_h1<100000 then scale:20000
    elseif P_h1<1000000 then scale:200000
    elseif P_h1<10000000 then scale:2000000
    ;

pi(0);pi(0)/scale;pi(h1)/scale;

mP_h1:integrate(ro*g*((H-h+h1)**2)*B,h,0,H);

h_D_h1:mP_h1/P_h1;

Rectangle with h1 (down)

mP_h1_down:integrate(ro*g*((H-h+h1)*h)*B,h,0,H);

h_D_h1_down:mP_h1_down/P_h1;

test rectangle + h1

h_D_h1+h_D_h1_down;

x_draw:3*B;y_draw:H+h1+2;

n: h_D_h1_down;mod(n,1);

if floor(n*100)/100>0 then n:floor(n*100)/100 elseif floor(n*1000)/1000>0 then n:floor(n*1000)/1000;

n:n,numer;

hh:sconcat(n);

pp:sconcat(P_h1);

scale_p:pi(0)/2;scale;

draw2d(xrange = [-5,x_draw],
yrange = [0,y_draw],
   font      = "Arial",
            font_size = 16,
title="Rectangle",
    xlabel = "Presure, Pa",
ylabel = "h,m",
   grid = true,
   proportional_axes=xy,
   line_type = solid,
    color = black,
   fill_color = "#cccccc",
  line_width=2,
rectangle([0,0],[B,H]),
   line_width=2,color=blue,
    water:polygon([[-3,H+h1],[-1,H+h1]]),
water:polygon([[0,H+h1],[B,H+h1]]),
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
vector([0,H+h1+del1],[B,0]),
   label(["B",B/2,H+h1+del3]),
     points_joined = true,
    point_size=0.1,
   points([[0,H+h1],[0,H+h1+del2]]),
   points([[B,H+h1],[B,H+h1+del2]]),
   points([[B,0],[B+del4,0]]),
   points([[B,H],[B+del4,H]]),
   vector([B+del4,0],[0,H]),
    points([[B,H+h1],[B+del4,H+h1]]),
   vector([B+del4,H],[0,h1]),
    line_width=2,
    points([[0,0],[0,H+del1/2+h1]]),
   points([[B,0],[B,H+del1/2+h1]]),
   points_joined = false,
   label_orientation = 'vertical,
label(["H",B+del2,H/2]), 
    label(["h1",B+del2,(H+h1/2)]), 
    /*  p_a  */
   color = black,
   label_orientation = 'horizontal,
   head_both = false,
   line_type = solid,
   head_length = 0.2,
head_angle = 10,
   color = black,
vector([-2.5,(H+h1+del3)],[0,−del3]),
   label(["p_a",-2.5-0.5+del3,H+h1+del3]),
     /* Epura  */
   line_width=1,color=blue,line_type = dashes,
  fill_color = white,
poly:polygon([[−1,0],[−1,H+h1],[−pi(0)/scale_p−1,0],[0−1,0]]),
    line_type = solid,
    fill_color = lightblue,
 poly:polygon([[−1,0],[−1,H],[−pi(H)/scale_p−1,H],[−pi(0)/scale_p−1,0],[0−1,0]]),
  head_length = 0.3,
head_angle = 10,
  color = blue,
  line_width=2,
    head_both = false,
  vector([−pi(dh*0)/scale_p−1,H-5*dh],[pi(dh*0)/scale_p,0]),
  vector([−pi(dh*1)/scale_p−1,H-4*dh],[pi(dh*1)/scale_p,0]),
  vector([−pi(dh*2)/scale_p−1,H-3*dh],[pi(dh*2)/scale_p,0]),
  vector([−pi(dh*3)/scale_p−1,H-2*dh],[pi(dh*3)/scale_p,0]),
  vector([−pi(dh*4)/scale_p−1,H-1*dh],[pi(dh*4)/scale_p,0]), 
     transparent = true,
    line_width=2,
    color = black,
    points_joined = true,
    point_size=0.1,
   points([[-2,0],[-1,0],[-1,H+h1+del1/2]]),
    line_width=2,color=blue,
   color = red,
  label(["Px",-1-del4,h_D_h1_down+del2]),
  label([hh,-1+del2,h_D_h1_down+del1]),
    line_type = solid,
  head_length = 0.3,
head_angle = 15,
  line_width=2,
    point_type = filled_circle,
    point_size=1,
    vector([-1−P_h1/(scale*2),h_D_h1_down],[P_h1/(scale*2),0]),
   points([[-1,h_D_h1_down]]),
    points([[B/2,h_D_h1_down]]),
    label_orientation = 'horizontal,
label(["D",B/2+del1,h_D_h1_down]), 
    /*  h_D_h1_down  */
    color=black,line_width=1,
   head_both = true,
   head_length = 0.2,
   head_angle = 10,
     vector([-1+del2,0],[0,h_D_h1_down]),
   points_joined = false,
   label_orientation = 'vertical,
label(["h_D_",-del2,h_D_h1_down/2]), 
    points_joined = true,
    point_size=0.1,
   points([[-1,h_D_h1_down],[-1+del3,h_D_h1_down]]),
    /* copy right  */
    color = "#0e406e",
label_orientation = 'vertical,
label(["www.k123.org.ua ",3*B-1,H/2]),
   label(["Kopanytsia Y (c)  2025",3*B-0.5,H/2]), 
    /*  Results  */
    color = "#0e406e",
   rectangle([x_draw/3,y_draw-del4],[x_draw,y_draw]), 
   label_orientation = 'horizontal,
label([hh,x_draw/2,y_draw-del3]),
    label(["h_D [m]",x_draw/2,y_draw-del1/2]),
    label([pp,x_draw-del4,y_draw-del3]),
    label(["P [N]",x_draw-del4,y_draw-del1/2])
/*    key = "Force",
xtics_secondary = true,
    ytics_secondary = true,
    xaxis_secondary = true,
    yaxis_secondary = true,
    xlabel_secondary="P[N]",
    ylabel_secondary="p[Pa]",
     yrange_secondary=[-49050.0,2/5*49050.0],
    xrange_secondary=[-P,P] */
)$;

D:\j_Iam_TEMP\_jh\jh_k123_Rectangle_v1_2.svg

# Triangle

-----------Triangle-------------

H:7;

fB(h):=(B/H)*(H-h);

fB(0);fB(H);

P_tri:integrate(ro*g*(H-h)*fB(h),h,0,H);

mP_tri:integrate(ro*g*((H-h)**2)*fB(h),h,0,H);

h_D_tri:mP_tri/P_tri;

h_D_tri_down:H-h_D_tri;

Trapetion

P_trap:integrate(ro*g*(H-h)*fB(h),h,0,H/2);

mP_trap:integrate(ro*g*((H-h)**2)*fB(h),h,0,H/2);

h_D_trap:mP_trap/P_trap;

mP_trap_down:integrate(ro*g*((H-h)*h)*fB(h),h,0,H/2);

h_D_trap_down:mP_trap_down/P_trap;

Circle UP half

R:1;

fB_circle(h):=2*sqrt(R**2-h**2);

fB_circle(0);fB_circle(R);

P_cir_up:integrate(ro*g*(R-h)*fB_circle(h),h,0,R);

P_cir_up,numer;

mP_cir_up:integrate(ro*g*((R-h)**2)*fB_circle(h),h,0,R);

h_D_cir_up:mP_cir_up/P_cir_up,numer;

test

h_c:(1-0.4244)*R;p:ro*g*h_c;w:(%pi*(R**2))/2;P:p*w,numer;I:0.1098*R**4;

h_D:h_c+I/(h_c*w),numer;