Post Reply 
HP Prime Program using Solve function
02-04-2020, 12:29 AM
Post: #6
RE: HP Prime Program using Solve function
Three comments:

1. From a program, solve() has to be sent to CAS via a string;
2. The variable you are solving for should not exist. In the edited program below I used lower case z. You have to use a variable that doesn't exist anywhere on your calculator;
3. Solve doesn't assign the answer to the variable, it just returns an answer; you have to assign that to a variable in your program.

With this in mind, here is a modified program:

Code:

export Tc, Pc, Tr, Pr;
export β,α,фi,fi;
export s,Є,Ω,ѱ;

EXPORT Pure_Fugacity()
BEGIN
 local Zv,Zl,Iv,Il;
 local w,c,q,Z;
 Ω:=.0778;
 Є:=1-√2;
 s:=1+√2;
 ѱ:=.45724;
// input({T,Tc,P,Pc});
// input({w});

T:=25;
Tc:=350;
P:=15;
Pc:=450;
w:=0.5;

 Tr:=T/Tc;
 Pr:=P/Pc;
 c:=1+(0.37464+1.54226*w-0.26992*w^(2));
 α:=(c*(1-Tr^(1/2)))^2;
 β:=(Ω*(Pr/Tr));
 q:=ѱ*α/Tr/Ω;
//Z for vapor
 Z:=CAS("solve(0=1+β-q*β*(z-β)/(z+β*Є)/(z+s*β),z,1)");
 Zv:=Z;
 msgbox(Zv);
//Z for liquid
 Z:=CAS("solve(0=1+β-q*β*(z-β)/(z+β*Є)/(z+s*β),z,β)");
 Zl:=Z;
//I for vapor
 Iv:=(1/(s-β))*ln((Zv+s*β)/(Zv+β*Є));
//I for liquid
 Il:=(1/(s-β))*ln((Zl+s*β)/(Zl+β*Є));
 фi:=e^(Zv-1-ln(Zv-β)-q*Iv);
 fi:=фi*P;
 print();
 print("Tr="+Tr);
 print("Pr="+Pr);
 print("α="+α);
 print("β="+β);
 print("q="+q);
 print("Zv="+Zv);
 print("Lv="+Iv);
 print("фi="+фi);
 print("fi="+fi);
END;

Hope this helps.

-road
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP Prime Program using Solve function - roadrunner - 02-04-2020 12:29 AM



User(s) browsing this thread: 2 Guest(s)