Why my result is 0×1 empty double column vector
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function[u_g] = viscosity(Pm) % viscosity() calculates viscosity of the gas at given reservoir % temperature and pressure.
M_air=[28.96;29;29.56;30;31;31.86;32;32.3;33;33.50];
Avg_Mol_Wt= [25.48;26;26.12;26.79;27;27.60;28;29;29.40;30];
spgr=Avg_Mol_Wt.\M_air;
Pm=[3800;3850;3400;3450;3500;3550;3600;3650;3700;3750]; %initial reservoir pressure
T=[660;680;720;740;760;780;800;820;840;860]; %Reservoir Temperature= 660 deg R (Literature)
u_uncorrected = ((1.709 * (10^(-5)-(2.062*10^(-6)*spgr))).*(T-460))+((8.118*10^(-3))-(6.15*10^(-3)*log10(spgr)));
yCO2 = 0.03;
yN2 = 0.02;
yH2S = 0.01;
u_CO2 = (yCO2*(((9.08*10^(-3))*(log10(spgr)))+ (6.24*10^(-3))));
u_N2 = (yN2*((8.48*10^(-3)*log10(spgr))+ (9.59*10^(-3))));
u_H2S = (yH2S*((8.49*10^(-3)*log10(spgr))+ (3.73*10^(-3))));
u1 = u_uncorrected + u_CO2 + u_N2 + u_H2S ;
Tpc = 168 + (325 * spgr) -(12.5*(spgr.^2));
Ppc = 677 + (15*spgr) -(37.5*(spgr.^2));
Tpr = T/Tpc;
Ppr = Pm/Ppc;
% Constants for viscosity relation
a0 = -2.4621182;
a1 = 2.970547414;
a2 = -0.286264054;
a3 = 0.008054205;
a4 = 2.80860949;
a5 = -3.49803305;
a6 = 0.36037302;
a7 = -0.01044324;
a8 = -0.793385648;
a9 = 1.39643306;
a10 = -0.149144925;
a11 = 0.004410155;
a12 = 0.083938718;
a13 = -0.186408848;
a14 =0.020336788;
a15 = -0.000609579;
syms ug;
con = a0+(a1.*Ppr)+(a2.*(Ppr.^2))+ (a3.*(Ppr.^3)) +(Tpr.*(a4+(a5.*Ppr)+(a6.*Ppr.^2)+(a7.*Ppr.^3)))+((Tpr.^2)*(a8+(a9.*Ppr)+(a10.*Ppr.^2)+(a11.*Ppr.^3)))+((Tpr.^3)*(a12+(a13.*Ppr)+(a14.*Ppr.^2)+(a15.*Ppr.^3)));
eqn = ((Tpr.*ug) == u1.*exp(con));
temp = solve(eqn,'ug');
u_g = double(temp);
end
results
>> viscosity
Warning: Do not specify equations and variables as
character vectors. Instead, create symbolic variables
with syms.
> In solve>getEqns (line 446)
In solve (line 226)
In viscosity (line 40)
ans =
0×1 empty double column vector
0 Kommentare
Antworten (2)
John D'Errico
am 18 Mai 2019
Bearbeitet: John D'Errico
am 18 Mai 2019
Um, LOOK AT WHAT YOU DID?
eqn
eqn =
[ 0 == 5780664229092589/18446744073709551616, 0 == 5780664229092589/18446744073709551616, 0 == 5780664229092589/18446744073709551616, 0 == 5780664229092589/18446744073709551616, 0 == 5780664229092589/18446744073709551616, (5645467684136263*ug)/4503599627370496 == 3053705270954071/288230376151711744, 0 == 5780664229092589/18446744073709551616, 0 == 4586793404289899/8796093022208, 0 == 5780664229092589/18446744073709551616, 0 == 5780664229092589/18446744073709551616]
[ 0 == 5600019709277477/18446744073709551616, 0 == 5600019709277477/18446744073709551616, 0 == 5600019709277477/18446744073709551616, 0 == 5600019709277477/18446744073709551616, 0 == 5600019709277477/18446744073709551616, (5816542462443423*ug)/4503599627370496 == 822835767405345/72057594037927936, 0 == 5600019709277477/18446744073709551616, 0 == 3047385662287835/4398046511104, 0 == 5600019709277477/18446744073709551616, 0 == 5600019709277477/18446744073709551616]
[ 0 == 2572630575198711/9223372036854775808, 0 == 2572630575198711/9223372036854775808, 0 == 2572630575198711/9223372036854775808, 0 == 2572630575198711/9223372036854775808, 0 == 2572630575198711/9223372036854775808, (3079346009528871*ug)/2251799813685248 == 7486683279545443/576460752303423488, 0 == 2572630575198711/9223372036854775808, 0 == 1741669557772335/2199023255552, 0 == 2572630575198711/9223372036854775808, 0 == 2572630575198711/9223372036854775808]
[ 0 == 2472319987732461/9223372036854775808, 0 == 2472319987732461/9223372036854775808, 0 == 2472319987732461/9223372036854775808, 0 == 2472319987732461/9223372036854775808, 0 == 2472319987732461/9223372036854775808, (6329766797364901*ug)/4503599627370496 == 4002404158088997/288230376151711744, 0 == 2472319987732461/9223372036854775808, 0 == 4733878050545925/4398046511104, 0 == 2472319987732461/9223372036854775808, 0 == 2472319987732461/9223372036854775808]
[ 0 == 2346687901508061/9223372036854775808, 0 == 2346687901508061/9223372036854775808, 0 == 2346687901508061/9223372036854775808, 0 == 2346687901508061/9223372036854775808, 0 == 2346687901508061/9223372036854775808, (6500841575672061*ug)/4503599627370496 == 8453485532814763/576460752303423488, 0 == 2346687901508061/9223372036854775808, 0 == 1593573526385771/1099511627776, 0 == 2346687901508061/9223372036854775808, 0 == 2346687901508061/9223372036854775808]
[ 0 == 8946768155106723/36893488147419103232, 0 == 8946768155106723/36893488147419103232, 0 == 8946768155106723/36893488147419103232, 0 == 8946768155106723/36893488147419103232, 0 == 8946768155106723/36893488147419103232, (1667979088494805*ug)/1125899906842624 == 8964393129251763/576460752303423488, 0 == 8946768155106723/36893488147419103232, 0 == 1080598422980285/549755813888, 0 == 8946768155106723/36893488147419103232, 0 == 8946768155106723/36893488147419103232]
[ 0 == 1069123269945641/4611686018427387904, 0 == 1069123269945641/4611686018427387904, 0 == 1069123269945641/4611686018427387904, 0 == 1069123269945641/4611686018427387904, 0 == 1069123269945641/4611686018427387904, (1710747783071595*ug)/1125899906842624 == 4767346375255051/288230376151711744, 0 == 1069123269945641/4611686018427387904, 0 == 2948226993291101/1099511627776, 0 == 1069123269945641/4611686018427387904, 0 == 1069123269945641/4611686018427387904]
[ 0 == 4100813596974095/18446744073709551616, 0 == 4100813596974095/18446744073709551616, 0 == 4100813596974095/18446744073709551616, 0 == 4100813596974095/18446744073709551616, 0 == 4100813596974095/18446744073709551616, (7014065910593539*ug)/4503599627370496 == 317887318073797/18014398509481984, 0 == 4100813596974095/18446744073709551616, 0 == 4045185938083311/1099511627776, 0 == 4100813596974095/18446744073709551616, 0 == 4100813596974095/18446744073709551616]
[ 0 == 7774278768879437/36893488147419103232, 0 == 7774278768879437/36893488147419103232, 0 == 7774278768879437/36893488147419103232, 0 == 7774278768879437/36893488147419103232, 0 == 7774278768879437/36893488147419103232, (7185140688900699*ug)/4503599627370496 == 670498029164941/36028797018963968, 0 == 7774278768879437/36893488147419103232, 0 == 2750305037577659/549755813888, 0 == 7774278768879437/36893488147419103232, 0 == 7774278768879437/36893488147419103232]
[ 0 == 1846563996020195/9223372036854775808, 0 == 1846563996020195/9223372036854775808, 0 == 1846563996020195/9223372036854775808, 0 == 1846563996020195/9223372036854775808, 0 == 1846563996020195/9223372036854775808, (3678107733603929*ug)/2251799813685248 == 354377367836401/18014398509481984, 0 == 1846563996020195/9223372036854775808, 0 == 7515208335023383/1099511627776, 0 == 1846563996020195/9223372036854775808, 0 == 1846563996020195/9223372036854775808]
So, most of that mess is of a form like this:
eqn(1)
ans =
0 == 5780664229092589/18446744073709551616
Which value of ug will satisfy that EXACTLY? Yeah, right. It looks like there will never be a solution to what you are doing. Not that we are given a hint as to what you really need to do, which is probably not what you actually wrote code to do since that system of equations is meaningless.
So, why is your result an empty vector? Because there is no solution to what you posed.
2 Kommentare
Walter Roberson
am 18 Mai 2019
function[u_g] = viscosity(Pm) % viscosity() calculates viscosity of the gas at given reservoir % temperature and pressure.
M_air=[28.96;29;29.56;30;31;31.86;32;32.3;33;33.50];
Avg_Mol_Wt= [25.48;26;26.12;26.79;27;27.60;28;29;29.40;30];
spgr=Avg_Mol_Wt.\M_air;
Pm=[3800;3850;3400;3450;3500;3550;3600;3650;3700;3750]; %initial reservoir pressure
T=[660;680;720;740;760;780;800;820;840;860]; %Reservoir Temperature= 660 deg R (Literature)
u_uncorrected = ((1.709 * (10^(-5)-(2.062*10^(-6)*spgr))).*(T-460))+((8.118*10^(-3))-(6.15*10^(-3)*log10(spgr)));
yCO2 = 0.03;
yN2 = 0.02;
yH2S = 0.01;
u_CO2 = (yCO2*(((9.08*10^(-3))*(log10(spgr)))+ (6.24*10^(-3))));
u_N2 = (yN2*((8.48*10^(-3)*log10(spgr))+ (9.59*10^(-3))));
u_H2S = (yH2S*((8.49*10^(-3)*log10(spgr))+ (3.73*10^(-3))));
u1 = u_uncorrected + u_CO2 + u_N2 + u_H2S ;
Tpc = 168 + (325 * spgr) -(12.5*(spgr.^2));
Ppc = 677 + (15*spgr) -(37.5*(spgr.^2));
Tpr = T./Tpc; %CHANGED
Ppr = Pm./Ppc; %CHANGED
% Constants for viscosity relation
a0 = -2.4621182;
a1 = 2.970547414;
a2 = -0.286264054;
a3 = 0.008054205;
a4 = 2.80860949;
a5 = -3.49803305;
a6 = 0.36037302;
a7 = -0.01044324;
a8 = -0.793385648;
a9 = 1.39643306;
a10 = -0.149144925;
a11 = 0.004410155;
a12 = 0.083938718;
a13 = -0.186408848;
a14 =0.020336788;
a15 = -0.000609579;
syms ug;
con = a0+(a1.*Ppr)+(a2.*(Ppr.^2))+ (a3.*(Ppr.^3)) +(Tpr.*(a4+(a5.*Ppr)+(a6.*Ppr.^2)+(a7.*Ppr.^3)))+((Tpr.^2).*(a8+(a9.*Ppr)+(a10.*Ppr.^2)+(a11.*Ppr.^3)))+((Tpr.^3).*(a12+(a13.*Ppr)+(a14.*Ppr.^2)+(a15.*Ppr.^3))); %CHANGED IN TWO PLACES
eqn = ((Tpr.*ug) == u1.*exp(con));
temp = solve(eqn,'ug');
u_g = double(temp);
end
This will still not work, but it will get you to the much more compact
eqn =
(5702507353183325*ug)/4503599627370496 == 7212478526205445/144115188075855872
(2973544911973051*ug)/2251799813685248 == 433318337191181/9007199254740992
(6238234906800469*ug)/4503599627370496 == 1518433413966557/36028797018963968
(1613828264998639*ug)/1125899906842624 == 5989232554701665/144115188075855872
(6523595956302411*ug)/4503599627370496 == 3031307013761477/72057594037927936
(1667979088494805*ug)/1125899906842624 == 6063175485720917/144115188075855872
(1225*ug)/801 == 6021374973680469/144115188075855872
(7178082536150291*ug)/4503599627370496 == 2979923091249657/72057594037927936
(3658295761408275*ug)/2251799813685248 == 3003315655091799/72057594037927936
(49536*ug)/29683 == 754534745967413/18014398509481984
This can be analyzed in a least-squared sense to get a best-fit ug of about 0.028997375328324588909163169559149
0 Kommentare
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!