0% found this document useful (0 votes)
275 views2 pages

K-Value Calculator

This document contains code to calculate the K value from experimental flow rate and pressure drop measurements. It defines constants, converts the measurements to appropriate units, calculates the fractional opening, velocity, and K value. Finally, it plots the K value against fractional opening on a semilog scale and overlays the data points.

Uploaded by

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

K-Value Calculator

This document contains code to calculate the K value from experimental flow rate and pressure drop measurements. It defines constants, converts the measurements to appropriate units, calculates the fractional opening, velocity, and K value. Finally, it plots the K value against fractional opening on a semilog scale and overlays the data points.

Uploaded by

Eric He
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

13/05/22 8:27 PM /Users/kodersale.../K_ValueCalculator.

m 1 of 2

% clear workspace variables, clear command window and close all figures at the start
clear all
clc
close all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Measured values from experiment %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Angle = [0 5 10 15 20 25 30 35 40 45 50]; % enter values for valve angle


Q_L_per_min = [15.25 15.25 14.39 12.39 11.52 8.61 7.74 4.78 3.89 2.69 0.90]; % enter
values for flowrate in L/min
DP_mbar = [32 36 46 75 90 140 150 180 188 200 214]; %\ enter values for pressure drop
in mbar

%
--------------------------------------------------------------------------------------
--
% below are some mock values (not real experimental values)that you can try plotting
with
% Angle = [0 10 20 30 40 50 60 70];
% Q_L_per_min = [20 19.5 19 18.5 18 17.5 17 16.5];
% DP_mbar = [10 20 30 50 70 100 150 220];
%
--------------------------------------------------------------------------------------
--

%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculations %
%%%%%%%%%%%%%%%%%%%%%%%%%%

% specify constants
rho = 998 % in kg/m3
D = 0.021 % pipe diameter in m

Q_m3_per_s = Q_L_per_min./60000; % convert Q from L/min to m3/s


DP_Pa = 100.*DP_mbar; % convert pressure drop from mbar to Pa
F_opening = 1- (Angle./90); % calculate fraction opening from Angle(0 degrees
= fraction opening of 1)
A = pi*D^2/4; % calculate cross section area of pipe (in m2)
v = (Q_m3_per_s)./A; % calculate flow velocity in m/s
K = (2.*DP_Pa)./(rho*v.^2); % calculate K factor

clc
disp('Q in m^3/s is')
disp(Q_m3_per_s)
disp('DeltaP is')
disp(DP_Pa)
disp('Fractional Opening is')
disp(F_opening)
disp('Velocity is')
disp(v)
disp('K value is')
disp(K)
%%%%%%%%%%%%%%
% Plotting %
%%%%%%%%%%%%%%
semilogy(F_opening,K, "rs-")
xlabel('Fractional Opening')
ylabel('K Value')
title('K Value Against Fractional Opening')
% plot loss curve using semilog scale, use the 'semilogy' function instead
13/05/22 8:27 PM /Users/kodersale.../K_ValueCalculator.m 2 of 2

% of 'plot'. Superimpose data points onto the line


% plot formatting (title, axes labels and grid)

You might also like