# how to solve non-linear equations in a nozzle

4 views (last 30 days)
M.S.R on 24 Nov 2022
Edited: Torsten on 27 Nov 2022
Dear friends
I want to solve these non-linear equations for inlet of a de-laval nozzle(8 equations and 8 variables). All the equations are both non-linear and parametric. I tried to use fsolve to solve them but I got many errors. Thank you for guiding me in this regard.
inputs:
di = 0.04; % k
alpha = 12.67; % degree
Ti = 291.65; % K
Pi = 90; % bar
Vi = 43.5; % m/s
Ci = 443.8; % m/s
Mi = 0.098;
Zi = 1;
rhoi = 60.17; % kg/m^3
k = 1.32;
R = 8.3114; % kj/kmol.K
Ai = 0.0013; % m^2
equations:
F(1) = Pt/rhot - Zt*R*Tt;
F(2) = sqrt(k*R*Zt*Tt) - Vt;
F(3) = (k*R*Zt*Tt) - (Vi^2+((2*k)/(k-1))*(Zi*R*Ti-Zt*R*Tt));
F(4) = ((Zi*Ti)/(Zt*Tt)) - (rhoi/rhot)^(k-1);
F(5) = (rhoi/rhot)^(k-1) - (Pi/Pt)^((k-1)/k);
F(6) = Ai*(rhoi/rhot)*(Vi/Vt) - At;
F(7) = (Ai^0.5 - At^0.5)/((pi^0.5)*tand(alpha)) - xt;
output:
[ Pt , Tt , rhot , Zt , Vt , At , xt ]

Torsten on 24 Nov 2022
Maybe you can give better initial guesses in x0 for the solution than I can ...
x0 = 10*rand(7,1);
options = optimset('MaxFunEvals',1000000,'MaxIter',1000000);
norm(fun(x0))
ans = 1.8557e+04
x = fsolve(@fun,x0,options)
Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 1.000000e+06.
x = 7×1
10.9152 12.7409 0.0048 21.5998 6.5697 8.0980 6.6604
norm(fun(x))
ans = 115.4423
function F = fun(x)
Pt = x(1);
Tt = x(2);
rhot = x(3);
Zt = x(4);
Vt = x(5);
At = x(6);
xt = x(7);
di = 0.04; % k
alpha = 12.67; % degree
Ti = 291.65; % K
Pi = 90; % bar
Vi = 43.5; % m/s
Ci = 443.8; % m/s
Mi = 0.098;
Zi = 1;
rhoi = 60.17; % kg/m^3
k = 1.32;
R = 8.3114; % kj/kmol.K
Ai = 0.0013; % m^2
%equations:
F(1) = Pt/rhot - Zt*R*Tt;
F(2) = sqrt(k*R*Zt*Tt) - Vt;
F(3) = (k*R*Zt*Tt) - (Vi^2+((2*k)/(k-1))*(Zi*R*Ti-Zt*R*Tt));
F(4) = ((Zi*Ti)/(Zt*Tt)) - (rhoi/rhot)^(k-1);
F(5) = (rhoi/rhot)^(k-1) - (Pi/Pt)^((k-1)/k);
F(6) = Ai*(rhoi/rhot)*(Vi/Vt) - At;
F(7) = (Ai^0.5 - At^0.5)/((pi^0.5)*tand(alpha)) - xt;
end
Alex Sha on 27 Nov 2022
I think Torsten is right， there is no exact numerical solution， the approximate solution is:
pt: 596435.381381668
tt: -21.0901443320853
rhot: 260.748232462543
zt: -13.0493323055227
vt: 54.9487704256482
at: 0.000237481729284569
xt: 0.00968011270311718

### Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!