Chemistry 版 (精华区)
发信人: zjliu (秋天的萝卜), 信区: Chemistry
标 题: [转载]化学程序——计算理想气体可逆过程
发信站: BBS 哈工大紫丁香站 (Fri Sep 17 09:18:43 2004)
发信站: 日月光华
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Ideal Gas Reversible Process</title>
</head>
<body>
<em><script language="VBScript"><!--
R0=8.31441
N0=1
W0=0.001
M0=0.001
M0=0.001
CV0=24.9432
CP0=33.2576
P1=101325
V1=.0224138
T1=273.15
P2=P1
V2=V1
T2=T1
Q0=0
A0=0
E0=0
V0=0
H0=0
Path="Adiabatic"
sub Change_Adiabatic
Path="Adiabatic"
end sub
sub Change_Isobaric
Path="Isobaric"
end sub
end sub
sub Change_Isochoric
Path="Isochoric"
end sub
sub Change_Isothermal
Path="Isothermal"
end sub
sub Gas_Constant_onChange
Ideal_Gas.Gas_Constant.value=R0*Ideal_Gas.R_Unit.value
MsgBox "Cannot change Gas Constant!"
end sub
sub R_Unit_onChange
Ideal_Gas.Gas_Constant.value=R0/Ideal_Gas.R_Unit.value
end sub
sub Amount_onChange
if Path="Adiabatic" then
Ideal_Gas.Amount.value=N0/Ideal_Gas.N_Unit.value
MsgBox "Cannot change Amount"
MsgBox "Cannot change Amount"
else
N0=Ideal_Gas.Amount.value*Ideal_Gas.N_Unit.value
Calc_Amount
end if
end sub
sub N_Unit_onChange
Ideal_Gas.Amount.value=N0/Ideal_Gas.N_Unit.value
end sub
sub Weight_onChange
W0=Ideal_Gas.Weight.value*Ideal_Gas.W_Unit.value
N0=W0/M0
Ideal_Gas.Amount.value=N0/Ideal_Gas.N_Unit.value
Calc_State
Calc_All
end sub
sub W_Unit_onChange
Ideal_Gas.Weight.value=W0/Ideal_Gas.W_Unit.value
end sub
sub Molecule_onChange
M0=Ideal_Gas.Molecule.value*Ideal_Gas.M_Unit.value
W0=N0*M0
Ideal_Gas.Weight.value=W0/Ideal_Gas.W_Unit.value
end sub
sub M_Unit_onChange
Ideal_Gas.Molecule.value=M0/Ideal_Gas.M_Unit.value
end sub
sub CV_onChange
CV0=Ideal_Gas.CV.value*Ideal_Gas.CV_Unit.value
CP0=CV0*1.0+R0
Ideal_Gas.CP.value=CP0/Ideal_Gas.CP_Unit.value
Calc_All
end sub
sub CV_Unit_onChange
Ideal_Gas.CV.value=CV0/Ideal_Gas.CV_Unit.value
end sub
sub CP_onChange
sub CP_onChange
CP0=Ideal_Gas.CP.value*Ideal_Gas.CP_Unit.value
CV0=CP0-R0
Ideal_Gas.CV.value=CV0/Ideal_Gas.CP_Unit.value
Calc_All
end sub
sub CP_Unit_onChange
Ideal_Gas.CP.value=CP0/Ideal_Gas.CP_Unit.value
end sub
sub First_Pressure_onChange
P1=Ideal_Gas.First_Pressure.value*Ideal_Gas.Pressure_Unit.value
select case Path
case "Adiabatic"
V1=exp(-CV0/CP0*log(P1/P2))*V2
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
T1=exp(R0/CP0*log(P1/P2))*T2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Adiabatic
case "Isobaric"
N0=P1*V1/R0/T1
Ideal_Gas.Amount.value=N0
Ideal_Gas.Amount.value=N0
Calc_Amount
case "Isochoric"
V1=V2
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
T1=T2*P1/P2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Isochoric
case "Isothermal"
V1=P2*V2/P1
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
T1=T2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Isothermal
end select
end sub
sub Second_Pressure_onChange
P2=Ideal_Gas.Second_Pressure.value*Ideal_Gas.Pressure_Unit.value
select case Path
case "Adiabatic"
V2=exp(-CV0/CP0*log(P2/P1))*V1
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
T2=exp(R0/CP0*log(P2/P1))*T1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Adiabatic
case "Isobaric"
N0=P2*V2/R0/T2
Ideal_Gas.Amount.value=N0
Calc_Amount
case "Isochoric"
V2=V1
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
T2=T1*P2/P1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Isochoric
case "Isothermal"
V2=P1*V1/P2
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
T2=T1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Isothermal
end select
end sub
sub Pressure_Unit_onChange
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
end sub
sub First_Volume_onChange
V1=Ideal_Gas.First_Volume.value*Ideal_Gas.Volume_Unit.value
select case Path
case "Adiabatic"
P1=exp(-CP0/CV0*log(V1/V2))*P2
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
T1=exp(-R0/CV0*log(V1/V2))*T2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Adiabatic
case "Isobaric"
P1=P2
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
T1=T2*V1/V2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Isobaric
case "Isochoric"
N0=P1*V1/R0/T1
N0=P1*V1/R0/T1
Ideal_Gas.Amount.value=N0
Calc_Amount
case "Isothermal"
P1=P2*V2/V1
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
T1=T2
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Calc_Isothermal
end select
end sub
sub Second_Volume_onChange
V2=Ideal_Gas.Second_Volume.value*Ideal_Gas.Volume_Unit.value
select case Path
case "Adiabatic"
P2=exp(-CP0/CV0*log(V2/V1))*P1
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
T2=exp(-R0/CV0*log(V2/V1))*T1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Adiabatic
case "Isobaric"
P2=P1
P2=P1
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
T2=T1*V2/V1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Isobaric
case "Isochoric"
N0=P2*V2/R0/T2
Ideal_Gas.Amount.value=N0
Calc_Amount
case "Isothermal"
P2=P1*V1/V2
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
T2=T1
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Isothermal
end select
end sub
sub Volume_Unit_onChange
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
end sub
sub First_Temperature_onChange
T1=Ideal_Gas.First_Temperature.value*1.0+Ideal_Gas.Temperature_Unit.value
select case Path
case "Adiabatic"
P1=exp(-CP0/R0*log(T1/T2))*P2
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
V1=exp(-CV0/R0*log(T1/T2))*V2
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
Calc_Adiabatic
case "Isobaric"
P1=P2
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
V1=V2*T1/T2
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
Calc_Isobaric
case "Isochoric"
P1=P2*T1/T2
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
V1=V2
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
Calc_Isochoric
case "Isothermal"
case "Isothermal"
N0=P1*V1/R0/T1
Ideal_Gas.Amount.value=N0
Calc_Amount
end select
end sub
sub Second_Temperature_onChange
T2=Ideal_Gas.Second_Temperature.value*1.0+Ideal_Gas.Temperature_Unit.value
select case Path
case "Adiabatic"
P2=exp(-CP0/R0*log(T2/T1))*P1
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
V2=exp(-CV0/R0*log(T2/T1))*V1
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
Calc_Adiabatic
case "Isobaric"
P2=P1
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
V2=V1*T2/T1
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
Calc_Isobaric
case "Isochoric"
case "Isochoric"
P2=P1*T2/T1
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
V2=V1
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
Calc_Isochoric
case "Isothermal"
N0=P2*V2/R0/T2
Ideal_Gas.Amount.value=N0
Calc_Amount
end select
end sub
sub Temperature_Unit_onChange
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
end sub
sub Heat_onChange
MsgBox "Cannot change Heat!"
Ideal_Gas.Heat.value=Q0/Ideal_Gas.Q_Unit.value
end sub
sub Q_Unit_onChange
Ideal_Gas.Heat.value=Q0/Ideal_Gas.Q_Unit.value
end sub
sub Work_onChange
MsgBox "Cannot change Work!"
Ideal_Gas.Work.value=A0/Ideal_Gas.A_Unit.value
end sub
sub A_Unit_onChange
Ideal_Gas.Work.value=A0/Ideal_Gas.A_Unit.value
end sub
sub Energy_onChange
MsgBox "Cannot change Energy!"
Ideal_Gas.Energy.value=E0/Ideal_Gas.E_Unit.value
end sub
sub E_Unit_onChange
Ideal_Gas.Energy.value=E0/Ideal_Gas.E_Unit.value
end sub
sub Enthalpy_onChange
MsgBox "Cannot change Enthalpy!"
Ideal_Gas.Enthalpy.value=H0/Ideal_Gas.H_Unit.value
end sub
sub H_Unit_onChange
Ideal_Gas.Enthalpy.value=H0/Ideal_Gas.H_Unit.value
end sub
sub Entropy_onChange
MsgBox "Cannot change Entropy!"
Ideal_Gas.Entropy.value=S0/Ideal_Gas.S_Unit.value
end sub
sub S_Unit_onChange
Ideal_Gas.Entropy.value=S0/Ideal_Gas.S_Unit.value
end sub
sub Free_Energy_onChange
MsgBox "Cannot change Free Energy!"
Ideal_Gas.Free_Energy.value="Unknown"
end sub
end sub
sub Calc_Adiabatic
Q0=0
A0=N0*CV0*(T2-T1)
Calc_States
end sub
sub Calc_Isobaric
Q0=N0*CP0*(T2-T1)
A0=N0*R0*(T2-T1)
Calc_States
end sub
sub Calc_Isochoric
Q0=N0*CV0*(T2-T1)
A0=0
Calc_States
end sub
sub Calc_Isothermal
Q0=N0*R0*T1*log(V2/V1)
A0=-Q0
A0=-Q0
Calc_States
end sub
sub Calc_States
Ideal_Gas.Heat.value=Q0/Ideal_Gas.Q_Unit.value
Ideal_Gas.Work.value=A0/Ideal_Gas.A_Unit.value
E0=N0*CV0*(T2-T1)
Ideal_Gas.Energy.value=E0/Ideal_Gas.E_Unit.value
H0=N0*CP0*(T2-T1)
Ideal_Gas.Enthalpy.value=H0/Ideal_Gas.H_Unit.value
S0=N0*(CV0*log(P2/P1)+CP0*log(V2/V1))
Ideal_Gas.Entropy.value=S0/Ideal_Gas.S_Unit.value
end sub
sub Calc_Amount
M0=N0*W0
Ideal_Gas.Weight.value=W0/Ideal_Gas.W_Unit.value
select case Path
case "Isobaric"
P1=N0*R0*T1/V1
Ideal_Gas.First_Pressure.value=P1/Ideal_Gas.Pressure_Unit.value
P2=N0*R0*T2/V2
P2=N0*R0*T2/V2
Ideal_Gas.Second_Pressure.value=P2/Ideal_Gas.Pressure_Unit.value
Calc_Isobaric
case "Isochoric"
V1=N0*R0*T1/P1
Ideal_Gas.First_Volume.value=V1/Ideal_Gas.Volume_Unit.value
V2=N0*R0*T2/P2
Ideal_Gas.Second_Volume.value=V2/Ideal_Gas.Volume_Unit.value
Calc_Isochoric
case "Isothermal"
T1=P1*V1/N0/R0
Ideal_Gas.First_Temperature.value=T1-Ideal_Gas.Temperature_Unit.value
T2=P2*V2/N0/R0
Ideal_Gas.Second_Temperature.value=T2-Ideal_Gas.Temperature_Unit.value
Calc_Isothermal
end select
end sub
--></script></em>
<p align="center"><font size="6"><em><strong>Ideal Gas Reversible
Process</strong></em></font> </p>
<form method="POST" name="Ideal_Gas">
<table border="0" width="100%">
<tr>
<td align="center" rowspan="2" colspan="2"><table
border="1">
<tr>
<td> </td>
<td>First State</td>
<td>Second State</td>
<td> </td>
<td><input type="radio" checked name="Path"
value="Adiabatic"
onclick="Change_Adiabatic">Adiabatic</td>
</tr>
<tr>
<td>Pressure:</td>
<td><input type="text" size="10"
name="First_Pressure" value="101325"></td>
<td><input type="text" size="10"
name="Second_Pressure" value="101325"></td>
<td><select name="Pressure_Unit" size="1">
<option value="101325">atm</option>
<option value="101325">atm</option>
<option value="133.322">mmHg</option>
<option selected value="1">Pa</option>
</select></td>
<td><input type="radio" name="Path"
value="Isobaric" onclick="Change_Isobaric">Isobaric</td>
</tr>
<tr>
<td>Volume:</td>
<td><input type="text" size="10"
name="First_Volume" value="22.4138"></td>
<td><input type="text" size="10"
name="Second_Volume" value="22.4138"></td>
<td><select name="Volume_Unit" size="1">
<option value="1">m^3</option>
<option selected value="0.001">L</option>
<option value="0.000001">mL</option>
</select></td>
<td><input type="radio" name="Path"
value="Isochoric"
onclick="Change_Isochoric">Isochoric</td>
</tr>
<tr>
<tr>
<td>Temperature:</td>
<td><input type="text" size="10"
name="First_Temperature" value="273.15"></td>
<td><input type="text" size="10"
name="Second_Temperature" value="273.15"></td>
<td><select name="Temperature_Unit" size="1">
<option selected value="0">K</option>
<option value="273.15">`C</option>
</select></td>
<td><input type="radio" name="Path"
value="Isothermal"
onclick="Change_Isothermal">Isothermal</td>
</tr>
</table>
<table border="1">
<tr>
<td align="center">Amount of Gas:</td>
<td align="center"><input type="text"
size="10" name="Amount" value="1"></td>
<td align="center"><select name="N_Unit"
size="1">
<option value="1">mol</option>
<option value="1">mol</option>
</select></td>
<td>Heat (Surroundings sent)</td>
<td><input type="text" size="10" name="Heat"
value="0"></td>
<td><select name="Q_Unit" size="1">
<option value="1000">kJ</option>
<option value="101.325">atmL</option>
<option selected value="1">J</option>
</select></td>
</tr>
<tr>
<td align="center">Mass of Gas:</td>
<td align="center"><input type="text"
size="10" name="Weight" value="1"></td>
<td align="center"><select name="W_Unit"
size="1">
<option value="1000">t</option>
<option value="1">kg</option>
<option selected value="0.001">g</option>
</select></td>
<td>Work (Surroundings done)</td>
<td><input type="text" size="10" name="Work"
<td><input type="text" size="10" name="Work"
value="0"></td>
<td><select name="A_Unit" size="1">
<option value="1000">kJ</option>
<option value="101.325">atmL</option>
<option selected value="1">J</option>
</select></td>
</tr>
<tr>
<td align="center">Molar Weight:</td>
<td align="center"><input type="text"
size="10" name="Molecule" value="1"></td>
<td align="center"><select name="M_Unit"
size="1">
<option value="1">kg/mol</option>
<option selected value="0.001">g/mol</option>
</select></td>
<td>Energy Change:</td>
<td><input type="text" size="10"
name="Energy" value="0"></td>
<td><select name="E_Unit" size="1">
<option value="1000">kJ</option>
<option value="101.325">atmL</option>
<option value="101.325">atmL</option>
<option selected value="1">J</option>
</select></td>
</tr>
<tr>
<td align="center">Gas Constant:</td>
<td align="center"><input type="text"
size="10" name="Gas_Constant" value="8.31441"></td>
<td align="center"><select name="R_Unit"
size="1">
<option value="101.325">atmL/molK</option>
<option selected value="1">J/molK</option>
</select></td>
<td>Enthalpy Change:</td>
<td><input type="text" size="10"
name="Enthalpy" value="0"></td>
<td><select name="H_Unit" size="1">
<option value="1000">kJ</option>
<option value="101.325">atmL</option>
<option selected value="1">J</option>
</select></td>
</tr>
<tr>
<tr>
<td align="center">Heat Capacity under
Constant Volume:</td>
<td align="center"><input type="text"
size="10" name="CV" value="24.9432"></td>
<td align="center"><select name="CV_Unit"
size="1">
<option value="101.325">atmL/molK</option>
<option selected value="1">J/molK</option>
</select></td>
<td>Entropy Change:</td>
<td><input type="text" size="10"
name="Entropy" value="0"></td>
<td><select name="S_Unit" size="1">
<option value="101.325">atmL/K</option>
<option selected value="1">J/K</option>
</select></td>
</tr>
<tr>
<td align="center">Heat Capacity under
Constant Pressure:</td>
<td align="center"><input type="text"
size="10" name="CP" value="33.2576"></td>
size="10" name="CP" value="33.2576"></td>
<td align="center"><select name="CP_Unit"
size="1">
<option value="101.325">atmL/molK</option>
<option selected value="1">J/molK</option>
</select></td>
<td>Free Energy Change:</td>
<td><input type="text" size="10"
name="Free_Energy" value="Unknown"></td>
<td><select name="G_Unit" size="1">
<option value="1000">kJ</option>
<option value="101.325">atmL</option>
<option selected value="1">J</option>
</select></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<td>Free Energy Change:</td>
--
╔═══════════════════╗
║★★★★★友谊第一 比赛第二★★★★★║
╚═══════════════════╝
※ 来源:·哈工大紫丁香 http://bbs.hit.edu.cn·[FROM: 219.147.183.*]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:207.649毫秒