Need some guidance to solve this problem for velocity and pressure variables
Afficher commentaires plus anciens
Hello all,
In my problem, I need to solve the following equations to calculate the variables velocity (from Eq .(1 and 2)) and pressure (from Eq .(3)).
∇.G=S (1)
∇×G-G×∇(ln(F1+F2*G))=0 (2)
∇^2 (P^2)=-(F1+F2*G)S - G∙∇(F1+F2*G) (3)
where, G, G = mass velocity vector and its magnitude, P = Pressure and S = source term.
Here is my code below and queries to follow:
1) While defining continuity Eq. (1), I'm facing an error,
% ERROR: Array indices must be positive integers or logical values.
2) Without Eq. (1), the velocity and pressure values obtained are not good as expected.
I'm not sure about my approach as how to find the appropriate velocity and pressure.
Someone kindly examine the code and judge my approach and assist me further.
Thank you
clear; clc; close all;
L=0.25; W =5;
Nx=10; Ny=200;
x = linspace(0,L,Nx);
y = linspace(0,W,Ny);
[X, Y] = meshgrid(x,y);
dx = x/Nx; dy = y/Ny;
rhoo = 0.8;
por = 0.3; mu =0.8E-5; dia = 0.003;
P = 101325.*ones(Ny,Nx);
V = zeros(Ny,Nx);
Gvec = zeros(Ny,Nx);
TimeStep =1;
Vx = gradient(X, TimeStep);
Vy = gradient(Y, TimeStep);
Vmag = sqrt(Vx.^2 + Vy.^2);
% Boundary conditions
V(:,1) = 0;
V(Ny,:) = 0;
V(1,:) = V(Ny-1,:);
V(:,Nx) = V(:,Nx-1);
V(Ny,1) = 0;
V(1,1) = 0;
S = [0 0 0.1458 0.2058 0.2161 0.2171 0 0 0 0];
f1 = (300*((1-por).^2)*P*mu)/(rhoo.*(dia.^2)*(por.^3));
f2 = (3.5.*(1-por).*P)/(rhoo.*dia.*(por.^3));
F1 = f1.*ones(Ny,Nx);
F2 = f2.*ones(Ny,Nx);
Gvec =rhoo.*V;
Gmag =rhoo.*Vmag;
%divergence(Gvec) = 0 % Eq. (1)
% ERROR: Array indices must be positive integers or logical values.
d1 = log (F1 + (F2.*Gmag));
d2 = gradient(d1);
A = curl(Gvec,X);
B = curl(d2,Gvec);
V = A - B % Eq. (2)
d3 = F1 + (F2.*Gmag);
d4 = gradient(d3);
P = gradient(gradient((P.^2))) + divergence(d3,Gvec) + d3.*S % Eq. (3)
4 commentaires
Your code above just assumes values for G and P - you must solve for them as they should satisfy your differential equations.
I think it's best if you use a commercial solver, e.g. ANSYS or COMSOL for the equations of fluid dynamics.
OPENFOAM also has prepared code for fluid dynamics problems.
Although I only recognize the continuity equation - pressure and momentum equations look quite strange.
Kumaresh Kumaresh
le 29 Août 2022
May I know why you are guiding to use black box tools like ANSYS or COSMOL ?
The laminar Navier Stokes equations need a special treatment because of the velocity-pressure coupling. They are hard to solve for a beginner. Or how much time do you plan to invest in reading before you start programming ?
Is that impossible to solve by MATLAB ?
If it can be done in OPENFOAM, ANSYS and COMSOL, it can also be done in MATLAB. But you will have to program it from scratch if you don't find code somewhere else. So again the question: how much time do you plan to invest ? I would estimate half a year if you have to do all by yourself.
Kumaresh Kumaresh
le 29 Août 2022
Réponses (0)
Catégories
En savoir plus sur Fluid Mechanics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!