0% found this document useful (0 votes)
6 views9 pages

Pump Process

The document outlines the overall process of a MATLAB app designed for fluid mechanics calculations, including user input for pipe and fluid parameters, and the computation of various hydraulic properties such as velocity, Reynolds number, and pump power. It details the app's structure, including class definitions, properties for UI components, and the core calculation logic executed upon user interaction. The app aims to assist in pipe system design, pump selection, and energy estimation through a user-friendly interface and event-driven programming.

Uploaded by

fg84s45yyq
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Pump Process

The document outlines the overall process of a MATLAB app designed for fluid mechanics calculations, including user input for pipe and fluid parameters, and the computation of various hydraulic properties such as velocity, Reynolds number, and pump power. It details the app's structure, including class definitions, properties for UI components, and the core calculation logic executed upon user interaction. The app aims to assist in pipe system design, pump selection, and energy estimation through a user-friendly interface and event-driven programming.

Uploaded by

fg84s45yyq
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Overall Process of the Program

This app:

1. Takes pipe and fluid inputs from the user

2. Calculates:

o Velocity

o Reynolds number

o Flow regime

o Friction factor

o Head loss

o Pump power

3. Displays numerical results

4. Plots Head Loss vs Flow Rate

It uses:

 Continuity equation

 Reynolds number formula

 Darcy–Weisbach equation

 Swamee–Jain equation (turbulent friction factor)

Class Definition Structure

classdef PumpCalculator < [Link]

🔹 Why This Is Important

 Defines a MATLAB App class

 Inherits from [Link]

 Without this, the GUI cannot exist

Properties Section (UI Components)


properties (Access = public)
UIFigure [Link]
LengthEditField [Link]
...
end

🔹 What This Does

Stores handles to:

 Input fields

 Labels

 Button

 Axes

🔹 Why It’s Important

The callback function needs access to these components.


If they aren’t stored as properties, you cannot read or update their values.

🔎 Demonstration Script (Concept Only)

fig = uifigure;
numField = uieditfield(fig,'numeric','Value',10);
disp([Link]) % Access property

This shows how GUI components store values.

Constructor – Building the Interface

function app = PumpCalculator

This section:

 Creates the window

 Creates edit fields

 Creates button

 Links button to callback

 Creates labels
 Creates plot area

🔹 Why This Is Important

Without this:

 No window

 No inputs

 No interaction

This builds the GUI manually instead of using App Designer drag-and-drop.

🔎 Demonstration Script – Simple Button Callback

fig = uifigure;
btn = uibutton(fig,'Text','Click Me');
[Link] = @(btn,event) disp('Button Pressed');

This shows how event-driven programming works.

The Core Engine: CalculateButtonPushed

This is the MOST IMPORTANT part.

function CalculateButtonPushed(app, ~)

It runs when the user clicks Calculate.

Step-by-Step Calculation Logic

🔹 Step 1: Read User Inputs

L = [Link];
D = [Link];
...

Why Important?

The app must collect data before performing calculations.


🔹 Step 2: Cross-Sectional Area

A=πD24A=4πD2

A = pi*D^2/4;

Why Important?

Velocity depends on area:

V=Q/AV=Q/A

🔎 Demonstration Script

D = 0.1;
A = pi*D^2/4

🔹 Step 3: Velocity Calculation

if A == 0 || Q == 0
V = 0;
else
V = Q/A;
end

Why Important?

Prevents division by zero.

Without this check → program crashes.

🔎 Demo

Q = 0.01;
A = 0.00785;
V = Q/A

🔹 Step 4: Reynolds Number

Re=ρVDμRe=μρVD
Re = (rho*V*D)/mu;

Why Important?

Determines flow regime.

🔎 Demo

rho = 1000;
V = 1;
D = 0.1;
mu = 0.001;
Re = (rho*V*D)/mu

Flow Regime Decision Logic

if Re < 2300
regime = "Laminar";
elseif Re <= 4000
regime = "Transitional";
elseif Re > 4000
regime = "Turbulent";

Why Important?

Different friction factor equations apply to different regimes.

If this classification is wrong → head loss is wrong.

Friction Factor Equations

🔹 Laminar

f=64/Ref=64/Re

🔹 Turbulent (Swamee-Jain)

f=0.25[log⁡10(ϵ3.7D+5.74Re0.9)]2f=[log10(3.7Dϵ+Re0.95.74)]20.25

🔎 Demo Script
Re = 10000;
epsilon = 1.5e-5;
D = 0.1;

f = 0.25/(log10((epsilon/(3.7*D)) + (5.74/Re^0.9)))^2

Head Loss (Darcy-Weisbach)

hf=fLDV22ghf=fDL2gV2

hf = f*(L/D)*(V^2/(2*g));

Why Important?

This is the main engineering result.

🔎 Demo

f = 0.02;
L = 10;
D = 0.1;
V = 1;
g = 9.81;

hf = f*(L/D)*(V^2/(2*g))

🔟 Pump Power

P=ρgQhfP=ρgQhf

P = rho*g*Q*hf;

Why Important?

Determines pump sizing.

🔎 Demo

rho = 1000;
g = 9.81;
Q = 0.01;
hf = 2;

P = rho*g*Q*hf

Updating GUI Labels

[Link] = "Velocity: " + num2str(V);

Why Important?

Displays results to user.

Without this → calculations happen but nothing shows.

Plotting Section

This part generates curve:

Q_values = linspace(0.001, max(Q*2,0.01), 50);

It:

1. Generates multiple flow rates

2. Recalculates head loss

3. Plots head loss vs flow rate

Why Important?

Shows system curve — critical for pump selection.

🔎 Standalone Plot Demo

Q = linspace(0.001,0.02,50);
hf = 500*Q.^2; % example quadratic relationship

plot(Q,hf)
xlabel('Flow Rate')
ylabel('Head Loss')
grid on
🔷 How Everything Connects

Button Click

Read Inputs

Compute Velocity

Compute Reynolds

Determine Regime

Compute Friction Factor

Compute Head Loss

Compute Power

Display Results

Plot System Curve

🔷 Why Each Part Is Critical For Code to Run

Why It Is
Part
Necessary

Class Definition Defines app structure

Properties Store UI components

Constructor Builds GUI

Callback
Executes calculations
Function

Input Reading Gets user data

Zero Checks Prevents crashes

Regime Logic Chooses correct


Why It Is
Part
Necessary

formula

Generates system
Plot Loop
curve

Label Updates Shows results

If any of these is removed → the program either crashes or becomes useless.

🔷 Engineering Importance

This app simulates real-world:

 Pipe system design

 Pump selection

 Energy estimation

 Flow regime analysis

It combines:

 Fluid mechanics

 Numerical computation

 GUI programming

 Event-driven logic

You might also like