Solve returs a empty syms

When I run the program, the solve returs s syms empty
%%---INPUT----------------------------------------------------------
load('termoDB2.mat','termo3')
reactantTemp = 273;
syms n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12 Temp;
prompt = 'Enter the fuel: ';
react = input(prompt,'s');
prompt = 'Enter the alpha: ';
alpha = input(prompt,'s');
prompt = 'Enter the beta: ';
beta = input(prompt,'s');
prompt = 'Enter the gamma: ';
gamma = input(prompt,'s');
lambda = 2;
R=8.3144621;
%T=zeros(1,length(lambda));
P=1;
Pref=1;
fuel = pos(termo3,react);
a=termo3(fuel).a;
b=termo3(fuel).b;
c=termo3(fuel).c;
n=zeros(1,12);
%for f=1:length(lambda)
%%---EQUILIBRIUM----------------------------------------------------
%CaHbOc + lambda(a+b/4)(O2+ alpha*N2+ beta*Ar+ gamma*H2O)->n1*CO2 + n2*H2O
%+ n3*O2 + n4*N2 +n5*Ar+n6*CO+n7*H2+n8*N+n9*H+n10*O+n11*OH+n12*NO
%C
eq1 = a == n1 + n6;
%H
eq2 = b + lambda*(a+b/4)*(gamma) == 2*n2 + 2*n7 + n9 + n11;
%O
eq3 = c + lambda*(a+b/4)*(2 + gamma) == 2*n1 + n2 + n3*2 + n6 + n10 + n11 +n12;
%N
eq4 = 2*lambda*(a+b/4)*alpha == 2*n4 + n8 +n12;
%Ar
eq5 = lambda*(a+b/4)*beta == n5;
%%---TEMPERATURA----------------------------------------------------
O2 = pos(termo3,'O2');
N2 = pos(termo3,'N2');
CO2 = pos(termo3,'CO2');
H2O = pos(termo3, 'H2O');
Ar = pos(termo3, 'Ar');
CO = pos(termo3, 'CO');
H2 = pos(termo3, 'H2');
N = pos(termo3, 'N');
H = pos(termo3, 'H');
O = pos(termo3, 'O');
OH = pos(termo3, 'OH');
NO = pos(termo3, 'NO');
% entalpies
hFuel = hk(reactantTemp,termo3(fuel).h,1);
hO2i = hk(reactantTemp,termo3(O2).h,1);
hN2i = hk(reactantTemp,termo3(N2).h,1);
hAri = hk(reactantTemp,termo3(Ar).h,1);
hH2Oi = hk(reactantTemp,termo3(H2O).h,1);
% entropies
sFuel = sk(reactantTemp,termo3(fuel).s,1);
sO2i = sk(reactantTemp,termo3(O2).s,1);
sN2i = sk(reactantTemp,termo3(N2).s,1);
sAri = sk(reactantTemp,termo3(Ar).s,1);
sH2Oi = hk(reactantTemp,termo3(H2O).s,1);
%x=[200:1:5000];
%y=(hFuel + hO2i*lambda(f)*(a+b/4) + hN2i*lambda(f)*(a+b/4)*3.76)*ones(1,4801);
%plot(x,y)
%hold;
k1=[200:1:1000];k2=[1000:1:5000];
for j=1:2
% enpalpies
hCO2 = hk(Temp,termo3(CO2).h,j);
hH2Oo = hk(Temp,termo3(H2O).h,j);
hO2o = hk(Temp,termo3(O2).h,j);
hN2o = hk(Temp,termo3(N2).h,j);
hAro = hk(Temp,termo3(Ar).h,j);
hCO = hk(Temp,termo3(CO).h,j);
hH2 = hk(Temp,termo3(H2).h,j);
hN = hk(Temp,termo3(N).h,j);
hH = hk(Temp,termo3(H).h,j);
hO = hk(Temp,termo3(O).h,j);
hOH = hk(Temp,termo3(OH).h,j);
hNO = hk(Temp,termo3(NO).h,j);
%entropies
sCO2 = sk(Temp,termo3(CO2).s,j);
sH2Oo = sk(Temp,termo3(H2O).s,j);
sO2o = sk(Temp,termo3(O2).s,j);
sN2o = sk(Temp,termo3(N2).s,j);
sAro = sk(Temp,termo3(Ar).s,j);
sCO = sk(Temp,termo3(CO).s,j);
sH2 = sk(Temp,termo3(H2).s,j);
sN = sk(Temp,termo3(N).s,j);
sH = sk(Temp,termo3(H).s,j);
sO = sk(Temp,termo3(O).s,j);
sOH = sk(Temp,termo3(OH).s,j);
sNO = sk(Temp,termo3(NO).s,j);
%gibbs energy
gCO2 = hCO2 - Temp*sCO2;
gH2Oo = hH2Oo - Temp*sH2Oo;
gO2o = hO2o - Temp*sO2o;
gN2o = hN2o - Temp*sN2o;
gAro = hAro - Temp*sAro;
gCO = hCO - Temp*sCO;
gH2 = hH2 - Temp*sH2;
gN = hN - Temp*sN;
gH = hH - Temp*sH;
gO = hO - Temp*sO;
gOH = hOH - Temp*sOH;
gNO = hNO - Temp*sNO;
%C02 <> CO + 0.5O2
g1 = n6*gCO + n3*gO2o - n1*gCO2;
%H2O <> H2 + 0.5O2
g2 = n7*gH2 + n3*gO2o - n2*gH2Oo;
%N2 <> 2N
g3 = n8*gN - n4*gN2o;
%H2 <> 2H
g4 = n9*gH-n7*gH2;
%O2 <> 2O
g5 = n10*gO - n3*gO2o;
%H2O <> OH + 0.5H2
g6 = n11*gOH + n7*gH2 - n2*gH2Oo;
%0.5O2 +0.5N2 <> NO
g7 = n12*gNO - n3*gO2o - n4*gN2o;
%kp
KpCO=exp(-g1/(R*Temp));
KpH2=exp(-g2/(R*Temp));
KpN=exp(-g3/(R*Temp));
KpH=exp(-g4/(R*Temp));
KpO=exp(-g5/(R*Temp));
KpOH=exp(-g6/(R*Temp));
KpNO=exp(-g7/(R*Temp));
%n1C02 <> n6CO + n30.5O2
eq6 = KpCO == (n6*sqrt(n3)/n1)*(P/((n1+n6+n3)*Pref));
%H2O <> H2 + 0.5O2
eq7 = KpH2 == (n7*sqrt(n3)/n2)*(P/((n2+n7+n3)*Pref));
%N2 <> 2N
eq8 = KpN == (n8^2/n4)*(P/((n4+n8)*Pref));
%H2 <> 2H
eq9 = KpH == (n9^2/n7)*(P/((n7+n9)*Pref));
%O2 <> 2O
eq10 = KpO == (n10^2/n3)*(P/((n10+n3)*Pref));
%H2O <> OH + 0.5H2
eq11 = KpOH == (n11*sqrt(n7)/n2)*(P/((n11+n7+n2)*Pref));
%0.5O2 +0.5N2 <> NO
eq12 = KpNO == (n12/sqrt(n3*n4))*(P/((n12+n4+n3)*Pref));
%
eq13=hFuel + hO2i*lambda*(a+b/4) + hN2i*lambda*(a+b/4)*alpha + hAri*lambda*(a+b/4)*beta + hH2Oi*lambda*(a+b/4)*gamma - hCO2*n1 - hH2Oo*n2 -hO2o*n3 - hN2o*n4 -(n5*hAro+n6*hCO+n7*hH2+n8*hN+n9*hH+n10*hO+n11*hOH+n12*hNO) == 0;
[n1s,n2s,n3s,n4s,n5s,n6s,n7s,n8s,n9s,n10s,n11s,n12s,temp] = vpasolve([eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,eq13],[n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,Temp]);
for i=1:5
if isreal(temp(i))
if temp(i)>=termo3(1).limits(j) && temp(i)<=termo3(1).limits(j+1)
T=temp(i);
end
end
end
end
T
I don't know why it happens
Also I tryed another method but happens the same
%%---INPUT----------------------------------------------------------
load('termoDB2.mat','termo3')
reactantTemp = 273;
syms n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12 Temp;
prompt = 'Enter the fuel: ';
react = input(prompt,'s');
prompt = 'Enter the alpha: ';
alpha = input(prompt,'s');
prompt = 'Enter the beta: ';
beta = input(prompt,'s');
prompt = 'Enter the gamma: ';
gamma = input(prompt,'s');
lambda = 2;
R=8.3144621;
%T=zeros(1,length(lambda));
P=1;
Pref=1;
fuel = pos(termo3,react);
a=termo3(fuel).a;
b=termo3(fuel).b;
c=termo3(fuel).c;
n=zeros(1,12);
%for f=1:length(lambda)
%%---EQUILIBRIUM----------------------------------------------------
%CaHbOc + lambda(a+b/4)(O2+ alpha*N2+ beta*Ar+ gamma*H2O)->n1*CO2 + n2*H2O
%+ n3*O2 + n4*N2 +n5*Ar+n6*CO+n7*H2+n8*N+n9*H+n10*O+n11*OH+n12*NO
%C
eq1 = a == n1 + n6;
%H
eq2 = b + lambda*(a+b/4)*(gamma) == 2*n2 + 2*n7 + n9 + n11;
%O
eq3 = c + lambda*(a+b/4)*(2 + gamma) == 2*n1 + n2 + n3*2 + n6 + n10 + n11 +n12;
%N
eq4 = 2*lambda*(a+b/4)*alpha == 2*n4 + n8 +n12;
%Ar
eq5 = lambda*(a+b/4)*beta == n5;
%%---TEMPERATURA----------------------------------------------------
O2 = pos(termo3,'O2');
N2 = pos(termo3,'N2');
CO2 = pos(termo3,'CO2');
H2O = pos(termo3, 'H2O');
Ar = pos(termo3, 'Ar');
CO = pos(termo3, 'CO');
H2 = pos(termo3, 'H2');
N = pos(termo3, 'N');
H = pos(termo3, 'H');
O = pos(termo3, 'O');
OH = pos(termo3, 'OH');
NO = pos(termo3, 'NO');
% entalpies
hFuel = hk(reactantTemp,termo3(fuel).h,1);
hO2i = hk(reactantTemp,termo3(O2).h,1);
hN2i = hk(reactantTemp,termo3(N2).h,1);
hAri = hk(reactantTemp,termo3(Ar).h,1);
hH2Oi = hk(reactantTemp,termo3(H2O).h,1);
% entropies
sFuel = sk(reactantTemp,termo3(fuel).s,1);
sO2i = sk(reactantTemp,termo3(O2).s,1);
sN2i = sk(reactantTemp,termo3(N2).s,1);
sAri = sk(reactantTemp,termo3(Ar).s,1);
sH2Oi = hk(reactantTemp,termo3(H2O).s,1);
%x=[200:1:5000];
%y=(hFuel + hO2i*lambda(f)*(a+b/4) + hN2i*lambda(f)*(a+b/4)*3.76)*ones(1,4801);
%plot(x,y)
%hold;
k1=[200:1:1000];k2=[1000:1:5000];
Tcal=300;
Tant=299;
while (Tcal-Tant>0.001)
Tant=Tcal;
if(Tant<termo3(1).limits(2))
j=1;
else
j=2;
end
% enpalpies
hCO2 = hk(Temp,termo3(CO2).h,j);
hH2Oo = hk(Temp,termo3(H2O).h,j);
hO2o = hk(Temp,termo3(O2).h,j);
hN2o = hk(Temp,termo3(N2).h,j);
hAro = hk(Temp,termo3(Ar).h,j);
hCO = hk(Temp,termo3(CO).h,j);
hH2 = hk(Temp,termo3(H2).h,j);
hN = hk(Temp,termo3(N).h,j);
hH = hk(Temp,termo3(H).h,j);
hO = hk(Temp,termo3(O).h,j);
hOH = hk(Temp,termo3(OH).h,j);
hNO = hk(Temp,termo3(NO).h,j);
%entalpies numeriques
hCO2n = hk(Tant,termo3(CO2).h,j);
hH2Oon = hk(Tant,termo3(H2O).h,j);
hO2on = hk(Tant,termo3(O2).h,j);
hN2on = hk(Tant,termo3(N2).h,j);
hAron = hk(Tant,termo3(Ar).h,j);
hCOn = hk(Tant,termo3(CO).h,j);
hH2n = hk(Tant,termo3(H2).h,j);
hNn = hk(Tant,termo3(N).h,j);
hHn = hk(Tant,termo3(H).h,j);
hOn = hk(Tant,termo3(O).h,j);
hOHn = hk(Tant,termo3(OH).h,j);
hNOn = hk(Tant,termo3(NO).h,j);
%entropies numeriques
sCO2n = sk(Tant,termo3(CO2).s,j);
sH2Oon = sk(Tant,termo3(H2O).s,j);
sO2on = sk(Tant,termo3(O2).s,j);
sN2on = sk(Tant,termo3(N2).s,j);
sAron = sk(Tant,termo3(Ar).s,j);
sCOn = sk(Tant,termo3(CO).s,j);
sH2n = sk(Tant,termo3(H2).s,j);
sNn = sk(Tant,termo3(N).s,j);
sHn = sk(Tant,termo3(H).s,j);
sOn = sk(Tant,termo3(O).s,j);
sOHn = sk(Tant,termo3(OH).s,j);
sNOn = sk(Tant,termo3(NO).s,j);
%gibbs energy
gCO2 = hCO2n - Tant*sCO2n;
gH2Oo = hH2Oon - Tant*sH2Oon;
gO2o = hO2on - Tant*sO2on;
gN2o = hN2on - Tant*sN2on;
gAro = hAron - Tant*sAron;
gCO = hCOn - Tant*sCOn;
gH2 = hH2n - Tant*sH2n;
gN = hNn - Tant*sNn;
gH = hHn - Tant*sHn;
gO = hOn - Tant*sOn;
gOH = hOHn - Tant*sOHn;
gNO = hNOn - Tant*sNOn;
%C02 <> CO + 0.5O2
g1 = n6*gCO + n3*gO2o - n1*gCO2;
%H2O <> H2 + 0.5O2
g2 = n7*gH2 + n3*gO2o - n2*gH2Oo;
%N2 <> 2N
g3 = n8*gN - n4*gN2o;
%H2 <> 2H
g4 = n9*gH-n7*gH2;
%O2 <> 2O
g5 = n10*gO - n3*gO2o;
%H2O <> OH + 0.5H2
g6 = n11*gOH + n7*gH2 - n2*gH2Oo;
%0.5O2 +0.5N2 <> NO
g7 = n12*gNO - n3*gO2o - n4*gN2o;
%kp
KpCO=exp(-g1/(R*Tant));
KpH2=exp(-g2/(R*Tant));
KpN=exp(-g3/(R*Tant));
KpH=exp(-g4/(R*Tant));
KpO=exp(-g5/(R*Tant));
KpOH=exp(-g6/(R*Tant));
KpNO=exp(-g7/(R*Tant));
%n1C02 <> n6CO + n30.5O2
eq6 = KpCO == (n6*sqrt(n3)/n1)*(P/((n1+n6+n3)*Pref));
%H2O <> H2 + 0.5O2
eq7 = KpH2 == (n7*sqrt(n3)/n2)*(P/((n2+n7+n3)*Pref));
%N2 <> 2N
eq8 = KpN == (n8^2/n4)*(P/((n4+n8)*Pref));
%H2 <> 2H
eq9 = KpH == (n9^2/n7)*(P/((n7+n9)*Pref));
%O2 <> 2O
eq10 = KpO == (n10^2/n3)*(P/((n10+n3)*Pref));
%H2O <> OH + 0.5H2
eq11 = KpOH == (n11*sqrt(n7)/n2)*(P/((n11+n7+n2)*Pref));
%0.5O2 +0.5N2 <> NO
eq12 = KpNO == (n12/sqrt(n3*n4))*(P/((n12+n4+n3)*Pref));
F=[eq1;eq2;eq3;eq4;eq5;eq6;eq7;eq8;eq9;eq10;eq11;eq12];
[n1s,n2s,n3s,n4s,n5s,n6s,n7s,n8s,n9s,n10s,n11s,n12s] = solve([eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12],[n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12]);
%
eq13=hFuel + hO2i*lambda*(a+b/4) + hN2i*lambda*(a+b/4)*alpha + hAri*lambda*(a+b/4)*beta + hH2Oi*lambda*(a+b/4)*gamma - hCO2*n1s - hH2O*n2s -hO2o*n3s - hN2o*n4s -(n5s*hAro+n6s*hCO+n7s*hH2+n8s*hN+n9s*hH+n10s*hO+n11s*hOH+n12s*hNO) == 0;
[temp]=vpasolve(eq13,Temp);, for i=1:5
if isreal(temp(i))
if temp(i)>=termo3(1).limits(j) && temp(i)<=termo3(1).limits(j+1)
T=temp(i);
end
end
end
end
T
Here the first solve returs a empty syms

Answers (1)

John D'Errico
John D'Errico on 26 Jun 2016
So you have an fairly complicated set of equations (12 of them) in many variables (also 12).
An empty return says that no solution was found.
What are the odds that a symbolic, analytical solution exists? (quite small.) A solution may not exist at all. You May try vpasolve, to search for a numerical solution.
In fact, it will be quite rare to expect such a solution to exist. (I was surprised once, 30 or so years ago, when a symbolic tool actually did manage to solve a system of 10 equations in 10 unknowns.) Typically when this happens, it turns out that the system was far simpler than it looks. In this case, that did not happen.

Products

Asked:

on 26 Jun 2016

Answered:

on 26 Jun 2016

Community Treasure Hunt

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

Start Hunting!