| Author |
Message |
thatguy69
Joined: 18 Nov 2010 Posts: 1
|
Posted: November 18, 2010 11:35 PM Post subject: Help! Chemistry Program. |
|
|
This is a program for my chemistry class designed to solve the Clausius-Clapeyron equation for an unknown variable. I can't seem to get it to work. It either tells me that for the 'solve' function "Argument must be a variable" or that somethings wrong with the units.
Can anyone tell me what's wrong?
| Code: | ()
Prgm
Local p1,p2,hvap,t1,t2,mv,expo
Dialog
Title "Clausius-Clapeyron"
DropDown "Missing Variable",{"Pressure 1","Pressure 2","H of Vapor","Temperature 1","Temperature 2"},mv
EndDlog
If mv=1 Then
Dialog
Title "Clausius-Clapeyron"
Request "Pressure 2",p2
Request "H of Vapor",hvap
Request "Temperature 1",t1
Request "Temperature 2",t2
EndDlog
solve(ln(p2/p1)=–hvap/ugas*(1/t2-1/t1),p1)
EndIf
If mv=2 Then
Dialog
Title "Clausius-Clapeyron"
Request "Pressure 1",p1
Request "H of Vapor",hvap
Request "Temperature 1",t1
Request "Temperature 2",t2
EndDlog
solve(ln(p2/p1)=–hvap/ugas*(1/t2-1/t1),p2)
EndIf
If mv=3 Then
Dialog
Title "Clausius-Clapeyron"
Request "Pressure 1",p1
Request "Pressure 2",p2
Request "Temperature 1",t1
Request "Temperature 2",t2
EndDlog
solve(ln(p2/p1)=–hvap/ugas*(1/t2-1/t1),hvap)
EndIf
If mv=4 Then
Dialog
Title "Clausius-Clapeyron"
Request "Pressure 1",p1
Request "Pressure 2",p2
Request "H of Vapor",hvap
Request "Temperature 2",t2
EndDlog
solve(ln(p2/p1)=–hvap/ugas*(1/t2-1/t1),t1)
EndIf
If mv=5 Then
Dialog
Title "Clausius-Clapeyron"
Request "Pressure 1",p1
Request "Pressure 2",p2
Request "H of Vapor",hvap
Request "Temperature 1",t1
EndDlog
solve(ln(p2/p1)=–hvap/ugas*(1/t2-1/t1),t2)
EndIf
EndPrgm |
|
|
| Back to top |
|
 |
mellamokb
Joined: 10 May 2007 Posts: 124
|
Posted: February 10, 2011 3:44 PM Post subject: |
|
|
Hi thatguy69,
It looks like you can't solve for an undefined local variable. Try using another variable name for the one being solved. For instance, the first expression would look something like this:
| Code: |
solve(ln(p2/thevar)=hvap/ugas*(1/t2-1/t1),thevar)
|
You would swap out thevar (which can be whatever you want) for each variable being solved for.
Edit: You also need to convert the request values. They are stored as strings, and need to be converted to numbers. Like this:
| Code: |
expr(p2) -> p2
expr(hvap) -> hvap
expr(t1) -> t1
expr(t2) -> t2
|
You will also want to print out the result. You can do something like this:
| Code: |
solve(ln(p2/thevar)=hvap/ugas*(1/t2-1/t1),thevar) -> p1
Disp p1
|
Hope this helps!
Regards,
~ mellamokb[/code] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
Saphic 1.5 // Theme created by Sopel
|
|