%% Calculation of the liquid film thickness in separated flows
clear all
clc
global g rho_g rho_l mu_g mu_l nu_g nu_l sigma D S A epsilon theta J_g J_l J
% Constants
g = 9.81; % m/s^2
% Phases' physical properties (input data) (101325 Pa and 298 K)
rho_g = 1.18; % kg/m^3
rho_l = 997; % kg/m^3
mu_g = 1.84e-5; % kg/(m.s)
mu_l = 8.9e-4; % kg/(m.s)
nu_g = mu_g / rho_g; % m^2/s
nu_l = mu_l / rho_l; % m^2/s
sigma = 7.197e-2; % N/m
% Pipe geometrical characteristics (input data)
D = 0.026; % m
S = pi * D; % m
A = pi * D.^2 / 4; % m^2
epsilon = 0; % m
theta = 0; % rad
% Superficial velocities of the phases and mixture (input data)
J_g = 20; % m/s
J_l = 1; % m/s
J = J_g + J_l; % m/s
% Implicit function of the liquid film thickness
function zero = funcdelta_f(delta_f)
global g rho_g rho_l mu_g mu_l nu_g nu_l sigma D S A epsilon theta J_g J_l J
% Phases' geometrical characteristics (core, film and interface)
if (theta <= 89) % Horizontal and inclined
lambda_i = 2 * acos(1 - 2 * delta_f);
phi_f = 0.5 * (lambda_i - sin(lambda_i)) / pi;
S_f = 0.5 * D * lambda_i;
S_c = S - S_f;
S_i = D * sin(0.5 * lambda_i);
else % Vertical
phi_f = 4 * delta_f * (1 - delta_f);
S_f = S;
S_c = 0;
S_i = S * (1 - 2 * delta_f);
endif
phi_c = 1 - phi_f;
A_f = A * phi_f;
A_c = A - A_f;
D_f = 4 * A_f / S_f;
D_c = 4 * A_c / (S_c + S_i);
% Fractions of entrainment and area of the liquid droplets
E_d = 0;
phi_d = J_l * E_d / (J_g + J_l * E_d);
phi_gc = 1 - phi_d;
% Phases' physical properties (core and film)
rho_c = rho_g * phi_gc + rho_l * phi_d;
rho_f = rho_l;
mu_c = mu_g * phi_gc + mu_l * phi_d;
mu_f = mu_l;
nu_c = mu_c / rho_c;
nu_f = mu_f / rho_f;
% Phases' velocities (core, film and relative)
U_c = (J_g + J_l * E_d) / phi_c;
U_f = (J_l - J_l * E_d) / phi_f;
V_r = U_c - U_f;
% Phases' Reynolds numbers (core and film)
Re_c = U_c * D_c / nu_c;
Re_f = U_f * D_f / nu_f;
% Phases' Fanning friction factors (core, film and interface)
C_fc = (-3.6 * log10((epsilon / (3.7 * D_c)).^(1.11) + (6.9 / Re_c))).^(-2);
C_ff = (-3.6 * log10((epsilon / (3.7 * D_f)).^(1.11) + (6.9 / Re_f))).^(-2);
if (theta <= 89) % Horizontal and inclined
if (J_g <= 15) % Smooth interface
C_fi = 0.014;
else % rough interface
C_fi = 0.0625 * (log10(15 / Re_c + 2.3 * delta_f / 3.715)).^(-2);
endif
else % Vertical
C_fi = C_fc * (1 + 300 * delta_f);
endif
% Phases' shear stresses (core, film and interface)
tau_i = 0.5 * C_fi * rho_c * V_r * abs(V_r);
tau_c = 0.5 * C_fc * rho_c * U_c * abs(U_c);
tau_f = 0.5 * C_ff * rho_f * U_f * abs(U_f);
% Implicit function
zero = tau_c * S_c / A_c - tau_f * S_f / A_f...
+ tau_i * S_i * (1 / A_c + 1 / A_f) - (rho_f - rho_c) * g * sin(theta);
endfunction
% Bisection method
function [result1, result2] = rootbisection(fx, x_l, x_r, tol)
if (fx(x_l) * fx(x_r) >= 0) % Checks the root value in interval
fprintf('Root is out of interval in "rootbisection"');
exit(1)
endif
x_m = 0.5 * (x_l + x_r);
fx_m = fx(x_m);
iteration_counter = 1;
while (abs(fx_m) >= tol) % Convergence criterion
fx_l = fx(x_l);
fx_r = fx(x_r);
if (fx_l * fx_m >= 0) % Orients the search
x_l = x_m;
else
x_r = x_m;
endif
x_m = 0.5 * (x_l + x_r);
fx_m = fx(x_m);
iteration_counter = iteration_counter + 2;
endwhile
result1 = x_m;
result2 = iteration_counter;
endfunction
% Solution of the implicit function by using the bisection method
function get_solution()
fx = @(x) funcdelta_f(x);
x_a = 0.00001;
x_b = 0.99999;
tol = 1e-6;
[solution, iteration_num] = rootbisection(fx, x_a, x_b, tol);
if (solution <= x_b) % Checks the solution
fprintf('Function calls number: %d\n', 1 + 2 * iteration_num);
fprintf('Function root: %f\n', solution);
else
fprintf('Abort execution.\n');
endif
endfunction
% Call the solution of the implicit function by using the bisection method
get_solution()
About Online Octave Compiler
Try our Online Octave Compiler (Version GNU Octave, v4.2.1) to Edit, Run, and Share your Octave Code directly from your browser. This online development environment provides you the latest version GNU Octave, v4.2.1.
How to use Online Octave Compiler?
Write and Execute Code
- Write your program (or, paste it) directly under the "Source Code" tab.
- If you want to save your program, go to the "Project" menu and save it.
- You can directly execute your program without saving it by clicking on on "Execute" button.
User Input
The latest version of Coding Ground allows to provide program input at run time from the termnial window exactly the same way as you run your program at your own computer. So simply run a program and provide your program input (if any) from the terminal window available in the right side.
Online Octave Compiler: Keyboard Shortcuts
The following are the keyword shortcut of this Online Octave Compiler:
Shortcut | Description |
⌘ + Enter | Run the program |
⌘ + S | Save Project (Login Required) |
⇧ + ⌘ + S | Save As Project |
⌘ + P | New Project |
⌘ + G | Share Project |
⌘ + Z | Undo Editing |
⌘ + Y | Redo Editing |
⌘ + A | Select All Text |
⌘ + X | Cut Selected Text |
⌘ + C | Copy Selected Text |
⌘ + V | Paste Copied Text |
⌘ + F | Search Text |
⌘ + ⌥ + F | Replace Text |
Shortcut | Description |
Ctrl + Enter | Run the program |
Ctrl + S | Save Project |
Shift + Ctrl + S | Save As Project |
Ctrl + G | Share Project |
Ctrl + Z | Undo Editing |
Ctrl + Y | Redo Editing |
Ctrl + A | Select All Text |
Ctrl + X | Cut Selected Text |
Ctrl + C | Copy Selected Text |
Ctrl + V | Paste Copied Text |
Ctrl + F | Search Text |
Ctrl + H | Replace Text |
Online Octave Compiler: Save and Share Octave Code (Project)
Save Octave Project Online
You can save your Octave Project with us so that you can access this project later on. To save a project you will need to create a login Id with us. So before you save a project, please create a login Id using a link given at the top right corner of this page.
Share Octave Project Online
You can use this feature to share your Octave Code with your teachers, classmates and colleagues. Just click Share Button and it will create a short link, which can be shared through Email, WhatsApp or even through Social Media. A shared link will be deleted if it has been passive for almost 3 months.
More Features of Online Octave Compiler
- Theme – You can change the current editor's theme from the "Editor Theme" option under "Settings" menu.
- Font Size – You can change the font size of the editor /compiler from from the "Font Size" option under "Settings" menu.
- Tab Size – You can change the tab size from the "Tab Size" option under "Settings" Menu.
- Show/Hide Line Numbers – You can show/hide the line number with the code from the "Show Line Numbers" or "Hide Line Numbers" option under "Settings" Menu.
- And, many more.
Benefits of Using Online Octave Compiler
There are several benefits of using the Online Octave Compiler to run your Octave code:
- Platform independence: You can run your code from any device without taking care of operating systems.
- Convenience: You don't need to install anything for using this.
- No setup required: There is no need for additional setup to run your code.
- Updated version: Our online compiler/editors/terminals are the latest up-to-date.