MATLAB Water Delivery System with Newtons Method

In summary: D).*(v.^2/2)+g*h)./b; %calculate pressure Ploop(j)=P; %store pressure valuesend%Power equationfor k=1:length(v) k=k+1; v=k; Wdotpump=mdot.*(Ploop(k)/rho + v.^2/2); %calculate power Wdotpumploop(k)=Wdotpump; %store power valuesend%PlottingWdotpump vs Qfigure(1);plot(v,Wdotpumploop);xlabel('Q (m/s)');ylabel('Wdotpump (W)');title('Wdotpump vs Q');%P vs Qfigure(2);plot(v,P
  • #1
sV.Hypnosis
1
0
1.We are asked to:
i - Plot Wdot(pump) vs Q where v varies from 1 m/s to 50 m/s in increments of 1 m/s
ii - plot P vs Q
iii - write a function that uses Newtons method with a numerical derivative to calculate the friction factor -- function f = frict (e_over_d,Re)

equations are below



In this program you will write a program that determines the pressure a pump must provide and the horsepower required to run an ideal pump for a system that removes water from a reservoir and discharges the water to a second water reservoir at a higher elevation.
water density ρ = 998 kg/m^3
water viscosity μ = 1.003E-3
roughness ratio e/D= 2E-4
g = 9.81 m/s^2




2. pump exit pressure, P
P = ρ[f*(L/D)*(v^2/2) + g*h]/b]

Colebrook equation for the friction factor f (based on Re=*v*D/μ)

1/√f = -2log(base10)[(ε/D*3.7)+(2.51/Re*√f)] which when solved for f (neglecting the f term on the right side of the equation) => f = 1.325/[ln(ε/3.7D + 5.74/Re^.9)]^2

horsepower for the pump

Wdot(pump) = mdot [P/ρ + v^2/2]



3. I created a for loop for the Reynolds number:
clc
clear all

rho=998;
mu=1.003e-3;
D=.5;
v=1:1:49;
Re=rho*v*D/mu;
i=0;
for i=1:length(v)
i=i+1
v=i;
Re=rho*v*D/mu
root(i)=funct(v(i))
end

Now i need to figure out how to call this loop into another loop using the friction factor equation f..

Once i get that i need to plug that f value "loop"(from 1 to 50 m/s for velocity of course) into the Pressure function and then that P loop into the Wdot(pump) equation so I can plot it..

Newtons method is applied here but I don't understand why because I am not taking derivative. The only thing i can think of is that since v changes by 1 m/s up to 50 m/s so its a rate of change. It will keep going up by adding small parts together with Newtons method which is this code:
function [ f ] = frict( e_over_d,Re )
%use secant method to calculate the friction factor
% Detailed explanation goes here
e_over_d=2e-4;
rho=998;
mu=1.003e-3;
vo=1;
D=.5
Re=rho*vo*D/mu;
f =1.325/(ln((e_over_d/3.7)+(5.74/Re^.9))^2);
eps=abs(f);
iter=0;
while eps>1.0e-12 && iter < 100

fprime=1.325/(ln((e_over_d/3.7)+(5.74/Re(vo)^.9))^2);
iter=iter+1
delx=1.0e-4*vo
vright=vo+delx
fright=1.325/(ln((e_over_d/3.7)+(5.74/Re(vright)^.9))^2)
fprime=(fright - f)/delx
v = vo-f/fprime
f= 1.325/(ln((e_over_d/3.7)+(5.74/Re^.9))^2);
eps=abs(f)
v=vo



end

this code is all messed up but the format is Newtons method.. I just cannot figure out how to use that Re loop i made with that function!

help!



The Attempt at a Solution



-Ethan G
 
Physics news on Phys.org
  • #2
.clcclear allrho=998;mu=1.003e-3;D=.5;v=1:1:49;Re=rho*v*D/mu;e_over_d = 2e-4; %roughness ratioi=0;%Newton's Method for friction factor calculation for i=1:length(v) i=i+1; v=i; Re=rho*v*D/mu; f = 1.325/(log((e_over_d/3.7)+ (5.74/Re^.9))^2); %initial guess of friction factor eps=abs(f); iter=0; while eps>1.0e-12 && iter < 100 fprime=1.325/(log((e_over_d/3.7)+ (5.74/Re^.9))^2); %derivative of friction factor iter=iter+1; delx=1.0e-4*v; vright=v+delx; fright=1.325/(log((e_over_d/3.7)+ (5.74/Re^.9))^2); %right side of friction factor fprime=(fright - f)/delx; %numerical derivative of friction factor v = v-f/fprime; %update to new friction factor f= 1.325/(log((e_over_d/3.7)+ (5.74/Re^.9))^2); %updated friction factor eps=abs(f); v=vo; end root(i)=f; %outputs final friction factorend%Pressure equationfor j=1:length(v) j=j+1; v=j; P=rho.*(root(j).*(L./
 

Related to MATLAB Water Delivery System with Newtons Method

1. What is MATLAB Water Delivery System with Newtons Method?

MATLAB Water Delivery System with Newtons Method is a program that uses the Newton-Raphson method to solve for the optimal flow rates in a water delivery system. It is designed to help engineers and researchers in the field of fluid mechanics analyze and optimize water distribution systems.

2. How does the Newton-Raphson method work in this program?

The Newton-Raphson method is an iterative algorithm that uses derivative information to find the roots of a given equation. In MATLAB Water Delivery System, it is used to solve for the optimal flow rates by iteratively updating the values of the unknowns until a convergence criterion is met.

3. What are the advantages of using MATLAB for this type of analysis?

MATLAB is a powerful computational tool that offers a wide range of built-in functions and tools for solving complex mathematical problems. It also has a user-friendly interface and allows for easy visualization of results, making it an ideal choice for engineers and researchers working on water delivery systems.

4. Can this program handle different types of water delivery systems?

Yes, MATLAB Water Delivery System is designed to handle a variety of water delivery systems, including open channel flow, pipe flow, and network flow systems. It can also handle systems with different boundary conditions and constraints.

5. Is this program suitable for beginners in MATLAB?

While some basic knowledge of MATLAB is required to use this program, it also provides a step-by-step guide and examples to help beginners understand and use the Newton-Raphson method for water delivery system analysis. It is a great tool for beginners to learn and apply their knowledge of MATLAB in fluid mechanics.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Replies
0
Views
1K
  • Special and General Relativity
2
Replies
38
Views
3K
  • Mechanical Engineering
Replies
8
Views
934
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Back
Top