Help regarding solving equations
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve a iterative design problem using programming.
Design Problem
Determine Flow depth (d) for following conditions:
Diameter of sewer (D) = 200mm
Discharge through sewer (Q) = 122.3 LPM
Sewer Material = Concrete, Manning's coefficient = 0.013
Longitudinal slope = 1 in 1000.
The algorithm is:
i. Assume a value of a, which is in between 0 to 360.
ii. Calculate the other parameters ar, A, P, R, Qi. (Formulas are as mentioned in code).
iii. Compare that Qi to Qd (Pre defined as numeric value), if both are same then proceed for printing calculated variables, if not then repeat the process again until Qi = Qd.
I had tried this code, I used for loop but it is not working, and I tried while loop, it is struck in calculations.
D = 200; %Diameter of sewer in mm
D = D/1000; %dia in meter
n = 0.013; %Manning's coefficient
S0 = 1/1000; %Bed slope
Q = 122.3; %LPM
Qd = Q/(1000*60); % Discharge in LPM to Cumecs
n = 360;
for a = 1:1:n
ar = a*0.0174; %theta in radians
A = ((D^2)/8)*(ar-sin(a));
P = (ar*D)/2;
R = A/P;
Qi = (A/n)*(R^(2/3))*sqrt(S0);
while Qi == Qd
fprintf('Area of flow is %d \n',A);
fprintf('Discharge is %.5f \n', Qi);
end
while Qi~ Qd
a= a+1 && a<360;
end
end
0 件のコメント
採用された回答
Torsten
2022 年 1 月 28 日
Change sin(a) to sind(a).
Further Qi will never be exactly Qd.
I suggest you print Qi-Qd over a and see if it intersects the a-axis.
For this, change the line
Qi = (A/n) ...
to Qi(a) = (A/n)...
and write
plot((1:360),Qi)
after the for loop.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!