Problem with my gamma_water values not giving me the correct pressure using fsolve
1 view (last 30 days)
Show older comments
Hi,
I'm having trouble with my "gamma_water" variable not giving me the correct P (PressureNonIdeal) value. I keep getting this message : No solution found.
fsolve stopped because the
last step was ineffective. However, the vector of function
values is not near zero, as measured by the value of the
Here is my current code :
DelH = -1* (-917.475 - (-600.351 + -247.184)) * 1000;
DelS = -1*(172.10 - (76.87 + 232.70));
DelV = -1*(((24.630 - (11.248))*1E-6) *1E5);
Grxn = 0; %because at equilibrium
R = 8.314;
T=948.15; %675 C
x0 = 2000;
fun = @DeltaGcalc;
%Ideal gas
gamma_water = 1
PressureIdeal=fsolve(@(P) fun(DelH,DelS,DelV,T,P,R,gamma_water),x0)
%Non-ideal gas
Ta = 873.15 ; ga = 0.5203; %For a constant pressure of 2000bar
Tb = 1273.15 ; gb = 0.7939;
gamma_water = ((gb-ga)/(Tb-Ta))*T;
PressureNonIdeal=fsolve(@(P) fun(DelH,DelS,DelV,T,P,R,gamma_water),x0)
function Grxn = DeltaGcalc(DelH,DelS,DelV,T,P,R,gamma_water)
Grxn = DelH - T*DelS + DelV*(P-1) + R*T*log(gamma_water*P); %because both the solids are pure, their activity is 1. the activity of the fluid only counts.
end
According to the question, «The pressure (PressureNonIdeal) for the value calculated with the fugacity coefficient (gamma_water) will be between 2 and 10 kbar (200 to 1 000 MPa). Note that you will have to interpolate between the values in the tables, both in terms of pressure and temperature; between any two values in the table at either constant pressure or at constant temperature you can assume that the variations are linear.»
I have attached the table to this description
0 Comments
Answers (1)
Torsten
on 21 Sep 2024
Look at the curves and see what's happening. Your first equation has two solutions while your second has none:
DelH = -1* (-917.475 - (-600.351 + -247.184)) * 1000;
DelS = -1*(172.10 - (76.87 + 232.70));
DelV = -1*(((24.630 - (11.248))*1E-6) *1E5);
Grxn = 0; %because at equilibrium
R = 8.314;
T=948.15; %675 C
x0 = 2000;
fun = @DeltaGcalc;
%Ideal gas
gamma_water = 1;
PressureIdeal=fsolve(@(P) fun(DelH,DelS,DelV,T,P,R,gamma_water),x0)
x=4e3:10:8e3;
figure()
plot(x,fun(DelH,DelS,DelV,T,x,R,gamma_water))
%Non-ideal gas
Ta = 873.15 ; ga = 0.5203; %For a constant pressure of 2000bar
Tb = 1273.15 ; gb = 0.7939;
gamma_water = ((gb-ga)/(Tb-Ta))*T;
PressureNonIdeal=fsolve(@(P) fun(DelH,DelS,DelV,T,P,R,gamma_water),x0)
x=0.1:100:1e4;
figure()
plot(x,fun(DelH,DelS,DelV,T,x,R,gamma_water))
function Grxn = DeltaGcalc(DelH,DelS,DelV,T,P,R,gamma_water)
Grxn = DelH - T*DelS + DelV*(P-1) + R*T*log(gamma_water*P); %because both the solids are pure, their activity is 1. the activity of the fluid only counts.
end
8 Comments
See Also
Categories
Find more on Thermal Analysis 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!