c begin file bridge.f c c This file contains conversion routines that allow applications c written for routines from Refprop versions 4 or 5 to use the c version 6 routines. c c contained here are: c subroutine BCONST (nc,ir) c subroutine REFMIX (x,nc) c subroutine FSET (ir,f,ft) c subroutine FFEST (i,j,fij) c subroutine BUBLT (t,xl,xv,p,vl,vv,lbub,lcrit) c subroutine BUBLP (p,xl,xv,t,vl,vv,lbub,lcrit) c subroutine HCVCPS (iq,t,v,x,h,cv,cp,w) c subroutine HCVCP2 (kph,t,p,x,h,cv,cp,w) c function ENTROP (t,v,x) c function PVT (t,v,x) c subroutine HPIN (h,p,x,t,xq,xl,xv,vl,vv,hl,hv) c subroutine SPIN (s,p,x,t,xq,xl,xv,vl,vv,sl,sv) c subroutine TRNSP (pbar,t,D,x,eta,tcx,kph) c subroutine DCST (pbar,D,t,x,kph,ier) c subroutine FLASHN (p,t,x,xl,xv,q,ncomp,vl,vv) c subroutine VIT (t,p,a,b,v,lliqi,lvcon) c subroutine ESPAR (iq,t,x,a,b) c c ====================================================================== c ====================================================================== c subroutine BCONST (nc,ir) c c specify the components c c A call to the BCONST routine is required. The specification of the c fluid files required by SETUP is especially problematical in these c bridge routines. You will need to edit the character variable hpath c to correspond to your own path specification to the subdirectory c containing the version 6 fluid data files. c c inputs: c nc--number of components (1 for pure fluid) [integer] c ir--code number(s) for the component(s) [array of integer] c additional input passed via common /PREFS/: c nrefst--code for reference state c 1: h,s = 0 for the saturated liquid at the boiling point c 2: h,s = 0 for the saturated liquid at -40 deg F c 3: h = 200 kJ/kg, s = 1.0 kJ/(kg-K) for saturated liquid c at 0 deg C (IIR convention) c states 1,2,3 are applied to each of the components of a mix; c additional choices apply the reference state to a particular c mixture composition, but these require an additional call to c REFMIX after the call to BCONST: c 4: h,s = 0 for the saturated liquid of composition x at c -40 deg F (ASHRAE convention) c 5: h = 200 kJ/kg, s = 1.0 kJ/(kg-K) for saturated liquid c of composition x at 0 deg C (IIR convention) c outputs: c [fluid parameters, etc. stored in various common blocks] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-10-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c c "old" parameters (used to dimension arrays) c nfl is a parameter set to max number of fluids in version 5; c this was 40 for version 4--if you are using code written for c version 4 AND you use information from common /ESDATA/, this should c be changed to 40 and the data statements below for fluids 41-43 c should be deleted parameter (nfl=50) !max number of fluids in version 5 parameter (ncmax5=5) !max number of components in version 5 c "new" parameters parameter (ncmax=5) !max number of components in version 6 parameter (n0=-ncmax,nx=ncmax) dimension ir(ncmax5) character*3 hrf character*20 href(nfl) character*60 hpath character*80 hfiles(ncmax),hfmix character*255 herr c "old" commons common /PREFS/ nunits,nrefst,intact,iclmn,jclmn(7),ieqn common /ESDATA/ coeff(10,nfl),crit(ncmax5,nfl) c "new" (version 6) common common /CCON/ wm(n0:nx),ttp(n0:nx),tnbp(n0:nx), & tc(n0:nx),pc(n0:nx),rhoc(n0:nx),Zcrit(n0:nx), & accen(n0:nx),dipole(n0:nx) c data href(1) /'R11.fld'/ data href(2) /'R12.fld'/ data href(3) /'R13.fld'/ data href(4) /'R13B1.fld'/ !not in version 6.0 data href(5) /'R14.fld'/ data href(6) /'R21.fld'/ !not in version 6.0 data href(7) /'R22.fld'/ data href(8) /'R23.fld'/ data href(9) /'R32.fld'/ data href(10) /'R113.fld'/ data href(11) /'R114.fld'/ data href(12) /'R115.fld'/ data href(13) /'R123.fld'/ data href(14) /'R123a.fld'/ !not in version 6.0 data href(15) /'R124.fld'/ data href(16) /'R125.fld'/ data href(17) /'R134.fld'/ !not in version 6.0 data href(18) /'R134a.fld'/ data href(19) /'R141b.fld'/ data href(20) /'R142b.fld'/ data href(21) /'R143.fld'/ !not in version 6.0 data href(22) /'R143a.fld'/ data href(23) /'R152a.fld'/ data href(24) /'R218.fld'/ !not in version 6.0 data href(25) /'R290.fld'/ data href(26) /'RC270.fld'/ !not in version 6.0 data href(27) /'RC318.fld'/ data href(28) /'R227ea.fld'/ data href(29) /'R236ea.fld'/ data href(30) /'R245cb.fld'/ data href(31) /'butane.fld'/ data href(32) /'isobutan.fld'/ data href(33) /'N-C5.fld'/ !not in version 6.0 data href(34) /'I-C5.fld'/ !not in version 6.0 data href(35) /'CO2.fld'/ data href(36) /'RE134.fld'/ !not in version 6.0 data href(37) /'RE245.fld'/ !not in version 6.0 data href(38) /'ammonia.fld'/ data href(39) /'R245ca.fld'/ data href(40) /'R236fa.fld'/ data href(41) /'propylen.fld'/ data href(42) /'R116.fld'/ data href(43) /'DME.fld'/ !not in version 6.0 data hfmix /'HMX.bnc'/ c c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! c c N.B. edit the following line to specify the path to the c directory containing the fluid data files; also, specify c the path to the mixture data file "HMX.bnc" c hpath='C:\Refprop6\fluids\' hfmix='C:\Refprop6\fluids\HMX.bnc' c c!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! c do 100 i=1,nc hfiles(i)=hpath//href(ir(i)) 100 continue if (nrefst.eq.1) then hrf='NBP' else if (nrefst.eq.2 .or. nrefst.eq.4) then hrf='ASH' else hrf='IIR' end if c call SETUP (nc,hfiles,hfmix,hrf,ierr,herr) c c transfer component information into old /ESDATA/ common block c (this information is available only for the defined fluids) do 200 i=1,nc crit(1,ir(i))=wm(i) crit(3,ir(i))=tc(i) crit(4,ir(i))=pc(i) crit(5,ir(i))=1.0d0/rhoc(i) if (nrefst.eq.1) then crit(2,ir(i))=tnbp(i) else if (nrefst.eq.2 .or. nrefst.eq.4) then crit(2,ir(i))=233.15d0 else crit(2,ir(i))=273.15d0 end if 200 continue c RETURN end !subroutine BCONST c c ====================================================================== c subroutine REFMIX (x,nc) c c set up a composition-dependent reference state (nrefst = 4 or 5) c c N.B. call this routine after calling BCONST. c c inputs: c x--composition [array of mole fractions] c nc--number of components (1 for pure fluid) [integer] c additional input passed via common /PREFS/ c nrefst--code for reference state c 4: h,s = 0 for the saturated liquid of composition x at c -40 deg F (ASHRAE convention) c 5: h = 200 kJ/kg, s = 1.0 kJ/(kg-K) for saturated liquid c of composition x at 0 deg C (IIR convention) c outputs: c [fluid parameters, etc. returned via various common blocks] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension x(ncmax5),x0(ncmax) character*3 hrf character*255 herr common /PREFS/ nunits,nrefst,intact,iclmn,jclmn(7),ieqn common /NCOMP/ ncomp c c copy input composition to x0 array (possibility that they are of c different dimension in future versions) do 100 i=1,MIN(ncomp,ncmax5) x0(i)=x(i) 100 continue c if (nrefst.eq.4) then hrf='ASH' ixflag=2 call SETREF (hrf,ixflag,x0,h0,s0,t0,p0,ierr,herr) else if (nrefst.eq.5) then hrf='IIR' ixflag=2 call SETREF (hrf,ixflag,x0,h0,s0,t0,p0,ierr,herr) end if c RETURN end !subroutine REFMIX c c ====================================================================== c subroutine FSET (ir,f,ft) c c initialize interaction parameters for the CSD equation of state c c N.B. As the CSD equation of state is no longer supported, this c routine has no effect. The parameters for the mixture c Helmholtz model are automatically read in from a data file. c If you desire to alter these values, the version 6 routine c SETKTV must be called. c c inputs: c ir--code number(s) for the component(s) [array of integer] c outputs: c f--interaction parameters for the mixture of interest; this is c filled with zeros [array of dimension 5 x 5] c ft--temperature dependence of the interaction parameters for the c mixture of interest; this is filled with zeros [array of c dimension 5 x 5] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax5=5) !max number of components in version 5 dimension ir(ncmax5) dimension f(ncmax5,ncmax5),ft(ncmax5,ncmax5) c do 120 i=1,ncmax5 do 100 j=1,ncmax5 f(i,j)=0.0d0 ft(i,j)=0.0d0 100 continue 120 continue c RETURN end !subroutine FSET c c ====================================================================== c subroutine FFEST (i,j,fij) c c estimate interaction parameter for the CSD equation of state for a c specified binary pair c c N.B. As the CSD equation of state is no longer supported, this c routine has no effect. The parameters for the mixture c Helmholtz model are automatically read in from a data file. c If you desire to alter these values, the version 6 routine c SETKTV must be called. c c inputs: c i--component i in binary pair [integer] c j--component j in binary pair [integer] c output: c fij--interaction parameter for the binary pair (i,j); this is c set to zero c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c fij=0.0d0 c RETURN end !subroutine FFEST c c ====================================================================== c subroutine BUBLT (t,xl,xv,p,vl,vv,lbub,lcrit) c c iterate for saturated liquid and vapor states given temperature c and the composition of one phase c c inputs: c t--temperature [K] c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c note: only one of xl or xv is input depending on lbub c lbub--phase flag: c .true. compute bubble point properties (xl is input) c .false. compute dew point properties (xv is input) c outputs: c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c p--pressure [kPa] c vl--molar volume [L/mol] of saturated liquid c vv--molar volume [L/mol] of saturated vapor c lcrit--error flag; set .true. if input is out of bounds (e.g. above c the critical point) or routine fails to converge c additional output passed via common /ERBUBT/ c ierbt--error flag: 0 = successful c <>0 = same as ierr out of version 6 SATT c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) logical lbub,lcrit c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension xl(ncmax5),xv(ncmax5) dimension x(ncmax),xliq(ncmax),xvap(ncmax) character*255 herr common /NCOMP/ ncomp common /ERBUBT/ ierbt c if (lbub) then c calculate bubble point kph=1 if (ncomp.le.1) then x(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to x array (possibility that they are of c different dimension in future versions) x(i)=xl(i) 100 continue end if else c calculate dew point kph=2 if (ncomp.le.1) then x(1)=1.0d0 else do 120 i=1,MIN(ncomp,ncmax5) x(i)=xv(i) 120 continue end if end if c call SATT (t,x,kph,p,rhol,rhov,xliq,xvap,ierr,herr) ierbt=ierr vl=1.0d0/rhol vv=1.0d0/rhol do 200 i=1,MIN(ncomp,ncmax5) xl(i)=xliq(i) xv(i)=xvap(i) 200 continue if (ierr.ne.0) then lcrit=.true. else lcrit=.false. end if c RETURN end !subroutine BUBLT c c ====================================================================== c subroutine BUBLP (p,xl,xv,t,vl,vv,lbub,lcrit) c c iterate for saturated liquid and vapor states given pressure c and the composition of one phase c c inputs: c p--pressure [kPa] c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c note: only one of xl or xv is input depending on lbub c lbub--phase flag: c .true. compute bubble point properties (xl is input) c .false. compute dew point properties (xv is input) c outputs: c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c t--temperature [K] c vl--molar volume [L/mol] of saturated liquid c vv--molar volume [L/mol] of saturated vapor c lcrit--error flag; set .true. if input is out of bounds (e.g. above c the critical point) or routine fails to converge c additional output passed via common /ERBUBP/ c ierbp--error flag: 0 = successful c <>0 = same as ierr out of version 6 SATP c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) logical lbub,lcrit c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension xl(ncmax5),xv(ncmax5) dimension x(ncmax),xliq(ncmax),xvap(ncmax) character*255 herr common /NCOMP/ ncomp common /ERBUBP/ ierbp c if (lbub) then c calculate bubble point kph=1 if (ncomp.le.1) then x(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to x array (possibility that they are of c different dimension in future versions) x(i)=xl(i) 100 continue end if else c calculate dew point kph=2 if (ncomp.le.1) then x(1)=1.0d0 else do 120 i=1,MIN(ncomp,ncmax5) x(i)=xv(i) 120 continue end if end if c call SATP (p,x,kph,t,rhol,rhov,xliq,xvap,ierr,herr) ierbp=ierr vl=1.0d0/rhol vv=1.0d0/rhol do 200 i=1,MIN(ncomp,ncmax5) xl(i)=xliq(i) xv(i)=xvap(i) 200 continue if (ierr.ne.0) then lcrit=.true. else lcrit=.false. end if c RETURN end !subroutine BUBLP c c ====================================================================== c subroutine HCVCPS (iq,t,v,x,h,cv,cp,w) c c calculate enthalpy and/or isochoric heat capacity and/or isobaric c heat capacity and/or speed of sound c c inputs: c iq--calculation flag c 1: compute only h c 2: compute h and Cv c 3: compute h, Cv, Cp, and w c t--temperature [K] c v--molar volume [L/mol] c x--composition [array of mole fractions] c outputs: c h--enthalpy [J/mol] c Cv--isochoric (constant volume) heat capacity [J/mol-K] c Cp--isobaric (constant pressure) heat capacity [J/mol-K] c w--speed of sound [m/s] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension x(ncmax5),z(ncmax) common /NCOMP/ ncomp c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c rho=1.0d0/v if (iq.eq.1) then call ENTHAL (t,rho,z,h) cv=0.0d0 !fill outputs with dummy values cp=0.0d0 w=0.0d0 else call THERM (t,rho,z,p,e,h,s,cv,cp,w,hjt) end if c RETURN end !subroutine HCVCPS c c ====================================================================== c subroutine HCVCP2 (kph,t,p,x,h,cv,cp,w) c c calculate enthalpy, isochoric heat capacity, isobaric heat capacity c speed of sound given temperature, pressure, and composition c c inputs: c kph--phase flag: 1 = liquid c 2 = vapor c 0 = stable phase c t--temperature [K] c p--pressure [kPa] c x--composition [array of mole fractions] c outputs: c h--enthalpy [J/mol] c Cv--isochoric (constant volume) heat capacity [J/mol-K] c Cp--isobaric (constant pressure) heat capacity [J/mol-K] c w--speed of sound [m/s] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),xl(ncmax),xv(ncmax),z(ncmax) common /NCOMP/ ncomp c flags indicating 'not applicable', '2-phase', etc. common /FLAGS/ xnota,x2ph,xsubc,xsuph,xsupc,xinf,x7,xnotd,xnotc c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c if (kph.eq.1 .or. kph.eq.2) then c phase is specified on input kguess=0 !no initial guess for density is provided call TPRHO (t,p,z,kph,kguess,rho,ierr,herr) call THERM (t,rho,z,p,e,h,s,cv,cp,w,hjt) else c must determine phase call TPFLSH (t,p,z,D,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr) end if c RETURN end !subroutine HCVCP2 c c ====================================================================== c function ENTROP (t,v,x) c c calculate molar entropy c c inputs: c t--temperature [K] c v--molar volume [L/mol] c x--composition [array of mole fractions] c output (as function value): c ENTROP--molar entropy [J/mol-K] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension x(ncmax5),z(ncmax) common /NCOMP/ ncomp c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c rho=1.0d0/v call ENTRO (t,rho,x,s) ENTROP=s c RETURN end !function ENTROP c c ====================================================================== c function PVT (t,v,x) c c calculate pressure given temperature, molar volume, and composition c c inputs: c t--temperature [K] c v--molar volume [L/mol] c x--composition [array of mole fractions] c output (as function value): c PVT--pressure [kPa] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 dimension x(ncmax5),z(ncmax) common /NCOMP/ ncomp c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c rho=1.0d0/v call PRESS (t,rho,x,p) PVT=p c RETURN end !function PVT c c ====================================================================== c subroutine HPIN (h,p,x,t,xq,xl,xv,vl,vv,hl,hv) c c flash calculation given pressure, bulk enthalpy, and bulk composition c c inputs: c h--overall (bulk) enthalpy [J/mol] c p--pressure [kPa] c x--composition [array of mole fractions] c outputs: c t--temperature [K] c xq--vapor quality on a MOLAR basis [moles vapor/total moles] c q < 0 indicates subcooled (compressed) liquid c q = 0 indicates saturated liquid c q = 1 indicates saturated vapor c q > 1 indicates superheated vapor c q = -998 subcooled liquid, but quality not defined (p > Pc) c q = 999 indicates supercritical state (t > Tc) and (p > Pc) c xl--composition [array of mol frac] for liquid phase c xv--composition [array of mol frac] for vapor phase c if only one phase is present, x = y = z c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c hl--liquid-phase enthalpy [J/mol] c hv--vapor-phase enthalpy [J/mol] c additional output passed via common /ERRHPN/ c ierh--error flag: 0 = successful c <>0 = same as ierr out of version 6 PHFLSH c c N.B.--if only subcooled liquid is present xv,vv,hv are set to the c bubble point conditions corresponding to p,x; c if only superheated vapor is present xl,vl,hl are set to the c dew point conditions corresponding to p,x; c this behavior is different from that in version 6 where if c only one phase is present, x = y = z c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),xl(ncmax5),xv(ncmax5), & zl(ncmax),zv(ncmax),z(ncmax),xbub(ncmax),ydew(ncmax) common /NCOMP/ ncomp c common passing error status to version 5 applications common /ERRHPN/ ierh c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c call PHFLSH (p,h,z,t,D,Dl,Dv,zl,zv,q,e,s,cv,cp,w,ierr,herr) ierh=ierr c c check for single-phase states; the version 5 routines handled these c differently; (e.g. if only sub-cooled liquid is present xv,vv,hv c are set to the bubble point conditions corresponding to p,x) c if (q.lt.0.0d0 .and. q.gt.-998.0d0) then c subcooled liquid--find vapor at bubble point kph=1 call SATP (p,z,kph,tbub,Dlbub,Dv,xbub,zv,ierr,herr) if (ierh.ne.0) then iers=ierr !pass on any error from SATP end if else if (q.gt.1.0d0 .and. q.lt.999.0d0) then c superheated vapor--find liquid at dew point kph=2 call SATP (p,z,kph,tdew,Dl,Dvdew,zl,ydew,ierr,herr) if (ierh.ne.0) then iers=ierr !pass on any error from SATP end if end if call ENTHAL (t,Dv,zv,hv) call ENTHAL (t,Dl,zl,hl) do 200 i=1,MIN(ncomp,ncmax5) c copy output compositions to xl, xv arrays (possibility that they are c of different dimension in future versions) xl(i)=zl(i) xv(i)=zv(i) 200 continue vl=1.0d0/Dl vv=1.0d0/Dv xq=q c RETURN end !subroutine HPIN c c ====================================================================== c subroutine SPIN (s,p,x,t,xq,xl,xv,vl,vv,sl,sv) c c flash calculation given pressure, bulk enthalpy, and bulk composition c c inputs: c s--overall (bulk) entropy [J/mol-K] c p--pressure [kPa] c x--composition [array of mole fractions] c outputs: c t--temperature [K] c xq--vapor quality on a MOLAR basis [moles vapor/total moles] c q < 0 indicates subcooled (compressed) liquid c q = 0 indicates saturated liquid c q = 1 indicates saturated vapor c q > 1 indicates superheated vapor c q = -998 subcooled liquid, but quality not defined (p > Pc) c q = 999 indicates supercritical state (t > Tc) and (p > Pc) c xl--composition [array of mol frac] for liquid phase c xv--composition [array of mol frac] for vapor phase c if only one phase is present, x = y = z c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c sl--liquid-phase entropy [J/mol-K] c sv--vapor-phase entropy [J/mol-K] c additional output passed via common /ERRSPN/ c iers--error flag: 0 = successful c <>0 = same as ierr out of version 6 PSFLSH c c N.B.--if only subcooled liquid is present xv,vv,sv are set to the c bubble point conditions corresponding to p,x; c if only superheated vapor is present xl,vl,sl are set to the c dew point conditions corresponding to p,x; c this behavior is different from that in version 6 where if c only one phase is present, x = y = z c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),xl(ncmax5),xv(ncmax5), & zl(ncmax),zv(ncmax),z(ncmax),xbub(ncmax),ydew(ncmax) common /NCOMP/ ncomp c common passing error status to version 5 applications common /ERRSPN/ iers c if (ncomp.le.1) then z(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue end if c call PSFLSH (p,s,z,t,D,Dl,Dv,zl,zv,q,e,s,cv,cp,w,ierr,herr) iers=ierr c c check for single-phase states; the version 5 routines handled these c differently; (e.g. if only sub-cooled liquid is present xv,vv,sv c are set to the bubble point conditions corresponding to p,x) c if (q.lt.0.0d0 .and. q.gt.-998.0d0) then c subcooled liquid--find vapor at bubble point kph=1 call SATP (p,z,kph,tbub,Dlbub,Dv,xbub,zv,ierr,herr) if (iers.ne.0) then iers=ierr !pass on any error from SATP end if else if (q.gt.1.0d0 .and. q.lt.999.0d0) then c superheated vapor--find liquid at dew point kph=2 call SATP (p,z,kph,tdew,Dl,Dvdew,zl,ydew,ierr,herr) if (iers.ne.0) then iers=ierr !pass on any error from SATP end if end if call ENTRO (t,Dv,zv,sv) call ENTRO (t,Dl,zl,sl) do 200 i=1,MIN(ncomp,ncmax5) c copy output compositions to xl, xv arrays (possibility that they are c of different dimension in future versions) xl(i)=zl(i) xv(i)=zv(i) 200 continue vl=1.0d0/Dl vv=1.0d0/Dv xq=q c RETURN end !subroutine SPIN c c ====================================================================== c subroutine TRNSP (pbar,t,D,x,eta,tcx,kph) c c calculate the transport properties of viscosity and thermal c conductivity given temperature, pressure, and composition c c inputs: c pbar--pressure [bar] c N.B. note units are bar, not kPa c t--temperature [K] c x--composition [array of mole fractions] c kph--phase flag: 1 = liquid c 2 = vapor c 0 = stable phase c kph = 1,2 useful for calculating saturation properties of c pure fluids where an input pressure equal to the c (saturation pressure +/- delta) might put you in the c wrong phase c outputs: c D--molar density (mol/L) c eta--viscosity (uPa.s) c tcx--thermal conductivity (W/m.K) c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),z(ncmax) common /NCOMP/ ncomp c flags indicating 'not applicable', '2-phase', etc. common /FLAGS/ xnota,x2ph,xsubc,xsuph,xsupc,xinf,x7,xnotd,xnotc c do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue c p=pbar*100.0d0 !version 6 routines use kPa rather than bar if (kph.eq.1 .or. kph.eq.2) then c phase is specified on input kguess=0 !no initial guess for density is provided call TPRHO (t,p,z,kph,kguess,D,ierr,herr) call TRNPRP (t,D,z,eta,tcx,ierr,herr) eta=eta*10.0d0 !version 6 uses uPa-s rather than micropoise else c must determine phase call TPFLSH (t,p,z,D,Dl,Dv,x,y,q,e,h,s,cv,cp,w,ierr,herr) if (q.gt.0.0d0 .and. q.lt.1.0d0) then c two-phase state, transport properties not defined eta=xnotd tcx=xnotd else call TRNPRP (t,D,z,eta,tcx,ierr,herr) eta=eta*10.0d0 !version 6 uses uPa-s rather than micropoise end if end if c RETURN end !subroutine TRNSP c c ====================================================================== c subroutine DCST (pbar,D,t,x,kph,ier) c c flash calculation given temperature, pressure, and bulk composition c c This routine accepts both single-phase and two-phase states as the c input. c c inputs: c pbar--pressure [bar] c N.B. note units are bar, not kPa c t--temperature [K] c x--composition [array of mole fractions] c kph--phase flag: 1 = liquid c 2 = vapor c 0 = stable phase c kph = 1,2 useful for calculating saturation properties of c pure fluids where an input pressure equal to the c (saturation pressure +/- delta) might put you in the c wrong phase c outputs: c D--molar density (mol/L) c ier--error flag: 0 = successful c <>0 = same as ierr out of version 6 TPFLSH c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),z(ncmax),zl(ncmax),zv(ncmax) common /NCOMP/ ncomp c do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue c p=pbar*100.0d0 !version 6 routines use kPa rather than bar if (kph.eq.1 .or. kph.eq.2) then c phase is specified on input kguess=0 !no initial guess for density is provided call TPRHO (t,p,z,kph,kguess,D,ierr,herr) else c must determine phase call TPFLSH (t,p,z,D,Dl,Dv,zl,zv,q,e,h,s,cv,cp,w,ierr,herr) end if ier=ierr c RETURN end !subroutine DCST c c ====================================================================== c subroutine FLASHN (p,t,x,xl,xv,q,nc,vl,vv) c c flash calculation given temperature, pressure, and bulk composition c c This routine accepts both single-phase and two-phase states as the c input. c c inputs: c p--pressure [kPa] c t--temperature [K] c x--composition [array of mole fractions] c nc--number of components (ignored in these bridge routines) c Note: the original FLASHN in version 5 required initial c guesses for xl and xv; these are no longer needed. c outputs: c xl--liquid-phase composition [array of mole fractions] c xv--vapor-phase composition [array of mole fractions] c q--vapor quality on a MOLAR basis [moles vapor/total moles] c vl--molar volume [L/mol] of liquid phase c vv--molar volume [L/mol] of vapor phase c additional output passed via common /FLASHE/ c ier--error flag: 0 = successful c <>0 = same as ierr out of version 6 TPFLSH c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension x(ncmax5),xl(ncmax5),xv(ncmax5), & z(ncmax),zl(ncmax),zv(ncmax) common /NCOMP/ ncomp common /FLASHE/ ier c flags indicating 'not applicable', '2-phase', etc. common /FLAGS/ xnota,x2ph,xsubc,xsuph,xsupc,xinf,x7,xnotd,xnotc c nc=ncomp !extract number of components from common do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to z array (possibility that they are of c different dimension in future versions) z(i)=x(i) 100 continue c c must determine phase call TPFLSH (t,p,z,D,Dl,Dv,zl,zv,q,e,h,s,cv,cp,w,ierr,herr) ier=ierr c do 200 i=1,MIN(ncomp,ncmax5) c copy output compositions to xl, xv arrays (possibility that they are c of different dimension in future versions) xl(i)=zl(i) xv(i)=zv(i) 200 continue vl=1.0d0/Dl if (Dv.gt.1.0d-20) then vv=1.0d0/Dv else vv=xinf !flag indicating infinite end if c RETURN end !subroutine FLASHN c c ====================================================================== c subroutine VIT (t,p,a,b,v,lliqi,lvcon) c c flash calculation given temperature and pressure for a specified c phase c c N.B. the composition is not an input to this routine, thus a prior c call to ESPAR or setting the composition in common /MOLX/ is c required prior to calling this routine. c c inputs: c t--temperature [K] c p--pressure [kPa] c a--attraction parameter in CSD EOS (not used) c b--volume parameter in CSD EOS (not used) c v--initial guess for the molar volume [L/mol] c lliqi--phase flag: c .true. compute liquid-phase properties c .false. compute vapor-phase properties c additional input passed via common /MOLX/ (e.g. set by ESPAR) c x--composition [array of mole fractions] c outputs: c v--molar volume [L/mol] c lvcon--error flag; set .true. if iteration fails to converge c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c implicit double precision (a-h,o-z) implicit integer (i-n) logical lliqi,lvcon c parameter (ncmax=5) !max number of components in mixture parameter (ncmax5=5) !max number of components in version 5 character*255 herr dimension z(ncmax) common /NCOMP/ ncomp common /MOLX/ wmi(ncmax5),wmr,wmx,xpass(ncmax5) c flags indicating 'not applicable', '2-phase', etc. common /FLAGS/ xnota,x2ph,xsubc,xsuph,xsupc,xinf,x7,xnotd,xnotc c c retrieve composition from /MOLX/ and check that it is reliable lvcon=.false. xsum=0.0d0 do 100 i=1,MIN(ncomp,ncmax5) z(i)=xpass(i) if (z(i).lt.-1.0d-8 .or. z(i).gt.1.00000001d0) then lvcon=.true. end if xsum=xsum+z(i) 100 continue if (ABS(1.0d0-xsum).gt.1.0d-8) then lvcon=.true. end if c if (.not.lvcon) then c calculate only if composition appears reasonable if (lliqi) then kph=1 !calculate liquid phase else kph=2 !calculate vapor phase end if if (v.gt.0.0d0) then c assume that initial guess for volume is available kguess=1 rho=1.0d0/v else c assume no initial guess kguess=0 end if call TPRHO (t,p,z,kph,kguess,rho,ierr,herr) if (rho.gt.1.0d-20) then v=1.0d0/rho end if if (ierr.eq.0) then lvcon=.false. else lvcon=.true. end if else v=xnotc !flag indicating 'not calculated' end if c RETURN end !subroutine VIT c c ====================================================================== c subroutine ESPAR (iq,t,x,a,b) c c The original ESPAR routine was used to calculate the a,b parameters c in the CSD equation of state; these were then typically passed to the c VIT routine. Since the CSD equation is no longer used, this routine c simply loads the composition into common /MOLX/ for use by VIT. c c inputs: c iq--calculation flag, no longer used [integer] c t--temperature [K] c x--composition [array of mole fractions] c outputs: c a--attraction parameter in CSD EOS (set to dummy value) c b--volume parameter in CSD EOS (set to dummy value) c additional output passed via common /MOLX/ c x--composition [array of mole fractions] c c written by M. McLinden, NIST Phys & Chem Properties Div, Boulder, CO c 10-14-97 MM, original version c 10-21-97 MM, if ncomp=1 set input composition (version 4 ignored c composition input for MBWR and pure-fluid ECS models, c so applications written for v4 may not set them) c implicit double precision (a-h,o-z) implicit integer (i-n) c parameter (ncmax5=5) !max number of components in version 5 dimension x(ncmax5) common /NCOMP/ ncomp common /MOLX/ wmi(ncmax5),wmr,wmx,xpass(ncmax5) c if (ncomp.le.1) then xpass(1)=1.0d0 else do 100 i=1,MIN(ncomp,ncmax5) c copy input composition to xpass array xpass(i)=x(i) 100 continue end if c a=0.2d0 !set to dummy values b=1.0d3 c RETURN end !subroutine ESPAR c c c 1 2 3 4 5 6 7 c23456789012345678901234567890123456789012345678901234567890123456789012 c c ====================================================================== c end file bridge.f c ======================================================================