A system of nonlinear equations with three variables (part II)
3 views (last 30 days)
Show older comments
Hi,
I thank you for your kind help in advance!
I am solving a system of nonlinear equations with two variable x, y, and a changing parameter T. I want to solve this problem using loop. But i met some code problems, particularly for the solutions of x and y.
The description of nonlinear equations is desribed as below code:
% a-b_CNS model at the steady state_Cheng Mei_2022
clear all
% effective normal stress (Pa)
p.sigma=5e7;p.To=273.15+20;p.R=8.314;p.K=6e10;p.Lt=8e-4;p.lambda=0.0625;
p.phio=0.32;p.dsb=2e-6;p.dbulk=2e-5;p.qsb=0.4;p.phic=0.2;p.phio=0.02;
p.qbulk=0.7;p.H=0.577;p.n=1.7;p.m=3;p.An=0.0759;p.At=4.4*p.An;
p.Ea=213e3;p.omega=3.69e-7;p.muo=0.6;p.ao=0.006;p.xo = 0.1813;
p.V0=1e-6;p.V1=0.1e-6;p.gammao=0.02;p.M = 2;p.N = 1;
% T=linspace(273.15,600,1000);
% x=linspace(0.1,0.2,1000);
% y=linspace(0.1,0.2,1000);
syms x y T positive
% At reference (prestep) velocity of V0
fn =((p.phic-x)./(x-p.phio)).^(-p.M);
eqnx = p.Lt.*p.lambda./p.V0*p.An.*exp(-p.Ea./p.R./T).*(p.sigma).^p.n./(p.dsb).^p.m.*fn==p.H.*(p.qsb-2.*x).^p.N;
solx = solve(eqnx,x,'MaxDegree', 3);
% At a velocity (poststep) of V1
fnn=((p.phic-y)./(y-p.phio)).^(-p.M);
eqny= p.Lt.*p.lambda./p.V1*p.An.*exp(-p.Ea./p.R./T).*(p.sigma).^p.n./(p.dsb).^p.m.*fnn==p.H.*(p.qsb-2.*y).^p.N;
soly = solve(eqny,y,'MaxDegree', 3);
format long
T_array=linspace(273,600,100);
for i = 1:numel(T_array)
sol_x = subs(solx,T,T_array(i));
tf = isAlways(sol_x >= 0.1 & sol_x <= 0.2);
x_array(i) = sol_x;
tanso(i) = 0.577*(0.4-2*x_array(i));
sol_y = subs(soly,T,T_array(i));
tff =isAlways(sol_y >= 0.1 & sol_y <= 0.2);
y_array(i) = sol_y;
tansi(i) = 0.577*(0.4-2*y_array(i));
end
musi=p.muo+p.ao*T_array./p.To.*log(p.V1./p.V0);
muso=p.muo;
bb=-tansi.*(1+musi.^2)./(1-musi.*tansi)./(1-musi.*tansi).*(1-(p.V1./p.V0).^(1/(p.M+p.N)))./log(p.V1./p.V0);
plot(T_array-273.15,bb,'k-',LineWidth=2);
%xlabel(''Temperature (°C)')
7 Comments
Torsten
on 30 Jan 2023
What do you expect from using "fsolve" ?
The three solutions for x and y you get from the above symbolic approach are the only ones your system has.
If they don't satisfy your constraints, then there are no solutions that satisfy your constraints.
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!