{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 34 "Th is script is setup_problem5.mws." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 28 "The complete solution is in " }}{PARA 0 " " 0 "" {TEXT -1 56 " problem5_A-n-V.mws - solution in A-V-n \+ space." }}{PARA 0 "" 0 "" {TEXT -1 17 " or" }}{PARA 0 " " 0 "" {TEXT -1 51 " problem5_A-X.mws - solution in A-X space ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 69 "Comp ute the L-V curve for water as predicted by the Van der Waals EoS" }} {PARA 0 "" 0 "" {TEXT -1 53 "by minimization of the Helmoltz Free Ener gy A(V,T,n):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 21 "Van der Waals EoS is:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "pvdw := nRT/(V-b) - a/V^2;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "We are concerned wit h isothermal minimization and our EoS predicts the properties of " }} {PARA 0 "" 0 "" {TEXT -1 35 "both phase, therefore we can write " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 17 "A = A0 - \+ int(p,V)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "where A0 is an arbitrary constant that we can set to 0, this only \+ possible because both" }}{PARA 0 "" 0 "" {TEXT -1 86 "phases (i.e., th e liquid and the gas are described by the same EoS, if the phases were " }}{PARA 0 "" 0 "" {TEXT -1 85 "described by different EoS's then it \+ would be necessary to introduce a parameter that" }}{PARA 0 "" 0 "" {TEXT -1 86 "defines the difference in A between the two phases at som e arbitrary T,V,n condition, " }}{PARA 0 "" 0 "" {TEXT -1 31 "i.e., a \+ reference state energy." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 18 "A := -int(pvdw,V);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 73 "Next we need the Van der Waals \+ constants, we can evaluate these by making" }}{PARA 0 "" 0 "" {TEXT -1 85 "use of the fact that at the critical point the first and second derivatives of p with" }}{PARA 0 "" 0 "" {TEXT -1 82 "respect to V mu st vanish. And noting that the critical point is at 374 C, 212 bar," } }{PARA 0 "" 0 "" {TEXT -1 42 "with R = 8.314 J/mol, and Vcrit ~ 3 J/ba r." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "avdw := solve(diff(pvdw,V),a):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "bvdwn := solve(subs (a=avdw, V=3,...,b);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "avdwn := subs(V=3,nRT=(374+273)*8.314,b=bvdwn,...);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 81 "lastly \+ we set up the minimization using pseudocompounds to represent A(V,n), \+ note" }}{PARA 0 "" 0 "" {TEXT -1 40 "we specify the temperature the ne xt line" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "nRTK := (324 + 273)*8.314;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 76 "we also have to guess the range of volume that will be of interest, note the" }}{PARA 0 "" 0 "" {TEXT -1 51 "vd w volume must be greater than the vdw constant b." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "vmin := 1.01*bvwdn; vmax := 20;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 50 "specify the spacing for the fluid pseudocompounds:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "dVol := (vmi n-vmax)/50;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "pvdwn := subs(a=avdw n,b=bvdwn,nRT=nRTK, pvdw);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "Anum \+ := subs(a=avdwn,b=bvdwn,nRT=nRTK, A);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "plot(pvdwn,V=vmin..vmax);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 " plot(Anum,V=..vmin..vmax);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "pi := 0: Vol := vmin:j := 'j':" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "while \+ Vol < 20 do:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " pi := pi + 1:" } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " nh2o[pi] := ...;" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 19 " vh2o[pi] := ...;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " ah2o[pi] := ...;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 " Vol := Vol + dVol;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "end d o:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Atot := sum(...):" }{MPLTEXT 0 21 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "ntot := sum(...):" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "vtot := sum(...):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "constraints := \{vtot = 3/4, ntot = 1/4\}:" } {MPLTEXT 0 21 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(simplex): " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 20 "do th e minimization:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "ans := minimize( Atot, constraints, NONNEGATIVE ):" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "filter t hrough the results to get the non-zero alphas, the index points to the volume" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "i := 0: j := 0:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "while i \+ < pi do:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 " i := i + 1:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " if (rhs(ans[i]) > 0) then" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 " j := j + 1;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 24 " rans[j] := ans[i];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " end if:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "end d o:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "rans[1];rans[2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 88 "use the volumes identified by t he indexes on the alpha's to back calculate the pressure:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "i1 := ...; i 2 := ...;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "subs(V=vh2o[i1],pvdwn) ;subs(V=vh2o[i2],pvdwn);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 45 "next back calculate by solving A = n*mu - p*V" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "wit h(linalg):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "avec := vector(2,[ah2 o[i1],ah2o[i2]]):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "mat := matrix( 2,2,[-vh2o[i1],nh2o[i1],-vh2o[i2],nh2o[i2]]):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "linsolve(mat,avec);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "and lastly compare the roots of the vdw at the pressure obtained by minimization to the" }}{PARA 0 "" 0 "" {TEXT -1 38 "volumes of the stable pseudocompounds:" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "solve(pvdwn-483); " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "vh2o[i1],vh2o[i2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 90 "at this point it would be possi ble to refine the solution by adding a loop to increase the" }}{PARA 0 "" 0 "" {TEXT -1 68 "pseudocompounds around the compounds at i1 and \+ i2. See problem5.mws." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 2 0" 29 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }