(*bottom line : 683000kJ/s/(289kJ/Mol) is number of Mol/second of CO2 in exhaust*)
(* solving van der Waals equation (P+N^2/V^2*a)*(V-N*b)=N*R*T  where a and b are molecule specific and can be looked up on the internet by googling
van der waals constants  *)
a1=553.7; (*H2O*)
a2=365.8; (*CO2*)
a3=147.2; (*CO*)
a4=138.2; (*O2*)
a5=137.0 ;(*N2*)
b1=.03049; (*H2O*)
b2=.04286; (*CO2*)
b3=0.03948; (*CO*)
b4=0.03186; (*O2*)
b5=0.0387; (*N2*)
CComment["Pressure in kPa"]
(*P=100/14.7*101.3   *)
P=1000
(* 100 psi (pounds per square inch) about 600000 kPa Constant Pressure so dP=0*)
CComment[Mol/second]
N1=227666.666/289 
N5=N1;
N6=0.21*N1*(.02802*.79+0.21/2*.044+0.21/2*2*.018)/(.018) (*actual number of mols/second in H2O coming out of turbine*)
N7=.21/2*N1*(.02802*.79+0.21/2*.044+0.21/2*2*.018)/.044 (*actual number of mols/second of CO2 coming out of turbine*)

CComment["Actual number of mols of N2 coming out of turbine"]
N8=0.79*N1*(.02802*.79+.21/2*.044+.21/2*2*.018)/.02802(*683 MW/3 /289 kJ/Mol to get Mol/second
683 MW is the power of the local Milton power plant and there are three 227.7 MW turbines GE 7F 05 there*)
CComment["Total number of Mols/second"]
CComment["N11 CO2"]
N11=N1
CComment["N10 H2O"]
N10=N1*N6/(N6+N7+N8)
CComment["N12 N2"]
N12=N1*N8/(N6+N7+N8)
N5=N1;
R=8.314;  (*Rydberg constant forPV=NRT*)
T=(2400-32)*5/9+273.15;(* the temperature in Fahrenheit 2400 degrees F is the output temperature of the GE 7F 05 turbine which exhausts 2H2O+CO2 *)

N1=N10;a=a1;b=b1;
CComment["Liquifying water"]
CComment["V1a H2O" follows]
(*solution to cubic in van der waals formula for V*)
V1a=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]


a=a2;b=b2;
N1=N10;
CComment["V1b CO2" follows]
V1b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
N1=N10;a=a1;b=b1;
T=100+273.15; (* boiling point of water where water comes out of gas*)
CComment["V2a" follows H2O]
V2a=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
N1=N11;a=a2;b=b2;
(*get volume of CO2 at moment water comes out*)
CComment["V2b" follows CO2]
V2b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

CComment["T1"]
N1=N12;
T1=(2400-32)*5/9+273.15
CComment["T2"]
T2=100+273.15
a=a5;b=b5;
T=T1;CComment["V1c N2"]
V1c=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
N1=N12;T=T2;CComment["V2c N2"]
V2c=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

NA=6.023*10^23; (*Avogadros number of particles / Mol*)
k=1.38065*10^(-23); (*boltzmans constant*)
h=6.62607*10^(-34); (*Plancks constant*)
m1=18/1000; (*molecular mass in kg/Mol of Water*)
m2=44/1000; (*molecular mass in kg/Mol of CO2*)
m3=28.02/1000;
(*molecular mass in kg/Mol of N2*)
m=(0.79*m3+0.21*m1*2+0.21m2); (*average molecular mass of exhaust*)
PI1=4*ArcTan[1]; (*PI*)
CComment["N1 " follows]
N1=227666.6666/289 (*mols/second coming out of turbine*)
CComment["s1 follows Joules/Mol/Kelvin/second"]
(*solved sackur-Tetrode equation from Statistical Mechanics by Pathria and Beale 4th Edition*)
N6=N10;
N7=N11;
N8=N12;
s1=N[-2N6*NA*k*Log[V1a/NA/2/N6]-5/2*2N6*NA*k-3/2*2N6*NA*k*Log[2*PI1*m1*k*T1/h^2]-N7*NA*k*Log[V1b/NA/N7]-5/2*N7*NA*k-3/2*N7*NA*k*Log[2*PI1*m2*k*T1/h^2]-N8*NA*k*Log[V1c/NA/N8]-5/2*N8*NA*k-3/2*N8*NA*k*Log[2*PI1*m3*k*T1/h^2]]
CComment["s2 follows Joules/Mol/Kelvin/second"]
s2=N[-2*N6*NA*k*Log[V2a/NA/2/N6]-5/2*2*N6*NA*k-3/2*2*N6*NA*k*Log[2*PI1*m1*k*T2/h^2]-N1*NA*k*Log[V2b/NA/N7]-5/2*N7*NA*k-3/2*N7*NA*k*Log[2*PI1*m2*k*T2/h^2]-N8*NA*k*Log[V2c/NA/N8]-5/2*N8*NA*k-3/2*N8*NA*k*Log[2*PI1*m2*k*T2/h^2]]
CComment["dG" follows kW]
V1=V1a+V1b+V1c;
V2=V2a+V2b+V2c;
N1=N10+N11+N12;
(*solve dG=PdV+VdP-sdT-Tds Gibbs Free Energy*)
c=N[2260*N6]/1000 (*heat of vaporization of water when water comes out*)
d=-P*(V2-V1)/1000 (* this is PdV with P constant integrated*)
(* e is -sdT -Tds integrated to get G *)
e=N[Re[(-h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s1]*Exp[-2/3*Log[V1/N1/NA]]*Exp[5/3]+h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s2]*Exp[-2/3*Log[V2/N1/NA]]*Exp[5/3]-N1*NA*k*Log[V1/N1/NA]*(T2-T1)+N1*NA*k*Log[V2/N1/NA]*(T2-T1)-5/2*N1*NA*k*(T2-T1)-3/2*N1*NA*k*(h^2/2/PI1/m/k/T2-h^2/2/PI1/m/k/T1))]]/1000
dG=(c+d+e)


N1=N7;a=a2;b=b2;

CComment["V1b CO2" follows]
V1b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

N1=N7;a=a2;b=b2;

CComment["V2b" follows CO2]
V2b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
(* from 100 celcius to -79 celcius to liquify CO2*)
CComment["T1"]
T1=100+273.15
CComment["T2"]
T2=273.15-79
T=T1;a=a5;b=b5;N1=N8;
CComment["V1c" follows N2]
V1c=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
T=T2;
CComment["V2c" follows N2]
V2c=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

NA=6.023*10^23;
k=1.38065*10^(-23);
h=6.62607*10^(-34);
m1=18/1000;(*H2O*)
m2=44/1000; (*CO2*)
m3=28.02/1000; (*N2*)
m=(.79*m3+0.21/2*m2)/(.79+.21/2);
PI1=4*ArcTan[1];
CComment["N1 " follows]
N1=227666.6666/289
CComment["s1 follows Joules/Mol/Kelvin/second"]
s1=N[-2N7*NA*k*Log[V1b/NA/2/N7]-5/2*2N7*NA*k-3/2*2N7*NA*k*Log[2*PI1*m2*k*T1/h^2]-N8*NA*k*Log[V1c/NA/N8]-5/2*N8*NA*k-3/2*N8*NA*k*Log[2*PI1*m3*k*T1/h^2]]
CComment["s2 follows Joules/Mol/second"]
s2=N[-2N7*NA*k*Log[V2b/NA/2/N7]-5/2*2N7*NA*k-3/2*2N7*NA*k*Log[2*PI1*m2*k*T2/h^2]-N8*NA*k*Log[V2b/NA/N8]-5/2*N8*NA*k-3/2*N8*NA*k*Log[2*PI1*m3*k*T2/h^2]]
CComment["dG" follows kW]
V1=V1b+V1c;
V2=V2b+V2c;
N1=N7+N8;
c=0
d=-P*(V2-V1)/1000
e=N[Re[(-h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s1]*Exp[-2/3*Log[V1/N1/NA]]*Exp[5/3]+h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s2]*Exp[-2/3*Log[V2/N1/NA]]*Exp[5/3]-N1*NA*k*Log[V1/N1/NA]*(T2-T1)+N1*NA*k*Log[V2/N1/NA]*(T2-T1)-5/2*N1*NA*k*(T2-T1)-3/2*N1*NA*k*(h^2/2/PI1/m/k/T2-h^2/2/PI1/m/k/T1))]]/1000
(c+d+e)
dG2=(c+d+e)+dG
T=400+273.15;
(* heat pumps can be used from the heat released from cooling the CO2 and H2O to warm the gas up after the water is out and warm it up to 400 celcius then cool it to -161.5 to liquify CO and separate it from the  O2*)
CComment["N1 for second stage"]
N1=N1*((44+2*16)/3)/44
N2=N1*((44+2*16)/3)/16
N3=N1*((44+2*16)/3)/(12+16);
N4=1/2*N3;
a=a3;
b=b3;
N5=N1;
N1=N3;
CComment["Liquifying CO"]
CComment["V1a CO"]
V1a=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

a=a4;b=b4;
N1=N4;
CComment["V1b O2" follows]
V1b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
N1=N3;a=a3;b=b3;
T=273.15-161.5; (* endpoint,  -161.5 celcius when liquid CO comes out of CO+0.5O2 mixture*)
CComment["V2a CO" follows]
V2a=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]
CComment["V2b O2" follows]
N1=N4;a=a4;b=b4;
V2b=N[Re[(1/P)0.2645668419946999306`5. (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3)-(0.4199736832982910261`5. (3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))/(P (√(4 (((3 a (N1^2) P-(((-b N1 P-N1 R T))^2)))^3)+(((18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3)))^2))+18 a b (N1^3) (P^2)-9 a (N1^3) P R T+6 b (N1^3) P (R^2) (T^2)+6 (b^2) (N1^3) (P^2) R T+2 (b^3) (N1^3) (P^3)+2 (N1^3) (R^3) (T^3))^(1/3))-(1/P)0.3333333333333333333`5. (-b N1 P-N1 R T)]]

T1=273.15+400;
T2=273.15-161.5;
m1=(12+16)/1000; (*molecular mass in kg/Mol of CO*)
m2=(32)/1000; 
(*molecular mass in kg/Mol of O2*)
m=(m1+0.5*m2)/1.5
CComment["S1 follows Joules/Mol/Kelvin/Kelvin/second"]
s1=N[-2N3*NA*k*Log[V1a/NA/2/N3]-5/2*2N3*NA*k-3/2*2N3*NA*k*Log[2*PI1*m1*k*T1/h^2]-N4*NA*k*Log[V1b/NA/N4]-5/2*N4*NA*k-3/2*N4*NA*k*Log[2*PI1*m2*k*T1/h^2]]
CComment["s2 follows Joules/Mol/Kelvin/second"]
s2=s1=N[-2N3*NA*k*Log[V2a/NA/2/N3]-5/2*2N3*NA*k-3/2*2N3*NA*k*Log[2*PI1*m1*k*T1/h^2]-N4*NA*k*Log[V2b/NA/N4]-5/2*N4*NA*k-3/2*N4*NA*k*Log[2*PI1*m2*k*T1/h^2]]
CComment["dG" follows kW]
N1=N3+N4;
V1=V1a+V1b;
V2=V2a+V2b;

dG3=N[Re[6000*N3-P*(V2-V1)+(-h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s1]*Exp[-2/3*Log[V1/N1/NA]]*Exp[5/3]+h^2/2/PI1/m/k*3/2*N1*NA*k*Exp[2/3/N1/NA/k*s2]*Exp[-2/3*Log[V2/N1/NA]]*Exp[5/3]-N1*NA*k*Log[V1/N1/NA]*(T2-T1)+N1*NA*k*Log[V2/N1/NA]*(T2-T1)-5/2*N1*NA*k*(T2-T1)-3/2*N1*NA*k*(h^2/2/PI1/m/k/T2-h^2/2/PI1/m/k/T1))]]/1000
CComment["tons per hour"]
tonsperhour = N7*.044*3600/1000
CComment["tons per year for 683 MW power plant"]
tonsperyear683=tonsperhour*3*20*350
CComment["theoretical most efficient kW per ton"]
dG2/tonsperhour
CComment["Cost per ton expensive electricity .08 cents per kW-h canadian dollars"]
dG/tonsperhour*.08
CComment["cost in USD expensive electricity"]
dG/tonsperhour*.08*.8
CComment["Cost per ton cheap surplus electricity at night .01 cents per kW-h canadian dollars"]
dG2/tonsperhour*.01
CComment["Cost in USD cheap electricity"]
dG2/tonsperhour*.01*.8
CComment["Actual Efficiency of compressors,heat pumps and refrigeration"]
dG2/1000/85
CComment["Actual kW per ton"]
675
CComment["Actual USD cost per ton"]
675*.08*.8
CComment["Actial USD cost per ton cheap electricity"]
675*.01*.82
CComment["The efficiency might be improved with cryogenics"]
CComment["kW per hour to process tons of CO2 in GE 7F 05 turbine"]
tonsperhour*675
CComment["Total value in cdn$ if converted to diesel over 30 years for the whole power plant 3 turbines"]
N7*.044*3600*(.012*16+17*.002)/.044/16*20*350*30/.85*1.2*.9*.97*.95*3
CComment["Total value in cdn$ if converted to gasoline over 30 years for the whole power plant 3 turbines"]
N7*.044*3600*(.012*8+9*.002)/.044/8*20*350*30/.75*1.2*.9*.97*.95*3