Older Version
Newer Version
cogburn
May 23, 2012
**Gas Law Solver** Should be useful to chemistry teachers. It allows user to choose which gas law to solve and which variables will be solved for. After entering knowns into the program the solution is revealed in a "notice" box. [[code format="lb"]] 'GAS LAW problem solver ' purpose is to solve gas law problems including Dalton's law of partial pressure '4/12/2010 nomainwin VP = 0 [begin] WindowWidth = 560 WindowHeight = 520 groupbox #cfg, "Boyle's Law", 240, 20, 200, 140 radiobutton #cfg.bP2, "Solve for Pressure 2", [BoylesLawUKP2], [waitHere], 260, 45, 130, 20 radiobutton #cfg.bP1, "Solve for Pressure 1", [BoylesLawUKP1], [waitHere], 260, 70, 130, 20 radiobutton #cfg.bV2, "Solve for Volume 2", [BoylesLawUKV2], [waitHere], 260, 95, 130, 20 radiobutton #cfg.bV1, "Solve for Volume I", [BoylesLawUKV1], [waitHere], 260, 120, 130, 20 groupbox #cfg, "Charles' Law", 20, 20, 200, 140 radiobutton #cfg.cv2, "Solve for Volume 2", [CharlesLawUKV2], [waitHere], 40, 45, 130, 20 radiobutton #cfg.ct2, "Solve for Temperature 2", [CharlesLawUKT2], [waitHere], 40, 70, 130, 20 radiobutton #cfg.cv1, "Solve for Volume 1", [CharlesLawUKV1], [waitHere], 40, 95, 130, 20 radiobutton #cfg.ct1, "Solve for Temperature 1", [CharlesLawUKT1], [waitHere], 40, 120, 130, 20 button #cfg, " &Quit ", [quit], UL, 450, 30 button #cfg, " Water " , [Dalton], UL, 30,450 Statictext #cfg.static, "Click Here if gas was collected by water displacement. ",120,460, 600,20 groupbox #cfg, "Gay-Lussac Law", 20, 240, 200, 140 radiobutton #cfg.Boyles, "Solve for Pressure 2", [GayLawUKP2], [waitHere], 40, 265, 130, 20 radiobutton #cfg.Char1es, "Solve for Temperature 2", [GayLawUKT2], [waitHere], 40, 290, 130, 20 radiobutton #cfg.Gay, "Solve for Pressure 1", [GayLawUKP1], [waitHere], 40, 315, 130, 20 radiobutton #cfg.Combined, "Solve for Temperature 1", [GayLawUKT1], [waitHere], 40, 340, 130, 20 groupbox #cfg, "Combined Gas Law", 240, 240, 200, 160 radiobutton #cfg.bP2, "Solve for Pressure 2", [CGLUKP2], [waitHere], 260, 255, 130, 20 radiobutton #cfg.bP1, "Solve for Pressure 1", [CGLUKP1], [waitHere], 260, 280, 130, 20 radiobutton #cfg.bV2, "Solve for Volume 2", [CGLUKV2], [waitHere], 260, 305, 130, 20 radiobutton #cfg.bV1, "Solve for Volume 1", [CGLUKV1], [waitHere], 260, 330, 130, 20 radiobutton #cfg.T2, "Solve for Temperature 2", [CGLUKT2], [waitHere], 260, 355, 130, 20 radiobutton #cfg.T1, "Solve Temperature 1", [CGLUKT1], [waitHere], 260, 380, 130, 20 open "Gas Law Solver" for dialog as #cfg print #cfg, "trapclose [quit]" [waitHere] wait [BoylesLawUKV2] prompt "pressure 1"; P1 PI = PI -VP prompt "volume l";V1 prompt "pressure 2"; P2 V2=(P1*V1)/P2 notice "V2 ="; V2 wait [BoylesLawUKP2] prompt "pressure 1"; P1 P1= P1 -VP prompt "volume 1"; V1 prompt "volume 2";V2 P2=(P1*V1)/V2 notice "P2 ="; P2 wait [BoylesLawUKV1] prompt "pressure 1" ; P1 P1 = P1 -VP prompt "volume 2";V2 prompt "pressure 2"; P2 V1=(P2*V2)/P1 notice "V1=";V1 wait [BoylesLawUKP1] prompt "volume l";V1 prompt "volume 2";V2 prompt "pres sure 2"; P2 P1=(P2*V2)/V1 notice "P1=" ; P1 wait [CharlesLawUKT1] prompt "Temperature 2 in Celsius";T2 prompt "volume l";V1 prompt "Volume 2";V2 T2 = T2 + 273 T1=(T2*V1)/V2 notice "T1=";T1;" Kelvin" wait [CharlesLawUKT2] prompt "Temperature 1 in Celsius";T1 prompt "volume 1";V1 prompt "Volume 2";V2 T1 = T1 + 273 T2=(T1*V2)/V1 notice "T2=" ; T2 wait [CharlesLawUKV1] prompt "Temperature 1 in Celsius";T1 prompt "volume 2";V2 prompt "Temperature 2 in Celsius";T2 T1 = T1 + 273 T2 = T2 + 273 V1=(T1*V2)/T2 notice "V1="; V1 wait [CharlesLawUKV2] prompt "Temperature 1 in Celsius" ;T1 prompt "volume 1"; V1 prompt "Temperature 2";T2 T1= T1 + 273 T2 = T2 + 273 V2=(T2*V1)/T1 notice "V2=";V2 wait [CGLUKT1] prompt "Pressure 1= "; P1 P1 = P1 -VP prompt "Volume 1= ";V1 prompt "Temperature 2 (in Celsius) = ";T2 prompt "Pressure 2= "; P2 prompt "Volume 2= ";V2 T2 = T2 + 273 T1 = (P1*V1*T2)/(P2*V2) notice "T1 = ";T1; " Kelvin" wait [CGLUKP2] prompt "Pressure 1= "; P1 P1 = P1 -VP prompt "Volume 1= ";V1 prompt "Temperature 2 (in Celsius) = ";T2 prompt "Temperature 1= ";T1 prompt "Volume 2= ";V2 T2 = T2 + 273 T1 = T1 + 273 P2 = (P1*V1*T2)/(T1*V2) notice "P2 = "; P2 wait [CGLUKT2] prompt "Pressure 1= "; PI P1 = PI -VP prompt "Volume 1= ";V1 prompt "Temperature 1 (in Celsius) = ";T1 prompt "Pressure 2= "; P2 prompt "Volume 2= ";V2 Tl = T1 + 273 T2 = (P2*V2*Tl)/(P1*V1) notice "T2 = ";T2; " Kelvin" wait [CGLUKVl] prompt "Pressure 1= " ;P1 P1 = PI -VP prompt "Temperature 1= ";T1 prompt "Temperature 2 (in Celsius) = ";T2 prompt "Pressure 2= " ;P2 prompt "Volume 2= ";V2 T1 = T1 + 273 T2 = T2 + 273 V1 = (P2*V2*T1)/(P1*T2) notice "V1 = " ;V1 wait [CGLUKV2] prompt "Pressure 1= "; P1 P1 = P1 -VP prompt "Volume 1= ";V1 prompt "Temperature 1 (in Celsius) = ";T1 prompt "Pressure 2= "; P2 prompt "Temperature 2 in (Celsius) = ";T2 T1 = T1 + 273 T2 = T2 + 273 V2 = (P1*V1*T2)/(P2*T1) notice "V2 = ";V2 wait [CGLUKP1] prompt "Temperature 2= "; T2 prompt "Volume 1= ";V1 prompt "Temperature 1 (in Celsius) = ";T1 prompt "Pressure 2= "; P2 prompt "Volume 2= ";V2 T2 = T2 + 273 T1 = T1 + 273 P1 = (P2*V2*T1)/(T2*V1) notice "P1 = ";P1 wait [GayLawUKP2] prompt "Temperature 1 (in Celsius) = ";T1 prompt "Temperature 2 (in Celsius) = ";T2 prompt "Pressure 1= "; P1 P1 = P1 -VP T2 = T2 + 273 T1 = T1 + 273 P2 = (P1*T2)/T1 notice "P2 = "; P2 wait [GayLawUKP1] prompt "Temperature 1 (in Celsius) = ";T1 prompt "Temperature 2 (in Celsius) = ";T2 prompt "Pressure 2= "; P2 T2 = T2 + 273 T1 = T1 + 273 P1 = (T1*P2)/T2 notice "P1 = "; P1 wait [GayLawUKT2] prompt "Temperature 1 (in Celsius) = ";T1 prompt "Pressure 1 = ";P1 P1 = P1 -VP prompt "Pressure 2= "; P2 T1 = T1 + 273 T2 = (T1*P2)/P1 notice "T2 = "; T2 wait [GayLawUKT1] prompt "Temperature 2= "; P1 prompt "Volume 1= "; V1 prompt "Temperature 1 (in Celsius) = ";T1 prompt "Pressure 2= "; P2 prompt "Volume 2= ";V2 T2 = T2 + 273 T1 = T1 + 273 P1 = (P2*V2*T1)/(P1*V1) notice "P1 = "; P1 wait [Dalton] prompt "Celsius Temperature ";C VP= 4.553 + .3335*C + .01108 *C^2 + .0001826 * C^3 + 2.337e-6 * C^4 + 1.948e-8 * C^5 notice "H2O Partial Pressure is "; VP ; " mmHg" wait [quit] close #cfg end [[code]]