5 !=======================================================================
7 ! *** This module calculates the thermodynamic equilibrium based on
9 ! *** Modified to make it WRF compatible by Rainer Schmitz, 23.12.2007
10 ! *** AireChile, Department of Geophysics, University of Chile
14 !=======================================================================
17 ! *** SUBROUTINE ISOROPIA
18 ! *** THIS SUBROUTINE IS THE MASTER ROUTINE FOR THE ISORROPIA
19 ! THERMODYNAMIC EQUILIBRIUM AEROSOL MODEL (VERSION 1.1 and above)
21 ! ======================== ARGUMENTS / USAGE ===========================
25 ! DOUBLE PRECISION array of length [5].
26 ! Concentrations, expressed in moles/m3. Depending on the type of
27 ! problem solved (specified in CNTRL(1)), WI contains either
28 ! GAS+AEROSOL or AEROSOL only concentratios.
36 ! DOUBLE PRECISION variable.
37 ! Ambient relative humidity expressed on a (0,1) scale.
40 ! DOUBLE PRECISION variable.
41 ! Ambient temperature expressed in Kelvins.
44 ! DOUBLE PRECISION array of length [2].
45 ! Parameters that control the type of problem solved.
47 ! CNTRL(1): Defines the type of problem solved.
48 ! 0 - Forward problem is solved. In this case, array WI contains
49 ! GAS and AEROSOL concentrations together.
50 ! 1 - Reverse problem is solved. In this case, array WI contains
51 ! AEROSOL concentrations only.
53 ! CNTRL(2): Defines the state of the aerosol
54 ! 0 - The aerosol can have both solid+liquid phases (deliquescent)
55 ! 1 - The aerosol is in only liquid state (metastable aerosol)
59 ! DOUBLE PRECISION array of length [5].
60 ! Total concentrations (GAS+AEROSOL) of species, expressed in moles/m3.
61 ! If the foreward probelm is solved (CNTRL(1)=0), array WT is
62 ! identical to array WI.
63 ! WT(1) - total sodium
64 ! WT(2) - total sulfate
65 ! WT(3) - total ammonium
66 ! WT(4) - total nitrate
67 ! WT(5) - total chloride
70 ! DOUBLE PRECISION array of length [03].
71 ! Gaseous species concentrations, expressed in moles/m3.
77 ! DOUBLE PRECISION array of length [11].
78 ! Liquid aerosol species concentrations, expressed in moles/m3.
80 ! AERLIQ(02) - Na+(aq)
81 ! AERLIQ(03) - NH4+(aq)
82 ! AERLIQ(04) - Cl-(aq)
83 ! AERLIQ(05) - SO4--(aq)
84 ! AERLIQ(06) - HSO4-(aq)
85 ! AERLIQ(07) - NO3-(aq)
87 ! AERLIQ(09) - NH3(aq) (undissociated)
88 ! AERLIQ(10) - HNCl(aq) (undissociated)
89 ! AERLIQ(11) - HNO3(aq) (undissociated)
90 ! AERLIQ(12) - OH-(aq)
93 ! DOUBLE PRECISION array of length [09].
94 ! Solid aerosol species concentrations, expressed in moles/m3.
95 ! AERSLD(01) - NaNO3(s)
96 ! AERSLD(02) - NH4NO3(s)
97 ! AERSLD(03) - NaCl(s)
98 ! AERSLD(04) - NH4Cl(s)
99 ! AERSLD(05) - Na2SO4(s)
100 ! AERSLD(06) - (NH4)2SO4(s)
101 ! AERSLD(07) - NaHSO4(s)
102 ! AERSLD(08) - NH4HSO4(s)
103 ! AERSLD(09) - (NH4)4H(SO4)2(s)
106 ! CHARACTER*15 variable.
107 ! Returns the subcase which the input corresponds to.
110 ! DOUBLE PRECISION array of length [6].
111 ! Returns solution information.
113 ! OTHER(1): Shows if aerosol water exists.
117 ! OTHER(2): Aerosol Sulfate ratio, defined as (in moles/m3) :
118 ! (total ammonia + total Na) / (total sulfate)
120 ! OTHER(3): Sulfate ratio based on aerosol properties that defines
121 ! a sulfate poor system:
122 ! (aerosol ammonia + aerosol Na) / (aerosol sulfate)
124 ! OTHER(4): Aerosol sodium ratio, defined as (in moles/m3) :
125 ! (total Na) / (total sulfate)
127 ! OTHER(5): Ionic strength of the aqueous aerosol (if it exists).
129 ! OTHER(6): Total number of calls to the activity coefficient
130 ! calculation subroutine.
132 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
133 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
134 ! *** WRITTEN BY ATHANASIOS NENES
135 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
137 !=======================================================================
139 SUBROUTINE ISOROPIA (WI, RHI, TEMPI, CNTRL, &
140 WT, GAS, AERLIQ, AERSLD, SCASI, OTHER)
143 INTEGER,PARAMETER::NCTRL=2,NOTHER=6
145 REAL(KIND=8) WI(NCOMP), WT(NCOMP), RHI, TEMPI, GAS(NGASAQ), &
146 AERSLD(NSLDS), AERLIQ(NIONS+NGASAQ+2), CNTRL(NCTRL), OTHER(NOTHER)
149 ! *** PROBLEM TYPE (0=FOREWARD, 1=REVERSE) ******************************
151 IPROB = NINT(CNTRL(1))
153 ! *** AEROSOL STATE (0=SOLID+LIQUID, 1=METASTABLE) **********************
155 METSTBL = NINT(CNTRL(2))
157 ! *** SOLVE FOREWARD PROBLEM ********************************************
159 50 IF (IPROB.EQ.0) THEN
160 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
161 CALL INIT1 (WI, RHI, TEMPI)
162 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
163 CALL ISRP1F (WI, RHI, TEMPI)
164 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
165 CALL ISRP2F (WI, RHI, TEMPI)
167 CALL ISRP3F (WI, RHI, TEMPI)
170 ! *** SOLVE REVERSE PROBLEM *********************************************
173 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
174 CALL INIT1 (WI, RHI, TEMPI)
175 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
176 CALL ISRP1R (WI, RHI, TEMPI)
177 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
178 CALL ISRP2R (WI, RHI, TEMPI)
180 CALL ISRP3R (WI, RHI, TEMPI)
184 ! *** ADJUST MASS BALANCE ***********************************************
186 IF (NADJ.EQ.1) CALL ADJUST (WI)
188 !ccC *** IF METASTABLE AND NO WATER - RESOLVE AS NORMAL ********************
190 !cc IF (WATER.LE.TINY .AND. METSTBL.EQ.1) THEN
195 ! *** SAVE RESULTS TO ARRAYS (units = mole/m3) ****************************
197 GAS(1) = GNH3 ! Gaseous aerosol species
201 DO 10 I=1,NIONS ! Liquid aerosol species
205 AERLIQ(NIONS+1+I) = GASAQ(I)
207 AERLIQ(NIONS+1) = WATER*1.0D3/18.0D0
208 AERLIQ(NIONS+NGASAQ+2) = COH
210 AERSLD(1) = CNANO3 ! Solid aerosol species
220 IF(WATER.LE.TINY) THEN ! Dry flag
226 OTHER(2) = SULRAT ! Other stuff
234 WT(1) = WI(1) ! Total gas+aerosol phase
239 IF (IPROB.GT.0 .AND. WATER.GT.TINY) THEN
241 WT(4) = WT(4) + GHNO3
247 ! *** END OF SUBROUTINE ISOROPIA ******************************************
249 END SUBROUTINE ISOROPIA
253 !=======================================================================
256 ! *** SUBROUTINE SETPARM
257 ! *** THIS SUBROUTINE REDEFINES THE SOLUTION PARAMETERS OF ISORROPIA
259 ! ======================== ARGUMENTS / USAGE ===========================
261 ! *** NOTE: IF NEGATIVE VALUES ARE GIVEN FOR A PARAMETER, IT IS
262 ! IGNORED AND THE CURRENT VALUE IS USED INSTEAD.
267 ! Defines the type of weighting algorithm for the solution in Mutual
268 ! Deliquescence Regions (MDR's):
269 ! 0 - MDR's are assumed dry. This is equivalent to the approach
271 ! 1 - The solution is assumed "half" dry and "half" wet throughout
273 ! 2 - The solution is a relative-humidity weighted mean of the
274 ! dry and wet solutions (as defined in Nenes et al., 1998)
278 ! Method of activity coefficient calculation:
279 ! 0 - Calculate coefficients during runtime
280 ! 1 - Use precalculated tables
283 ! DOUBLE PRECITION variable.
284 ! Defines the convergence criterion for all iterative processes
285 ! in ISORROPIA, except those for activity coefficient calculations
286 ! (EPSACTI controls that).
290 ! Defines the maximum number of iterations for all iterative
291 ! processes in ISORROPIA, except for activity coefficient calculations
292 ! (NSWEEPI controls that).
296 ! Defines the maximum number of iterations for activity coefficient
300 ! DOUBLE PRECISION variable.
301 ! Defines the convergence criterion for activity coefficient
306 ! Defines the number of subdivisions needed for the initial root
307 ! tracking for the bisection method. Usually this parameter should
308 ! not be altered, but is included for completeness.
312 ! Forces the solution obtained to satisfy total mass balance
313 ! to machine precision
314 ! 0 - No adjustment done (default)
317 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
318 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
319 ! *** WRITTEN BY ATHANASIOS NENES
320 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
322 !=======================================================================
324 SUBROUTINE SETPARM (WFTYPI, IACALCI, EPSI, MAXITI, NSWEEPI, &
325 EPSACTI, NDIVI, NADJI)
328 REAL(KIND=8) EPSI, EPSACTI
329 INTEGER WFTYPI, IACALCI, MAXITI, NSWEEPI, NDIVI, NADJI
331 ! *** SETUP SOLUTION PARAMETERS *****************************************
333 IF (WFTYPI .GE. 0) WFTYP = WFTYPI
334 IF (IACALCI.GE. 0) IACALC = IACALCI
335 IF (EPSI .GE.ZERO) EPS = EPSI
336 IF (MAXITI .GT. 0) MAXIT = MAXITI
337 IF (NSWEEPI.GT. 0) NSWEEP = NSWEEPI
338 IF (EPSACTI.GE.ZERO) EPSACT = EPSACTI
339 IF (NDIVI .GT. 0) NDIV = NDIVI
340 IF (NADJI .GE. 0) NADJ = NADJI
342 ! *** END OF SUBROUTINE SETPARM *****************************************
345 END SUBROUTINE SETPARM
350 !=======================================================================
353 ! *** SUBROUTINE GETPARM
354 ! *** THIS SUBROUTINE OBTAINS THE CURRENT VAULES OF THE SOLUTION
355 ! PARAMETERS OF ISORROPIA
357 ! ======================== ARGUMENTS / USAGE ===========================
359 ! *** THE PARAMETERS ARE THOSE OF SUBROUTINE SETPARM
361 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
362 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
363 ! *** WRITTEN BY ATHANASIOS NENES
364 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
366 !=======================================================================
368 SUBROUTINE GETPARM (WFTYPI, IACALCI, EPSI, MAXITI, NSWEEPI, &
369 EPSACTI, NDIVI, NADJI)
371 REAL(KIND=8) EPSI, EPSACTI
372 INTEGER WFTYPI, IACALCI, MAXITI, NSWEEPI, NDIVI, NADJI
374 ! *** GET SOLUTION PARAMETERS *******************************************
385 ! *** END OF SUBROUTINE GETPARM *****************************************
388 END SUBROUTINE GETPARM
390 !=======================================================================
393 ! *** SUBROUTINE INIT1
394 ! *** THIS SUBROUTINE INITIALIZES ALL GLOBAL VARIABLES FOR AMMONIUM
395 ! SULFATE AEROSOL SYSTEMS (SUBROUTINE ISRP1)
397 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
398 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
399 ! *** WRITTEN BY ATHANASIOS NENES
400 ! *** UPDATED BY !HRISTOS FOUNTOUKIS
402 !=======================================================================
404 SUBROUTINE INIT1 (WI, RHI, TEMPI)
406 REAL(KIND=8) WI(NCOMP),RHI,TEMPI
407 REAL(KIND=8) T0, T0T, COEF, TCF
410 REAL,PARAMETER::LN10=2.3025851
413 ! *** SAVE INPUT VARIABLES IN COMMON BLOCK ******************************
415 IF (IPROB.EQ.0) THEN ! FORWARD CALCULATION
417 W(I) = MAX(WI(I), TINY)
420 DO 15 I=1,NCOMP ! REVERSE CALCULATION
421 WAER(I) = MAX(WI(I), TINY)
428 ! *** CALCULATE EQUILIBRIUM CONSTANTS ***********************************
430 XK1 = 1.015e-2 ! HSO4(aq) <==> H(aq) + SO4(aq)
431 XK21 = 57.639 ! NH3(g) <==> NH3(aq)
432 XK22 = 1.805e-5 ! NH3(aq) <==> NH4(aq) + OH(aq)
433 XK7 = 1.817 ! (NH4)2SO4(s) <==> 2*NH4(aq) + SO4(aq)
434 XK12 = 1.382e2 ! NH4HSO4(s) <==> NH4(aq) + HSO4(aq)
435 XK13 = 29.268 ! (NH4)3H(SO4)2(s) <==> 3*NH4(aq) + HSO4(aq) + SO4(aq)
436 XKW = 1.010e-14 ! H2O <==> H(aq) + OH(aq)
438 IF (INT(TEMP) .NE. 298) THEN ! FOR T != 298K or 298.15K
441 COEF= 1.0+LOG(T0T)-T0T
442 XK1 = XK1 *EXP( 8.85*(T0T-1.0) + 25.140*COEF)
443 XK21= XK21*EXP( 13.79*(T0T-1.0) - 5.393*COEF)
444 XK22= XK22*EXP( -1.50*(T0T-1.0) + 26.920*COEF)
445 XK7 = XK7 *EXP( -2.65*(T0T-1.0) + 38.570*COEF)
446 XK12= XK12*EXP( -2.87*(T0T-1.0) + 15.830*COEF)
447 XK13= XK13*EXP( -5.19*(T0T-1.0) + 54.400*COEF)
448 XKW = XKW *EXP(-22.52*(T0T-1.0) + 26.920*COEF)
452 ! *** CALCULATE DELIQUESCENCE RELATIVE HUMIDITIES (UNICOMPONENT) ********
458 IF (INT(TEMP) .NE. 298) THEN
460 TCF = 1.0/TEMP - 1.0/T0
461 DRNH42S4 = DRNH42S4*EXP( 80.*TCF)
462 DRNH4HS4 = DRNH4HS4*EXP(384.*TCF)
463 DRLC = DRLC *EXP(186.*TCF)
466 ! *** CALCULATE MUTUAL DELIQUESCENCE RELATIVE HUMIDITIES ****************
468 DRMLCAB = 0.3780D0 ! (NH4)3H(SO4)2 & NH4HSO4
469 DRMLCAS = 0.6900D0 ! (NH4)3H(SO4)2 & (NH4)2SO4
470 !CC IF (INT(TEMP) .NE. 298) THEN ! For the time being.
472 !CC TCF = 1.0/TEMP - 1.0/T0
473 !CC DRMLCAB = DRMLCAB*EXP(507.506*TCF)
474 !CC DRMLCAS = DRMLCAS*EXP(133.865*TCF)
477 ! *** LIQUID PHASE ******************************************************
506 ! *** SOLID PHASE *******************************************************
518 ! *** GAS PHASE *********************************************************
524 ! *** CALCULATE ZSR PARAMETERS ******************************************
526 IRH = MIN (INT(RH*NZSR+0.5),NZSR) ! Position in ZSR arrays
529 ! M0(01) = AWSC(IRH) ! NACl
530 ! IF (M0(01) .LT. 100.0) THEN
532 ! CALL KMTAB(IC,298.0, GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
533 ! CALL KMTAB(IC,SNGL(TEMP),GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
534 ! M0(01) = M0(01)*EXP(LN10*(GI0-GII))
537 ! M0(02) = AWSS(IRH) ! (NA)2SO4
538 ! IF (M0(02) .LT. 100.0) THEN
540 ! CALL KMTAB(IC,298.0, XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
541 ! CALL KMTAB(IC,SNGL(TEMP),XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
542 ! M0(02) = M0(02)*EXP(LN10*(GI0-GII))
545 ! M0(03) = AWSN(IRH) ! NANO3
546 ! IF (M0(03) .LT. 100.0) THEN
548 ! CALL KMTAB(IC,298.0, XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX)
549 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX)
550 ! M0(03) = M0(03)*EXP(LN10*(GI0-GII))
553 M0(04) = AWAS(IRH) ! (NH4)2SO4
554 ! IF (M0(04) .LT. 100.0) THEN
556 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX)
557 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX)
558 ! M0(04) = M0(04)*EXP(LN10*(GI0-GII))
561 ! M0(05) = AWAN(IRH) ! NH4NO3
562 ! IF (M0(05) .LT. 100.0) THEN
564 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX)
565 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX)
566 ! M0(05) = M0(05)*EXP(LN10*(GI0-GII))
569 ! M0(06) = AWAC(IRH) ! NH4CL
570 ! IF (M0(06) .LT. 100.0) THEN
572 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX)
573 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX)
574 ! M0(06) = M0(06)*EXP(LN10*(GI0-GII))
577 M0(07) = AWSA(IRH) ! 2H-SO4
578 ! IF (M0(07) .LT. 100.0) THEN
580 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX)
581 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX)
582 ! M0(07) = M0(07)*EXP(LN10*(GI0-GII))
585 M0(08) = AWSA(IRH) ! H-HSO4
586 !CC IF (M0(08) .LT. 100.0) THEN ! These are redundant, because M0(8) is not used
588 !CC CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
589 !CC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
590 !CCCCC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX)
591 !CC M0(08) = M0(08)*EXP(LN10*(GI0-GII))
594 M0(09) = AWAB(IRH) ! NH4HSO4
595 ! IF (M0(09) .LT. 100.0) THEN
597 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX)
598 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX)
599 ! M0(09) = M0(09)*EXP(LN10*(GI0-GII))
602 ! M0(12) = AWSB(IRH) ! NAHSO4
603 ! IF (M0(12) .LT. 100.0) THEN
605 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GI0)
606 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GII)
607 ! M0(12) = M0(12)*EXP(LN10*(GI0-GII))
610 M0(13) = AWLC(IRH) ! (NH4)3H(SO4)2
611 ! IF (M0(13) .LT. 100.0) THEN
613 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
614 ! G130 = 0.2*(3.0*GI0+2.0*GII)
615 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
616 ! G13I = 0.2*(3.0*GI0+2.0*GII)
617 ! M0(13) = M0(13)*EXP(LN10*SNGL(G130-G13I))
620 ! *** OTHER INITIALIZATIONS *********************************************
633 ERRMSG(I) = 'MESSAGE N/A'
636 ! *** END OF SUBROUTINE INIT1 *******************************************
657 ! *** SUBROUTINE ISOPLUS
658 ! *** THIS SUBROUTINE IS THE MASTER ROUTINE FOR THE ISORROPIA-PLUS
659 ! THERMODYNAMIC EQUILIBRIUM AEROSOL MODEL (VERSION 1.0)
661 ! *** NOTE: THIS SUBROUTINE IS INCLUDED FOR BACKWARD COMPATABILITY ONLY.
662 ! A PROGRAMMER SHOULD USE THE MORE COMPLETE SUBROUTINE ISOROPIA INSTEAD
664 ! ======================== ARGUMENTS / USAGE ===========================
668 ! DOUBLE PRECISION array of length [5].
669 ! Concentrations, expressed in moles/m3. Depending on the type of
670 ! problem solved, WI contains either GAS+AEROSOL or AEROSOL only
679 ! DOUBLE PRECISION variable.
680 ! Ambient relative humidity expressed in a (0,1) scale.
683 ! DOUBLE PRECISION variable.
684 ! Ambient temperature expressed in Kelvins.
688 ! The type of problem solved.
689 ! IPROB = 0 - Forward problem is solved. In this case, array WI
690 ! contains GAS and AEROSOL concentrations together.
691 ! IPROB = 1 - Reverse problem is solved. In this case, array WI
692 ! contains AEROSOL concentrations only.
696 ! DOUBLE PRECISION array of length [03].
697 ! Gaseous species concentrations, expressed in moles/m3.
703 ! DOUBLE PRECISION array of length [11].
704 ! Liquid aerosol species concentrations, expressed in moles/m3.
705 ! AERLIQ(01) - H+(aq)
706 ! AERLIQ(02) - Na+(aq)
707 ! AERLIQ(03) - NH4+(aq)
708 ! AERLIQ(04) - Cl-(aq)
709 ! AERLIQ(05) - SO4--(aq)
710 ! AERLIQ(06) - HSO4-(aq)
711 ! AERLIQ(07) - NO3-(aq)
713 ! AERLIQ(09) - NH3(aq) (undissociated)
714 ! AERLIQ(10) - HNCl(aq) (undissociated)
715 ! AERLIQ(11) - HNO3(aq) (undissociated)
718 ! DOUBLE PRECISION array of length [09].
719 ! Solid aerosol species concentrations, expressed in moles/m3.
720 ! AERSLD(01) - NaNO3(s)
721 ! AERSLD(02) - NH4NO3(s)
722 ! AERSLD(03) - NaCl(s)
723 ! AERSLD(04) - NH4Cl(s)
724 ! AERSLD(05) - Na2SO4(s)
725 ! AERSLD(06) - (NH4)2SO4(s)
726 ! AERSLD(07) - NaHSO4(s)
727 ! AERSLD(08) - NH4HSO4(s)
728 ! AERSLD(09) - (NH4)4H(SO4)2(s)
732 ! Contains information about the physical state of the system.
733 ! .TRUE. - There is no aqueous phase present
734 ! .FALSE.- There is an aqueous phase present
736 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
737 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
738 ! *** WRITTEN BY ATHANASIOS NENES
739 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
741 !=======================================================================
743 SUBROUTINE ISOPLUS (WI, RHI, TEMPI, IPROBI, &
744 GAS, AERLIQ, AERSLD, DRYI )
747 REAL(KIND=8) WI(NCOMP), GAS(NGASAQ), AERLIQ(NIONS+NGASAQ+1), &
749 REAL(KIND=8) RHI, TEMPI
754 ! *** PROBLEM TYPE (0=FOREWARD, 1=REVERSE) ******************************
758 ! *** SOLVE FOREWARD PROBLEM ********************************************
761 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
762 CALL INIT1 (WI, RHI, TEMPI)
763 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
764 CALL ISRP1F (WI, RHI, TEMPI)
765 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
766 CALL ISRP2F (WI, RHI, TEMPI)
768 CALL ISRP3F (WI, RHI, TEMPI)
771 ! *** SOLVE REVERSE PROBLEM *********************************************
774 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
775 CALL INIT1 (WI, RHI, TEMPI)
776 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
777 CALL ISRP1R (WI, RHI, TEMPI)
778 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
779 CALL ISRP2R (WI, RHI, TEMPI)
781 CALL ISRP3R (WI, RHI, TEMPI)
785 ! *** SAVE RESULTS TO ARRAYS (units = mole/m3, kg/m3 for water) *********
794 AERLIQ(NIONS+1) = WATER*1.0D3/18.0D0
796 AERLIQ(NIONS+1+I) = GASAQ(I)
813 ! *** END OF SUBROUTINE ISOPLUS ******************************************
815 END SUBROUTINE ISOPLUS
820 !=======================================================================
823 ! *** SUBROUTINE ISRPIA
824 ! *** THIS SUBROUTINE IS THE MASTER ROUTINE FOR THE ISORROPIA-PLUS
825 ! THERMODYNAMIC EQUILIBRIUM AEROSOL MODEL (VERSIONS 0.x)
827 ! *** NOTE: THIS SUBROUTINE IS INCLUDED FOR BACKWARD COMPATABILITY ONLY.
828 ! A PROGRAMMER SHOULD USE THE MORE COMPLETE SUBROUTINE ISOROPIA INSTEAD
831 ! DEPENDING ON THE INPUT VALUES PROVIDED, THE FOLLOWING MODEL
832 ! SUBVERSIONS ARE CALLED:
834 ! FOREWARD PROBLEM (IPROB=0):
835 ! Na SO4 NH4 NO3 CL SUBROUTINE CALLED
836 ! ---- ---- ---- ---- ---- -----------------
837 ! 0.0 >0.0 >0.0 0.0 0.0 SUBROUTINE ISRP1F
838 ! 0.0 >0.0 >0.0 >0.0 0.0 SUBROUTINE ISRP2F
839 ! >0.0 >0.0 >0.0 >0.0 >0.0 SUBROUTINE ISRP3F
841 ! REVERSE PROBLEM (IPROB=1):
842 ! Na SO4 NH4 NO3 CL SUBROUTINE CALLED
843 ! ---- ---- ---- ---- ---- -----------------
844 ! 0.0 >0.0 >0.0 0.0 0.0 SUBROUTINE ISRP1R
845 ! 0.0 >0.0 >0.0 >0.0 0.0 SUBROUTINE ISRP2R
846 ! >0.0 >0.0 >0.0 >0.0 >0.0 SUBROUTINE ISRP3R
848 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
849 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
850 ! *** WRITTEN BY ATHANASIOS NENES
851 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
853 !=======================================================================
855 SUBROUTINE ISRPIA (WI, RHI, TEMPI, IPROBI)
858 REAL(KIND=8) WI(NCOMP),RHI,TEMPI
861 ! *** PROBLEM TYPE (0=FOREWARD, 1=REVERSE) ******************************
865 ! *** SOLVE FOREWARD PROBLEM ********************************************
868 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
869 CALL INIT1 (WI, RHI, TEMPI)
870 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
871 CALL ISRP1F (WI, RHI, TEMPI)
872 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
873 CALL ISRP2F (WI, RHI, TEMPI)
875 CALL ISRP3F (WI, RHI, TEMPI)
878 ! *** SOLVE REVERSE PROBLEM *********************************************
881 IF (WI(1)+WI(2)+WI(3)+WI(4)+WI(5) .LE. TINY) THEN ! Everything=0
882 CALL INIT1 (WI, RHI, TEMPI)
883 ELSE IF (WI(1)+WI(4)+WI(5) .LE. TINY) THEN ! Na,Cl,NO3=0
884 CALL ISRP1R (WI, RHI, TEMPI)
885 ELSE IF (WI(1)+WI(5) .LE. TINY) THEN ! Na,Cl=0
886 CALL ISRP2R (WI, RHI, TEMPI)
888 CALL ISRP3R (WI, RHI, TEMPI)
892 ! *** SETUP 'DRY' FLAG ***************************************************
896 ! *** FIND TOTALS *******************************************************
916 ! *** END OF SUBROUTINE ISRPIA *******************************************
918 END SUBROUTINE ISRPIA
920 !=======================================================================
923 ! *** FUNCTION GETASR
924 ! *** CALCULATES THE LIMITING NH4+/SO4 RATIO OF A SULFATE POOR SYSTEM
925 ! (i.e. SULFATE RATIO = 2.0) FOR GIVEN SO4 LEVEL AND RH
927 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
928 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
929 ! *** WRITTEN BY ATHANASIOS NENES
930 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
932 !=======================================================================
934 REAL(KIND=8) FUNCTION GETASR (SO4I, RHI)
935 PARAMETER (NSO4S=14, NRHS=20, NASRD=NSO4S*NRHS)
936 COMMON /ASRC/ ASRAT(NASRD), ASSO4(NSO4S)
937 DOUBLE PRECISION SO4I, RHI
939 !CC *** SOLVE USING FULL COMPUTATIONS, NOT LOOK-UP TABLES **************
942 !CC W(3) = WAER(2)*2.0001D0
944 !CC SULRATW = MOLAL(3)/WAER(2)
945 !CC CALL INIT1 (WI, RHI, TEMPI) ! Re-initialize COMMON BLOCK
947 ! *** CALCULATE INDICES ************************************************
950 A1 = INT(ALOG10(RAT)) ! Magnitude of RAT
951 IA1 = INT(RAT/2.5/10.0**A1)
953 INDS = 4.0*A1 + MIN(IA1,4)
954 INDS = MIN(MAX(0, INDS), NSO4S-1) + 1 ! SO4 component of IPOS
956 INDR = INT(99.0-RHI*100.0) + 1
957 INDR = MIN(MAX(1, INDR), NRHS) ! RH component of IPOS
959 ! *** GET VALUE AND RETURN *********************************************
962 INDSH = MIN(INDSL+1, NSO4S)
963 IPOSL = (INDSL-1)*NRHS + INDR ! Low position in array
964 IPOSH = (INDSH-1)*NRHS + INDR ! High position in array
966 WF = (SO4I-ASSO4(INDSL))/(ASSO4(INDSH)-ASSO4(INDSL) + 1e-7)
967 WF = MIN(MAX(WF, 0.0), 1.0)
969 GETASR = WF*ASRAT(IPOSH) + (1.0-WF)*ASRAT(IPOSL)
971 ! *** END OF FUNCTION GETASR *******************************************
983 !=======================================================================
986 ! *** SUBROUTINE INIT2
987 ! *** THIS SUBROUTINE INITIALIZES ALL GLOBAL VARIABLES FOR AMMONIUM,
988 ! NITRATE, SULFATE AEROSOL SYSTEMS (SUBROUTINE ISRP2)
990 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
991 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
992 ! *** WRITTEN BY ATHANASIOS NENES
993 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
995 !=======================================================================
997 SUBROUTINE INIT2 (WI, RHI, TEMPI)
999 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
1000 REAL(KIND=8) T0, T0T, COEF, TCF
1002 REAL IC,GII,GI0,XX,LN10
1003 PARAMETER (LN10=2.3025851)
1006 ! *** SAVE INPUT VARIABLES IN COMMON BLOCK ******************************
1008 IF (IPROB.EQ.0) THEN ! FORWARD CALCULATION
1010 W(I) = MAX(WI(I), TINY)
1013 DO 15 I=1,NCOMP ! REVERSE CALCULATION
1014 WAER(I) = MAX(WI(I), TINY)
1021 ! *** CALCULATE EQUILIBRIUM CONSTANTS ***********************************
1023 XK1 = 1.015e-2 ! HSO4(aq) <==> H(aq) + SO4(aq)
1024 XK21 = 57.639 ! NH3(g) <==> NH3(aq)
1025 XK22 = 1.805e-5 ! NH3(aq) <==> NH4(aq) + OH(aq)
1026 XK4 = 2.511e6 ! HNO3(g) <==> H(aq) + NO3(aq) ! ISORR
1027 !CC XK4 = 3.638e6 ! HNO3(g) <==> H(aq) + NO3(aq) ! SEQUIL
1028 XK41 = 2.100e5 ! HNO3(g) <==> HNO3(aq)
1029 XK7 = 1.817 ! (NH4)2SO4(s) <==> 2*NH4(aq) + SO4(aq)
1030 XK10 = 5.746e-17 ! NH4NO3(s) <==> NH3(g) + HNO3(g) ! ISORR
1031 !CC XK10 = 2.985e-17 ! NH4NO3(s) <==> NH3(g) + HNO3(g) ! SEQUIL
1032 XK12 = 1.382e2 ! NH4HSO4(s) <==> NH4(aq) + HSO4(aq)
1033 XK13 = 29.268 ! (NH4)3H(SO4)2(s) <==> 3*NH4(aq) + HSO4(aq) + SO4(aq)
1034 XKW = 1.010e-14 ! H2O <==> H(aq) + OH(aq)
1036 IF (INT(TEMP) .NE. 298) THEN ! FOR T != 298K or 298.15K
1039 COEF= 1.0+LOG(T0T)-T0T
1040 XK1 = XK1 *EXP( 8.85*(T0T-1.0) + 25.140*COEF)
1041 XK21= XK21*EXP( 13.79*(T0T-1.0) - 5.393*COEF)
1042 XK22= XK22*EXP( -1.50*(T0T-1.0) + 26.920*COEF)
1043 XK4 = XK4 *EXP( 29.17*(T0T-1.0) + 16.830*COEF) !ISORR
1044 !CC XK4 = XK4 *EXP( 29.47*(T0T-1.0) + 16.840*COEF) ! SEQUIL
1045 XK41= XK41*EXP( 29.17*(T0T-1.0) + 16.830*COEF)
1046 XK7 = XK7 *EXP( -2.65*(T0T-1.0) + 38.570*COEF)
1047 XK10= XK10*EXP(-74.38*(T0T-1.0) + 6.120*COEF) ! ISORR
1048 !CC XK10= XK10*EXP(-75.11*(T0T-1.0) + 13.460*COEF) ! SEQUIL
1049 XK12= XK12*EXP( -2.87*(T0T-1.0) + 15.830*COEF)
1050 XK13= XK13*EXP( -5.19*(T0T-1.0) + 54.400*COEF)
1051 XKW = XKW *EXP(-22.52*(T0T-1.0) + 26.920*COEF)
1056 ! *** CALCULATE DELIQUESCENCE RELATIVE HUMIDITIES (UNICOMPONENT) ********
1063 IF (INT(TEMP) .NE. 298) THEN
1065 TCF = 1.0/TEMP - 1.0/T0
1066 DRNH4NO3 = DRNH4NO3*EXP(852.*TCF)
1067 DRNH42S4 = DRNH42S4*EXP( 80.*TCF)
1068 DRNH4HS4 = DRNH4HS4*EXP(384.*TCF)
1069 DRLC = DRLC *EXP(186.*TCF)
1070 DRNH4NO3 = MIN (DRNH4NO3,DRNH42S4) ! ADJUST FOR DRH CROSSOVER AT T<271K
1073 ! *** CALCULATE MUTUAL DELIQUESCENCE RELATIVE HUMIDITIES ****************
1075 DRMLCAB = 0.3780D0 ! (NH4)3H(SO4)2 & NH4HSO4
1076 DRMLCAS = 0.6900D0 ! (NH4)3H(SO4)2 & (NH4)2SO4
1077 DRMASAN = 0.6000D0 ! (NH4)2SO4 & NH4NO3
1078 !CC IF (INT(TEMP) .NE. 298) THEN ! For the time being
1080 !CC TCF = 1.0/TEMP - 1.0/T0
1081 !CC DRMLCAB = DRMLCAB*EXP( 507.506*TCF)
1082 !CC DRMLCAS = DRMLCAS*EXP( 133.865*TCF)
1083 !CC DRMASAN = DRMASAN*EXP(1269.068*TCF)
1086 ! *** LIQUID PHASE ******************************************************
1115 ! *** SOLID PHASE *******************************************************
1127 ! *** GAS PHASE *********************************************************
1133 ! *** CALCULATE ZSR PARAMETERS ******************************************
1135 IRH = MIN (INT(RH*NZSR+0.5),NZSR) ! Position in ZSR arrays
1138 ! M0(01) = AWSC(IRH) ! NACl
1139 ! IF (M0(01) .LT. 100.0) THEN
1141 ! CALL KMTAB(IC,298.0, GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1142 ! CALL KMTAB(IC,SNGL(TEMP),GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1143 ! M0(01) = M0(01)*EXP(LN10*(GI0-GII))
1146 ! M0(02) = AWSS(IRH) ! (NA)2SO4
1147 ! IF (M0(02) .LT. 100.0) THEN
1149 ! CALL KMTAB(IC,298.0, XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1150 ! CALL KMTAB(IC,SNGL(TEMP),XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1151 ! M0(02) = M0(02)*EXP(LN10*(GI0-GII))
1154 ! M0(03) = AWSN(IRH) ! NANO3
1155 ! IF (M0(03) .LT. 100.0) THEN
1157 ! CALL KMTAB(IC,298.0, XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1158 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1159 ! M0(03) = M0(03)*EXP(LN10*(GI0-GII))
1162 M0(04) = AWAS(IRH) ! (NH4)2SO4
1163 ! IF (M0(04) .LT. 100.0) THEN
1165 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX)
1166 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX)
1167 ! M0(04) = M0(04)*EXP(LN10*(GI0-GII))
1170 M0(05) = AWAN(IRH) ! NH4NO3
1171 ! IF (M0(05) .LT. 100.0) THEN
1173 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX)
1174 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX)
1175 ! M0(05) = M0(05)*EXP(LN10*(GI0-GII))
1178 ! M0(06) = AWAC(IRH) ! NH4CL
1179 ! IF (M0(06) .LT. 100.0) THEN
1181 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX)
1182 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX)
1183 ! M0(06) = M0(06)*EXP(LN10*(GI0-GII))
1186 M0(07) = AWSA(IRH) ! 2H-SO4
1187 ! IF (M0(07) .LT. 100.0) THEN
1189 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX)
1190 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX)
1191 ! M0(07) = M0(07)*EXP(LN10*(GI0-GII))
1194 M0(08) = AWSA(IRH) ! H-HSO4
1195 !CC IF (M0(08) .LT. 100.0) THEN ! These are redundant, because M0(8) is not used
1197 !CC CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
1198 !CC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
1199 !CCCCC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX)
1200 !CC M0(08) = M0(08)*EXP(LN10*(GI0-GII))
1203 M0(09) = AWAB(IRH) ! NH4HSO4
1204 ! IF (M0(09) .LT. 100.0) THEN
1206 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX)
1207 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX)
1208 ! M0(09) = M0(09)*EXP(LN10*(GI0-GII))
1211 ! M0(12) = AWSB(IRH) ! NAHSO4
1212 ! IF (M0(12) .LT. 100.0) THEN
1214 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GI0)
1215 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GII)
1216 ! M0(12) = M0(12)*EXP(LN10*(GI0-GII))
1219 M0(13) = AWLC(IRH) ! (NH4)3H(SO4)2
1220 ! IF (M0(13) .LT. 100.0) THEN
1222 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
1223 ! G130 = 0.2*(3.0*GI0+2.0*GII)
1224 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
1225 ! G13I = 0.2*(3.0*GI0+2.0*GII)
1226 ! M0(13) = M0(13)*EXP(LN10*SNGL(G130-G13I))
1229 ! *** OTHER INITIALIZATIONS *********************************************
1242 ERRMSG(I) = 'MESSAGE N/A'
1245 ! *** END OF SUBROUTINE INIT2 *******************************************
1247 END SUBROUTINE INIT2
1253 !=======================================================================
1255 ! *** ISORROPIA CODE
1256 ! *** SUBROUTINE ISOINIT3
1257 ! *** THIS SUBROUTINE INITIALIZES ALL GLOBAL VARIABLES FOR AMMONIUM,
1258 ! SODIUM, CHLORIDE, NITRATE, SULFATE AEROSOL SYSTEMS (SUBROUTINE
1261 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1262 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1263 ! *** WRITTEN BY ATHANASIOS NENES
1264 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1266 !=======================================================================
1268 SUBROUTINE ISOINIT3 (WI, RHI, TEMPI)
1270 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
1271 REAL(KIND=8) T0, T0T, COEF, TCF
1273 REAL IC,GII,GI0,XX,LN10
1274 PARAMETER (LN10=2.3025851)
1277 ! *** SAVE INPUT VARIABLES IN COMMON BLOCK ******************************
1279 IF (IPROB.EQ.0) THEN ! FORWARD CALCULATION
1281 W(I) = MAX(WI(I), TINY)
1284 DO 15 I=1,NCOMP ! REVERSE CALCULATION
1285 WAER(I) = MAX(WI(I), TINY)
1292 ! *** CALCULATE EQUILIBRIUM CONSTANTS ***********************************
1294 XK1 = 1.015D-2 ! HSO4(aq) <==> H(aq) + SO4(aq)
1295 XK21 = 57.639D0 ! NH3(g) <==> NH3(aq)
1296 XK22 = 1.805D-5 ! NH3(aq) <==> NH4(aq) + OH(aq)
1297 XK3 = 1.971D6 ! HCL(g) <==> H(aq) + CL(aq)
1298 XK31 = 2.500e3 ! HCL(g) <==> HCL(aq)
1299 XK4 = 2.511e6 ! HNO3(g) <==> H(aq) + NO3(aq) ! ISORR
1300 !CC XK4 = 3.638e6 ! HNO3(g) <==> H(aq) + NO3(aq) ! SEQUIL
1301 XK41 = 2.100e5 ! HNO3(g) <==> HNO3(aq)
1302 XK5 = 0.4799D0 ! NA2SO4(s) <==> 2*NA(aq) + SO4(aq)
1303 XK6 = 1.086D-16 ! NH4CL(s) <==> NH3(g) + HCL(g)
1304 XK7 = 1.817D0 ! (NH4)2SO4(s) <==> 2*NH4(aq) + SO4(aq)
1305 XK8 = 37.661D0 ! NACL(s) <==> NA(aq) + CL(aq)
1306 XK10 = 5.746D-17 ! NH4NO3(s) <==> NH3(g) + HNO3(g) ! ISORR
1307 !CC XK10 = 2.985e-17 ! NH4NO3(s) <==> NH3(g) + HNO3(g) ! SEQUIL
1308 XK11 = 2.413D4 ! NAHSO4(s) <==> NA(aq) + HSO4(aq)
1309 XK12 = 1.382D2 ! NH4HSO4(s) <==> NH4(aq) + HSO4(aq)
1310 XK13 = 29.268D0 ! (NH4)3H(SO4)2(s) <==> 3*NH4(aq) + HSO4(aq) + SO4(aq)
1311 XK14 = 22.05D0 ! NH4CL(s) <==> NH4(aq) + CL(aq)
1312 XKW = 1.010D-14 ! H2O <==> H(aq) + OH(aq)
1313 XK9 = 11.977D0 ! NANO3(s) <==> NA(aq) + NO3(aq)
1315 IF (INT(TEMP) .NE. 298) THEN ! FOR T != 298K or 298.15K
1318 COEF= 1.0+LOG(T0T)-T0T
1319 XK1 = XK1 *EXP( 8.85*(T0T-1.0) + 25.140*COEF)
1320 XK21= XK21*EXP( 13.79*(T0T-1.0) - 5.393*COEF)
1321 XK22= XK22*EXP( -1.50*(T0T-1.0) + 26.920*COEF)
1322 XK3 = XK3 *EXP( 30.20*(T0T-1.0) + 19.910*COEF)
1323 XK31= XK31*EXP( 30.20*(T0T-1.0) + 19.910*COEF)
1324 XK4 = XK4 *EXP( 29.17*(T0T-1.0) + 16.830*COEF) !ISORR
1325 !CC XK4 = XK4 *EXP( 29.47*(T0T-1.0) + 16.840*COEF) ! SEQUIL
1326 XK41= XK41*EXP( 29.17*(T0T-1.0) + 16.830*COEF)
1327 XK5 = XK5 *EXP( 0.98*(T0T-1.0) + 39.500*COEF)
1328 XK6 = XK6 *EXP(-71.00*(T0T-1.0) + 2.400*COEF)
1329 XK7 = XK7 *EXP( -2.65*(T0T-1.0) + 38.570*COEF)
1330 XK8 = XK8 *EXP( -1.56*(T0T-1.0) + 16.900*COEF)
1331 XK9 = XK9 *EXP( -8.22*(T0T-1.0) + 16.010*COEF)
1332 XK10= XK10*EXP(-74.38*(T0T-1.0) + 6.120*COEF) ! ISORR
1333 !CC XK10= XK10*EXP(-75.11*(T0T-1.0) + 13.460*COEF) ! SEQUIL
1334 XK11= XK11*EXP( 0.79*(T0T-1.0) + 14.746*COEF)
1335 XK12= XK12*EXP( -2.87*(T0T-1.0) + 15.830*COEF)
1336 XK13= XK13*EXP( -5.19*(T0T-1.0) + 54.400*COEF)
1337 XK14= XK14*EXP( 24.55*(T0T-1.0) + 16.900*COEF)
1338 XKW = XKW *EXP(-22.52*(T0T-1.0) + 26.920*COEF)
1344 ! *** CALCULATE DELIQUESCENCE RELATIVE HUMIDITIES (UNICOMPONENT) ********
1356 IF (INT(TEMP) .NE. 298) THEN
1358 TCF = 1.0/TEMP - 1.0/T0
1359 DRNACL = DRNACL *EXP( 25.*TCF)
1360 DRNANO3 = DRNANO3 *EXP(304.*TCF)
1361 DRNA2SO4 = DRNA2SO4*EXP( 80.*TCF)
1362 DRNH4NO3 = DRNH4NO3*EXP(852.*TCF)
1363 DRNH42S4 = DRNH42S4*EXP( 80.*TCF)
1364 DRNH4HS4 = DRNH4HS4*EXP(384.*TCF)
1365 DRLC = DRLC *EXP(186.*TCF)
1366 DRNH4CL = DRNH4Cl *EXP(239.*TCF)
1367 DRNAHSO4 = DRNAHSO4*EXP(-45.*TCF)
1369 ! *** ADJUST FOR DRH "CROSSOVER" AT LOW TEMPERATURES
1371 DRNH4NO3 = MIN (DRNH4NO3, DRNH4CL, DRNH42S4, DRNANO3, DRNACL)
1372 DRNANO3 = MIN (DRNANO3, DRNACL)
1373 DRNH4CL = MIN (DRNH4Cl, DRNH42S4)
1377 ! *** CALCULATE MUTUAL DELIQUESCENCE RELATIVE HUMIDITIES ****************
1379 DRMLCAB = 0.378D0 ! (NH4)3H(SO4)2 & NH4HSO4
1380 DRMLCAS = 0.690D0 ! (NH4)3H(SO4)2 & (NH4)2SO4
1381 DRMASAN = 0.600D0 ! (NH4)2SO4 & NH4NO3
1382 DRMG1 = 0.460D0 ! (NH4)2SO4, NH4NO3, NA2SO4, NH4CL
1383 DRMG2 = 0.691D0 ! (NH4)2SO4, NA2SO4, NH4CL
1384 DRMG3 = 0.697D0 ! (NH4)2SO4, NA2SO4
1385 DRMH1 = 0.240D0 ! NA2SO4, NANO3, NACL, NH4NO3, NH4CL
1386 DRMH2 = 0.596D0 ! NA2SO4, NANO3, NACL, NH4CL
1387 DRMI1 = 0.240D0 ! LC, NAHSO4, NH4HSO4, NA2SO4, (NH4)2SO4
1388 DRMI2 = 0.363D0 ! LC, NAHSO4, NA2SO4, (NH4)2SO4 - NO DATA -
1389 DRMI3 = 0.610D0 ! LC, NA2SO4, (NH4)2SO4
1390 DRMQ1 = 0.494D0 ! (NH4)2SO4, NH4NO3, NA2SO4
1391 DRMR1 = 0.663D0 ! NA2SO4, NANO3, NACL
1392 DRMR2 = 0.735D0 ! NA2SO4, NACL
1393 DRMR3 = 0.673D0 ! NANO3, NACL
1394 DRMR4 = 0.694D0 ! NA2SO4, NACL, NH4CL
1395 DRMR5 = 0.731D0 ! NA2SO4, NH4CL
1396 DRMR6 = 0.596D0 ! NA2SO4, NANO3, NH4CL
1397 DRMR7 = 0.380D0 ! NA2SO4, NANO3, NACL, NH4NO3
1398 DRMR8 = 0.380D0 ! NA2SO4, NACL, NH4NO3
1399 DRMR9 = 0.494D0 ! NA2SO4, NH4NO3
1400 DRMR10 = 0.476D0 ! NA2SO4, NANO3, NH4NO3
1401 DRMR11 = 0.340D0 ! NA2SO4, NACL, NH4NO3, NH4CL
1402 DRMR12 = 0.460D0 ! NA2SO4, NH4NO3, NH4CL
1403 DRMR13 = 0.438D0 ! NA2SO4, NANO3, NH4NO3, NH4CL
1404 !CC IF (INT(TEMP) .NE. 298) THEN
1406 !CC TCF = 1.0/TEMP - 1.0/T0
1407 !CC DRMLCAB = DRMLCAB*EXP( 507.506*TCF)
1408 !CC DRMLCAS = DRMLCAS*EXP( 133.865*TCF)
1409 !CC DRMASAN = DRMASAN*EXP(1269.068*TCF)
1410 !CC DRMG1 = DRMG1 *EXP( 572.207*TCF)
1411 !CC DRMG2 = DRMG2 *EXP( 58.166*TCF)
1412 !CC DRMG3 = DRMG3 *EXP( 22.253*TCF)
1413 !CC DRMH1 = DRMH1 *EXP(2116.542*TCF)
1414 !CC DRMH2 = DRMH2 *EXP( 650.549*TCF)
1415 !CC DRMI1 = DRMI1 *EXP( 565.743*TCF)
1416 !CC DRMI2 = DRMI2 *EXP( 91.745*TCF)
1417 !CC DRMI3 = DRMI3 *EXP( 161.272*TCF)
1418 !CC DRMQ1 = DRMQ1 *EXP(1616.621*TCF)
1419 !CC DRMR1 = DRMR1 *EXP( 292.564*TCF)
1420 !CC DRMR2 = DRMR2 *EXP( 14.587*TCF)
1421 !CC DRMR3 = DRMR3 *EXP( 307.907*TCF)
1422 !CC DRMR4 = DRMR4 *EXP( 97.605*TCF)
1423 !CC DRMR5 = DRMR5 *EXP( 98.523*TCF)
1424 !CC DRMR6 = DRMR6 *EXP( 465.500*TCF)
1425 !CC DRMR7 = DRMR7 *EXP( 324.425*TCF)
1426 !CC DRMR8 = DRMR8 *EXP(2660.184*TCF)
1427 !CC DRMR9 = DRMR9 *EXP(1617.178*TCF)
1428 !CC DRMR10 = DRMR10 *EXP(1745.226*TCF)
1429 !CC DRMR11 = DRMR11 *EXP(3691.328*TCF)
1430 !CC DRMR12 = DRMR12 *EXP(1836.842*TCF)
1431 !CC DRMR13 = DRMR13 *EXP(1967.938*TCF)
1434 ! *** LIQUID PHASE ******************************************************
1463 ! *** SOLID PHASE *******************************************************
1475 ! *** GAS PHASE *********************************************************
1481 ! *** CALCULATE ZSR PARAMETERS ******************************************
1483 IRH = MIN (INT(RH*NZSR+0.5),NZSR) ! Position in ZSR arrays
1486 M0(01) = AWSC(IRH) ! NACl
1487 ! IF (M0(01) .LT. 100.0) THEN
1489 ! CALL KMTAB(IC,298.0, GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1490 ! CALL KMTAB(IC,SNGL(TEMP),GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1491 ! M0(01) = M0(01)*EXP(LN10*(GI0-GII))
1494 M0(02) = AWSS(IRH) ! (NA)2SO4
1495 ! IF (M0(02) .LT. 100.0) THEN
1497 ! CALL KMTAB(IC,298.0, XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1498 ! CALL KMTAB(IC,SNGL(TEMP),XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1499 ! M0(02) = M0(02)*EXP(LN10*(GI0-GII))
1502 M0(03) = AWSN(IRH) ! NANO3
1503 ! IF (M0(03) .LT. 100.0) THEN
1505 ! CALL KMTAB(IC,298.0, XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1506 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX,XX)
1507 ! M0(03) = M0(03)*EXP(LN10*(GI0-GII))
1510 M0(04) = AWAS(IRH) ! (NH4)2SO4
1511 ! IF (M0(04) .LT. 100.0) THEN
1513 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX,XX)
1514 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX,XX)
1515 ! M0(04) = M0(04)*EXP(LN10*(GI0-GII))
1518 M0(05) = AWAN(IRH) ! NH4NO3
1519 ! IF (M0(05) .LT. 100.0) THEN
1521 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX,XX)
1522 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX,XX)
1523 ! M0(05) = M0(05)*EXP(LN10*(GI0-GII))
1526 M0(06) = AWAC(IRH) ! NH4CL
1527 ! IF (M0(06) .LT. 100.0) THEN
1529 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX,XX)
1530 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX,XX)
1531 ! M0(06) = M0(06)*EXP(LN10*(GI0-GII))
1534 M0(07) = AWSA(IRH) ! 2H-SO4
1535 ! IF (M0(07) .LT. 100.0) THEN
1537 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX,XX)
1538 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX,XX)
1539 ! M0(07) = M0(07)*EXP(LN10*(GI0-GII))
1542 M0(08) = AWSA(IRH) ! H-HSO4
1543 !CC IF (M0(08) .LT. 100.0) THEN ! These are redundant, because M0(8) is not used
1545 !CC CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
1546 !CC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX,XX)
1547 !CCCCC CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX,XX)
1548 !CC M0(08) = M0(08)*EXP(LN10*(GI0-GII))
1551 M0(09) = AWAB(IRH) ! NH4HSO4
1552 ! IF (M0(09) .LT. 100.0) THEN
1554 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,GI0,XX,XX,XX)
1555 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,GII,XX,XX,XX)
1556 ! M0(09) = M0(09)*EXP(LN10*(GI0-GII))
1559 M0(12) = AWSB(IRH) ! NAHSO4
1560 ! IF (M0(12) .LT. 100.0) THEN
1562 ! CALL KMTAB(IC,298.0, XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GI0)
1563 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,GII)
1564 ! M0(12) = M0(12)*EXP(LN10*(GI0-GII))
1567 M0(13) = AWLC(IRH) ! (NH4)3H(SO4)2
1568 ! IF (M0(13) .LT. 100.0) THEN
1570 ! CALL KMTAB(IC,298.0, XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
1571 ! G130 = 0.2*(3.0*GI0+2.0*GII)
1572 ! CALL KMTAB(IC,SNGL(TEMP),XX,XX,XX,GI0,XX,XX,XX,XX,GII,XX,XX,XX)
1573 ! G13I = 0.2*(3.0*GI0+2.0*GII)
1574 ! M0(13) = M0(13)*EXP(LN10*SNGL(G130-G13I))
1577 ! *** OTHER INITIALIZATIONS *********************************************
1589 ERRMSG(I) = 'MESSAGE N/A'
1593 ! *** END OF SUBROUTINE ISOINIT3 *******************************************
1595 END SUBROUTINE ISOINIT3
1597 !=======================================================================
1599 ! *** ISORROPIA CODE
1600 ! *** SUBROUTINE ADJUST
1601 ! *** ADJUSTS FOR MASS BALANCE BETWEEN VOLATILE SPECIES AND SULFATE
1602 ! FIRST CALCULATE THE EXCESS OF EACH PRECURSOR, AND IF IT EXISTS, THEN
1603 ! ADJUST SEQUENTIALY AEROSOL PHASE SPECIES WHICH CONTAIN THE EXCESS
1606 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1607 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1608 ! *** WRITTEN BY ATHANASIOS NENES
1609 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1611 !=======================================================================
1613 SUBROUTINE ADJUST (WI)
1616 REAL(KIND=8) EXNH4, EXNO3, EXCl, EXS4
1618 ! *** FOR AMMONIUM *****************************************************
1620 IF (IPROB.EQ.0) THEN ! Calculate excess (solution - input)
1621 EXNH4 = GNH3 + MOLAL(3) + CNH4CL + CNH4NO3 + CNH4HS4 &
1622 + 2D0*CNH42S4 + 3D0*CLC &
1625 EXNH4 = MOLAL(3) + CNH4CL + CNH4NO3 + CNH4HS4 + 2D0*CNH42S4 &
1630 EXNH4 = MAX(EXNH4,ZERO)
1631 IF (EXNH4.LT.TINY) GOTO 20 ! No excess NH4, go to next precursor
1633 IF (MOLAL(3).GT.EXNH4) THEN ! Adjust aqueous phase NH4
1634 MOLAL(3) = MOLAL(3) - EXNH4
1637 EXNH4 = EXNH4 - MOLAL(3)
1641 IF (CNH4CL.GT.EXNH4) THEN ! Adjust NH4Cl(s)
1642 CNH4CL = CNH4CL - EXNH4 ! more solid than excess
1643 GHCL = GHCL + EXNH4 ! evaporate Cl to gas phase
1645 ELSE ! less solid than excess
1646 GHCL = GHCL + CNH4CL ! evaporate into gas phase
1647 EXNH4 = EXNH4 - CNH4CL ! reduce excess
1648 CNH4CL = ZERO ! zero salt concentration
1651 IF (CNH4NO3.GT.EXNH4) THEN ! Adjust NH4NO3(s)
1652 CNH4NO3 = CNH4NO3- EXNH4 ! more solid than excess
1653 GHNO3 = GHNO3 + EXNH4 ! evaporate NO3 to gas phase
1655 ELSE ! less solid than excess
1656 GHNO3 = GHNO3 + CNH4NO3! evaporate into gas phase
1657 EXNH4 = EXNH4 - CNH4NO3! reduce excess
1658 CNH4NO3 = ZERO ! zero salt concentration
1661 IF (CLC.GT.3d0*EXNH4) THEN ! Adjust (NH4)3H(SO4)2(s)
1662 CLC = CLC - EXNH4/3d0 ! more solid than excess
1664 ELSE ! less solid than excess
1665 EXNH4 = EXNH4 - 3d0*CLC ! reduce excess
1666 CLC = ZERO ! zero salt concentration
1669 IF (CNH4HS4.GT.EXNH4) THEN ! Adjust NH4HSO4(s)
1670 CNH4HS4 = CNH4HS4- EXNH4 ! more solid than excess
1672 ELSE ! less solid than excess
1673 EXNH4 = EXNH4 - CNH4HS4! reduce excess
1674 CNH4HS4 = ZERO ! zero salt concentration
1677 IF (CNH42S4.GT.EXNH4) THEN ! Adjust (NH4)2SO4(s)
1678 CNH42S4 = CNH42S4- EXNH4 ! more solid than excess
1680 ELSE ! less solid than excess
1681 EXNH4 = EXNH4 - CNH42S4! reduce excess
1682 CNH42S4 = ZERO ! zero salt concentration
1685 ! *** FOR NITRATE ******************************************************
1687 20 IF (IPROB.EQ.0) THEN ! Calculate excess (solution - input)
1688 EXNO3 = GHNO3 + MOLAL(7) + CNH4NO3 - WI(4)
1690 EXNO3 = MOLAL(7) + CNH4NO3 - WI(4)
1692 EXNO3 = MAX(EXNO3,ZERO)
1693 IF (EXNO3.LT.TINY) GOTO 30 ! No excess NO3, go to next precursor
1695 IF (MOLAL(7).GT.EXNO3) THEN ! Adjust aqueous phase NO3
1696 MOLAL(7) = MOLAL(7) - EXNO3
1699 EXNO3 = EXNO3 - MOLAL(7)
1703 IF (CNH4NO3.GT.EXNO3) THEN ! Adjust NH4NO3(s)
1704 CNH4NO3 = CNH4NO3- EXNO3 ! more solid than excess
1705 GNH3 = GNH3 + EXNO3 ! evaporate NO3 to gas phase
1707 ELSE ! less solid than excess
1708 GNH3 = GNH3 + CNH4NO3! evaporate into gas phase
1709 EXNO3 = EXNO3 - CNH4NO3! reduce excess
1710 CNH4NO3 = ZERO ! zero salt concentration
1713 ! *** FOR CHLORIDE *****************************************************
1715 30 IF (IPROB.EQ.0) THEN ! Calculate excess (solution - input)
1716 EXCl = GHCL + MOLAL(4) + CNH4CL -WI(5)
1718 EXCl = MOLAL(4) + CNH4CL -WI(5)
1720 EXCl = MAX(EXCl,ZERO)
1721 IF (EXCl.LT.TINY) GOTO 40 ! No excess Cl, go to next precursor
1723 IF (MOLAL(4).GT.EXCL) THEN ! Adjust aqueous phase Cl
1724 MOLAL(4) = MOLAL(4) - EXCL
1727 EXCL = EXCL - MOLAL(4)
1731 IF (CNH4CL.GT.EXCL) THEN ! Adjust NH4Cl(s)
1732 CNH4CL = CNH4CL - EXCL ! more solid than excess
1733 GHCL = GHCL + EXCL ! evaporate Cl to gas phase
1735 ELSE ! less solid than excess
1736 GHCL = GHCL + CNH4CL ! evaporate into gas phase
1737 EXCL = EXCL - CNH4CL ! reduce excess
1738 CNH4CL = ZERO ! zero salt concentration
1741 ! *** FOR SULFATE ******************************************************
1743 40 EXS4 = MOLAL(5) + MOLAL(6) + 2.d0*CLC + CNH42S4 + CNH4HS4 +&
1744 CNA2SO4 + CNAHSO4 - WI(2)
1745 EXS4 = MAX(EXS4,ZERO) ! Calculate excess (solution - input)
1746 IF (EXS4.LT.TINY) GOTO 50 ! No excess SO4, return
1748 IF (MOLAL(6).GT.EXS4) THEN ! Adjust aqueous phase HSO4
1749 MOLAL(6) = MOLAL(6) - EXS4
1752 EXS4 = EXS4 - MOLAL(6)
1756 IF (MOLAL(5).GT.EXS4) THEN ! Adjust aqueous phase SO4
1757 MOLAL(5) = MOLAL(5) - EXS4
1760 EXS4 = EXS4 - MOLAL(5)
1764 IF (CLC.GT.2d0*EXS4) THEN ! Adjust (NH4)3H(SO4)2(s)
1765 CLC = CLC - EXS4/2d0 ! more solid than excess
1766 GNH3 = GNH3 +1.5d0*EXS4! evaporate NH3 to gas phase
1768 ELSE ! less solid than excess
1769 GNH3 = GNH3 + 1.5d0*CLC! evaporate NH3 to gas phase
1770 EXS4 = EXS4 - 2d0*CLC ! reduce excess
1771 CLC = ZERO ! zero salt concentration
1774 IF (CNH4HS4.GT.EXS4) THEN ! Adjust NH4HSO4(s)
1775 CNH4HS4 = CNH4HS4 - EXS4 ! more solid than excess
1776 GNH3 = GNH3 + EXS4 ! evaporate NH3 to gas phase
1778 ELSE ! less solid than excess
1779 GNH3 = GNH3 + CNH4HS4 ! evaporate NH3 to gas phase
1780 EXS4 = EXS4 - CNH4HS4 ! reduce excess
1781 CNH4HS4 = ZERO ! zero salt concentration
1784 IF (CNH42S4.GT.EXS4) THEN ! Adjust (NH4)2SO4(s)
1785 CNH42S4 = CNH42S4- EXS4 ! more solid than excess
1786 GNH3 = GNH3 + 2.d0*EXS4! evaporate NH3 to gas phase
1788 ELSE ! less solid than excess
1789 GNH3 = GNH3+2.d0*CNH42S4 ! evaporate NH3 to gas phase
1790 EXS4 = EXS4 - CNH42S4 ! reduce excess
1791 CNH42S4 = ZERO ! zero salt concentration
1794 ! *** RETURN **********************************************************
1797 END SUBROUTINE ADJUST
1800 !=======================================================================
1802 ! *** ISORROPIA CODE
1803 ! *** SUBROUTINE CALCHA
1804 ! *** CALCULATES CHLORIDES SPECIATION
1806 ! HYDROCHLORIC ACID IN THE LIQUID PHASE IS ASSUMED A MINOR SPECIES,
1807 ! AND DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM. THE
1808 ! HYDROCHLORIC ACID DISSOLVED IS CALCULATED FROM THE
1809 ! HCL(G) <-> (H+) + (CL-)
1810 ! EQUILIBRIUM, USING THE (H+) FROM THE SULFATES.
1812 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1813 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1814 ! *** WRITTEN BY ATHANASIOS NENES
1815 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1817 !=======================================================================
1821 REAL(KIND=8) KAPA, X, DELT, DIAK, ALFA, GHCL
1822 !C CHARACTER ERRINF*40
1824 ! *** CALCULATE HCL DISSOLUTION *****************************************
1828 IF (WATER.GT.TINY) THEN
1830 ALFA = XK3*R*TEMP*(WATER/GAMA(11))**2.0
1831 DIAK = SQRT( (KAPA+ALFA)**2.0 + 4.0*ALFA*X)
1832 DELT = 0.5*(-(KAPA+ALFA) + DIAK)
1833 !C IF (DELT/KAPA.GT.0.1d0) THEN
1834 !C WRITE (ERRINF,'(1PE10.3)') DELT/KAPA*100.0
1835 !C CALL PUSHERR (0033, ERRINF)
1839 ! *** CALCULATE HCL SPECIATION IN THE GAS PHASE *************************
1841 GHCL = MAX(X-DELT, 0.0d0) ! GAS HCL
1843 ! *** CALCULATE HCL SPECIATION IN THE LIQUID PHASE **********************
1845 MOLAL(4) = DELT ! CL-
1846 MOLAL(1) = MOLAL(1) + DELT ! H+
1850 ! *** END OF SUBROUTINE CALCHA ******************************************
1852 END SUBROUTINE CALCHA
1858 !=======================================================================
1860 ! *** ISORROPIA CODE
1861 ! *** SUBROUTINE CALCHAP
1862 ! *** CALCULATES CHLORIDES SPECIATION
1864 ! HYDROCHLORIC ACID IN THE LIQUID PHASE IS ASSUMED A MINOR SPECIES,
1865 ! THAT DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM.
1866 ! THE HYDROCHLORIC ACID DISSOLVED IS CALCULATED FROM THE
1867 ! HCL(G) -> HCL(AQ) AND HCL(AQ) -> (H+) + (CL-)
1868 ! EQUILIBRIA, USING (H+) FROM THE SULFATES.
1870 ! THIS IS THE VERSION USED BY THE INVERSE PROBLEM SOVER
1872 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1873 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1874 ! *** WRITTEN BY ATHANASIOS NENES
1875 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1877 !=======================================================================
1881 REAL(KIND=8) ALFA, DELT
1883 ! *** IS THERE A LIQUID PHASE? ******************************************
1885 IF (WATER.LE.TINY) RETURN
1887 ! *** CALCULATE HCL SPECIATION IN THE GAS PHASE *************************
1889 CALL CALCCLAQ (MOLAL(4), MOLAL(1), DELT)
1890 ALFA = XK3*R*TEMP*(WATER/GAMA(11))**2.0
1892 MOLAL(1) = MOLAL(1) - DELT
1893 MOLAL(4) = MOLAL(4) - DELT
1894 GHCL = MOLAL(1)*MOLAL(4)/ALFA
1898 ! *** END OF SUBROUTINE CALCHAP *****************************************
1900 END SUBROUTINE CALCHAP
1903 !=======================================================================
1905 ! *** ISORROPIA CODE
1906 ! *** SUBROUTINE CALCNA
1907 ! *** CALCULATES NITRATES SPECIATION
1909 ! NITRIC ACID IN THE LIQUID PHASE IS ASSUMED A MINOR SPECIES, THAT
1910 ! DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM. THE NITRIC
1911 ! ACID DISSOLVED IS CALCULATED FROM THE HNO3(G) -> (H+) + (NO3-)
1912 ! EQUILIBRIUM, USING THE (H+) FROM THE SULFATES.
1914 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1915 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1916 ! *** WRITTEN BY ATHANASIOS NENES
1917 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1919 !=======================================================================
1923 REAL(KIND=8) X, DELT, DIAK, GHNO3, ALFA
1925 !C CHARACTER ERRINF*40
1927 ! *** CALCULATE HNO3 DISSOLUTION ****************************************
1931 IF (WATER.GT.TINY) THEN
1933 ALFA = XK4*R*TEMP*(WATER/GAMA(10))**2.0
1934 DIAK = SQRT( (KAPA+ALFA)**2.0 + 4.0*ALFA*X)
1935 DELT = 0.5*(-(KAPA+ALFA) + DIAK)
1936 !C IF (DELT/KAPA.GT.0.1d0) THEN
1937 !C WRITE (ERRINF,'(1PE10.3)') DELT/KAPA*100.0
1938 !C CALL PUSHERR (0019, ERRINF) ! WARNING ERROR: NO SOLUTION
1942 ! *** CALCULATE HNO3 SPECIATION IN THE GAS PHASE ************************
1944 GHNO3 = MAX(X-DELT, 0.0d0) ! GAS HNO3
1946 ! *** CALCULATE HNO3 SPECIATION IN THE LIQUID PHASE *********************
1948 MOLAL(7) = DELT ! NO3-
1949 MOLAL(1) = MOLAL(1) + DELT ! H+
1953 ! *** END OF SUBROUTINE CALCNA ******************************************
1955 END SUBROUTINE CALCNA
1959 !=======================================================================
1961 ! *** ISORROPIA CODE
1962 ! *** SUBROUTINE CALCNAP
1963 ! *** CALCULATES NITRATES SPECIATION
1965 ! NITRIC ACID IN THE LIQUID PHASE IS ASSUMED A MINOR SPECIES, THAT
1966 ! DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM. THE NITRIC
1967 ! ACID DISSOLVED IS CALCULATED FROM THE HNO3(G) -> HNO3(AQ) AND
1968 ! HNO3(AQ) -> (H+) + (CL-) EQUILIBRIA, USING (H+) FROM THE SULFATES.
1970 ! THIS IS THE VERSION USED BY THE INVERSE PROBLEM SOVER
1972 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1973 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1974 ! *** WRITTEN BY ATHANASIOS NENES
1975 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
1977 !=======================================================================
1981 REAL(KIND=8) ALFA, DELT
1983 ! *** IS THERE A LIQUID PHASE? ******************************************
1985 IF (WATER.LE.TINY) RETURN
1987 ! *** CALCULATE HNO3 SPECIATION IN THE GAS PHASE ************************
1989 CALL CALCNIAQ (MOLAL(7), MOLAL(1), DELT)
1990 ALFA = XK4*R*TEMP*(WATER/GAMA(10))**2.0
1992 MOLAL(1) = MOLAL(1) - DELT
1993 MOLAL(7) = MOLAL(7) - DELT
1994 GHNO3 = MOLAL(1)*MOLAL(7)/ALFA
1996 write (*,*) ALFA, MOLAL(1), MOLAL(7), GHNO3, DELT
2000 ! *** END OF SUBROUTINE CALCNAP *****************************************
2002 END SUBROUTINE CALCNAP
2004 !=======================================================================
2006 ! *** ISORROPIA CODE
2007 ! *** SUBROUTINE CALCNH3
2008 ! *** CALCULATES AMMONIA IN GAS PHASE
2010 ! AMMONIA IN THE GAS PHASE IS ASSUMED A MINOR SPECIES, THAT
2011 ! DOES NOT SIGNIFICANTLY PERTURB THE AEROSOL EQUILIBRIUM.
2012 ! AMMONIA GAS IS CALCULATED FROM THE NH3(g) + (H+)(l) <==> (NH4+)(l)
2013 ! EQUILIBRIUM, USING (H+), (NH4+) FROM THE AEROSOL SOLUTION.
2015 ! THIS IS THE VERSION USED BY THE DIRECT PROBLEM
2017 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2018 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2019 ! *** WRITTEN BY ATHANASIOS NENES
2020 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2022 !=======================================================================
2026 REAL(KIND=8) BB, CC, DIAK, PSI
2028 ! *** IS THERE A LIQUID PHASE? ******************************************
2030 IF (WATER.LE.TINY) RETURN
2032 ! *** CALCULATE NH3 SUBLIMATION *****************************************
2034 A1 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2038 BB =(CHI2 + ONE/A1) ! a=1; b!=1; c!=1
2040 DIAK = SQRT(BB*BB - 4.D0*CC) ! Always > 0
2041 PSI = 0.5*(-BB + DIAK) ! One positive root
2042 PSI = MAX(TINY, MIN(PSI,CHI1))! Constrict in acceptible range
2044 ! *** CALCULATE NH3 SPECIATION IN THE GAS PHASE *************************
2046 GNH3 = PSI ! GAS HNO3
2048 ! *** CALCULATE NH3 AFFECT IN THE LIQUID PHASE **************************
2050 MOLAL(3) = CHI1 - PSI ! NH4+
2051 MOLAL(1) = CHI2 + PSI ! H+
2055 ! *** END OF SUBROUTINE CALCNH3 *****************************************
2057 END SUBROUTINE CALCNH3
2061 !=======================================================================
2063 ! *** ISORROPIA CODE
2064 ! *** SUBROUTINE CALCNH3P
2065 ! *** CALCULATES AMMONIA IN GAS PHASE
2067 ! AMMONIA GAS IS CALCULATED FROM THE NH3(g) + (H+)(l) <==> (NH4+)(l)
2068 ! EQUILIBRIUM, USING (H+), (NH4+) FROM THE AEROSOL SOLUTION.
2070 ! THIS IS THE VERSION USED BY THE INVERSE PROBLEM SOLVER
2072 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2073 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2074 ! *** WRITTEN BY ATHANASIOS NENES
2075 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2077 !=======================================================================
2082 ! *** IS THERE A LIQUID PHASE? ******************************************
2084 IF (WATER.LE.TINY) RETURN
2086 ! *** CALCULATE NH3 GAS PHASE CONCENTRATION *****************************
2088 A1 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2089 GNH3 = MOLAL(3)/MOLAL(1)/A1
2093 ! *** END OF SUBROUTINE CALCNH3P ****************************************
2095 END SUBROUTINE CALCNH3P
2098 !=======================================================================
2100 ! *** ISORROPIA CODE
2101 ! *** SUBROUTINE CALCNHA
2103 ! THIS SUBROUTINE CALCULATES THE DISSOLUTION OF HCL, HNO3 AT
2104 ! THE PRESENCE OF (H,SO4). HCL, HNO3 ARE CONSIDERED MINOR SPECIES,
2105 ! THAT DO NOT SIGNIFICANTLY AFFECT THE EQUILIBRIUM POINT.
2107 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2108 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2109 ! *** WRITTEN BY ATHANASIOS NENES
2110 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2112 !=======================================================================
2116 REAL(KIND=8) M1, M2, M3
2117 REAL(KIND=8) DELCL, DELNO, OMEGA, C1, C2, C3
2121 ! *** SPECIAL CASE; WATER=ZERO ******************************************
2123 IF (WATER.LE.TINY) THEN
2126 ! *** SPECIAL CASE; HCL=HNO3=ZERO ***************************************
2128 ELSEIF (W(5).LE.TINY .AND. W(4).LE.TINY) THEN
2131 ! *** SPECIAL CASE; HCL=ZERO ********************************************
2133 ELSE IF (W(5).LE.TINY) THEN
2134 CALL CALCNA ! CALL HNO3 DISSOLUTION ROUTINE
2137 ! *** SPECIAL CASE; HNO3=ZERO *******************************************
2139 ELSE IF (W(4).LE.TINY) THEN
2140 CALL CALCHA ! CALL HCL DISSOLUTION ROUTINE
2144 ! *** CALCULATE EQUILIBRIUM CONSTANTS ***********************************
2146 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0 ! HNO3
2147 A4 = XK3*R*TEMP*(WATER/GAMA(11))**2.0 ! HCL
2149 ! *** CALCULATE CUBIC EQUATION COEFFICIENTS *****************************
2154 OMEGA = MOLAL(1) ! H+
2162 M1 = (C1 + C2 + (OMEGA+A4)*C3)/C3
2163 M2 = ((OMEGA+A4)*C2 - A4*C3*CHI4)/C3
2166 ! *** CALCULATE ROOTS ***************************************************
2168 CALL POLY3 (M1, M2, M3, DELCL, ISLV) ! HCL DISSOLUTION
2170 DELCL = TINY ! TINY AMOUNTS OF HCL ASSUMED WHEN NO ROOT
2171 WRITE (ERRINF,'(1PE7.1)') TINY
2172 CALL PUSHERR (0022, ERRINF) ! WARNING ERROR: NO SOLUTION
2174 DELCL = MIN(DELCL, CHI4)
2176 DELNO = C1*DELCL/(C2 + C3*DELCL)
2177 DELNO = MIN(DELNO, CHI3)
2179 IF (DELCL.LT.ZERO .OR. DELNO.LT.ZERO .OR.&
2180 DELCL.GT.CHI4 .OR. DELNO.GT.CHI3 ) THEN
2181 DELCL = TINY ! TINY AMOUNTS OF HCL ASSUMED WHEN NO ROOT
2183 WRITE (ERRINF,'(1PE7.1)') TINY
2184 CALL PUSHERR (0022, ERRINF) ! WARNING ERROR: NO SOLUTION
2187 !CC *** COMPARE DELTA TO TOTAL H+ ; ESTIMATE EFFECT TO HSO4 ***************
2189 !C IF ((DELCL+DELNO)/MOLAL(1).GT.0.1d0) THEN
2190 !C WRITE (ERRINF,'(1PE10.3)') (DELCL+DELNO)/MOLAL(1)*100.0
2191 !C CALL PUSHERR (0021, ERRINF)
2194 ! *** EFFECT ON LIQUID PHASE ********************************************
2196 50 MOLAL(1) = MOLAL(1) + (DELNO+DELCL) ! H+ CHANGE
2197 MOLAL(4) = MOLAL(4) + DELCL ! CL- CHANGE
2198 MOLAL(7) = MOLAL(7) + DELNO ! NO3- CHANGE
2200 ! *** EFFECT ON GAS PHASE ***********************************************
2202 55 GHCL = MAX(W(5) - MOLAL(4), TINY)
2203 GHNO3 = MAX(W(4) - MOLAL(7), TINY)
2207 ! *** END OF SUBROUTINE CALCNHA *****************************************
2209 END SUBROUTINE CALCNHA
2213 !=======================================================================
2215 ! *** ISORROPIA CODE
2216 ! *** SUBROUTINE CALCNHP
2218 ! THIS SUBROUTINE CALCULATES THE GAS PHASE NITRIC AND HYDROCHLORIC
2219 ! ACID. CONCENTRATIONS ARE CALCULATED FROM THE DISSOLUTION
2220 ! EQUILIBRIA, USING (H+), (Cl-), (NO3-) IN THE AEROSOL PHASE.
2222 ! THIS IS THE VERSION USED BY THE INVERSE PROBLEM SOLVER
2224 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2225 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2226 ! *** WRITTEN BY ATHANASIOS NENES
2227 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2229 !=======================================================================
2235 ! *** IS THERE A LIQUID PHASE? ******************************************
2237 IF (WATER.LE.TINY) RETURN
2239 ! *** CALCULATE EQUILIBRIUM CONSTANTS ***********************************
2241 A3 = XK3*R*TEMP*(WATER/GAMA(11))**2.0
2242 A4 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
2243 MOLAL(1) = MOLAL(1) + WAER(4) + WAER(5) ! H+ increases because NO3, Cl are added.
2245 ! *** CALCULATE CONCENTRATIONS ******************************************
2246 ! *** ASSUME THAT 'DELT' FROM HNO3 >> 'DELT' FROM HCL
2248 CALL CALCNIAQ (WAER(4), MOLAL(1)+MOLAL(7)+MOLAL(4), DELT)
2249 MOLAL(1) = MOLAL(1) - DELT
2250 MOLAL(7) = WAER(4) - DELT ! NO3- = Waer(4) minus any turned into (HNO3aq)
2253 CALL CALCCLAQ (WAER(5), MOLAL(1)+MOLAL(7)+MOLAL(4), DELT)
2254 MOLAL(1) = MOLAL(1) - DELT
2255 MOLAL(4) = WAER(5) - DELT ! Cl- = Waer(4) minus any turned into (HNO3aq)
2258 GHNO3 = MOLAL(1)*MOLAL(7)/A4
2259 GHCL = MOLAL(1)*MOLAL(4)/A3
2263 ! *** END OF SUBROUTINE CALCNHP *****************************************
2265 END SUBROUTINE CALCNHP
2267 !=======================================================================
2269 ! *** ISORROPIA CODE
2270 ! *** SUBROUTINE CALCAMAQ
2271 ! *** THIS SUBROUTINE CALCULATES THE NH3(aq) GENERATED FROM (H,NH4+).
2273 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2274 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2275 ! *** WRITTEN BY ATHANASIOS NENES
2276 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2278 !=======================================================================
2280 SUBROUTINE CALCAMAQ (NH4I, OHI, DELT)
2282 REAL(KIND=8) NH4I, OHI, DELT, DEL1, DEL2
2283 REAL(KIND=8) A22, AKW, OM1, OM2, BB, CC, DD
2285 !C CHARACTER ERRINF*40
2287 ! *** EQUILIBRIUM CONSTANTS
2289 A22 = XK22/XKW/WATER*(GAMA(8)/GAMA(9))**2. ! GAMA(NH3) ASSUMED 1
2290 AKW = XKW *RH*WATER*WATER
2296 BB =-(OM1+OM2+A22*AKW)
2298 DD = SQRT(BB*BB-4.D0*CC)
2299 DEL1 = 0.5D0*(-BB - DD)
2300 DEL2 = 0.5D0*(-BB + DD)
2302 ! *** GET APPROPRIATE ROOT.
2304 IF (DEL1.LT.ZERO) THEN
2305 IF (DEL2.GT.NH4I .OR. DEL2.GT.OHI) THEN
2314 !C *** COMPARE DELTA TO TOTAL NH4+ ; ESTIMATE EFFECT *********************
2316 !C IF (DELTA/HYD.GT.0.1d0) THEN
2317 !C WRITE (ERRINF,'(1PE10.3)') DELTA/HYD*100.0
2318 !C CALL PUSHERR (0020, ERRINF)
2323 ! *** END OF SUBROUTINE CALCAMAQ ****************************************
2325 END SUBROUTINE CALCAMAQ
2329 !=======================================================================
2331 ! *** ISORROPIA CODE
2332 ! *** SUBROUTINE CALCAMAQ2
2334 ! THIS SUBROUTINE CALCULATES THE NH3(aq) GENERATED FROM (H,NH4+).
2336 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2337 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2338 ! *** WRITTEN BY ATHANASIOS NENES
2339 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2341 !=======================================================================
2343 SUBROUTINE CALCAMAQ2 (GGNH3, NH4I, OHI, NH3AQ)
2345 REAL(KIND=8) GGNH3, NH4I, OHI, NH3AQ
2346 REAL(KIND=8) A22, AKW, ALF1, ALF2
2347 REAL(KIND=8) BB, CC, DEL
2349 ! *** EQUILIBRIUM CONSTANTS
2351 A22 = XK22/XKW/WATER*(GAMA(8)/GAMA(9))**2. ! GAMA(NH3) ASSUMED 1
2352 AKW = XKW *RH*WATER*WATER
2360 DEL = 0.5D0*(-BB + SQRT(BB*BB-4.D0*CC))
2362 ! *** ADJUST CONCENTRATIONS
2366 IF (OHI.LE.TINY) OHI = SQRT(AKW) ! If solution is neutral.
2371 ! *** END OF SUBROUTINE CALCAMAQ2 ****************************************
2373 END SUBROUTINE CALCAMAQ2
2377 !=======================================================================
2379 ! *** ISORROPIA CODE
2380 ! *** SUBROUTINE CALCCLAQ
2382 ! THIS SUBROUTINE CALCULATES THE HCL(aq) GENERATED FROM (H+,CL-).
2384 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2385 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2386 ! *** WRITTEN BY ATHANASIOS NENES
2387 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2389 !=======================================================================
2391 SUBROUTINE CALCCLAQ (CLI, HI, DELT)
2393 REAL(KIND=8) CLI, HI, DELT
2394 REAL(KIND=8) A32, OM1, OM2, BB, CC, DD, DEL1, DEL2
2396 ! *** EQUILIBRIUM CONSTANTS
2398 A32 = XK32*WATER/(GAMA(11))**2. ! GAMA(HCL) ASSUMED 1
2406 DD = SQRT(BB*BB-4.D0*CC)
2408 DEL1 = 0.5D0*(-BB - DD)
2409 DEL2 = 0.5D0*(-BB + DD)
2411 ! *** GET APPROPRIATE ROOT.
2413 IF (DEL1.LT.ZERO) THEN
2414 IF (DEL2.LT.ZERO .OR. DEL2.GT.CLI .OR. DEL2.GT.HI) THEN
2425 ! *** END OF SUBROUTINE CALCCLAQ ****************************************
2427 END SUBROUTINE CALCCLAQ
2431 !=======================================================================
2433 ! *** ISORROPIA CODE
2434 ! *** SUBROUTINE CALCCLAQ2
2436 ! THIS SUBROUTINE CALCULATES THE HCL(aq) GENERATED FROM (H+,CL-).
2438 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2439 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2440 ! *** WRITTEN BY ATHANASIOS NENES
2441 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2443 !====================================================================
2445 SUBROUTINE CALCCLAQ2 (GGCL, CLI, HI, CLAQ)
2447 REAL(KIND=8) GGCL, CLI, HI, CLAQ
2448 REAL(KIND=8) A32, AKW, ALF1, ALF2, COEF, DEL1
2450 ! *** EQUILIBRIUM CONSTANTS
2452 A32 = XK32*WATER/(GAMA(11))**2. ! GAMA(HCL) ASSUMED 1
2453 AKW = XKW *RH*WATER*WATER
2460 DEL1 = 0.5*(-COEF + SQRT(COEF*COEF+4.D0*A32*ALF2))
2462 ! *** CORRECT CONCENTRATIONS
2466 IF (HI.LE.TINY) HI = SQRT(AKW) ! If solution is neutral.
2471 ! *** END OF SUBROUTINE CALCCLAQ2 ****************************************
2473 END SUBROUTINE CALCCLAQ2
2477 !=======================================================================
2479 ! *** ISORROPIA CODE
2480 ! *** SUBROUTINE CALCNIAQ
2482 ! THIS SUBROUTINE CALCULATES THE HNO3(aq) GENERATED FROM (H,NO3-).
2484 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2485 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2486 ! *** WRITTEN BY ATHANASIOS NENES
2487 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2489 !=======================================================================
2491 SUBROUTINE CALCNIAQ (NO3I, HI, DELT)
2493 REAL(KIND=8) NO3I, HI, DELT
2494 REAL(KIND=8) A42, OM1, OM2, BB, CC, DD, DEL1, DEL2
2496 ! *** EQUILIBRIUM CONSTANTS
2498 A42 = XK42*WATER/(GAMA(10))**2. ! GAMA(HNO3) ASSUMED 1
2506 DD = SQRT(BB*BB-4.D0*CC)
2508 DEL1 = 0.5D0*(-BB - DD)
2509 DEL2 = 0.5D0*(-BB + DD)
2511 ! *** GET APPROPRIATE ROOT.
2513 IF (DEL1.LT.ZERO .OR. DEL1.GT.HI .OR. DEL1.GT.NO3I) THEN
2520 IF (DEL2.LT.ZERO .OR. DEL2.GT.NO3I .OR. DEL2.GT.HI) THEN
2528 ! *** END OF SUBROUTINE CALCNIAQ ****************************************
2530 END SUBROUTINE CALCNIAQ
2534 !=======================================================================
2536 ! *** ISORROPIA CODE
2537 ! *** SUBROUTINE CALCNIAQ2
2539 ! THIS SUBROUTINE CALCULATES THE UNDISSOCIATED HNO3(aq)
2541 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2542 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2543 ! *** WRITTEN BY ATHANASIOS NENES
2544 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2546 !=======================================================================
2548 SUBROUTINE CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ)
2550 REAL(KIND=8) GGNO3, NO3I, HI, NO3AQ
2551 REAL(KIND=8) A42, AKW, ALF1, ALF2, ALF3
2552 REAL(KIND=8) BB, CC, DEL1
2555 ! *** EQUILIBRIUM CONSTANTS
2557 A42 = XK42*WATER/(GAMA(10))**2. ! GAMA(HNO3) ASSUMED 1
2558 AKW = XKW *RH*WATER*WATER
2566 BB = ALF3 + ALF1 + A42
2567 CC = ALF3*ALF1 - A42*ALF2
2568 DEL1 = 0.5*(-BB + SQRT(BB*BB-4.D0*CC))
2570 ! *** CORRECT CONCENTRATIONS
2574 IF (HI.LE.TINY) HI = SQRT(AKW) ! If solution is neutral.
2579 ! *** END OF SUBROUTINE CALCNIAQ2 ****************************************
2581 END SUBROUTINE CALCNIAQ2
2584 !=======================================================================
2586 ! *** ISORROPIA CODE
2587 ! *** SUBROUTINE CALCMR
2588 ! *** THIS SUBROUTINE CALCULATES:
2589 ! 1. ION PAIR CONCENTRATIONS (FROM [MOLAR] ARRAY)
2590 ! 2. WATER CONTENT OF LIQUID AEROSOL PHASE (FROM ZSR CORRELATION)
2592 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2593 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2594 ! *** WRITTEN BY ATHANASIOS NENES
2595 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2597 !=======================================================================
2602 REAL(KIND=8) SO4I, HSO4I, AML5, TOTS4, FRNH4, FRNO3, FRCL
2605 ! *** CALCULATE ION PAIR CONCENTRATIONS ACCORDING TO SPECIFIC CASE ****
2607 SC =SCASE(1:1) ! SULRAT & SODRAT case
2609 ! *** NH4-SO4 SYSTEM ; SULFATE POOR CASE
2612 MOLALR(4) = MOLAL(5)+MOLAL(6) ! (NH4)2SO4 - CORRECT FOR SO4 TO HSO4
2614 ! *** NH4-SO4 SYSTEM ; SULFATE RICH CASE ; NO FREE ACID
2616 ELSE IF (SC.EQ.'B') THEN
2617 SO4I = MOLAL(5)-MOLAL(1) ! CORRECT FOR HSO4 DISSOCIATION
2618 HSO4I = MOLAL(6)+MOLAL(1)
2619 IF (SO4I.LT.HSO4I) THEN
2620 MOLALR(13) = SO4I ! [LC] = [SO4]
2621 MOLALR(9) = MAX(HSO4I-SO4I, ZERO) ! NH4HSO4
2623 MOLALR(13) = HSO4I ! [LC] = [HSO4]
2624 MOLALR(4) = MAX(SO4I-HSO4I, ZERO) ! (NH4)2SO4
2627 ! *** NH4-SO4 SYSTEM ; SULFATE RICH CASE ; FREE ACID
2629 ELSE IF (SC.EQ.'C') THEN
2630 MOLALR(9) = MOLAL(3) ! NH4HSO4
2631 MOLALR(7) = MAX(W(2)-W(3), ZERO) ! H2SO4
2633 ! *** NH4-SO4-NO3 SYSTEM ; SULFATE POOR CASE
2635 ELSE IF (SC.EQ.'D') THEN
2636 MOLALR(4) = MOLAL(5) + MOLAL(6) ! (NH4)2SO4
2637 AML5 = MOLAL(3)-2.D0*MOLALR(4) ! "free" NH4
2638 MOLALR(5) = MAX(MIN(AML5,MOLAL(7)), ZERO)! NH4NO3 = MIN("free", NO3)
2640 ! *** NH4-SO4-NO3 SYSTEM ; SULFATE RICH CASE ; NO FREE ACID
2642 ELSE IF (SC.EQ.'E') THEN
2643 SO4I = MAX(MOLAL(5)-MOLAL(1),ZERO) ! FROM HSO4 DISSOCIATION
2644 HSO4I = MOLAL(6)+MOLAL(1)
2645 IF (SO4I.LT.HSO4I) THEN
2646 MOLALR(13) = SO4I ! [LC] = [SO4]
2647 MOLALR(9) = MAX(HSO4I-SO4I, ZERO) ! NH4HSO4
2649 MOLALR(13) = HSO4I ! [LC] = [HSO4]
2650 MOLALR(4) = MAX(SO4I-HSO4I, ZERO) ! (NH4)2SO4
2653 ! *** NH4-SO4-NO3 SYSTEM ; SULFATE RICH CASE ; FREE ACID
2655 ELSE IF (SC.EQ.'F') THEN
2656 MOLALR(9) = MOLAL(3) ! NH4HSO4
2657 MOLALR(7) = MAX(MOLAL(5)+MOLAL(6)-MOLAL(3),ZERO) ! H2SO4
2659 ! *** NA-NH4-SO4-NO3-CL SYSTEM ; SULFATE POOR ; SODIUM POOR CASE
2661 ELSE IF (SC.EQ.'G') THEN
2662 MOLALR(2) = 0.5*MOLAL(2) ! NA2SO4
2663 TOTS4 = MOLAL(5)+MOLAL(6) ! Total SO4
2664 MOLALR(4) = MAX(TOTS4 - MOLALR(2), ZERO) ! (NH4)2SO4
2665 FRNH4 = MAX(MOLAL(3) - 2.D0*MOLALR(4), ZERO)
2666 MOLALR(5) = MIN(MOLAL(7),FRNH4) ! NH4NO3
2667 FRNH4 = MAX(FRNH4 - MOLALR(5), ZERO)
2668 MOLALR(6) = MIN(MOLAL(4), FRNH4) ! NH4CL
2670 ! *** NA-NH4-SO4-NO3-CL SYSTEM ; SULFATE POOR ; SODIUM RICH CASE
2671 ! *** RETREIVE DISSOLVED SALTS DIRECTLY FROM COMMON BLOCK /SOLUT/
2673 ELSE IF (SC.EQ.'H') THEN
2674 MOLALR(1) = PSI7 ! NACL
2675 MOLALR(2) = PSI1 ! NA2SO4
2676 MOLALR(3) = PSI8 ! NANO3
2677 MOLALR(4) = ZERO ! (NH4)2SO4
2678 FRNO3 = MAX(MOLAL(7) - MOLALR(3), ZERO) ! "FREE" NO3
2679 FRCL = MAX(MOLAL(4) - MOLALR(1), ZERO) ! "FREE" CL
2680 MOLALR(5) = MIN(MOLAL(3),FRNO3) ! NH4NO3
2681 FRNH4 = MAX(MOLAL(3) - MOLALR(5), ZERO) ! "FREE" NH3
2682 MOLALR(6) = MIN(FRCL, FRNH4) ! NH4CL
2684 ! *** NA-NH4-SO4-NO3-CL SYSTEM ; SULFATE RICH CASE ; NO FREE ACID
2685 ! *** RETREIVE DISSOLVED SALTS DIRECTLY FROM COMMON BLOCK /SOLUT/
2687 ELSE IF (SC.EQ.'I') THEN
2688 MOLALR(04) = PSI5 ! (NH4)2SO4
2689 MOLALR(02) = PSI4 ! NA2SO4
2690 MOLALR(09) = PSI1 ! NH4HSO4
2691 MOLALR(12) = PSI3 ! NAHSO4
2692 MOLALR(13) = PSI2 ! LC
2694 ! *** NA-NH4-SO4-NO3-CL SYSTEM ; SULFATE RICH CASE ; FREE ACID
2696 ELSE IF (SC.EQ.'J') THEN
2697 MOLALR(09) = MOLAL(3) ! NH4HSO4
2698 MOLALR(12) = MOLAL(2) ! NAHSO4
2699 MOLALR(07) = MOLAL(5)+MOLAL(6)-MOLAL(3)-MOLAL(2) ! H2SO4
2700 MOLALR(07) = MAX(MOLALR(07),ZERO)
2702 ! ======= REVERSE PROBLEMS ===========================================
2704 ! *** NH4-SO4-NO3 SYSTEM ; SULFATE POOR CASE
2706 ELSE IF (SC.EQ.'N') THEN
2707 MOLALR(4) = MOLAL(5) + MOLAL(6) ! (NH4)2SO4
2708 AML5 = WAER(3)-2.D0*MOLALR(4) ! "free" NH4
2709 MOLALR(5) = MAX(MIN(AML5,WAER(4)), ZERO) ! NH4NO3 = MIN("free", NO3)
2711 ! *** NH4-SO4-NO3-NA-CL SYSTEM ; SULFATE POOR, SODIUM POOR CASE
2713 ELSE IF (SC.EQ.'Q') THEN
2714 MOLALR(2) = PSI1 ! NA2SO4
2715 MOLALR(4) = PSI6 ! (NH4)2SO4
2716 MOLALR(5) = PSI5 ! NH4NO3
2717 MOLALR(6) = PSI4 ! NH4CL
2719 ! *** NH4-SO4-NO3-NA-CL SYSTEM ; SULFATE POOR, SODIUM RICH CASE
2721 ELSE IF (SC.EQ.'R') THEN
2722 MOLALR(1) = PSI3 ! NACL
2723 MOLALR(2) = PSI1 ! NA2SO4
2724 MOLALR(3) = PSI2 ! NANO3
2725 MOLALR(4) = ZERO ! (NH4)2SO4
2726 MOLALR(5) = PSI5 ! NH4NO3
2727 MOLALR(6) = PSI4 ! NH4CL
2732 CALL PUSHERR (1001, ' ') ! FATAL ERROR: CASE NOT SUPPORTED
2735 ! *** CALCULATE WATER CONTENT ; ZSR CORRELATION ***********************
2739 WATER = WATER + MOLALR(I)/M0(I)
2741 WATER = MAX(WATER, TINY)
2745 ! *** END OF SUBROUTINE CALCMR ******************************************
2747 END SUBROUTINE CALCMR
2748 !=======================================================================
2750 ! *** ISORROPIA CODE
2751 ! *** SUBROUTINE CALCMDRH
2753 ! THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
2754 ! DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
2755 ! SOLUTIONS ; THE 'DRY' SOLUTION (SUBROUTINE DRYCASE) AND THE
2756 ! 'SATURATED LIQUID' SOLUTION (SUBROUTINE LIQCASE).
2758 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2759 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2760 ! *** WRITTEN BY ATHANASIOS NENES
2761 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2763 !=======================================================================
2765 SUBROUTINE CALCMDRH (RHI, RHDRY, RHLIQ, DRYCASE, LIQCASE)
2767 REAL(KIND=8) RHI, RHDRY, RHLIQ!, DRYCASE, LIQCASE
2768 REAL(KIND=8) WF, ONEMWF
2769 REAL(KIND=8) CNH42SO, CNH4HSO, CLCO, CNH4N3O, CNH4CLO, CNA2SO
2770 REAL(KIND=8) CNAHSO, CNANO, CNACLO, GNH3O, GHNO3O, GHCLO
2771 REAL(KIND=8) DAMSUL, DSOSUL, DAMBIS, DSOBIS, DLC, DAMNIT, DAMCHL
2772 REAL(KIND=8) DSONIT, DSOCHL, DAMG, DHAG, DNAG
2774 EXTERNAL DRYCASE, LIQCASE
2776 ! *** FIND WEIGHT FACTOR **********************************************
2778 IF (WFTYP.EQ.0) THEN
2780 ELSEIF (WFTYP.EQ.1) THEN
2783 WF = (RHLIQ-RHI)/(RHLIQ-RHDRY)
2787 ! *** FIND FIRST SECTION ; DRY ONE ************************************
2790 IF (ABS(ONEMWF).LE.1D-5) GOTO 200 ! DRY AEROSOL
2792 CNH42SO = CNH42S4 ! FIRST (DRY) SOLUTION
2805 ! *** FIND SECOND SECTION ; DRY & LIQUID ******************************
2819 CALL LIQCASE ! SECOND (LIQUID) SOLUTION
2821 ! *** ADJUST THINGS FOR THE CASE THAT THE LIQUID SUB PREDICTS DRY AEROSOL
2823 IF (WATER.LE.TINY) THEN
2825 MOLAL(I)= ZERO ! Aqueous phase
2829 CNH42S4 = CNH42SO ! Solid phase
2839 GNH3 = GNH3O ! Gas phase
2846 ! *** FIND SALT DISSOLUTIONS BETWEEN DRY & LIQUID SOLUTIONS.
2848 DAMSUL = CNH42SO - CNH42S4
2849 DSOSUL = CNA2SO - CNA2SO4
2850 DAMBIS = CNH4HSO - CNH4HS4
2851 DSOBIS = CNAHSO - CNAHSO4
2853 DAMNIT = CNH4N3O - CNH4NO3
2854 DAMCHL = CNH4CLO - CNH4CL
2855 DSONIT = CNANO - CNANO3
2856 DSOCHL = CNACLO - CNACL
2858 ! *** FIND GAS DISSOLUTIONS BETWEEN DRY & LIQUID SOLUTIONS.
2862 DNAG = GHNO3O - GHNO3
2864 ! *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
2868 MOLAL(1)= ONEMWF*MOLAL(1) ! H+
2869 MOLAL(2)= ONEMWF*(2.D0*DSOSUL + DSOBIS + DSONIT + DSOCHL) ! NA+
2870 MOLAL(3)= ONEMWF*(2.D0*DAMSUL + DAMG + DAMBIS + DAMCHL +&
2871 3.D0*DLC + DAMNIT ) ! NH4+
2872 MOLAL(4)= ONEMWF*( DAMCHL + DSOCHL + DHAG) ! CL-
2873 MOLAL(5)= ONEMWF*( DAMSUL + DSOSUL + DLC - MOLAL(6)) ! SO4-- !VB 17 Sept 2001
2874 MOLAL(6)= ONEMWF*( MOLAL(6) + DSOBIS + DAMBIS + DLC) ! HSO4-
2875 MOLAL(7)= ONEMWF*( DAMNIT + DSONIT + DNAG) ! NO3-
2876 WATER = ONEMWF*WATER
2880 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
2881 CNA2SO4 = WF*CNA2SO + ONEMWF*CNA2SO4
2882 CNAHSO4 = WF*CNAHSO + ONEMWF*CNAHSO4
2883 CNH4HS4 = WF*CNH4HSO + ONEMWF*CNH4HS4
2884 CLC = WF*CLCO + ONEMWF*CLC
2885 CNH4NO3 = WF*CNH4N3O + ONEMWF*CNH4NO3
2886 CNANO3 = WF*CNANO + ONEMWF*CNANO3
2887 CNACL = WF*CNACLO + ONEMWF*CNACL
2888 CNH4CL = WF*CNH4CLO + ONEMWF*CNH4CL
2892 GNH3 = WF*GNH3O + ONEMWF*GNH3
2893 GHNO3 = WF*GHNO3O + ONEMWF*GHNO3
2894 GHCL = WF*GHCLO + ONEMWF*GHCL
2900 ! *** END OF SUBROUTINE CALCMDRH ****************************************
2902 END SUBROUTINE CALCMDRH
2909 !=======================================================================
2911 ! *** ISORROPIA CODE
2912 ! *** SUBROUTINE CALCMDRP
2914 ! THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
2915 ! DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
2916 ! SOLUTIONS ; THE 'DRY' SOLUTION (SUBROUTINE DRYCASE) AND THE
2917 ! 'SATURATED LIQUID' SOLUTION (SUBROUTINE LIQCASE).
2919 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2920 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2921 ! *** WRITTEN BY ATHANASIOS NENES
2922 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
2924 !=======================================================================
2926 SUBROUTINE CALCMDRP (RHI, RHDRY, RHLIQ, DRYCASE, LIQCASE)
2928 REAL(KIND=8) RHI, RHDRY, RHLIQ!, DRYCASE, LIQCASE
2929 REAL(KIND=8) WF, ONEMWF
2930 REAL(KIND=8) CNH42SO, CNH4HSO, CLCO, CNH4N3O, CNH4CLO, CNA2SO
2931 REAL(KIND=8) CNAHSO, CNANO, CNACLO
2932 REAL(KIND=8) DAMBIS, DSOBIS, DLC
2933 REAL(KIND=8) HIEQ, HIEN
2936 EXTERNAL DRYCASE, LIQCASE
2938 ! *** FIND WEIGHT FACTOR **********************************************
2940 IF (WFTYP.EQ.0) THEN
2942 ELSEIF (WFTYP.EQ.1) THEN
2945 WF = (RHLIQ-RHI)/(RHLIQ-RHDRY)
2949 ! *** FIND FIRST SECTION ; DRY ONE ************************************
2952 IF (ABS(ONEMWF).LE.1D-5) GOTO 200 ! DRY AEROSOL
2954 CNH42SO = CNH42S4 ! FIRST (DRY) SOLUTION
2964 ! *** FIND SECOND SECTION ; DRY & LIQUID ******************************
2978 CALL LIQCASE ! SECOND (LIQUID) SOLUTION
2980 ! *** ADJUST THINGS FOR THE CASE THAT THE LIQUID SUB PREDICTS DRY AEROSOL
2982 IF (WATER.LE.TINY) THEN
2991 ! *** FIND SALT DISSOLUTIONS BETWEEN DRY & LIQUID SOLUTIONS.
2993 DAMBIS = CNH4HSO - CNH4HS4
2994 DSOBIS = CNAHSO - CNAHSO4
2997 ! *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
3001 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
3002 CNA2SO4 = WF*CNA2SO + ONEMWF*CNA2SO4
3003 CNAHSO4 = WF*CNAHSO + ONEMWF*CNAHSO4
3004 CNH4HS4 = WF*CNH4HSO + ONEMWF*CNH4HS4
3005 CLC = WF*CLCO + ONEMWF*CLC
3006 CNH4NO3 = WF*CNH4N3O + ONEMWF*CNH4NO3
3007 CNANO3 = WF*CNANO + ONEMWF*CNANO3
3008 CNACL = WF*CNACLO + ONEMWF*CNACL
3009 CNH4CL = WF*CNH4CLO + ONEMWF*CNH4CL
3013 WATER = ONEMWF*WATER
3015 MOLAL(2)= WAER(1) - 2.D0*CNA2SO4 - CNAHSO4 - CNANO3 - &
3017 MOLAL(3)= WAER(3) - 2.D0*CNH42S4 - CNH4HS4 - CNH4CL - &
3018 3.D0*CLC - CNH4NO3 ! NH4+
3019 MOLAL(4)= WAER(5) - CNACL - CNH4CL ! CL-
3020 MOLAL(7)= WAER(4) - CNANO3 - CNH4NO3 ! NO3-
3021 MOLAL(6)= ONEMWF*(MOLAL(6) + DSOBIS + DAMBIS + DLC) ! HSO4-
3022 MOLAL(5)= WAER(2) - MOLAL(6) - CLC - CNH42S4 - CNA2SO4 ! SO4--
3024 A8 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
3025 IF (MOLAL(5).LE.TINY) THEN
3026 HIEQ = SQRT(XKW *RH*WATER*WATER) ! Neutral solution
3028 HIEQ = A8*MOLAL(6)/MOLAL(5)
3030 HIEN = MOLAL(4) + MOLAL(7) + MOLAL(6) + 2.D0*MOLAL(5) -&
3032 MOLAL(1)= MAX (HIEQ, HIEN) ! H+
3034 ! *** GAS (ACTIVITY COEFS FROM LIQUID SOLUTION)
3036 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
3037 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
3038 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
3040 GNH3 = MOLAL(3)/MAX(MOLAL(1),TINY)/A2
3041 GHNO3 = MOLAL(1)*MOLAL(7)/A3
3042 GHCL = MOLAL(1)*MOLAL(4)/A4
3046 ! *** END OF SUBROUTINE CALCMDRP ****************************************
3048 END SUBROUTINE CALCMDRP
3049 !=======================================================================
3051 ! *** ISORROPIA CODE
3052 ! *** SUBROUTINE CALCHS4
3053 ! *** THIS SUBROUTINE CALCULATES THE HSO4 GENERATED FROM (H,SO4).
3055 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3056 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3057 ! *** WRITTEN BY ATHANASIOS NENES
3058 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3060 !=======================================================================
3062 SUBROUTINE CALCHS4 (HI, SO4I, HSO4I, DELTA)
3064 REAL(KIND=8) HI, SO4I, HSO4I, DELTA
3065 REAL(KIND=8) BB, CC, DD, SQDD, DELTA1, DELTA2
3066 !C CHARACTER ERRINF*40
3068 ! *** IF TOO LITTLE WATER, DONT SOLVE
3070 IF (WATER.LE.1d1*TINY) THEN
3075 ! *** CALCULATE HSO4 SPECIATION *****************************************
3077 A8 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
3079 BB =-(HI + SO4I + A8)
3080 CC = HI*SO4I - HSO4I*A8
3081 DD = BB*BB - 4.D0*CC
3083 IF (DD.GE.ZERO) THEN
3085 DELTA1 = 0.5*(-BB + SQDD)
3086 DELTA2 = 0.5*(-BB - SQDD)
3087 IF (HSO4I.LE.TINY) THEN
3089 ELSEIF( HI*SO4I .GE. A8*HSO4I ) THEN
3091 ELSEIF( HI*SO4I .LT. A8*HSO4I ) THEN
3100 !CC *** COMPARE DELTA TO TOTAL H+ ; ESTIMATE EFFECT OF HSO4 ***************
3102 !C HYD = MAX(HI, MOLAL(1))
3103 !C IF (HYD.GT.TINY) THEN
3104 !C IF (DELTA/HYD.GT.0.1d0) THEN
3105 !C WRITE (ERRINF,'(1PE10.3)') DELTA/HYD*100.0
3106 !C CALL PUSHERR (0020, ERRINF)
3112 ! *** END OF SUBROUTINE CALCHS4 *****************************************
3114 END SUBROUTINE CALCHS4
3117 !=======================================================================
3119 ! *** ISORROPIA CODE
3120 ! *** SUBROUTINE CALCPH
3122 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3123 ! *** GEORGIA INSTITUTE OF
3125 ! *** WRITTEN BY ATHANASIOS NENES
3126 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3128 !=======================================================================
3130 SUBROUTINE CALCPH (GG, HI, OHI)
3132 REAL(KIND=8) GG, HI, OHI
3133 REAL(KIND=8) AKW,CN, BB, CC, DD
3135 AKW = XKW *RH*WATER*WATER
3138 ! *** GG = (negative charge) - (positive charge)
3140 IF (GG.GT.TINY) THEN ! H+ in excess
3143 DD = BB*BB - 4.D0*CC
3144 HI = MAX(0.5D0*(-BB + SQRT(DD)),CN)
3146 ELSE ! OH- in excess
3149 DD = BB*BB - 4.D0*CC
3150 OHI= MAX(0.5D0*(-BB + SQRT(DD)),CN)
3156 ! *** END OF SUBROUTINE CALCPH ******************************************
3158 END SUBROUTINE CALCPH
3160 !=======================================================================
3162 ! *** ISORROPIA CODE
3163 ! *** SUBROUTINE CALCACT
3164 ! *** CALCULATES MULTI-COMPONENET ACTIVITY COEFFICIENTS FROM BROMLEYS
3165 ! METHOD. THE BINARY ACTIVITY COEFFICIENTS ARE CALCULATED BY
3166 ! KUSIK-MEISNER RELATION (SUBROUTINE KMTAB or SUBROUTINE KMFUL).
3168 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3169 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3170 ! *** WRITTEN BY ATHANASIOS NENES
3171 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3173 !=======================================================================
3179 REAL G0(3,4),ZPL,ZMI,AGAMA,SION,H,CH,F1(3),F2(4)
3180 REAL(KIND=8) MPL, XIJ, YJI
3181 REAL(KIND=8) ERROU, ERRIN
3182 ! PARAMETER (URF=0.5)
3183 REAL(KIND=8),PARAMETER:: LN10=2.30258509299404568402D0
3190 ! G(I,J)= (F1(I)/Z(I) + F2(J)/Z(J+3)) / (Z(I)+Z(J+3)) - H
3192 ! *** SAVE ACTIVITIES IN OLD ARRAY *************************************
3194 IF (FRST) THEN ! Outer loop
3200 DO 20 I=1,NPAIR ! Inner loop
3204 ! *** CALCULATE IONIC ACTIVITY OF SOLUTION *****************************
3208 IONIC=IONIC + MOLAL(I)*Z(I)*Z(I)
3210 IONIC = MAX(MIN(0.5*IONIC/WATER,500.d0), TINY)
3212 ! *** CALCULATE BINARY ACTIVITY COEFFICIENTS ***************************
3214 ! G0(1,1)=G11;G0(1,2)=G07;G0(1,3)=G08;G0(1,4)=G10;G0(2,1)=G01;G0(2,2)=G02
3215 ! G0(2,3)=G12;G0(2,4)=G03;G0(3,1)=G06;G0(3,2)=G04;G0(3,3)=G09;G0(3,4)=G05
3217 IF (IACALC.EQ.0) THEN ! K.M.; FULL
3218 CALL KMFUL (IONIC, SNGL(TEMP),G0(2,1),G0(2,2),G0(2,4), &
3219 G0(3,2),G0(3,4),G0(3,1),G0(1,2),G0(1,3),G0(3,3),&
3220 G0(1,4),G0(1,1),G0(2,3))
3221 ELSE ! K.M.; TABULATED
3222 CALL KMTAB (IONIC, SNGL(TEMP),G0(2,1),G0(2,2),G0(2,4), &
3223 G0(3,2),G0(3,4),G0(3,1),G0(1,2),G0(1,3),G0(3,3),&
3224 G0(1,4),G0(1,1),G0(2,3))
3227 ! *** CALCULATE MULTICOMPONENT ACTIVITY COEFFICIENTS *******************
3229 AGAMA = 0.511*(298.0/TEMP)**1.5 ! Debye Huckel const. at T
3231 H = AGAMA*SION/(1+SION)
3241 MPL = MOLAL(I)/WATER
3244 CH = 0.25*(ZPL+ZMI)*(ZPL+ZMI)/IONIC
3246 YJI = CH*MOLAL(J+3)/WATER
3247 F1(I) = F1(I) + SNGL(YJI*(G0(I,J) + ZPL*ZMI*H))
3248 F2(J) = F2(J) + SNGL(XIJ*(G0(I,J) + ZPL*ZMI*H))
3251 ! *** LOG10 OF ACTIVITY COEFFICIENTS ***********************************
3253 GAMA(01) = G_GAMA(F1,F2,Z,H,2,1)*ZZ(01)! NACL
3254 GAMA(02) = G_GAMA(F1,F2,Z,H,2,2)*ZZ(02)! NA2SO4
3255 GAMA(03) = G_GAMA(F1,F2,Z,H,2,4)*ZZ(03)! NANO3
3256 GAMA(04) = G_GAMA(F1,F2,Z,H,3,2)*ZZ(04)! (NH4)2SO4
3257 GAMA(05) = G_GAMA(F1,F2,Z,H,3,4)*ZZ(05)! NH4NO3
3258 GAMA(06) = G_GAMA(F1,F2,Z,H,3,1)*ZZ(06)! NH4CL
3259 GAMA(07) = G_GAMA(F1,F2,Z,H,1,2)*ZZ(07)! 2H-SO4
3260 GAMA(08) = G_GAMA(F1,F2,Z,H,1,3)*ZZ(08)! H-HSO4
3261 GAMA(09) = G_GAMA(F1,F2,Z,H,3,3)*ZZ(09)! NH4HSO4
3262 GAMA(10) = G_GAMA(F1,F2,Z,H,1,4)*ZZ(10)! HNO3
3263 GAMA(11) = G_GAMA(F1,F2,Z,H,1,1)*ZZ(11)! HCL
3264 GAMA(12) = G_GAMA(F1,F2,Z,H,2,3)*ZZ(12)! NAHSO4
3265 GAMA(13) = 0.20*(3.0*GAMA(04)+2.0*GAMA(09)) ! LC ; SCAPE
3266 !C GAMA(13) = 0.50*(GAMA(04)+GAMA(09)) ! LC ; SEQUILIB
3267 !C GAMA(13) = 0.25*(3.0*GAMA(04)+GAMA(07)) ! LC ; AIM
3270 ! *** CONVERT LOG (GAMA) COEFFICIENTS TO GAMA **************************
3273 GAMA(I)=MAX(-11.0d0, MIN(GAMA(I),11.0d0) ) ! F77 LIBRARY ROUTINE
3274 ! GAMA(I)=10.0**GAMA(I)
3275 ! GAMA(I)=EXP(LN10*GAMA(I))
3276 GAMA(I)=EXP(2*GAMA(I))
3277 !C GAMA(I)=EX10(SNGL(GAMA(I)), 5.0) ! CUTOFF SET TO [-5,5]
3278 ! GAMA(I) = GAMIN(I)*(1.0-URF) + URF*GAMA(I) ! Under-relax GAMA's
3281 ! *** SETUP ACTIVITY CALCULATION FLAGS *********************************
3283 ! OUTER CALCULATION LOOP ; ONLY IF FRST=.TRUE.
3286 ERROU = ZERO ! CONVERGENCE CRITERION
3288 ERROU=MAX(ERROU, ABS((GAMOU(I)-GAMA(I))/GAMOU(I)))
3290 CALAOU = ERROU .GE. EPSACT ! SETUP FLAGS
3294 ! INNER CALCULATION LOOP ; ALWAYS
3296 ERRIN = ZERO ! CONVERGENCE CRITERION
3298 ERRIN = MAX (ERRIN, ABS((GAMIN(I)-GAMA(I))/GAMIN(I)))
3300 CALAIN = ERRIN .GE. EPSACT
3302 ICLACT = ICLACT + 1 ! Increment ACTIVITY call counter
3304 ! *** END OF SUBROUTINE ACTIVITY ****************************************
3307 END SUBROUTINE CALCACT
3309 !======================================================================
3311 REAL(KIND=8) FUNCTION G_GAMA(F1,F2,ZI,H,I,J)
3314 REAL(KIND=8)ZI(NIONS)
3317 G_GAMA = (F1(I)/Z(I) + F2(J)/Z(J+3)) / (Z(I)+Z(J+3)) - H
3322 ! *** END OF FUNCTION G_GAMA ****************************************
3325 !=======================================================================
3327 ! *** ISORROPIA CODE
3328 ! *** SUBROUTINE RSTGAM
3329 ! *** RESETS ACTIVITY COEFFICIENT ARRAYS TO DEFAULT VALUE OF 0.1
3331 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3332 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3333 ! *** WRITTEN BY ATHANASIOS NENES
3334 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3336 !=======================================================================
3346 ! *** END OF SUBROUTINE RSTGAM ******************************************
3349 END SUBROUTINE RSTGAM
3350 !=======================================================================
3352 ! *** ISORROPIA CODE
3353 ! *** SUBROUTINE KMFUL
3354 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3356 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3357 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3358 ! *** WRITTEN BY ATHANASIOS NENES
3359 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3361 !=======================================================================
3363 SUBROUTINE KMFUL (IONIC,TEMP,G01,G02,G03,G04,G05,G06,G07,G08,G09,&
3367 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3368 REAL Z01,Z02,Z03,Z04,Z05,Z06,Z07,Z08,Z10,Z11
3369 DATA Z01,Z02,Z03,Z04,Z05,Z06,Z07,Z08,Z10,Z11&
3370 /1, 2, 1, 2, 1, 1, 2, 1, 1, 1/
3372 REAL TI, TC, CF1, CF2
3376 ! *** Coefficients at 25 oC
3378 CALL MKBI(2.230, IONIC, SION, Z01, G01)
3379 CALL MKBI(-0.19, IONIC, SION, Z02, G02)
3380 CALL MKBI(-0.39, IONIC, SION, Z03, G03)
3381 CALL MKBI(-0.25, IONIC, SION, Z04, G04)
3382 CALL MKBI(-1.15, IONIC, SION, Z05, G05)
3383 CALL MKBI(0.820, IONIC, SION, Z06, G06)
3384 CALL MKBI(-.100, IONIC, SION, Z07, G07)
3385 CALL MKBI(8.000, IONIC, SION, Z08, G08)
3386 CALL MKBI(2.600, IONIC, SION, Z10, G10)
3387 CALL MKBI(6.000, IONIC, SION, Z11, G11)
3389 ! *** Correct for T other than 298 K
3393 IF (ABS(TC) .GT. 1.0) THEN
3394 CF1 = 1.125-0.005*TI
3395 CF2 = (0.125-0.005*TI)*(0.039*IONIC**0.92-0.41*SION/(1.+SION))
3396 G01 = CF1*G01 - CF2*Z01
3397 G02 = CF1*G02 - CF2*Z02
3398 G03 = CF1*G03 - CF2*Z03
3399 G04 = CF1*G04 - CF2*Z04
3400 G05 = CF1*G05 - CF2*Z05
3401 G06 = CF1*G06 - CF2*Z06
3402 G07 = CF1*G07 - CF2*Z07
3403 G08 = CF1*G08 - CF2*Z08
3404 G10 = CF1*G10 - CF2*Z10
3405 G11 = CF1*G11 - CF2*Z11
3408 G09 = G06 + G08 - G11
3409 G12 = G01 + G08 - G11
3411 ! *** Return point ; End of subroutine
3414 END SUBROUTINE KMFUL
3417 !=======================================================================
3419 ! *** ISORROPIA CODE
3420 ! *** SUBROUTINE MKBI
3421 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3423 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3424 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3425 ! *** WRITTEN BY ATHANASIOS NENES
3426 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3428 !=======================================================================
3430 SUBROUTINE MKBI(Q,IONIC,SION,ZIP,BI)
3434 REAL Q,IONIC,SION,ZIP
3440 IF (IONIC.LT.6.0) C=1.+.055*Q*EXP(-.023*IONIC*IONIC*IONIC)
3441 XX=-0.5107*SION/(1.+C*SION)
3442 BI=(1.+B*(1.+.1*IONIC)**Q-B)
3443 BI=ZIP*ALOG10(BI) + ZIP*XX
3447 !=======================================================================
3449 ! *** ISORROPIA CODE
3450 ! *** SUBROUTINE KMTAB
3451 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3452 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3453 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IONIC' IS INPUT, AND THE ARRAY
3454 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3456 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3457 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3458 ! *** WRITTEN BY ATHANASIOS NENES
3459 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3461 !=======================================================================
3463 SUBROUTINE KMTAB (IN,TEMP,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,&
3467 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3470 ! *** Find temperature range
3472 IND = NINT((TEMP-198.0)/25.0) + 1
3473 IND = MIN(MAX(IND,1),6)
3475 ! *** Call appropriate routine
3478 CALL KM198 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3479 ELSEIF (IND.EQ.2) THEN
3480 CALL KM223 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3481 ELSEIF (IND.EQ.3) THEN
3482 CALL KM248 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3483 ELSEIF (IND.EQ.4) THEN
3484 CALL KM273 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3485 ELSEIF (IND.EQ.5) THEN
3486 CALL KM298 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3488 CALL KM323 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12)
3491 ! *** Return point; End of subroutine
3494 END SUBROUTINE KMTAB
3497 INTEGER FUNCTION IBACPOS(IN)
3499 ! Compute the index in the binary activity coefficient array
3500 ! based on the input ionic strength.
3502 ! Chris Nolte, 6/16/05
3506 IF (IN .LE. 0.300000E+02) THEN
3507 ibacpos = MIN(NINT( 0.200000E+02*IN) + 1, 600)
3509 ibacpos = 600+NINT( 0.200000E+01*IN- 0.600000E+02)
3511 ibacpos = min(ibacpos, 741)
3513 end FUNCTION IBACPOS
3515 !=======================================================================
3517 ! *** ISORROPIA CODE
3518 ! *** SUBROUTINE KM198
3519 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3520 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3521 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3522 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3524 ! TEMPERATURE IS 198K
3526 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3527 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3528 ! *** WRITTEN BY ATHANASIOS NENES
3529 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3531 !=======================================================================
3533 SUBROUTINE KM198 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10, &
3537 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3539 ! *** Common block definition
3542 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3543 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3544 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3548 ! *** Find position in arrays for binary activity coefficients
3552 ! *** Assign values to return array
3567 ! *** Return point ; End of subroutine
3570 END SUBROUTINE KM198
3573 !=======================================================================
3575 ! *** ISORROPIA CODE
3576 ! *** SUBROUTINE KM223
3577 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3578 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3579 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3580 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3582 ! TEMPERATURE IS 223K
3584 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3585 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3586 ! *** WRITTEN BY ATHANASIOS NENES
3587 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3589 !=======================================================================
3591 SUBROUTINE KM223 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,&
3594 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3597 ! *** Common block definition
3600 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3601 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3602 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3606 ! *** Find position in arrays for binary activity coefficients
3610 ! *** Assign values to return array
3625 ! *** Return point ; End of subroutine
3628 END SUBROUTINE KM223
3632 !=======================================================================
3634 ! *** ISORROPIA CODE
3635 ! *** SUBROUTINE KM248
3636 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3637 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3638 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3639 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3641 ! TEMPERATURE IS 248K
3643 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3644 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3645 ! *** WRITTEN BY ATHANASIOS NENES
3646 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3648 !=======================================================================
3650 SUBROUTINE KM248 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10, &
3653 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3656 ! *** Common block definition
3659 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3660 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3661 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3665 ! *** Find position in arrays for binary activity coefficients
3669 ! *** Assign values to return array
3684 ! *** Return point ; End of subroutine
3687 END SUBROUTINE KM248
3690 !=======================================================================
3692 ! *** ISORROPIA CODE
3693 ! *** SUBROUTINE KM273
3694 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3695 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3696 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3697 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3699 ! TEMPERATURE IS 273K
3701 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3702 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3703 ! *** WRITTEN BY ATHANASIOS NENES
3704 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3706 !=======================================================================
3708 SUBROUTINE KM273 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10, &
3711 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3714 ! *** Common block definition
3717 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3718 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3719 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3723 ! *** Find position in arrays for binary activity coefficients
3727 ! *** Assign values to return array
3742 ! *** Return point ; End of subroutine
3745 END SUBROUTINE KM273
3748 !=======================================================================
3750 ! *** ISORROPIA CODE
3751 ! *** SUBROUTINE KM298
3752 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3753 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3754 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3755 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3757 ! TEMPERATURE IS 298K
3759 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3760 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3761 ! *** WRITTEN BY ATHANASIOS NENES
3762 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3764 !=======================================================================
3766 SUBROUTINE KM298 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10, &
3769 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3772 ! *** Common block definition
3775 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3776 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3777 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3781 ! *** Find position in arrays for binary activity coefficients
3785 ! *** Assign values to return array
3800 ! *** Return point ; End of subroutine
3803 END SUBROUTINE KM298
3806 !=======================================================================
3808 ! *** ISORROPIA CODE
3809 ! *** SUBROUTINE KM323
3810 ! *** CALCULATES BINARY ACTIVITY COEFFICIENTS BY KUSIK-MEISSNER METHOD.
3811 ! THE COMPUTATIONS HAVE BEEN PERFORMED AND THE RESULTS ARE STORED IN
3812 ! LOOKUP TABLES. THE IONIC ACTIVITY 'IN' IS INPUT, AND THE ARRAY
3813 ! 'BINARR' IS RETURNED WITH THE BINARY COEFFICIENTS.
3815 ! TEMPERATURE IS 323K
3817 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3818 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3819 ! *** WRITTEN BY ATHANASIOS NENES
3820 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
3822 !=======================================================================
3824 SUBROUTINE KM323 (IN,G01,G02,G03,G04,G05,G06,G07,G08,G09,G10, &
3827 REAL G01,G02,G03,G04,G05,G06,G07,G08,G09,G10,G11,G12
3830 ! *** Common block definition
3833 ! BNC01M( 741),BNC02M( 741),BNC03M( 741),BNC04M( 741),&
3834 ! BNC05M( 741),BNC06M( 741),BNC07M( 741),BNC08M( 741),&
3835 ! BNC09M( 741),BNC10M( 741),BNC11M( 741),BNC12M( 741),&
3839 ! *** Find position in arrays for binary activity coefficients
3843 ! *** Assign values to return array
3858 ! *** Return point ; End of subroutine
3861 END SUBROUTINE KM323
3866 !C*************************************************************************
3868 !C TOOLBOX LIBRARY v.1.0 (May 1995)
3870 !C Program unit : SUBROUTINE CHRBLN
3871 !C Purpose : Position of last non-blank character in a string
3872 !C Author : Athanasios Nenes
3874 !C ======================= ARGUMENTS / USAGE =============================
3876 !C STR is the CHARACTER variable containing the string examined
3877 !C IBLK is a INTEGER variable containing the position of last non
3878 !C blank character. If string is all spaces (ie ' '), then
3879 !C the value returned is 1.
3882 !C STR = 'TEST1.DAT '
3883 !C CALL CHRBLN (STR, IBLK)
3885 !C after execution of this code segment, "IBLK" has the value "9", which
3886 !C is the position of the last non-blank character of "STR".
3888 !C***********************************************************************
3890 SUBROUTINE CHRBLN (STR, IBLK)
3893 !C***********************************************************************
3898 IBLK = 1 ! Substring pointer (default=1)
3899 ILEN = LEN(STR) ! Length of string
3901 IF (STR(i:i).NE.' ' .AND. STR(i:i).NE.CHAR(0)) THEN
3908 END SUBROUTINE CHRBLN
3911 !C*************************************************************************
3913 !C TOOLBOX LIBRARY v.1.0 (May 1995)
3915 !C Program unit : SUBROUTINE SHFTRGHT
3916 !C Purpose : RIGHT-JUSTIFICATION FUNCTION ON A STRING
3917 !C Author : Athanasios Nenes
3919 !C ======================= ARGUMENTS / USAGE =============================
3921 !C STRING is the CHARACTER variable with the string to be justified
3925 !C CALL SHFTRGHT (STRING)
3927 !C after execution of this code segment, STRING contains the value
3930 !C*************************************************************************
3932 SUBROUTINE SHFTRGHT (CHR)
3935 !C***********************************************************************
3939 I1 = LEN(CHR) ! Total length of string
3940 CALL CHRBLN(CHR,I2) ! Position of last non-blank character
3941 IF (I2.EQ.I1) RETURN
3943 DO 10 I=I2,1,-1 ! Shift characters
3944 CHR(I1+I-I2:I1+I-I2) = CHR(I:I)
3949 END SUBROUTINE SHFTRGHT
3954 !C*************************************************************************
3956 !C TOOLBOX LIBRARY v.1.0 (May 1995)
3958 !C Program unit : SUBROUTINE RPLSTR
3959 !C Purpose : REPLACE CHARACTERS OCCURING IN A STRING
3960 !C Author : Athanasios Nenes
3962 !C ======================= ARGUMENTS / USAGE =============================
3964 !C STRING is the CHARACTER variable with the string to be edited
3965 !C OLD is the old character which is to be replaced
3966 !C NEW is the new character which OLD is to be replaced with
3967 !C IERR is 0 if everything went well, is 1 if 'NEW' contains 'OLD'.
3968 !C In this case, this is invalid, and no change is done.
3974 !C CALL RPLSTR (STRING, OLD, NEW)
3976 !C after execution of this code segment, STRING contains the value
3979 !C*************************************************************************
3981 SUBROUTINE RPLSTR (STRING, OLD, NEW, IERR)
3984 !C***********************************************************************
3985 CHARACTER STRING*(*), OLD*(*), NEW*(*)
3989 ! *** INITIALIZE ********************************************************
3993 ! *** CHECK AND SEE IF 'NEW' CONTAINS 'OLD', WHICH CANNOT ***************
4003 ! *** PROCEED WITH REPLACING *******************************************
4005 10 IP = INDEX(STRING,OLD) ! SEE IF 'OLD' EXISTS IN 'STRING'
4006 IF (IP.EQ.0) RETURN ! 'OLD' DOES NOT EXIST ; RETURN
4007 STRING(IP:IP+ILO-1) = NEW ! REPLACE SUBSTRING 'OLD' WITH 'NEW'
4008 GOTO 10 ! GO FOR NEW OCCURANCE OF 'OLD'
4010 END SUBROUTINE RPLSTR
4013 !C*************************************************************************
4015 !C TOOLBOX LIBRARY v.1.0 (May 1995)
4017 !C Program unit : SUBROUTINE INPTD
4018 !C Purpose : Prompts user for a value (DOUBLE). A default value
4019 !C is provided, so if user presses <Enter>, the default
4021 !C Author : Athanasios Nenes
4023 !C ======================= ARGUMENTS / USAGE =============================
4025 !C VAR is the DOUBLE PRECISION variable which value is to be saved
4026 !C DEF is a DOUBLE PRECISION variable, with the default value of VAR.
4027 !C PROMPT is a CHARACTER varible containing the prompt string.
4028 !C PRFMT is a CHARACTER variable containing the FORMAT specifier
4029 !C for the default value DEF.
4030 !C IERR is an INTEGER error flag, and has the values:
4031 !C 0 - No error detected.
4032 !C 1 - Invalid FORMAT and/or Invalid default value.
4033 !C 2 - Bad value specified by user
4036 !C CALL INPTD (VAR, 1.0D0, 'Give value for A ', '*', Ierr)
4038 !C after execution of this code segment, the user is prompted for the
4039 !C value of variable VAR. If <Enter> is pressed (ie no value is specified)
4040 !C then 1.0 is assigned to VAR. The default value is displayed in free-
4041 !C format. The error status is specified by variable Ierr
4043 !C***********************************************************************
4045 SUBROUTINE INPTD (VAR, DEF, PROMPT, PRFMT, IERR)
4048 !C***********************************************************************
4049 CHARACTER PROMPT*(*), PRFMT*(*), BUFFER*128
4050 REAL(KIND=8) DEF, VAR
4055 ! *** WRITE DEFAULT VALUE TO WORK BUFFER *******************************
4057 WRITE (BUFFER, FMT=PRFMT, ERR=10) DEF
4058 CALL CHRBLN (BUFFER, IEND)
4060 ! *** PROMPT USER FOR INPUT AND READ IT ********************************
4062 WRITE (*,*) PROMPT,' [',BUFFER(1:IEND),']: '
4063 READ (*, '(A)', ERR=20, END=20) BUFFER
4064 CALL CHRBLN (BUFFER,IEND)
4066 ! *** READ DATA OR SET DEFAULT ? ****************************************
4068 IF (IEND.EQ.1 .AND. BUFFER(1:1).EQ.' ') THEN
4071 READ (BUFFER, *, ERR=20, END=20) VAR
4074 ! *** RETURN POINT ******************************************************
4078 ! *** ERROR HANDLER *****************************************************
4080 10 IERR = 1 ! Bad FORMAT and/or bad default value
4083 20 IERR = 2 ! Bad number given by user
4086 END SUBROUTINE INPTD
4089 !C*************************************************************************
4091 !C TOOLBOX LIBRARY v.1.0 (May 1995)
4093 !C Program unit : SUBROUTINE Pushend
4094 !C Purpose : Positions the pointer of a sequential file at its end
4095 !C Simulates the ACCESS='APPEND' clause of a F77L OPEN
4096 !C statement with Standard Fortran commands.
4098 !C ======================= ARGUMENTS / USAGE =============================
4100 !C Iunit is a INTEGER variable, the file unit which the file is
4104 !C CALL PUSHEND (10)
4106 !C after execution of this code segment, the pointer of unit 10 is
4107 !C pushed to its end.
4109 !C***********************************************************************
4111 SUBROUTINE Pushend (Iunit)
4114 !C***********************************************************************
4120 ! *** INQUIRE IF Iunit CONNECTED TO FILE ********************************
4122 INQUIRE (UNIT=Iunit, OPENED=OPNED)
4123 IF (.NOT.OPNED) GOTO 25
4125 ! *** Iunit CONNECTED, PUSH POINTER TO END ******************************
4127 10 READ (Iunit,'()', ERR=20, END=20)
4130 ! *** RETURN POINT ******************************************************
4132 20 BACKSPACE (Iunit)
4134 END SUBROUTINE Pushend
4138 !C*************************************************************************
4140 !C TOOLBOX LIBRARY v.1.0 (May 1995)
4142 !C Program unit : SUBROUTINE APPENDEXT
4143 !C Purpose : Fix extension in file name string
4145 !C ======================= ARGUMENTS / USAGE =============================
4147 !C Filename is the CHARACTER variable with the file name
4148 !C Defext is the CHARACTER variable with extension (including '.',
4150 !C Overwrite is a LOGICAL value, .TRUE. overwrites any existing extension
4151 !C in "Filename" with "Defext", .FALSE. puts "Defext" only if
4152 !C there is no extension in "Filename".
4155 !C FILENAME1 = 'TEST.DAT'
4156 !C FILENAME2 = 'TEST.DAT'
4157 !C CALL APPENDEXT (FILENAME1, '.TXT', .FALSE.)
4158 !C CALL APPENDEXT (FILENAME2, '.TXT', .TRUE. )
4160 !C after execution of this code segment, "FILENAME1" has the value
4161 !C 'TEST.DAT', while "FILENAME2" has the value 'TEST.TXT'
4163 !C***********************************************************************
4165 SUBROUTINE Appendext (Filename, Defext, Overwrite)
4168 !C***********************************************************************
4169 CHARACTER*(*) Filename, Defext
4173 CALL CHRBLN (Filename, Iend)
4174 IF (Filename(1:1).EQ.' ' .AND. Iend.EQ.1) RETURN ! Filename empty
4175 Idot = INDEX (Filename, '.') ! Append extension ?
4176 IF (Idot.EQ.0) Filename = Filename(1:Iend)//Defext
4177 IF (Overwrite .AND. Idot.NE.0)&
4178 Filename = Filename(:Idot-1)//Defext
4180 END SUBROUTINE Appendext
4186 !=======================================================================
4188 ! *** ISORROPIA CODE
4189 ! *** SUBROUTINE POLY3
4190 ! *** FINDS THE REAL ROOTS OF THE THIRD ORDER ALGEBRAIC EQUATION:
4191 ! X**3 + A1*X**2 + A2*X + A3 = 0.0
4192 ! THE EQUATION IS SOLVED ANALYTICALLY.
4194 ! PARAMETERS A1, A2, A3 ARE SPECIFIED BY THE USER. THE MINIMUM
4195 ! NONEGATIVE ROOT IS RETURNED IN VARIABLE 'ROOT'. IF NO ROOT IS
4196 ! FOUND (WHICH IS GREATER THAN ZERO), ROOT HAS THE VALUE 1D30.
4197 ! AND THE FLAG ISLV HAS A VALUE GREATER THAN ZERO.
4199 ! SOLUTION FORMULA IS FOUND IN PAGE 32 OF:
4200 ! MATHEMATICAL HANDBOOK OF FORMULAS AND TABLES
4201 ! SCHAUM'S OUTLINE SERIES
4202 ! MURRAY SPIEGER, McGRAW-HILL, NEW YORK, 1968
4203 ! (GREEK TRANSLATION: BY SOTIRIOS PERSIDES, ESPI, ATHENS, 1976)
4205 ! A SPECIAL CASE IS CONSIDERED SEPERATELY ; WHEN A3 = 0, THEN
4206 ! ONE ROOT IS X=0.0, AND THE OTHER TWO FROM THE SOLUTION OF THE
4207 ! QUADRATIC EQUATION X**2 + A1*X + A2 = 0.0
4208 ! THIS SPECIAL CASE IS CONSIDERED BECAUSE THE ANALYTICAL FORMULA
4209 ! DOES NOT YIELD ACCURATE RESULTS (DUE TO NUMERICAL ROUNDOFF ERRORS)
4211 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4212 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4213 ! *** WRITTEN BY ATHANASIOS NENES
4214 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4216 !=======================================================================
4218 SUBROUTINE POLY3 (A1, A2, A3, ROOT, ISLV)
4221 REAL(KIND=8) A1, A2, A3, ROOT
4223 REAL(KIND=8),PARAMETER::EXPON=1.D0/3.D0, ZERO=0.D0, THET1=120.D0/180.D0, &
4224 THET2=240.D0/180.D0, PI=3.14159265358932, EPS=1D-50
4228 REAL(KIND=8) D, SQD, Q, R, THET, COEF, SSIG, S, T, TSIG
4230 ! *** SPECIAL CASE : QUADRATIC*X EQUATION *****************************
4232 IF (ABS(A3).LE.EPS) THEN
4240 X(2) = 0.5*(-A1+SQD)
4241 X(3) = 0.5*(-A1-SQD)
4245 ! *** NORMAL CASE : CUBIC EQUATION ************************************
4247 ! DEFINE PARAMETERS Q, R, S, T, D
4250 Q = (3.D0*A2 - A1*A1)/9.D0
4251 R = (9.D0*A1*A2 - 27.D0*A3 - 2.D0*A1*A1*A1)/54.D0
4254 ! *** CALCULATE ROOTS *************************************************
4256 ! D < 0, THREE REAL ROOTS
4258 IF (D.LT.-EPS) THEN ! D < -EPS : D < ZERO
4260 THET = EXPON*ACOS(R/SQRT(-Q*Q*Q))
4261 COEF = 2.D0*SQRT(-Q)
4262 X(1) = COEF*COS(THET) - EXPON*A1
4263 X(2) = COEF*COS(THET + THET1*PI) - EXPON*A1
4264 X(3) = COEF*COS(THET + THET2*PI) - EXPON*A1
4266 ! D = 0, THREE REAL (ONE DOUBLE) ROOTS
4268 ELSE IF (D.LE.EPS) THEN ! -EPS <= D <= EPS : D = ZERO
4270 SSIG = SIGN (1.D0, R)
4271 S = SSIG*(ABS(R))**EXPON
4272 X(1) = 2.D0*S - EXPON*A1
4273 X(2) = -S - EXPON*A1
4275 ! D > 0, ONE REAL ROOT
4277 ELSE ! D > EPS : D > ZERO
4280 SSIG = SIGN (1.D0, R+SQD) ! TRANSFER SIGN TO SSIG
4281 TSIG = SIGN (1.D0, R-SQD)
4282 S = SSIG*(ABS(R+SQD))**EXPON ! EXPONENTIATE ABS()
4283 T = TSIG*(ABS(R-SQD))**EXPON
4284 X(1) = S + T - EXPON*A1
4288 ! *** SELECT APPROPRIATE ROOT *****************************************
4292 IF (X(I).GT.ZERO) THEN
4293 ROOT = MIN (ROOT, X(I))
4298 ! *** END OF SUBROUTINE POLY3 *****************************************
4301 END SUBROUTINE POLY3
4306 !=======================================================================
4308 ! *** ISORROPIA CODE
4309 ! *** SUBROUTINE POLY3B
4310 ! *** FINDS A REAL ROOT OF THE THIRD ORDER ALGEBRAIC EQUATION:
4311 ! X**3 + A1*X**2 + A2*X + A3 = 0.0
4312 ! THE EQUATION IS SOLVED NUMERICALLY (BISECTION).
4314 ! PARAMETERS A1, A2, A3 ARE SPECIFIED BY THE USER. THE MINIMUM
4315 ! NONEGATIVE ROOT IS RETURNED IN VARIABLE 'ROOT'. IF NO ROOT IS
4316 ! FOUND (WHICH IS GREATER THAN ZERO), ROOT HAS THE VALUE 1D30.
4317 ! AND THE FLAG ISLV HAS A VALUE GREATER THAN ZERO.
4319 ! RTLW, RTHI DEFINE THE INTERVAL WHICH THE ROOT IS LOOKED FOR.
4321 !=======================================================================
4323 SUBROUTINE POLY3B (A1, A2, A3, RTLW, RTHI, ROOT, ISLV)
4326 REAL(KIND=8) A1, A2, A3, RTLW, RTHI, ROOT
4328 REAL(KIND=8),PARAMETER::ZERO=0.D0, EPS=1D-15
4329 INTEGER,PARAMETER::MAXIT=100, NDIV=5
4331 REAL(KIND=8) X1, Y1, X2, Y2, X3, Y3, DX
4334 ! FUNC(X) = X**3.d0 + A1*X**2.0 + A2*X + A3
4336 ! *** INITIAL VALUES FOR BISECTION *************************************
4340 Y1 = X1**3.d0 + A1*X1**2.0 + A2*X1 + A3
4341 IF (ABS(Y1).LE.EPS) THEN ! Is low a root?
4346 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
4348 DX = (RTHI-RTLW)/FLOAT(NDIV)
4352 Y2 = X2**3.d0 + A1*X2**2.0 + A2*X2 + A3
4353 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2) .LT. ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
4358 ! *** NO SUBDIVISION WITH SOLUTION FOUND
4360 IF (ABS(Y2) .LT. EPS) THEN ! X2 is a root
4368 ! *** BISECTION *******************************************************
4373 Y3 = X3**3.d0 + A1*X3**2.0 + A2*X3 + A3
4374 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
4381 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
4384 ! *** CONVERGED ; RETURN ***********************************************
4388 Y3 = X3**3.d0 + A1*X3**2.0 + A2*X3 + A3
4394 ! *** END OF SUBROUTINE POLY3B *****************************************
4396 END SUBROUTINE POLY3B
4401 !cc DOUBLE PRECISION ROOT
4403 !cc CALL POLY3 (-1.d0, 1.d0, -1.d0, ROOT, ISLV)
4404 !cc IF (ISLV.NE.0) STOP 'Error in POLY3'
4405 !cc WRITE (*,*) 'Root=', ROOT
4407 !cc CALL POLY3B (-1.d0, 1.d0, -1.d0, -10.d0, 10.d0, ROOT, ISLV)
4408 !cc IF (ISLV.NE.0) STOP 'Error in POLY3B'
4409 !cc WRITE (*,*) 'Root=', ROOT
4412 !=======================================================================
4414 ! *** ISORROPIA CODE
4416 ! *** 10^X FUNCTION ; ALTERNATE OF LIBRARY ROUTINE ; USED BECAUSE IT IS
4417 ! MUCH FASTER BUT WITHOUT GREAT LOSS IN ACCURACY. ,
4418 ! MAXIMUM ERROR IS 2%, EXECUTION TIME IS 42% OF THE LIBRARY ROUTINE
4419 ! (ON A 80286/80287 MACHINE, using Lahey FORTRAN 77 v.3.0).
4421 ! EXPONENT RANGE IS BETWEEN -K AND K (K IS THE REAL ARGUMENT 'K')
4422 ! MAX VALUE FOR K: 9.999
4423 ! IF X < -K, X IS SET TO -K, IF X > K, X IS SET TO K
4425 ! THE EXPONENT IS CALCULATED BY THE PRODUCT ADEC*AINT, WHERE ADEC
4426 ! IS THE MANTISSA AND AINT IS THE MAGNITUDE (EXPONENT). BOTH
4427 ! MANTISSA AND MAGNITUDE ARE PRE-CALCULATED AND STORED IN LOOKUP
4428 ! TABLES ; THIS LEADS TO THE INCREASED SPEED.
4430 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4431 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4432 ! *** WRITTEN BY ATHANASIOS NENES
4433 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4435 !=======================================================================
4439 REAL X, EX10, Y, AINT10, ADEC10, K
4441 COMMON /EXPNC/ AINT10(20), ADEC10(200)
4443 ! *** LIMIT X TO [-K, K] RANGE *****************************************
4445 Y = MAX(-K, MIN(X,K)) ! MIN: -9.999, MAX: 9.999
4447 ! *** GET INTEGER AND DECIMAL PART *************************************
4450 K2 = INT(100*(Y-K1))
4452 ! *** CALCULATE EXP FUNCTION *******************************************
4454 EX10 = AINT10(K1+10)*ADEC10(K2+100)
4456 ! *** END OF EXP FUNCTION **********************************************
4463 !=======================================================================
4465 !=======================================================================
4467 ! *** ISORROPIA CODE
4468 ! *** SUBROUTINE PUSHERR
4469 ! *** THIS SUBROUTINE SAVES AN ERROR MESSAGE IN THE ERROR STACK
4471 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4472 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4473 ! *** WRITTEN BY ATHANASIOS NENES
4474 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4476 !=======================================================================
4478 SUBROUTINE PUSHERR (IERR,ERRINF)
4480 CHARACTER ERRINF*(*)
4483 ! *** SAVE ERROR CODE IF THERE IS ANY SPACE ***************************
4485 IF (NOFER.LT.NERRMX) THEN
4487 ERRSTK(NOFER) = IERR
4488 ERRMSG(NOFER) = ERRINF
4491 STKOFL =.TRUE. ! STACK OVERFLOW
4494 ! *** END OF SUBROUTINE PUSHERR ****************************************
4496 END SUBROUTINE PUSHERR
4500 !=======================================================================
4502 ! *** ISORROPIA CODE
4503 ! *** SUBROUTINE ISERRINF
4504 ! *** THIS SUBROUTINE OBTAINS A COPY OF THE ERROR STACK (& MESSAGES)
4506 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4507 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4508 ! *** WRITTEN BY ATHANASIOS NENES
4509 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4511 !=======================================================================
4513 SUBROUTINE ISERRINF (ERRSTKI, ERRMSGI, NOFERI, STKOFLI)
4515 CHARACTER(len=40) :: ERRMSGI(NERRMX)
4516 INTEGER ERRSTKI(NERRMX)
4520 ! DIMENSION ERRMSGI(NERRMX), ERRSTKI(NERRMX)
4522 ! *** OBTAIN WHOLE ERROR STACK ****************************************
4524 DO 10 I=1,NOFER ! Error messages & codes
4525 ERRSTKI(I) = ERRSTK(I)
4526 ERRMSGI(I) = ERRMSG(I)
4534 ! *** END OF SUBROUTINE ISERRINF ***************************************
4536 END SUBROUTINE ISERRINF
4540 !=======================================================================
4542 ! *** ISORROPIA CODE
4543 ! *** SUBROUTINE ERRSTAT
4544 ! *** THIS SUBROUTINE REPORTS ERROR MESSAGES TO UNIT 'IO'
4546 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4547 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4548 ! *** WRITTEN BY ATHANASIOS NENES
4549 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4551 !=======================================================================
4553 SUBROUTINE ERRSTAT (IO,IERR,ERRINF)
4555 CHARACTER CER*4, NCIS*29, NCIF*27, NSIS*26, NSIF*24, ERRINF*(*)
4556 DATA NCIS /'NO CONVERGENCE IN SUBROUTINE '/,&
4557 NCIF /'NO CONVERGENCE IN FUNCTION ' /,&
4558 NSIS /'NO SOLUTION IN SUBROUTINE ' /,&
4559 NSIF /'NO SOLUTION IN FUNCTION ' /
4560 INTEGER IO,IERR,IOK,IEND
4562 ! *** WRITE ERROR IN CHARACTER *****************************************
4564 WRITE (CER,'(I4)') IERR
4565 CALL RPLSTR (CER, ' ', '0',IOK) ! REPLACE BLANKS WITH ZEROS
4566 CALL CHRBLN (ERRINF, IEND) ! LAST POSITION OF ERRINF CHAR
4568 ! *** WRITE ERROR TYPE (FATAL, WARNING ) *******************************
4571 WRITE (IO,1000) 'NO ERRORS DETECTED '
4574 ELSE IF (IERR.LT.0) THEN
4575 WRITE (IO,1000) 'ERROR STACK EXHAUSTED '
4578 ELSE IF (IERR.GT.1000) THEN
4579 WRITE (IO,1100) 'FATAL',CER
4582 WRITE (IO,1100) 'WARNING',CER
4585 ! *** WRITE ERROR MESSAGE **********************************************
4589 IF (IERR.EQ.1001) THEN
4590 CALL CHRBLN (SCASE, IEND)
4591 WRITE (IO,1000) 'CASE NOT SUPPORTED IN CALCMR ['//SCASE(1:IEND) //']'
4593 ELSEIF (IERR.EQ.1002) THEN
4594 CALL CHRBLN (SCASE, IEND)
4595 WRITE (IO,1000) 'CASE NOT SUPPORTED ['//SCASE(1:IEND)//']'
4599 ELSEIF (IERR.EQ.0001) THEN
4600 WRITE (IO,1000) NSIS,ERRINF
4602 ELSEIF (IERR.EQ.0002) THEN
4603 WRITE (IO,1000) NCIS,ERRINF
4605 ELSEIF (IERR.EQ.0003) THEN
4606 WRITE (IO,1000) NSIF,ERRINF
4608 ELSEIF (IERR.EQ.0004) THEN
4609 WRITE (IO,1000) NCIF,ERRINF
4611 ELSE IF (IERR.EQ.0019) THEN
4612 WRITE (IO,1000) 'HNO3(aq) AFFECTS H+, WHICH '// &
4613 'MIGHT AFFECT SO4/HSO4 RATIO'
4614 WRITE (IO,1000) 'DIRECT INCREASE IN H+ [',ERRINF(1:IEND),'] %'
4616 ELSE IF (IERR.EQ.0020) THEN
4617 IF (W(4).GT.TINY .AND. W(5).GT.TINY) THEN
4618 WRITE (IO,1000) 'HSO4-SO4 EQUILIBRIUM MIGHT AFFECT HNO3,'&
4621 WRITE (IO,1000) 'HSO4-SO4 EQUILIBRIUM MIGHT AFFECT NH3 '&
4624 WRITE (IO,1000) 'DIRECT DECREASE IN H+ [',ERRINF(1:IEND),'] %'
4626 ELSE IF (IERR.EQ.0021) THEN
4627 WRITE (IO,1000) 'HNO3(aq),HCL(aq) AFFECT H+, WHICH '//&
4628 'MIGHT AFFECT SO4/HSO4 RATIO'
4629 WRITE (IO,1000) 'DIRECT INCREASE IN H+ [',ERRINF(1:IEND),'] %'
4631 ELSE IF (IERR.EQ.0022) THEN
4632 WRITE (IO,1000) 'HCL(g) EQUILIBRIUM YIELDS NONPHYSICAL '//&
4634 WRITE (IO,1000) 'A TINY AMOUNT [',ERRINF(1:IEND),'] IS '//&
4635 'ASSUMED TO BE DISSOLVED'
4637 ELSEIF (IERR.EQ.0033) THEN
4638 WRITE (IO,1000) 'HCL(aq) AFFECTS H+, WHICH '//&
4639 'MIGHT AFFECT SO4/HSO4 RATIO'
4640 WRITE (IO,1000) 'DIRECT INCREASE IN H+ [',ERRINF(1:IEND),'] %'
4642 ELSEIF (IERR.EQ.0050) THEN
4643 WRITE (IO,1000) 'TOO MUCH SODIUM GIVEN AS INPUT.'
4644 WRITE (IO,1000) 'REDUCED TO COMPLETELY NEUTRALIZE SO4,Cl,NO3.'
4645 WRITE (IO,1000) 'EXCESS SODIUM IS IGNORED.'
4648 WRITE (IO,1000) 'NO DIAGNOSTIC MESSAGE AVAILABLE'
4653 ! *** FORMAT STATEMENTS *************************************
4655 1000 FORMAT (1X,A:A:A:A:A)
4656 1100 FORMAT (1X,A,' ERROR [',A4,']:')
4658 ! *** END OF SUBROUTINE ERRSTAT *****************************
4660 END SUBROUTINE ERRSTAT
4661 !=======================================================================
4663 ! *** ISORROPIA CODE
4664 ! *** SUBROUTINE ISORINF
4665 ! *** THIS SUBROUTINE PROVIDES INFORMATION ABOUT ISORROPIA
4667 ! ======================== ARGUMENTS / USAGE ===========================
4671 ! CHARACTER*15 variable.
4672 ! Contains version-date information of ISORROPIA
4676 ! The number of components needed in input array WI
4677 ! (or, the number of major species accounted for by ISORROPIA)
4681 ! The number of ions considered in the aqueous phase
4685 ! The number of undissociated species found in aqueous aerosol
4690 ! The number of solids considered in the solid aerosol phase
4694 ! The size of the error stack (maximum number of errors that can
4695 ! be stored before the stack exhausts).
4698 ! DOUBLE PRECISION variable
4699 ! The value used for a very small number.
4702 ! DOUBLE PRECISION variable
4703 ! The value used for a very large number.
4705 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4706 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4707 ! *** WRITTEN BY ATHANASIOS NENES
4708 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
4710 !=======================================================================
4712 SUBROUTINE ISORINF (VERSI, NCMP, NION, NAQGAS, NSOL, NERR, TIN, GRT)
4714 integer NCMP, NION, NAQGAS, NSOL, NERR
4715 REAL(KIND=8) TIN, GRT
4718 ! *** ASSIGN INFO *******************************************************
4728 TIN = 9.999999999999999E-021
4729 GRT = 10000000000.0000
4738 ! *** END OF SUBROUTINE ISORINF *******************************************
4740 END SUBROUTINE ISORINF
4753 !=======================================================================
4755 ! *** ISORROPIA CODE
4756 ! *** SUBROUTINE ISRP1R
4757 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
4758 ! AN AMMONIUM-SULFATE AEROSOL SYSTEM.
4759 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
4760 ! THE AMBIENT RELATIVE HUMIDITY.
4762 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4763 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4764 ! *** WRITTEN BY ATHANASIOS NENES
4766 !=======================================================================
4768 SUBROUTINE ISRP1R (WI, RHI, TEMPI)
4771 REAL(KIND=8) WI(NCOMP),RHI,TEMPI
4773 ! *** INITIALIZE COMMON BLOCK VARIABLES *********************************
4775 CALL INIT1 (WI, RHI, TEMPI)
4777 ! *** CALCULATE SULFATE RATIO *******************************************
4779 IF (RH.GE.DRNH42S4) THEN ! WET AEROSOL, NEED NH4 AT SRATIO=2.0
4780 SULRATW = GETASR(WAER(2), RHI) ! AEROSOL SULFATE RATIO
4782 SULRATW = 2.0D0 ! DRY AEROSOL SULFATE RATIO
4784 SULRAT = WAER(3)/WAER(2) ! SULFATE RATIO
4786 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
4790 IF (SULRATW.LE.SULRAT) THEN
4792 IF(METSTBL.EQ.1) THEN
4794 CALL CALCK2 ! Only liquid (metastable)
4797 IF (RH.LT.DRNH42S4) THEN
4799 CALL CALCK1 ! NH42SO4 ; case K1
4801 ELSEIF (DRNH42S4.LE.RH) THEN
4803 CALL CALCK2 ! Only liquid ; case K2
4807 ! *** SULFATE RICH (NO ACID)
4809 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
4813 IF(METSTBL.EQ.1) THEN
4815 CALL CALCB4 ! Only liquid (metastable)
4819 IF (RH.LT.DRNH4HS4) THEN
4821 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case B1
4824 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
4826 CALL CALCB2 ! LC,NH42S4 ; case B2
4829 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
4831 CALL CALCB3 ! NH42S4 ; case B3
4834 ELSEIF (DRNH42S4.LE.RH) THEN
4836 CALL CALCB4 ! Only liquid ; case B4
4841 CALL CALCNH3P ! Compute NH3(g)
4843 ! *** SULFATE RICH (FREE ACID)
4845 ELSEIF (SULRAT.LT.1.0) THEN
4849 IF(METSTBL.EQ.1) THEN
4851 CALL CALCC2 ! Only liquid (metastable)
4855 IF (RH.LT.DRNH4HS4) THEN
4857 CALL CALCC1 ! NH4HSO4 ; case C1
4860 ELSEIF (DRNH4HS4.LE.RH) THEN
4862 CALL CALCC2 ! Only liquid ; case C2
4872 ! *** END OF SUBROUTINE ISRP1R *****************************************
4874 END SUBROUTINE ISRP1R
4877 !=======================================================================
4879 ! *** ISORROPIA CODE
4880 ! *** SUBROUTINE ISRP2R
4881 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
4882 ! AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
4883 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
4884 ! THE AMBIENT RELATIVE HUMIDITY.
4886 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4887 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
4888 ! *** WRITTEN BY ATHANASIOS NENES
4890 !=======================================================================
4892 SUBROUTINE ISRP2R (WI, RHI, TEMPI)
4895 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
4898 ! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
4900 TRYLIQ = .TRUE. ! Assume liquid phase, sulfate poor limit
4902 10 CALL INIT2 (WI, RHI, TEMPI)
4904 ! *** CALCULATE SULFATE RATIO *******************************************
4906 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! *** WET AEROSOL
4907 SULRATW = GETASR(WAER(2), RHI) ! LIMITING SULFATE RATIO
4909 SULRATW = 2.0D0 ! *** DRY AEROSOL
4911 SULRAT = WAER(3)/WAER(2)
4913 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
4917 IF (SULRATW.LE.SULRAT) THEN
4919 IF(METSTBL.EQ.1) THEN
4921 CALL CALCN3 ! Only liquid (metastable)
4924 IF (RH.LT.DRNH4NO3) THEN
4926 CALL CALCN1 ! NH42SO4,NH4NO3 ; case N1
4928 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH42S4) THEN
4930 CALL CALCN2 ! NH42S4 ; case N2
4932 ELSEIF (DRNH42S4.LE.RH) THEN
4934 CALL CALCN3 ! Only liquid ; case N3
4938 ! *** SULFATE RICH (NO ACID)
4940 ! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
4941 ! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
4942 ! AEROSOL EQUILIBRIUM.
4944 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
4949 IF(METSTBL.EQ.1) THEN
4951 CALL CALCB4 ! Only liquid (metastable)
4955 IF (RH.LT.DRNH4HS4) THEN
4957 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case O1
4960 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
4962 CALL CALCB2 ! LC,NH42S4 ; case O2
4965 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
4967 CALL CALCB3 ! NH42S4 ; case O3
4970 ELSEIF (DRNH42S4.LE.RH) THEN
4972 CALL CALCB4 ! Only liquid ; case O4
4977 ! *** Add the NO3 to the solution now and calculate partitioning.
4979 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
4980 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
4981 CALL CALCNAP ! HNO3, NH3 dissolved
4984 ! *** SULFATE RICH (FREE ACID)
4986 ! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
4987 ! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
4988 ! AEROSOL EQUILIBRIUM.
4990 ELSEIF (SULRAT.LT.1.0) THEN
4995 IF(METSTBL.EQ.1) THEN
4997 CALL CALCC2 ! Only liquid (metastable)
5001 IF (RH.LT.DRNH4HS4) THEN
5003 CALL CALCC1 ! NH4HSO4 ; case P1
5006 ELSEIF (DRNH4HS4.LE.RH) THEN
5008 CALL CALCC2 ! Only liquid ; case P2
5013 ! *** Add the NO3 to the solution now and calculate partitioning.
5015 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
5016 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
5018 CALL CALCNAP ! HNO3, NH3 dissolved
5022 ! *** IF SULRATW < SULRAT < 2.0 and WATER = 0 => SULFATE RICH CASE.
5024 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 .AND. WATER.LE.TINY) THEN
5031 ! *** END OF SUBROUTINE ISRP2R *****************************************
5033 END SUBROUTINE ISRP2R
5034 !=======================================================================
5036 ! *** ISORROPIA CODE
5037 ! *** SUBROUTINE ISRP3R
5038 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
5039 ! AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
5040 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
5041 ! RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
5043 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5044 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5045 ! *** WRITTEN BY ATHANASIOS NENES
5047 !=======================================================================
5049 SUBROUTINE ISRP3R (WI, RHI, TEMPI)
5052 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
5056 !cC *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
5058 !c WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
5059 !c WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
5061 ! *** INITIALIZE ALL VARIABLES ******************************************
5063 TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
5065 10 CALL ISOINIT3 (WI, RHI, TEMPI) ! COMMON block variables
5067 !cC *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
5069 !c REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
5070 !c IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
5071 !c WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
5072 !c CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
5075 ! *** CALCULATE SULFATE & SODIUM RATIOS *********************************
5077 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! ** WET AEROSOL
5078 FRSO4 = WAER(2) - WAER(1)/2.0D0 ! SULFATE UNBOUND BY SODIUM
5079 FRSO4 = MAX(FRSO4, TINY)
5080 SRI = GETASR(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
5081 SULRATW = (WAER(1)+FRSO4*SRI)/WAER(2) ! LIMITING SULFATE RATIO
5082 SULRATW = MIN (SULRATW, 2.0D0)
5084 SULRATW = 2.0D0 ! ** DRY AEROSOL
5086 SULRAT = (WAER(1)+WAER(3))/WAER(2)
5087 SODRAT = WAER(1)/WAER(2)
5089 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
5091 ! *** SULFATE POOR ; SODIUM POOR
5093 IF (SULRATW.LE.SULRAT .AND. SODRAT.LT.2.0) THEN
5095 IF(METSTBL.EQ.1) THEN
5097 CALL CALCQ5 ! Only liquid (metastable)
5101 IF (RH.LT.DRNH4NO3) THEN
5103 CALL CALCQ1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
5105 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
5107 CALL CALCQ2 ! NH42SO4,NH4CL,NA2SO4
5109 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
5111 CALL CALCQ3 ! NH42SO4,NA2SO4
5113 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
5115 CALL CALCQ4 ! NA2SO4
5118 ELSEIF (DRNA2SO4.LE.RH) THEN
5120 CALL CALCQ5 ! Only liquid
5125 ! *** SULFATE POOR ; SODIUM RICH
5127 ELSE IF (SULRAT.GE.SULRATW .AND. SODRAT.GE.2.0) THEN
5129 IF(METSTBL.EQ.1) THEN
5131 CALL CALCR6 ! Only liquid (metastable)
5135 IF (RH.LT.DRNH4NO3) THEN
5137 CALL CALCR1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
5139 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
5141 CALL CALCR2 ! NH4CL,NA2SO4,NACL,NANO3
5143 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
5145 CALL CALCR3 ! NH4CL,NA2SO4,NACL
5147 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4CL) THEN
5149 CALL CALCR4 ! NH4CL,NA2SO4
5151 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNA2SO4) THEN
5153 CALL CALCR5 ! NA2SO4
5156 ELSEIF (DRNA2SO4.LE.RH) THEN
5158 CALL CALCR6 ! NO SOLID
5163 ! *** SULFATE RICH (NO ACID)
5165 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
5170 IF(METSTBL.EQ.1) THEN
5172 CALL CALCI6 ! Only liquid (metastable)
5176 IF (RH.LT.DRNH4HS4) THEN
5178 CALL CALCI1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
5181 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
5183 CALL CALCI2 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
5186 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
5188 CALL CALCI3 ! NA2SO4,(NH4)2SO4,LC
5191 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
5193 CALL CALCI4 ! NA2SO4,(NH4)2SO4
5196 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
5198 CALL CALCI5 ! NA2SO4
5201 ELSEIF (DRNA2SO4.LE.RH) THEN
5203 CALL CALCI6 ! NO SOLIDS
5208 CALL CALCNHP ! HNO3, NH3, HCL in gas phase
5211 ! *** SULFATE RICH (FREE ACID)
5213 ELSEIF (SULRAT.LT.1.0) THEN
5218 IF(METSTBL.EQ.1) THEN
5220 CALL CALCJ3 ! Only liquid (metastable)
5224 IF (RH.LT.DRNH4HS4) THEN
5226 CALL CALCJ1 ! NH4HSO4,NAHSO4
5229 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
5231 CALL CALCJ2 ! NAHSO4
5234 ELSEIF (DRNAHSO4.LE.RH) THEN
5241 CALL CALCNHP ! HNO3, NH3, HCL in gas phase
5246 ! *** IF AFTER CALCULATIONS, SULRATW < SULRAT < 2.0
5247 ! and WATER = 0 => SULFATE RICH CASE.
5249 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 .AND. WATER.LE.TINY) THEN
5256 ! *** END OF SUBROUTINE ISRP3R *****************************************
5258 END SUBROUTINE ISRP3R
5262 !=======================================================================
5264 ! *** ISORROPIA CODE
5265 ! *** SUBROUTINE CALCK2
5268 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5269 ! 1. SULFATE POOR (SULRAT > 2.0)
5270 ! 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
5272 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5273 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5274 ! *** WRITTEN BY ATHANASIOS NENES
5276 !=======================================================================
5280 REAL(KIND=8) NH4I, NH3GI, NH3AQ
5281 REAL(KIND=8) AKW, SO4I, HSO4I, HI, OHI, DEL
5284 ! *** SETUP PARAMETERS ************************************************
5286 CALAOU =.TRUE. ! Outer loop activity calculation flag
5290 ! *** CALCULATE WATER CONTENT *****************************************
5292 MOLALR(4)= MIN(WAER(2), 0.5d0*WAER(3))
5293 WATER = MOLALR(4)/M0(4) ! ZSR correlation
5295 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5298 !C A21 = XK21*WATER*R*TEMP
5299 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
5300 AKW = XKW *RH*WATER*WATER
5306 CALL CALCPH (2.D0*SO4I - NH4I, HI, OHI) ! Get pH
5308 NH3AQ = ZERO ! AMMONIA EQUILIBRIUM
5310 CALL CALCAMAQ (NH4I, OHI, DEL)
5311 NH4I = MAX (NH4I-DEL, ZERO)
5312 OHI = MAX (OHI -DEL, TINY)
5317 CALL CALCHS4 (HI, SO4I, ZERO, DEL) ! SULFATE EQUILIBRIUM
5322 NH3GI = NH4I/HI/A2 ! NH3AQ/A21
5324 ! *** SPECIATION & WATER CONTENT ***************************************
5334 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5336 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5345 ! *** END OF SUBROUTINE CALCK2 ****************************************
5347 END SUBROUTINE CALCK2
5348 !=======================================================================
5350 ! *** ISORROPIA CODE
5351 ! *** SUBROUTINE CALCK1
5354 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5355 ! 1. SULFATE POOR (SULRAT > 2.0)
5356 ! 2. SOLID AEROSOL ONLY
5357 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
5359 ! A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
5360 ! IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
5363 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5364 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5365 ! *** WRITTEN BY ATHANASIOS NENES
5367 !=======================================================================
5372 CNH42S4 = MIN(WAER(2),0.5d0*WAER(3)) ! For bad input problems
5376 W(3) = 2.D0*CNH42S4 + GNH3
5380 ! *** END OF SUBROUTINE CALCK1 ******************************************
5382 END SUBROUTINE CALCK1
5385 !=======================================================================
5387 ! *** ISORROPIA CODE
5388 ! *** SUBROUTINE CALCN3
5391 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5392 ! 1. SULFATE POOR (SULRAT > 2.0)
5393 ! 2. THERE IS ONLY A LIQUID PHASE
5395 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5396 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5397 ! *** WRITTEN BY ATHANASIOS NENES
5399 !=======================================================================
5403 REAL(KIND=8) NH4I, NO3I, NH3AQ, NO3AQ
5404 REAL(KIND=8) AML5, AKW, SO4I, HSO4I, HI, OHI, GG, DEL
5407 ! *** SETUP PARAMETERS ************************************************
5409 CALAOU =.TRUE. ! Outer loop activity calculation flag
5413 ! *** AEROSOL WATER CONTENT
5415 MOLALR(4) = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
5416 AML5 = MAX(WAER(3)-2.D0*MOLALR(4),ZERO) ! "free" NH4
5417 MOLALR(5) = MAX(MIN(AML5,WAER(4)), ZERO) ! NH4NO3=MIN("free",NO3)
5418 WATER = MOLALR(4)/M0(4) + MOLALR(5)/M0(5)
5419 WATER = MAX(WATER, TINY)
5421 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5424 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
5425 !C A21 = XK21*WATER*R*TEMP
5426 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
5427 A4 = XK7*(WATER/GAMA(4))**3.0
5428 AKW = XKW *RH*WATER*WATER
5430 ! ION CONCENTRATIONS
5437 CALL CALCPH (2.D0*SO4I + NO3I - NH4I, HI, OHI)
5439 ! AMMONIA ASSOCIATION EQUILIBRIUM
5443 GG = 2.D0*SO4I + NO3I - NH4I
5445 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5449 CALL CALCNIAQ2 (GG, NO3I, HI, NO3AQ) ! HNO3
5451 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5453 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
5460 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5476 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
5478 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP ******************
5480 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5487 ! *** RETURN ***********************************************************
5491 ! *** END OF SUBROUTINE CALCN3 *****************************************
5493 END SUBROUTINE CALCN3
5494 !=======================================================================
5496 ! *** ISORROPIA CODE
5497 ! *** SUBROUTINE CALCN2
5500 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5501 ! 1. SULFATE POOR (SULRAT > 2.0)
5502 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
5503 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
5505 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5506 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5507 ! *** WRITTEN BY ATHANASIOS NENES
5509 !=======================================================================
5513 REAL(KIND=8) PSI1LO, PSI1HI, YLO, YHI, DX, X1, X2, X3, Y1, Y2, Y3
5517 ! *** SETUP PARAMETERS ************************************************
5519 CHI1 = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
5520 CHI2 = MAX(WAER(3) - 2.D0*CHI1, ZERO) ! "Free" NH4+
5521 CHI3 = MAX(WAER(4) - CHI2, ZERO) ! "Free" NO3
5526 CALAOU = .TRUE. ! Outer loop activity calculation flag
5527 PSI1LO = TINY ! Low limit
5528 PSI1HI = CHI1 ! High limit
5530 ! *** INITIAL VALUES FOR BISECTION ************************************
5534 IF (Y1.LE.EPS) RETURN ! IF (ABS(Y1).LE.EPS .OR. Y1.LE.ZERO) RETURN
5535 YHI= Y1 ! Save Y-value at HI position
5537 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
5539 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
5541 X2 = MAX(X1-DX, ZERO)
5543 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
5548 ! *** NO SUBDIVISION WITH SOLUTION FOUND
5550 YLO= Y1 ! Save Y-value at Hi position
5551 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
5554 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
5556 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
5561 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
5563 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
5568 CALL PUSHERR (0001, 'CALCN2') ! WARNING ERROR: NO SOLUTION
5572 ! *** PERFORM BISECTION ***********************************************
5577 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
5584 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
5586 CALL PUSHERR (0002, 'CALCN2') ! WARNING ERROR: NO CONVERGENCE
5588 ! *** CONVERGED ; RETURN **********************************************
5595 ! *** END OF SUBROUTINE CALCN2 ******************************************
5597 END SUBROUTINE CALCN2
5601 !======================================================================
5603 ! *** ISORROPIA CODE
5604 ! *** FUNCTION FUNCN2
5606 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D2 ;
5607 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCN2.
5609 !=======================================================================
5611 REAL(KIND=8) FUNCTION FUNCN2 (P1)
5614 REAL(KIND=8) NH4I, NO3I, NH3AQ, NO3AQ
5615 REAL(KIND=8) AKW, SO4I, HSO4I, HI, OHI, GG, DEL
5618 ! *** SETUP PARAMETERS ************************************************
5624 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5627 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
5628 !C A21 = XK21*WATER*R*TEMP
5629 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
5630 A4 = XK7*(WATER/GAMA(4))**3.0
5631 AKW = XKW *RH*WATER*WATER
5633 ! ION CONCENTRATIONS
5635 NH4I = 2.D0*PSI1 + PSI2
5640 CALL CALCPH (2.D0*SO4I + NO3I - NH4I, HI, OHI)
5642 ! AMMONIA ASSOCIATION EQUILIBRIUM
5646 GG = 2.D0*SO4I + NO3I - NH4I
5648 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5652 CALL CALCNIAQ2 (GG, NO3I, HI, NO3AQ) ! HNO3
5654 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5656 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
5663 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5672 CNH42S4 = CHI1 - PSI1
5679 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
5681 ! *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
5685 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5687 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5694 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
5696 20 FUNCN2= NH4I*NH4I*SO4I/A4 - ONE
5699 ! *** END OF FUNCTION FUNCN2 ********************************************
5702 !=======================================================================
5704 ! *** ISORROPIA CODE
5705 ! *** SUBROUTINE CALCN1
5708 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5709 ! 1. SULFATE POOR (SULRAT > 2.0)
5710 ! 2. SOLID AEROSOL ONLY
5711 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
5713 ! THERE ARE TWO REGIMES DEFINED BY RELATIVE HUMIDITY:
5714 ! 1. RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCN1A)
5715 ! 2. RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
5717 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5718 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5719 ! *** WRITTEN BY ATHANASIOS NENES
5721 !=======================================================================
5725 ! EXTERNAL CALCN1A, CALCN2
5727 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
5729 IF (RH.LT.DRMASAN) THEN
5730 SCASE = 'N1 ; SUBCASE 1'
5731 CALL CALCN1A ! SOLID PHASE ONLY POSSIBLE
5732 SCASE = 'N1 ; SUBCASE 1'
5734 SCASE = 'N1 ; SUBCASE 2'
5735 CALL CALCMDRP (RH, DRMASAN, DRNH4NO3, CALCN1A, CALCN2)
5736 SCASE = 'N1 ; SUBCASE 2'
5741 ! *** END OF SUBROUTINE CALCN1 ******************************************
5743 END SUBROUTINE CALCN1
5747 !=======================================================================
5749 ! *** ISORROPIA CODE
5750 ! *** SUBROUTINE CALCN1A
5751 ! *** CASE N1 ; SUBCASE 1
5753 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5754 ! 1. SULFATE POOR (SULRAT > 2.0)
5755 ! 2. SOLID AEROSOL ONLY
5756 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
5758 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5759 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5760 ! *** WRITTEN BY ATHANASIOS NENES
5762 !=======================================================================
5768 ! *** SETUP PARAMETERS *************************************************
5770 !CC A1 = XK10/R/TEMP/R/TEMP
5772 ! *** CALCULATE AEROSOL COMPOSITION ************************************
5774 !CC CHI1 = 2.D0*WAER(4) ! Free parameter ; arbitrary value.
5777 ! *** The following statment is here to avoid negative NH4+ values in
5778 ! CALCN? routines that call CALCN1A
5780 PSI2 = MAX(MIN(WAER(2),0.5d0*(WAER(3)-PSI1)),TINY)
5785 !CC GNH3 = CHI1 + PSI1 + 2.0*PSI2
5786 !CC GHNO3 = A1/(CHI1-PSI1) + PSI1
5791 W(3) = GNH3 + PSI1 + 2.0*PSI2
5796 ! *** END OF SUBROUTINE CALCN1A *****************************************
5798 END SUBROUTINE CALCN1A
5800 !=======================================================================
5802 ! *** ISORROPIA CODE
5803 ! *** SUBROUTINE CALCQ5
5806 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5807 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
5808 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
5810 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5811 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5812 ! *** WRITTEN BY ATHANASIOS NENES
5814 !=======================================================================
5820 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
5821 REAL(KIND=8) AKW, SO4I, CLI, GG, BB, CC, DD, HI, OHI
5822 REAL(KIND=8) GGNO3, GGCL, DEL, HSO4I
5824 ! *** SETUP PARAMETERS ************************************************
5830 ! *** CALCULATE INITIAL SOLUTION ***************************************
5834 PSI1 = CNA2SO4 ! SALTS DISSOLVED
5845 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5848 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
5850 ! ION CONCENTRATIONS
5858 ! SOLUTION ACIDIC OR BASIC?
5860 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
5861 IF (GG.GT.TINY) THEN ! H+ in excess
5864 DD = BB*BB - 4.D0*CC
5865 HI = 0.5D0*(-BB + SQRT(DD))
5867 ELSE ! OH- in excess
5870 DD = BB*BB - 4.D0*CC
5871 OHI= 0.5D0*(-BB + SQRT(DD))
5875 ! UNDISSOCIATED SPECIES EQUILIBRIA
5878 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5882 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
5883 GGCL = MAX(GG-GGNO3, ZERO)
5884 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
5885 IF (GGNO3.GT.TINY) THEN
5886 IF (GGCL.LE.TINY) HI = ZERO
5887 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
5890 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5892 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
5899 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5909 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5911 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5917 !cc CALL PUSHERR (0002, 'CALCQ5') ! WARNING ERROR: NO CONVERGENCE
5919 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5921 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
5922 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
5923 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
5942 ! *** END OF SUBROUTINE CALCQ5 ******************************************
5944 END SUBROUTINE CALCQ5
5945 !=======================================================================
5947 ! *** ISORROPIA CODE
5948 ! *** SUBROUTINE CALCQ4
5951 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5952 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
5953 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
5955 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5956 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
5957 ! *** WRITTEN BY ATHANASIOS NENES
5959 !=======================================================================
5965 REAL(KIND=8) PSI1O, ROOT3, NAI, SO4I, NH4I, NO3I, CLI
5966 REAL(KIND=8) NH3AQ, NO3AQ, CLAQ, AKW, BB, CC, DD, GG, HI, OHI
5967 REAL(KIND=8) GGNO3, GGCL, DEL, HSO4I
5971 ! *** SETUP PARAMETERS ************************************************
5981 ! *** CALCULATE INITIAL SOLUTION ***************************************
5985 CHI1 = CNA2SO4 ! SALTS
5987 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
5994 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6004 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6007 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
6008 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6012 IF (NAI*NAI*SO4I .GT. A5) THEN
6013 BB =-(WAER(2) + WAER(1))
6014 CC = WAER(1)*WAER(2) + 0.25*WAER(1)*WAER(1)
6015 DD =-0.25*(WAER(1)*WAER(1)*WAER(2) - A5)
6016 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
6017 IF (ISLV.NE.0) ROOT3 = TINY
6018 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2), CHI1)
6019 ROOT3 = MAX (ROOT3, ZERO)
6022 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6025 ! ION CONCENTRATIONS ; CORRECTIONS
6027 NAI = WAER(1) - 2.D0*ROOT3
6028 SO4I= WAER(2) - ROOT3
6033 ! SOLUTION ACIDIC OR BASIC?
6035 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
6036 IF (GG.GT.TINY) THEN ! H+ in excess
6039 DD = BB*BB - 4.D0*CC
6040 HI = 0.5D0*(-BB + SQRT(DD))
6042 ELSE ! OH- in excess
6045 DD = BB*BB - 4.D0*CC
6046 OHI= 0.5D0*(-BB + SQRT(DD))
6050 ! UNDISSOCIATED SPECIES EQUILIBRIA
6053 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6057 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
6058 GGCL = MAX(GG-GGNO3, ZERO)
6059 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6060 IF (GGNO3.GT.TINY) THEN
6061 IF (GGCL.LE.TINY) HI = ZERO
6062 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6065 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6067 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
6074 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6084 ! *** CALCULATE WATER **************************************************
6088 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6090 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6093 IF (PSCONV1) GOTO 20
6096 !cc CALL PUSHERR (0002, 'CALCQ4') ! WARNING ERROR: NO CONVERGENCE
6098 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6100 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6101 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6102 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6117 CNA2SO4 = CHI1 - PSI1
6121 ! *** END OF SUBROUTINE CALCQ4 ******************************************
6123 END SUBROUTINE CALCQ4
6124 !=======================================================================
6126 ! *** ISORROPIA CODE
6127 ! *** SUBROUTINE CALCQ3
6130 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6131 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
6132 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
6133 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
6135 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6136 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6137 ! *** WRITTEN BY ATHANASIOS NENES
6139 !=======================================================================
6144 ! EXTERNAL CALCQ1A, CALCQ4
6146 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
6148 EXNO = WAER(4).GT.TINY
6149 EXCL = WAER(5).GT.TINY
6151 IF (EXNO .OR. EXCL) THEN ! *** NITRATE OR CHLORIDE EXISTS
6152 SCASE = 'Q3 ; SUBCASE 1'
6154 SCASE = 'Q3 ; SUBCASE 1'
6156 ELSE ! *** NO CHLORIDE AND NITRATE
6157 IF (RH.LT.DRMG3) THEN
6158 SCASE = 'Q3 ; SUBCASE 2'
6159 CALL CALCQ1A ! SOLID
6160 SCASE = 'Q3 ; SUBCASE 2'
6162 SCASE = 'Q3 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4
6163 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
6164 SCASE = 'Q3 ; SUBCASE 3'
6170 ! *** END OF SUBROUTINE CALCQ3 ******************************************
6172 END SUBROUTINE CALCQ3
6176 !=======================================================================
6178 ! *** ISORROPIA CODE
6179 ! *** SUBROUTINE CALCQ3A
6180 ! *** CASE Q3 ; SUBCASE A
6182 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6183 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
6184 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
6186 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6187 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6188 ! *** WRITTEN BY ATHANASIOS NENES
6190 !=======================================================================
6195 LOGICAL PSCONV1, PSCONV6
6196 REAL(KIND=8) PSI1O, ROOT3, NAI, SO4I, NH4I, NO3I, CLI
6197 REAL(KIND=8) NH3AQ, NO3AQ, CLAQ, AKW, BB, CC, DD, GG, HI, OHI
6198 REAL(KIND=8) GGNO3, GGCL, DEL, HSO4I,PSI6O, ROOT1
6202 ! *** SETUP PARAMETERS ************************************************
6217 ! *** CALCULATE INITIAL SOLUTION ***************************************
6221 CHI1 = CNA2SO4 ! SALTS
6225 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
6232 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6242 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6245 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
6246 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> Na+
6247 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6251 IF (NAI*NAI*SO4I .GT. A5) THEN
6252 BB =-(WAER(2) + WAER(1) - ROOT1)
6253 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
6254 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
6255 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
6256 IF (ISLV.NE.0) ROOT3 = TINY
6257 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
6258 ROOT3 = MAX (ROOT3, ZERO)
6261 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6266 IF (NH4I*NH4I*SO4I .GT. A4) THEN
6267 BB =-(WAER(2)+WAER(3)-ROOT3)
6268 CC = WAER(3)*(WAER(2)-ROOT3+0.5D0*WAER(3))
6269 DD =-((WAER(2)-ROOT3)*WAER(3)**2.D0 + A4)/4.D0
6270 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
6271 IF (ISLV.NE.0) ROOT1 = TINY
6272 ROOT1 = MIN(ROOT1, WAER(3), WAER(2)-ROOT3, CHI6)
6273 ROOT1 = MAX(ROOT1, ZERO)
6276 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
6279 ! ION CONCENTRATIONS
6281 NAI = WAER(1) - 2.D0*ROOT3
6282 SO4I= WAER(2) - ROOT1 - ROOT3
6283 NH4I= WAER(3) - 2.D0*ROOT1
6287 ! SOLUTION ACIDIC OR BASIC?
6289 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
6290 IF (GG.GT.TINY) THEN ! H+ in excess
6293 DD = BB*BB - 4.D0*CC
6294 HI = 0.5D0*(-BB + SQRT(DD))
6296 ELSE ! OH- in excess
6299 DD = BB*BB - 4.D0*CC
6300 OHI= 0.5D0*(-BB + SQRT(DD))
6304 ! UNDISSOCIATED SPECIES EQUILIBRIA
6307 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6311 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
6312 GGCL = MAX(GG-GGNO3, ZERO)
6313 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6314 IF (GGNO3.GT.TINY) THEN
6315 IF (GGCL.LE.TINY) HI = ZERO
6316 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6319 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6321 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
6328 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6338 ! *** CALCULATE WATER **************************************************
6342 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6344 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6347 IF (PSCONV1 .AND. PSCONV6) GOTO 20
6350 !cc CALL PUSHERR (0002, 'CALCQ3A') ! WARNING ERROR: NO CONVERGENCE
6352 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6354 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6355 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6356 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6366 CNH42S4 = CHI6 - PSI6
6371 CNA2SO4 = CHI1 - PSI1
6375 ! *** END OF SUBROUTINE CALCQ3A *****************************************
6377 END SUBROUTINE CALCQ3A
6381 !=======================================================================
6383 ! *** ISORROPIA CODE
6384 ! *** SUBROUTINE CALCQ2
6387 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6388 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
6389 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
6390 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
6392 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6393 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6394 ! *** WRITTEN BY ATHANASIOS NENES
6396 !=======================================================================
6401 ! EXTERNAL CALCQ1A, CALCQ3A, CALCQ4
6403 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
6405 EXNO = WAER(4).GT.TINY
6406 EXCL = WAER(5).GT.TINY
6408 IF (EXNO) THEN ! *** NITRATE EXISTS
6409 SCASE = 'Q2 ; SUBCASE 1'
6411 SCASE = 'Q2 ; SUBCASE 1'
6413 ELSEIF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
6414 IF (RH.LT.DRMG2) THEN
6415 SCASE = 'Q2 ; SUBCASE 2'
6416 CALL CALCQ1A ! SOLID
6417 SCASE = 'Q2 ; SUBCASE 2'
6419 SCASE = 'Q2 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
6420 CALL CALCMDRP (RH, DRMG2, DRNH4CL, CALCQ1A, CALCQ3A)
6421 SCASE = 'Q2 ; SUBCASE 3'
6424 ELSE ! *** NO CHLORIDE AND NITRATE
6425 IF (RH.LT.DRMG3) THEN
6426 SCASE = 'Q2 ; SUBCASE 2'
6427 CALL CALCQ1A ! SOLID
6428 SCASE = 'Q2 ; SUBCASE 2'
6430 SCASE = 'Q2 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4
6431 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
6432 SCASE = 'Q2 ; SUBCASE 4'
6438 ! *** END OF SUBROUTINE CALCQ2 ******************************************
6440 END SUBROUTINE CALCQ2
6443 !=======================================================================
6445 ! *** ISORROPIA CODE
6446 ! *** SUBROUTINE CALCQ2A
6447 ! *** CASE Q2 ; SUBCASE A
6449 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6450 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
6451 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
6453 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6454 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6455 ! *** WRITTEN BY ATHANASIOS NENES
6457 !=======================================================================
6462 LOGICAL PSCONV1, PSCONV4, PSCONV6
6463 REAL(KIND=8) NH4I, NAI, NO3I, HSO4I, NH3AQ, NO3AQ, CLAQ, SO4I, CLI
6464 REAL(KIND=8) PSI1O, PSI4O, PSI6O, ROOT1, ROOT2, ROOT3
6465 REAL(KIND=8) ROOT2A, ROOT2B
6466 REAL(KIND=8) AKW, BB, CC, DD, GG, HI, OHI
6467 REAL(KIND=8) GGNO3, GGCL
6468 REAL(KIND=8) A14, DEL
6473 ! *** SETUP PARAMETERS ************************************************
6491 ! *** CALCULATE INITIAL SOLUTION ***************************************
6495 CHI1 = CNA2SO4 ! SALTS
6499 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
6506 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6516 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6519 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
6520 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
6521 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> Na+
6522 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6526 IF (NH4I*CLI .GT. A14) THEN
6527 BB =-(WAER(3) + WAER(5) - 2.D0*ROOT1)
6528 CC = WAER(5)*(WAER(3) - 2.D0*ROOT1) - A14
6529 DD = BB*BB - 4.D0*CC
6530 IF (DD.LT.ZERO) THEN
6534 ROOT2A= 0.5D0*(-BB+DD)
6535 ROOT2B= 0.5D0*(-BB-DD)
6536 IF (ZERO.LE.ROOT2A) THEN
6541 ROOT2 = MIN(ROOT2, WAER(5), WAER(3) - 2.D0*ROOT1, CHI4)
6542 ROOT2 = MAX(ROOT2, ZERO)
6546 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
6551 IF (NAI*NAI*SO4I .GT. A5) THEN
6552 BB =-(WAER(2) + WAER(1) - ROOT1)
6553 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
6554 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
6555 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
6556 IF (ISLV.NE.0) ROOT3 = TINY
6557 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
6558 ROOT3 = MAX (ROOT3, ZERO)
6561 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6566 IF (NH4I*NH4I*SO4I .GT. A4) THEN
6567 BB =-(WAER(2)+WAER(3)-ROOT2-ROOT3)
6568 CC = (WAER(3)-ROOT2)*(WAER(2)-ROOT3+0.5D0*(WAER(3)-ROOT2))
6569 DD =-((WAER(2)-ROOT3)*(WAER(3)-ROOT2)**2.D0 + A4)/4.D0
6570 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
6571 IF (ISLV.NE.0) ROOT1 = TINY
6572 ROOT1 = MIN(ROOT1, WAER(3)-ROOT2, WAER(2)-ROOT3, CHI6)
6573 ROOT1 = MAX(ROOT1, ZERO)
6576 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
6579 ! ION CONCENTRATIONS
6581 NAI = WAER(1) - 2.D0*ROOT3
6582 SO4I= WAER(2) - ROOT1 - ROOT3
6583 NH4I= WAER(3) - ROOT2 - 2.D0*ROOT1
6585 CLI = WAER(5) - ROOT2
6587 ! SOLUTION ACIDIC OR BASIC?
6589 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
6590 IF (GG.GT.TINY) THEN ! H+ in excess
6593 DD = BB*BB - 4.D0*CC
6594 HI = 0.5D0*(-BB + SQRT(DD))
6596 ELSE ! OH- in excess
6599 DD = BB*BB - 4.D0*CC
6600 OHI= 0.5D0*(-BB + SQRT(DD))
6604 ! UNDISSOCIATED SPECIES EQUILIBRIA
6607 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6611 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
6612 GGCL = MAX(GG-GGNO3, ZERO)
6613 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6614 IF (GGNO3.GT.TINY) THEN
6615 IF (GGCL.LE.TINY) HI = ZERO
6616 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6619 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6621 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
6628 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6638 ! *** CALCULATE WATER **************************************************
6642 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6644 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6647 IF (PSCONV1 .AND. PSCONV4 .AND. PSCONV6) GOTO 20
6650 !cc CALL PUSHERR (0002, 'CALCQ2A') ! WARNING ERROR: NO CONVERGENCE
6652 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6654 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6655 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6656 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6666 CNH42S4 = CHI6 - PSI6
6668 CNH4CL = CHI4 - PSI4
6671 CNA2SO4 = CHI1 - PSI1
6675 ! *** END OF SUBROUTINE CALCQ2A *****************************************
6677 END SUBROUTINE CALCQ2A
6678 !=======================================================================
6680 ! *** ISORROPIA CODE
6681 ! *** SUBROUTINE CALCQ1
6684 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6685 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
6686 ! 2. SOLID AEROSOL ONLY
6687 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
6689 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6690 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6691 ! *** WRITTEN BY ATHANASIOS NENES
6693 !=======================================================================
6698 ! EXTERNAL CALCQ1A, CALCQ2A, CALCQ3A, CALCQ4
6700 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
6702 EXNO = WAER(4).GT.TINY
6703 EXCL = WAER(5).GT.TINY
6705 IF (EXNO .AND. EXCL) THEN ! *** NITRATE & CHLORIDE EXIST
6706 IF (RH.LT.DRMG1) THEN
6707 SCASE = 'Q1 ; SUBCASE 1'
6708 CALL CALCQ1A ! SOLID
6709 SCASE = 'Q1 ; SUBCASE 1'
6711 SCASE = 'Q1 ; SUBCASE 2' ! MDRH (NH4)2SO4, NA2SO4, NH4CL, NH4NO3
6712 CALL CALCMDRP (RH, DRMG1, DRNH4NO3, CALCQ1A, CALCQ2A)
6713 SCASE = 'Q1 ; SUBCASE 2'
6716 ELSE IF (EXNO .AND. .NOT.EXCL) THEN ! *** ONLY NITRATE EXISTS
6717 IF (RH.LT.DRMQ1) THEN
6718 SCASE = 'Q1 ; SUBCASE 1'
6719 CALL CALCQ1A ! SOLID
6720 SCASE = 'Q1 ; SUBCASE 1'
6722 SCASE = 'Q1 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4NO3
6723 CALL CALCMDRP (RH, DRMQ1, DRNH4NO3, CALCQ1A, CALCQ2A)
6724 SCASE = 'Q1 ; SUBCASE 3'
6727 ELSE IF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
6728 IF (RH.LT.DRMG2) THEN
6729 SCASE = 'Q1 ; SUBCASE 1'
6730 CALL CALCQ1A ! SOLID
6731 SCASE = 'Q1 ; SUBCASE 1'
6733 SCASE = 'Q1 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
6734 CALL CALCMDRP (RH, DRMG2, DRNH4CL, CALCQ1A, CALCQ3A)
6735 SCASE = 'Q1 ; SUBCASE 4'
6738 ELSE ! *** NO CHLORIDE AND NITRATE
6739 IF (RH.LT.DRMG3) THEN
6740 SCASE = 'Q1 ; SUBCASE 1'
6741 CALL CALCQ1A ! SOLID
6742 SCASE = 'Q1 ; SUBCASE 1'
6744 SCASE = 'Q1 ; SUBCASE 5' ! MDRH (NH4)2SO4, NA2SO4
6745 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
6746 SCASE = 'Q1 ; SUBCASE 5'
6752 ! *** END OF SUBROUTINE CALCQ1 ******************************************
6754 END SUBROUTINE CALCQ1
6757 !=======================================================================
6759 ! *** ISORROPIA CODE
6760 ! *** SUBROUTINE CALCQ1A
6761 ! *** CASE Q1 ; SUBCASE 1
6763 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6764 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
6765 ! 2. SOLID AEROSOL ONLY
6766 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
6768 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6769 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6770 ! *** WRITTEN BY ATHANASIOS NENES
6772 !=======================================================================
6778 ! *** CALCULATE SOLIDS **************************************************
6780 CNA2SO4 = 0.5d0*WAER(1)
6781 FRSO4 = MAX (WAER(2)-CNA2SO4, ZERO)
6783 CNH42S4 = MAX (MIN(FRSO4,0.5d0*WAER(3)), TINY)
6784 FRNH3 = MAX (WAER(3)-2.D0*CNH42S4, ZERO)
6786 CNH4NO3 = MIN (FRNH3, WAER(4))
6787 !CC FRNO3 = MAX (WAER(4)-CNH4NO3, ZERO)
6788 FRNH3 = MAX (FRNH3-CNH4NO3, ZERO)
6790 CNH4CL = MIN (FRNH3, WAER(5))
6791 !CC FRCL = MAX (WAER(5)-CNH4CL, ZERO)
6792 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
6794 ! *** OTHER PHASES ******************************************************
6804 ! *** END OF SUBROUTINE CALCQ1A *****************************************
6806 END SUBROUTINE CALCQ1A
6807 !=======================================================================
6809 ! *** ISORROPIA CODE
6810 ! *** SUBROUTINE CALCR6
6813 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6814 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
6815 ! 2. THERE IS ONLY A LIQUID PHASE
6817 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6818 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6819 ! *** WRITTEN BY ATHANASIOS NENES
6821 !=======================================================================
6826 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, HSO4I
6827 REAL(KIND=8) AKW, SO4I, CLI, GG, BB, CC, DD,HI, OHI, DEL
6828 REAL(KIND=8) GGNO3, GGCL
6831 ! *** SETUP PARAMETERS ************************************************
6845 ! *** CALCULATE WATER **************************************************
6849 ! *** SETUP LIQUID CONCENTRATIONS **************************************
6856 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6859 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6867 ! SOLUTION ACIDIC OR BASIC?
6869 GG = 2.D0*WAER(2) + NO3I + CLI - NAI - NH4I
6870 IF (GG.GT.TINY) THEN ! H+ in excess
6873 DD = BB*BB - 4.D0*CC
6874 HI = 0.5D0*(-BB + SQRT(DD))
6876 ELSE ! OH- in excess
6879 DD = BB*BB - 4.D0*CC
6880 OHI= 0.5D0*(-BB + SQRT(DD))
6884 ! UNDISSOCIATED SPECIES EQUILIBRIA
6887 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6890 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
6891 GGCL = MAX(GG-GGNO3, ZERO)
6892 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6893 IF (GGNO3.GT.TINY) THEN
6894 IF (GGCL.LE.TINY) HI = ZERO
6895 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6898 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6900 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
6907 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6917 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6919 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6925 !cc CALL PUSHERR (0002, 'CALCR6') ! WARNING ERROR: NO CONVERGENCE
6927 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6929 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6930 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6931 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6950 ! *** END OF SUBROUTINE CALCR6 ******************************************
6952 END SUBROUTINE CALCR6
6953 !=======================================================================
6955 ! *** ISORROPIA CODE
6956 ! *** SUBROUTINE CALCR5
6959 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6960 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
6961 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
6963 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6964 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
6965 ! *** WRITTEN BY ATHANASIOS NENES
6967 !=======================================================================
6973 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
6974 REAL(KIND=8) PSIO, SO4I, CLI, AKW, HSO4I, ROOT, BB, CC, DD, GG, HI, OHI
6975 REAL(KIND=8) GGNO3, GGCL, DEL
6976 LOGICAL NEAN, NEAC, NESN, NESC
6980 ! *** SETUP PARAMETERS ************************************************
6982 CALL CALCR1A ! DRY SOLUTION
6984 NEAN = CNH4NO3.LE.TINY ! NH4NO3 ! Water exists?
6985 NEAC = CNH4CL .LE.TINY ! NH4CL
6986 NESN = CNANO3 .LE.TINY ! NANO3
6987 NESC = CNACL .LE.TINY ! NACL
6988 IF (NEAN .AND. NEAC .AND. NESN .AND. NESC) RETURN
7000 ! *** CALCULATE WATER **************************************************
7009 ! *** SETUP LIQUID CONCENTRATIONS **************************************
7021 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7024 A5 = XK5*(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
7025 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7030 IF (NAI*NAI*SO4I .GT. A5) THEN
7033 DD =-CHI1**3.0 + 0.25D0*A5
7034 CALL POLY3(BB, CC, DD, ROOT, ISLV)
7035 IF (ISLV.NE.0) ROOT = TINY
7036 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
7039 PSCONV = ABS(PSI1-PSIO) .LE. EPS*PSIO
7042 ! ION CONCENTRATIONS
7044 NAI = WAER(1) - 2.D0*ROOT
7045 SO4I = WAER(2) - ROOT
7050 ! SOLUTION ACIDIC OR BASIC?
7052 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
7053 IF (GG.GT.TINY) THEN ! H+ in excess
7056 DD = BB*BB - 4.D0*CC
7057 HI = 0.5D0*(-BB + SQRT(DD))
7059 ELSE ! OH- in excess
7062 DD = BB*BB - 4.D0*CC
7063 OHI= 0.5D0*(-BB + SQRT(DD))
7067 ! UNDISSOCIATED SPECIES EQUILIBRIA
7070 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7073 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
7074 GGCL = MAX(GG-GGNO3, ZERO)
7075 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
7076 IF (GGNO3.GT.TINY) THEN
7077 IF (GGCL.LE.TINY) HI = ZERO
7078 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
7081 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
7083 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
7090 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7100 ! *** CALCULATE WATER **************************************************
7104 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7106 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7112 !cc CALL PUSHERR (0002, 'CALCR5') ! WARNING ERROR: NO CONVERGENCE
7114 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7116 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
7117 !C A21 = XK21*WATER*R*TEMP
7118 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
7119 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
7121 GNH3 = NH4I/HI/A2 ! NH4I*OHI/A2/AKW
7134 CNA2SO4 = CHI1 - PSI1
7138 ! *** END OF SUBROUTINE CALCR5 ******************************************
7140 END SUBROUTINE CALCR5
7141 !=======================================================================
7143 ! *** ISORROPIA CODE
7144 ! *** SUBROUTINE CALCR4
7147 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7148 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
7149 ! 2. SOLID AEROSOL ONLY
7150 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
7152 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7153 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7154 ! *** WRITTEN BY ATHANASIOS NENES
7156 !=======================================================================
7160 LOGICAL EXAN, EXAC, EXSN, EXSC
7161 ! EXTERNAL CALCR1A, CALCR5
7163 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
7165 SCASE = 'R4 ; SUBCASE 2'
7166 CALL CALCR1A ! SOLID
7167 SCASE = 'R4 ; SUBCASE 2'
7169 EXAN = CNH4NO3.GT.TINY ! NH4NO3
7170 EXAC = CNH4CL .GT.TINY ! NH4CL
7171 EXSN = CNANO3 .GT.TINY ! NANO3
7172 EXSC = CNACL .GT.TINY ! NACL
7174 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
7176 IF (EXAN .OR. EXSN .OR. EXSC) THEN ! *** NH4NO3,NANO3 EXIST
7177 IF (RH.GE.DRMH1) THEN
7178 SCASE = 'R4 ; SUBCASE 1'
7180 SCASE = 'R4 ; SUBCASE 1'
7183 ELSE IF (EXAC) THEN ! *** NH4CL EXISTS ONLY
7184 IF (RH.GE.DRMR5) THEN
7185 SCASE = 'R4 ; SUBCASE 3'
7186 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR5)
7187 SCASE = 'R4 ; SUBCASE 3'
7193 ! *** END OF SUBROUTINE CALCR4 ******************************************
7195 END SUBROUTINE CALCR4
7199 !=======================================================================
7201 ! *** ISORROPIA CODE
7202 ! *** SUBROUTINE CALCR4A
7205 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7206 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
7207 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
7209 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7210 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7211 ! *** WRITTEN BY ATHANASIOS NENES
7213 !=======================================================================
7218 LOGICAL PSCONV1, PSCONV4
7219 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
7220 REAL(KIND=8) PSIO1, PSIO4, PSI10, PSI3O, A14, SO4I, CLI, AKW, HSO4I, ROOT, BB, CC, DD, GG, HI, OHI
7221 REAL(KIND=8) GGNO3, GGCL, DEL
7225 ! *** SETUP PARAMETERS ************************************************
7235 ! *** CALCULATE INITIAL SOLUTION ***************************************
7239 CHI1 = CNA2SO4 ! SALTS
7250 NAI = WAER(1) ! LIQUID CONCENTRATIONS
7260 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7263 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
7264 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
7265 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7270 IF (NAI*NAI*SO4I .GT. A5) THEN
7273 DD =-CHI1**3.0 + 0.25D0*A5
7274 CALL POLY3(BB, CC, DD, ROOT, ISLV)
7275 IF (ISLV.NE.0) ROOT = TINY
7276 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
7278 NAI = WAER(1) - 2.D0*ROOT
7279 SO4I = WAER(2) - ROOT
7281 PSCONV1 = ABS(PSI1-PSIO1) .LE. EPS*PSIO1
7287 IF (NH4I*CLI .GT. A14) THEN
7290 DD = BB*BB - 4.D0*CC
7291 ROOT = 0.5D0*(-BB-SQRT(DD))
7292 IF (ROOT.GT.TINY) THEN
7293 ROOT = MIN(ROOT, CHI4)
7295 NH4I = WAER(3) - ROOT
7296 CLI = WAER(5) - ROOT
7299 PSCONV4 = ABS(PSI4-PSIO4) .LE. EPS*PSIO4
7304 ! SOLUTION ACIDIC OR BASIC?
7306 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
7307 IF (GG.GT.TINY) THEN ! H+ in excess
7310 DD = BB*BB - 4.D0*CC
7311 HI = 0.5D0*(-BB + SQRT(DD))
7313 ELSE ! OH- in excess
7316 DD = BB*BB - 4.D0*CC
7317 OHI= 0.5D0*(-BB + SQRT(DD))
7321 ! UNDISSOCIATED SPECIES EQUILIBRIA
7324 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7327 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
7328 GGCL = MAX(GG-GGNO3, ZERO)
7329 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
7330 IF (GGNO3.GT.TINY) THEN
7331 IF (GGCL.LE.TINY) HI = ZERO
7332 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
7335 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
7337 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
7344 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7354 ! *** CALCULATE WATER **************************************************
7358 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7360 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7363 IF (PSCONV1 .AND. PSCONV4) GOTO 20
7366 !cc CALL PUSHERR (0002, 'CALCR4A') ! WARNING ERROR: NO CONVERGENCE
7368 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7370 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
7371 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
7372 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
7384 CNH4CL = CHI4 - PSI4
7387 CNA2SO4 = CHI1 - PSI1
7391 ! *** END OF SUBROUTINE CALCR4A *****************************************
7393 END SUBROUTINE CALCR4A
7394 !=======================================================================
7396 ! *** ISORROPIA CODE
7397 ! *** SUBROUTINE CALCR3
7400 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7401 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
7402 ! 2. SOLID AEROSOL ONLY
7403 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
7405 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7406 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7407 ! *** WRITTEN BY ATHANASIOS NENES
7409 !=======================================================================
7413 LOGICAL EXAN, EXAC, EXSN, EXSC
7414 ! EXTERNAL CALCR1A, CALCR4A, CALCR5
7416 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
7418 SCASE = 'R3 ; SUBCASE 2'
7419 CALL CALCR1A ! SOLID
7420 SCASE = 'R3 ; SUBCASE 2'
7422 EXAN = CNH4NO3.GT.TINY ! NH4NO3
7423 EXAC = CNH4CL .GT.TINY ! NH4CL
7424 EXSN = CNANO3 .GT.TINY ! NANO3
7425 EXSC = CNACL .GT.TINY ! NACL
7427 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
7429 IF (EXAN .OR. EXSN) THEN ! *** NH4NO3,NANO3 EXIST
7430 IF (RH.GE.DRMH1) THEN
7431 SCASE = 'R3 ; SUBCASE 1'
7433 SCASE = 'R3 ; SUBCASE 1'
7436 ELSE IF (.NOT.EXAN .AND. .NOT.EXSN) THEN ! *** NH4NO3,NANO3 = 0
7437 IF ( EXAC .AND. EXSC) THEN
7438 IF (RH.GE.DRMR4) THEN
7439 SCASE = 'R3 ; SUBCASE 3'
7440 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR4A)
7441 SCASE = 'R3 ; SUBCASE 3'
7444 ELSE IF (.NOT.EXAC .AND. EXSC) THEN
7445 IF (RH.GE.DRMR2) THEN
7446 SCASE = 'R3 ; SUBCASE 4'
7447 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR4A)
7448 SCASE = 'R3 ; SUBCASE 4'
7451 ELSE IF ( EXAC .AND. .NOT.EXSC) THEN
7452 IF (RH.GE.DRMR5) THEN
7453 SCASE = 'R3 ; SUBCASE 5'
7454 CALL CALCMDRP (RH, DRMR5, DRNACL, CALCR1A, CALCR5)
7455 SCASE = 'R3 ; SUBCASE 5'
7463 ! *** END OF SUBROUTINE CALCR3 ******************************************
7465 END SUBROUTINE CALCR3
7468 !=======================================================================
7470 ! *** ISORROPIA CODE
7471 ! *** SUBROUTINE CALCR3A
7474 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7475 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
7476 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
7478 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7479 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7480 ! *** WRITTEN BY ATHANASIOS NENES
7482 !=======================================================================
7487 LOGICAL PSCONV1, PSCONV3, PSCONV4
7488 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, HSO4I, SO4I, CLI
7489 REAL(KIND=8) A14, AKW, BB, CC, DD, GG, HI, OHI
7490 REAL(KIND=8) PSI1O, PSI4O, PSI3O, ROOT1, ROOT2, ROOT3
7491 REAL(KIND=8) ROOT2A, ROOT2B, ROOT3A, ROOT3B
7492 REAL(KIND=8) GGNO3, GGCL, DEL
7496 ! *** SETUP PARAMETERS ************************************************
7511 ! *** CALCULATE INITIAL SOLUTION ***************************************
7515 CHI1 = CNA2SO4 ! SALTS
7527 NAI = WAER(1) ! LIQUID CONCENTRATIONS
7545 CALL CALCACT ! CALCULATE ACTIVITY COEFFICIENTS
7547 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7550 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
7551 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
7552 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
7553 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7557 IF (NH4I*CLI .GT. A14) THEN
7558 BB =-(WAER(3) + WAER(5) - ROOT3)
7559 CC =-A14 + NH4I*(WAER(5) - ROOT3)
7560 DD = MAX(BB*BB - 4.D0*CC, ZERO)
7561 ROOT2A= 0.5D0*(-BB+SQRT(DD))
7562 ROOT2B= 0.5D0*(-BB-SQRT(DD))
7563 IF (ZERO.LE.ROOT2A) THEN
7568 ROOT2 = MIN(MAX(ZERO, ROOT2), MAX(WAER(5)-ROOT3,ZERO), CHI4, WAER(3))
7571 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
7576 IF (NAI*NAI*SO4I .GT. A5) THEN
7577 BB =-(CHI1 + WAER(1) - ROOT3)
7578 CC = 0.25D0*(WAER(1) - ROOT3)*(4.D0*CHI1+WAER(1)-ROOT3)
7579 DD =-0.25D0*(CHI1*(WAER(1)-ROOT3)**2.D0 - A5)
7580 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
7581 IF (ISLV.NE.0) ROOT1 = TINY
7582 ROOT1 = MIN (MAX(ROOT1,ZERO), MAX(WAER(1)-ROOT3,ZERO), CHI1, WAER(2))
7585 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
7588 ! ION CONCENTRATIONS
7590 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3)
7591 SO4I= WAER(2) - ROOT1
7592 NH4I= WAER(3) - ROOT2
7593 CLI = WAER(5) - (ROOT3 + ROOT2)
7596 ! SODIUM CHLORIDE ; To obtain new value for ROOT3
7598 IF (NAI*CLI .GT. A8) THEN
7599 BB =-((CHI1-2.D0*ROOT1) + (WAER(5) - ROOT2))
7600 CC = (CHI1-2.D0*ROOT1)*(WAER(5) - ROOT2) - A8
7601 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7602 ROOT3A= 0.5D0*(-BB-SQRT(DD))
7603 ROOT3B= 0.5D0*(-BB+SQRT(DD))
7604 IF (ZERO.LE.ROOT3A) THEN
7609 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
7612 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
7615 ! SOLUTION ACIDIC OR BASIC?
7617 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
7618 IF (GG.GT.TINY) THEN ! H+ in excess
7621 DD = BB*BB - 4.D0*CC
7622 HI = 0.5D0*(-BB + SQRT(DD))
7624 ELSE ! OH- in excess
7627 DD = BB*BB - 4.D0*CC
7628 OHI= 0.5D0*(-BB + SQRT(DD))
7632 ! UNDISSOCIATED SPECIES EQUILIBRIA
7635 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7638 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
7639 GGCL = MAX(GG-GGNO3, ZERO)
7640 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
7641 IF (GGNO3.GT.TINY) THEN
7642 IF (GGCL.LE.TINY) HI = ZERO
7643 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
7646 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
7648 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
7655 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7665 ! *** CALCULATE WATER **************************************************
7669 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7671 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7674 IF (PSCONV1.AND.PSCONV3.AND.PSCONV4) GOTO 20
7677 !cc CALL PUSHERR (0002, 'CALCR3A') ! WARNING ERROR: NO CONVERGENCE
7679 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7681 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
7690 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
7691 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
7692 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
7704 CNH4CL = CHI4 - PSI4
7707 CNA2SO4 = CHI1 - PSI1
7712 ! *** END OF SUBROUTINE CALCR3A *****************************************
7714 END SUBROUTINE CALCR3A
7715 !=======================================================================
7717 ! *** ISORROPIA CODE
7718 ! *** SUBROUTINE CALCR2
7721 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7722 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
7723 ! 2. SOLID AEROSOL ONLY
7724 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
7726 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7727 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7728 ! *** WRITTEN BY ATHANASIOS NENES
7730 !=======================================================================
7734 LOGICAL EXAN, EXAC, EXSN, EXSC
7735 ! EXTERNAL CALCR1A, CALCR3A, CALCR4A, CALCR5
7737 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
7739 SCASE = 'R2 ; SUBCASE 2'
7740 CALL CALCR1A ! SOLID
7741 SCASE = 'R2 ; SUBCASE 2'
7743 EXAN = CNH4NO3.GT.TINY ! NH4NO3
7744 EXAC = CNH4CL .GT.TINY ! NH4CL
7745 EXSN = CNANO3 .GT.TINY ! NANO3
7746 EXSC = CNACL .GT.TINY ! NACL
7748 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
7750 IF (EXAN) THEN ! *** NH4NO3 EXISTS
7751 IF (RH.GE.DRMH1) THEN
7752 SCASE = 'R2 ; SUBCASE 1'
7754 SCASE = 'R2 ; SUBCASE 1'
7757 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
7758 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
7759 IF (RH.GE.DRMH2) THEN
7760 SCASE = 'R2 ; SUBCASE 3'
7761 CALL CALCMDRP (RH, DRMH2, DRNANO3, CALCR1A, CALCR3A)
7762 SCASE = 'R2 ; SUBCASE 3'
7765 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
7766 IF (RH.GE.DRMR1) THEN
7767 SCASE = 'R2 ; SUBCASE 4'
7768 CALL CALCMDRP (RH, DRMR1, DRNANO3, CALCR1A, CALCR3A)
7769 SCASE = 'R2 ; SUBCASE 4'
7772 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7773 IF (RH.GE.DRMR2) THEN
7774 SCASE = 'R2 ; SUBCASE 5'
7775 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR4A)
7776 SCASE = 'R2 ; SUBCASE 5'
7779 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7780 IF (RH.GE.DRMR3) THEN
7781 SCASE = 'R2 ; SUBCASE 6'
7782 CALL CALCMDRP (RH, DRMR3, DRNANO3, CALCR1A, CALCR3A)
7783 SCASE = 'R2 ; SUBCASE 6'
7786 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7787 IF (RH.GE.DRMR4) THEN
7788 SCASE = 'R2 ; SUBCASE 7'
7789 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR4A)
7790 SCASE = 'R2 ; SUBCASE 7'
7793 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
7794 IF (RH.GE.DRMR5) THEN
7795 SCASE = 'R2 ; SUBCASE 8'
7796 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR5)
7797 SCASE = 'R2 ; SUBCASE 8'
7800 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7801 IF (RH.GE.DRMR6) THEN
7802 SCASE = 'R2 ; SUBCASE 9'
7803 CALL CALCMDRP (RH, DRMR6, DRNANO3, CALCR1A, CALCR3A)
7804 SCASE = 'R2 ; SUBCASE 9'
7812 ! *** END OF SUBROUTINE CALCR2 ******************************************
7814 END SUBROUTINE CALCR2
7817 !=======================================================================
7819 ! *** ISORROPIA CODE
7820 ! *** SUBROUTINE CALCR2A
7823 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7824 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
7825 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
7827 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7828 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
7829 ! *** WRITTEN BY ATHANASIOS NENES
7831 !=======================================================================
7836 LOGICAL PSCONV1, PSCONV2, PSCONV3, PSCONV4
7837 REAL(KIND=8) NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, HSO4I, SO4I, CLI
7838 REAL(KIND=8) A9, A14, AKW, BB, CC, DD, GG, HI, OHI
7839 REAL(KIND=8) PSI1O, PSI2O, PSI4O, PSI3O, ROOT1, ROOT2, ROOT3, ROOT4
7840 REAL(KIND=8) ROOT2A, ROOT2B, ROOT3A, ROOT3B, ROOT4A, ROOT4B
7841 REAL(KIND=8) GGNO3, GGCL, DEL
7845 ! *** SETUP PARAMETERS ************************************************
7866 ! *** CALCULATE INITIAL SOLUTION ***************************************
7870 CHI1 = CNA2SO4 ! SALTS
7883 NAI = WAER(1) ! LIQUID CONCENTRATIONS
7901 CALL CALCACT ! CALCULATE ACTIVITY COEFFICIENTS
7903 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7906 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
7907 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
7908 A9 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
7909 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
7910 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7914 IF (NH4I*CLI .GT. A14) THEN
7915 BB =-(WAER(3) + WAER(5) - ROOT3)
7916 CC = NH4I*(WAER(5) - ROOT3) - A14
7917 DD = MAX(BB*BB - 4.D0*CC, ZERO)
7919 ROOT2A= 0.5D0*(-BB+DD)
7920 ROOT2B= 0.5D0*(-BB-DD)
7921 IF (ZERO.LE.ROOT2A) THEN
7926 ROOT2 = MIN(MAX(ROOT2, ZERO), CHI4)
7929 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
7934 IF (NAI*NAI*SO4I .GT. A5) THEN
7935 BB =-(WAER(2) + WAER(1) - ROOT3 - ROOT4)
7936 CC = WAER(1)*(2.D0*ROOT3 + 2.D0*ROOT4 - 4.D0*WAER(2) - ONE)&
7937 -(ROOT3 + ROOT4)**2.0 + 4.D0*WAER(2)*(ROOT3 + ROOT4)
7939 DD = WAER(1)*WAER(2)*(ONE - 2.D0*ROOT3 - 2.D0*ROOT4) + &
7940 WAER(2)*(ROOT3 + ROOT4)**2.0 - A5
7942 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
7943 IF (ISLV.NE.0) ROOT1 = TINY
7944 ROOT1 = MIN (MAX(ROOT1,ZERO), CHI1)
7947 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
7952 IF (NAI*NO3I .GT. A9) THEN
7953 BB =-(WAER(4) + WAER(1) - 2.D0*ROOT1 - ROOT3)
7954 CC = WAER(4)*(WAER(1) - 2.D0*ROOT1 - ROOT3) - A9
7955 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7956 ROOT4A= 0.5D0*(-BB-DD)
7957 ROOT4B= 0.5D0*(-BB+DD)
7958 IF (ZERO.LE.ROOT4A) THEN
7963 ROOT4 = MIN(MAX(ROOT4, ZERO), CHI2)
7966 PSCONV2 = ABS(PSI2-PSI2O) .LE. EPS*PSI2O
7969 ! ION CONCENTRATIONS
7971 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3 + ROOT4)
7972 SO4I= WAER(2) - ROOT1
7973 NH4I= WAER(3) - ROOT2
7974 NO3I= WAER(4) - ROOT4
7975 CLI = WAER(5) - (ROOT3 + ROOT2)
7977 ! SODIUM CHLORIDE ; To obtain new value for ROOT3
7979 IF (NAI*CLI .GT. A8) THEN
7980 BB =-(WAER(1) - 2.D0*ROOT1 + WAER(5) - ROOT2 - ROOT4)
7981 CC = (WAER(5) + ROOT2)*(WAER(1) - 2.D0*ROOT1 - ROOT4) - A8
7982 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7983 ROOT3A= 0.5D0*(-BB-DD)
7984 ROOT3B= 0.5D0*(-BB+DD)
7985 IF (ZERO.LE.ROOT3A) THEN
7990 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
7993 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
7996 ! SOLUTION ACIDIC OR BASIC?
7998 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
7999 IF (GG.GT.TINY) THEN ! H+ in excess
8002 DD = BB*BB - 4.D0*CC
8003 HI = 0.5D0*(-BB + SQRT(DD))
8005 ELSE ! OH- in excess
8008 DD = BB*BB - 4.D0*CC
8009 OHI= 0.5D0*(-BB + SQRT(DD))
8013 ! UNDISSOCIATED SPECIES EQUILIBRIA
8016 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
8019 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
8020 GGCL = MAX(GG-GGNO3, ZERO)
8021 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
8022 IF (GGNO3.GT.TINY) THEN
8023 IF (GGCL.LE.TINY) HI = ZERO
8024 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
8027 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
8029 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
8036 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8046 ! *** CALCULATE WATER **************************************************
8050 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8052 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8055 IF (PSCONV1.AND.PSCONV2.AND.PSCONV3.AND.PSCONV4) GOTO 20
8058 !cc CALL PUSHERR (0002, 'CALCR2A') ! WARNING ERROR: NO CONVERGENCE
8060 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8062 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
8070 ELSE ! OK, aqueous phase present
8071 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
8072 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
8073 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
8085 CNH4CL = CHI4 - PSI4
8087 CNANO3 = CHI2 - PSI2
8088 CNA2SO4 = CHI1 - PSI1
8093 ! *** END OF SUBROUTINE CALCR2A *****************************************
8095 END SUBROUTINE CALCR2A
8096 !=======================================================================
8098 ! *** ISORROPIA CODE
8099 ! *** SUBROUTINE CALCR1
8102 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8103 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
8104 ! 2. SOLID AEROSOL ONLY
8105 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
8107 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8108 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8109 ! *** WRITTEN BY ATHANASIOS NENES
8111 !=======================================================================
8115 LOGICAL EXAN, EXAC, EXSN, EXSC
8116 ! EXTERNAL CALCR1A, CALCR2A, CALCR3A, CALCR4A, CALCR5
8118 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
8120 SCASE = 'R1 ; SUBCASE 1'
8121 CALL CALCR1A ! SOLID
8122 SCASE = 'R1 ; SUBCASE 1'
8124 EXAN = CNH4NO3.GT.TINY ! NH4NO3
8125 EXAC = CNH4CL .GT.TINY ! NH4CL
8126 EXSN = CNANO3 .GT.TINY ! NANO3
8127 EXSC = CNACL .GT.TINY ! NACL
8129 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
8131 IF (EXAN.AND.EXAC.AND.EXSC.AND.EXSN) THEN ! *** ALL EXIST
8132 IF (RH.GE.DRMH1) THEN
8133 SCASE = 'R1 ; SUBCASE 2' ! MDRH
8134 CALL CALCMDRP (RH, DRMH1, DRNH4NO3, CALCR1A, CALCR2A)
8135 SCASE = 'R1 ; SUBCASE 2'
8138 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
8139 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
8140 IF (RH.GE.DRMH2) THEN
8141 SCASE = 'R1 ; SUBCASE 3'
8142 CALL CALCMDRP (RH, DRMH2, DRNANO3, CALCR1A, CALCR3A)
8143 SCASE = 'R1 ; SUBCASE 3'
8146 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
8147 IF (RH.GE.DRMR1) THEN
8148 SCASE = 'R1 ; SUBCASE 4'
8149 CALL CALCMDRP (RH, DRMR1, DRNANO3, CALCR1A, CALCR3A)
8150 SCASE = 'R1 ; SUBCASE 4'
8153 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
8154 IF (RH.GE.DRMR2) THEN
8155 SCASE = 'R1 ; SUBCASE 5'
8156 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR3A) !, CALCR4A)
8157 SCASE = 'R1 ; SUBCASE 5'
8160 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
8161 IF (RH.GE.DRMR3) THEN
8162 SCASE = 'R1 ; SUBCASE 6'
8163 CALL CALCMDRP (RH, DRMR3, DRNANO3, CALCR1A, CALCR3A)
8164 SCASE = 'R1 ; SUBCASE 6'
8167 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
8168 IF (RH.GE.DRMR4) THEN
8169 SCASE = 'R1 ; SUBCASE 7'
8170 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR3A) !, CALCR4A)
8171 SCASE = 'R1 ; SUBCASE 7'
8174 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
8175 IF (RH.GE.DRMR5) THEN
8176 SCASE = 'R1 ; SUBCASE 8'
8177 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR3A) !, CALCR5)
8178 SCASE = 'R1 ; SUBCASE 8'
8181 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
8182 IF (RH.GE.DRMR6) THEN
8183 SCASE = 'R1 ; SUBCASE 9'
8184 CALL CALCMDRP (RH, DRMR6, DRNANO3, CALCR1A, CALCR3A)
8185 SCASE = 'R1 ; SUBCASE 9'
8189 ELSE IF (.NOT.EXAC) THEN ! *** NH4CL = 0
8190 IF ( EXAN .AND. EXSN .AND. EXSC) THEN
8191 IF (RH.GE.DRMR7) THEN
8192 SCASE = 'R1 ; SUBCASE 10'
8193 CALL CALCMDRP (RH, DRMR7, DRNH4NO3, CALCR1A, CALCR2A)
8194 SCASE = 'R1 ; SUBCASE 10'
8197 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. EXSC) THEN
8198 IF (RH.GE.DRMR8) THEN
8199 SCASE = 'R1 ; SUBCASE 11'
8200 CALL CALCMDRP (RH, DRMR8, DRNH4NO3, CALCR1A, CALCR2A)
8201 SCASE = 'R1 ; SUBCASE 11'
8204 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
8205 IF (RH.GE.DRMR9) THEN
8206 SCASE = 'R1 ; SUBCASE 12'
8207 CALL CALCMDRP (RH, DRMR9, DRNH4NO3, CALCR1A, CALCR2A)
8208 SCASE = 'R1 ; SUBCASE 12'
8211 ELSE IF ( EXAN .AND. EXSN .AND. .NOT.EXSC) THEN
8212 IF (RH.GE.DRMR10) THEN
8213 SCASE = 'R1 ; SUBCASE 13'
8214 CALL CALCMDRP (RH, DRMR10, DRNH4NO3, CALCR1A, CALCR2A)
8215 SCASE = 'R1 ; SUBCASE 13'
8219 ELSE IF (.NOT.EXSN) THEN ! *** NANO3 = 0
8220 IF ( EXAN .AND. EXAC .AND. EXSC) THEN
8221 IF (RH.GE.DRMR11) THEN
8222 SCASE = 'R1 ; SUBCASE 14'
8223 CALL CALCMDRP (RH, DRMR11, DRNH4NO3, CALCR1A, CALCR2A)
8224 SCASE = 'R1 ; SUBCASE 14'
8227 ELSE IF ( EXAN .AND. EXAC .AND. .NOT.EXSC) THEN
8228 IF (RH.GE.DRMR12) THEN
8229 SCASE = 'R1 ; SUBCASE 15'
8230 CALL CALCMDRP (RH, DRMR12, DRNH4NO3, CALCR1A, CALCR2A)
8231 SCASE = 'R1 ; SUBCASE 15'
8235 ELSE IF (.NOT.EXSC) THEN ! *** NACL = 0
8236 IF ( EXAN .AND. EXAC .AND. EXSN) THEN
8237 IF (RH.GE.DRMR13) THEN
8238 SCASE = 'R1 ; SUBCASE 16'
8239 CALL CALCMDRP (RH, DRMR13, DRNH4NO3, CALCR1A, CALCR2A)
8240 SCASE = 'R1 ; SUBCASE 16'
8247 ! *** END OF SUBROUTINE CALCR1 ******************************************
8249 END SUBROUTINE CALCR1
8252 !=======================================================================
8254 ! *** ISORROPIA CODE
8255 ! *** SUBROUTINE CALCR1A
8256 ! *** CASE R1 ; SUBCASE 1
8258 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8259 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
8260 ! 2. SOLID AEROSOL ONLY
8261 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NANO3, NA2SO4, NANO3, NACL
8263 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8264 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8265 ! *** WRITTEN BY ATHANASIOS NENES
8267 !=======================================================================
8271 REAL(KIND=8) FRNA,CNANO3, FRNO3, FRCL, FRNH3
8273 ! *** CALCULATE SOLIDS **************************************************
8276 FRNA = MAX (WAER(1)-2*CNA2SO4, ZERO)
8280 CNANO3 = MIN (FRNA, WAER(4))
8281 FRNO3 = MAX (WAER(4)-CNANO3, ZERO)
8282 FRNA = MAX (FRNA-CNANO3, ZERO)
8284 CNACL = MIN (FRNA, WAER(5))
8285 FRCL = MAX (WAER(5)-CNACL, ZERO)
8286 FRNA = MAX (FRNA-CNACL, ZERO)
8288 CNH4NO3 = MIN (FRNO3, WAER(3))
8289 FRNO3 = MAX (FRNO3-CNH4NO3, ZERO)
8290 FRNH3 = MAX (WAER(3)-CNH4NO3, ZERO)
8292 CNH4CL = MIN (FRCL, FRNH3)
8293 FRCL = MAX (FRCL-CNH4CL, ZERO)
8294 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
8296 ! *** OTHER PHASES ******************************************************
8306 ! *** END OF SUBROUTINE CALCR1A *****************************************
8308 END SUBROUTINE CALCR1A
8314 !=======================================================================
8316 ! *** ISORROPIA CODE
8317 ! *** SUBROUTINE ISRP1F
8318 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FOREWARD PROBLEM OF
8319 ! AN AMMONIUM-SULFATE AEROSOL SYSTEM.
8320 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
8321 ! THE AMBIENT RELATIVE HUMIDITY.
8323 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8324 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8325 ! *** WRITTEN BY ATHANASIOS NENES
8326 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8328 !=======================================================================
8330 SUBROUTINE ISRP1F (WI, RHI, TEMPI)
8332 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
8335 ! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
8337 CALL INIT1 (WI, RHI, TEMPI)
8339 ! *** CALCULATE SULFATE RATIO *******************************************
8343 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
8347 IF (2.0.LE.SULRAT) THEN
8348 DC = W(3) - 2.001D0*W(2) ! For numerical stability
8349 W(3) = W(3) + MAX(-DC, ZERO)
8351 IF(METSTBL.EQ.1) THEN
8353 CALL CALCA2 ! Only liquid (metastable)
8356 IF (RH.LT.DRNH42S4) THEN
8358 CALL CALCA1 ! NH42SO4 ; case A1
8360 ELSEIF (DRNH42S4.LE.RH) THEN
8362 CALL CALCA2 ! Only liquid ; case A2
8366 ! *** SULFATE RICH (NO ACID)
8368 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
8370 IF(METSTBL.EQ.1) THEN
8372 CALL CALCB4 ! Only liquid (metastable)
8375 IF (RH.LT.DRNH4HS4) THEN
8377 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case B1
8379 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
8381 CALL CALCB2 ! LC,NH42S4 ; case B2
8383 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
8385 CALL CALCB3 ! NH42S4 ; case B3
8387 ELSEIF (DRNH42S4.LE.RH) THEN
8389 CALL CALCB4 ! Only liquid ; case B4
8394 ! *** SULFATE RICH (FREE ACID)
8396 ELSEIF (SULRAT.LT.1.0) THEN
8398 IF(METSTBL.EQ.1) THEN
8400 CALL CALCC2 ! Only liquid (metastable)
8403 IF (RH.LT.DRNH4HS4) THEN
8405 CALL CALCC1 ! NH4HSO4 ; case C1
8407 ELSEIF (DRNH4HS4.LE.RH) THEN
8409 CALL CALCC2 ! Only liquid ; case C2
8420 ! *** END OF SUBROUTINE ISRP1F *****************************************
8422 END SUBROUTINE ISRP1F
8426 !=======================================================================
8428 ! *** ISORROPIA CODE
8429 ! *** SUBROUTINE ISRP2F
8430 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FOREWARD PROBLEM OF
8431 ! AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
8432 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
8433 ! THE AMBIENT RELATIVE HUMIDITY.
8435 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8436 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8437 ! *** WRITTEN BY ATHANASIOS NENES
8438 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8440 !=======================================================================
8442 SUBROUTINE ISRP2F (WI, RHI, TEMPI)
8445 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
8447 ! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
8449 CALL INIT2 (WI, RHI, TEMPI)
8451 ! *** CALCULATE SULFATE RATIO *******************************************
8455 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
8459 IF (2.0.LE.SULRAT) THEN
8461 IF(METSTBL.EQ.1) THEN
8463 CALL CALCD3 ! Only liquid (metastable)
8466 IF (RH.LT.DRNH4NO3) THEN
8468 CALL CALCD1 ! NH42SO4,NH4NO3 ; case D1
8470 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH42S4) THEN
8472 CALL CALCD2 ! NH42S4 ; case D2
8474 ELSEIF (DRNH42S4.LE.RH) THEN
8476 CALL CALCD3 ! Only liquid ; case D3
8480 ! *** SULFATE RICH (NO ACID)
8481 ! FOR SOLVING THIS CASE, NITRIC ACID IS ASSUMED A MINOR SPECIES,
8482 ! THAT DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM.
8483 ! SUBROUTINES CALCB? ARE CALLED, AND THEN THE NITRIC ACID IS DISSOLVED
8484 ! FROM THE HNO3(G) -> (H+) + (NO3-) EQUILIBRIUM.
8486 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
8488 IF(METSTBL.EQ.1) THEN
8490 CALL CALCB4 ! Only liquid (metastable)
8494 IF (RH.LT.DRNH4HS4) THEN
8496 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case E1
8499 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
8501 CALL CALCB2 ! LC,NH42S4 ; case E2
8504 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
8506 CALL CALCB3 ! NH42S4 ; case E3
8509 ELSEIF (DRNH42S4.LE.RH) THEN
8511 CALL CALCB4 ! Only liquid ; case E4
8516 CALL CALCNA ! HNO3(g) DISSOLUTION
8518 ! *** SULFATE RICH (FREE ACID)
8519 ! FOR SOLVING THIS CASE, NITRIC ACID IS ASSUMED A MINOR SPECIES,
8520 ! THAT DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM
8521 ! SUBROUTINE CALCC? IS CALLED, AND THEN THE NITRIC ACID IS DISSOLVED
8522 ! FROM THE HNO3(G) -> (H+) + (NO3-) EQUILIBRIUM.
8524 ELSEIF (SULRAT.LT.1.0) THEN
8526 IF(METSTBL.EQ.1) THEN
8528 CALL CALCC2 ! Only liquid (metastable)
8532 IF (RH.LT.DRNH4HS4) THEN
8534 CALL CALCC1 ! NH4HSO4 ; case F1
8537 ELSEIF (DRNH4HS4.LE.RH) THEN
8539 CALL CALCC2 ! Only liquid ; case F2
8544 CALL CALCNA ! HNO3(g) DISSOLUTION
8551 ! *** END OF SUBROUTINE ISRP2F *****************************************
8553 END SUBROUTINE ISRP2F
8554 !=======================================================================
8556 ! *** ISORROPIA CODE
8557 ! *** SUBROUTINE ISRP3F
8558 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FORWARD PROBLEM OF
8559 ! AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
8560 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
8561 ! RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
8563 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8564 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8565 ! *** WRITTEN BY ATHANASIOS NENES
8566 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8568 !=======================================================================
8570 SUBROUTINE ISRP3F (WI, RHI, TEMPI)
8572 REAL(KIND=8) WI(NCOMP), RHI, TEMPI
8575 ! *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
8577 WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
8578 WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
8580 ! *** ADJUST FOR TOO LITTLE SODIUM, SULFATE AND NITRATE COMBINED ********
8582 IF (WI(1)+WI(2)+WI(4) .LE. 1d-10) THEN
8583 WI(1) = 1.D-10 ! Na+ : 1e-4 umoles/m3
8584 WI(2) = 1.D-10 ! SO4- : 1e-4 umoles/m3
8587 ! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
8589 CALL ISOINIT3 (WI, RHI, TEMPI)
8591 ! *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
8593 REST = 2.D0*W(2) + W(4) + W(5)
8594 IF (W(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
8595 W(1) = (ONE-1D-6)*REST ! Adjust Na amount
8596 CALL PUSHERR (0050, 'ISRP3F') ! Warning error: Na adjusted
8599 ! *** CALCULATE SULFATE & SODIUM RATIOS *********************************
8601 SULRAT = (W(1)+W(3))/W(2)
8604 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
8606 ! *** SULFATE POOR ; SODIUM POOR
8608 IF (2.0.LE.SULRAT .AND. SODRAT.LT.2.0) THEN
8610 IF(METSTBL.EQ.1) THEN
8612 CALL CALCG5 ! Only liquid (metastable)
8615 IF (RH.LT.DRNH4NO3) THEN
8617 CALL CALCG1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
8619 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
8621 CALL CALCG2 ! NH42SO4,NH4CL,NA2SO4
8623 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
8625 CALL CALCG3 ! NH42SO4,NA2SO4
8627 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
8629 CALL CALCG4 ! NA2SO4
8631 ELSEIF (DRNA2SO4.LE.RH) THEN
8633 CALL CALCG5 ! Only liquid
8637 ! *** SULFATE POOR ; SODIUM RICH
8639 ELSE IF (SULRAT.GE.2.0 .AND. SODRAT.GE.2.0) THEN
8641 IF(METSTBL.EQ.1) THEN
8643 CALL CALCH6 ! Only liquid (metastable)
8646 IF (RH.LT.DRNH4NO3) THEN
8648 CALL CALCH1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
8650 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
8652 CALL CALCH2 ! NH4CL,NA2SO4,NACL,NANO3
8654 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
8656 CALL CALCH3 ! NH4CL,NA2SO4,NACL
8658 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4Cl) THEN
8660 CALL CALCH4 ! NH4CL,NA2SO4
8662 ELSEIF (DRNH4Cl.LE.RH .AND. RH.LT.DRNA2SO4) THEN
8664 CALL CALCH5 ! NA2SO4
8666 ELSEIF (DRNA2SO4.LE.RH) THEN
8668 CALL CALCH6 ! NO SOLID
8672 ! *** SULFATE RICH (NO ACID)
8674 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
8676 IF(METSTBL.EQ.1) THEN
8678 CALL CALCI6 ! Only liquid (metastable)
8681 IF (RH.LT.DRNH4HS4) THEN
8683 CALL CALCI1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
8685 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
8687 CALL CALCI2 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
8689 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
8691 CALL CALCI3 ! NA2SO4,(NH4)2SO4,LC
8693 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
8695 CALL CALCI4 ! NA2SO4,(NH4)2SO4
8697 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
8699 CALL CALCI5 ! NA2SO4
8701 ELSEIF (DRNA2SO4.LE.RH) THEN
8703 CALL CALCI6 ! NO SOLIDS
8707 CALL CALCNHA ! MINOR SPECIES: HNO3, HCl
8710 ! *** SULFATE RICH (FREE ACID)
8712 ELSEIF (SULRAT.LT.1.0) THEN
8714 IF(METSTBL.EQ.1) THEN
8716 CALL CALCJ3 ! Only liquid (metastable)
8719 IF (RH.LT.DRNH4HS4) THEN
8721 CALL CALCJ1 ! NH4HSO4,NAHSO4
8723 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
8725 CALL CALCJ2 ! NAHSO4
8727 ELSEIF (DRNAHSO4.LE.RH) THEN
8733 CALL CALCNHA ! MINOR SPECIES: HNO3, HCl
8741 ! *** END OF SUBROUTINE ISRP3F *****************************************
8743 END SUBROUTINE ISRP3F
8744 !=======================================================================
8746 ! *** ISORROPIA CODE
8747 ! *** SUBROUTINE CALCA2
8750 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8751 ! 1. SULFATE POOR (SULRAT > 2.0)
8752 ! 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
8754 ! FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS X, THE
8755 ! AMOUNT OF HYDROGEN IONS (H+) FOUND IN THE LIQUID PHASE.
8756 ! FOR EACH ESTIMATION OF H+, FUNCTION FUNCB2A CALCULATES THE
8757 ! CONCENTRATION OF IONS FROM THE NH3(GAS) - NH4+(LIQ) EQUILIBRIUM.
8758 ! ELECTRONEUTRALITY IS USED AS THE OBJECTIVE FUNCTION.
8760 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8761 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8762 ! *** WRITTEN BY ATHANASIOS NENES
8763 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8765 !=======================================================================
8769 REAL(KIND=8) REST,OMELO, OMEHI, X1, X2, X3, Y1, Y2, Y3, DX
8772 ! *** SETUP PARAMETERS ************************************************
8774 CALAOU =.TRUE. ! Outer loop activity calculation flag
8775 OMELO = TINY ! Low limit: SOLUTION IS VERY BASIC
8776 OMEHI = 2.0D0*W(2) ! High limit: FROM NH4+ -> NH3(g) + H+(aq)
8778 ! *** CALCULATE WATER CONTENT *****************************************
8784 ! *** INITIAL VALUES FOR BISECTION ************************************
8788 IF (ABS(Y1).LE.EPS) RETURN
8790 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
8792 DX = (OMEHI-OMELO)/FLOAT(NDIV)
8794 X2 = MAX(X1-DX, OMELO)
8796 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
8800 IF (ABS(Y2).LE.EPS) THEN
8803 CALL PUSHERR (0001, 'CALCA2') ! WARNING ERROR: NO SOLUTION
8807 ! *** PERFORM BISECTION ***********************************************
8812 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
8819 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
8821 CALL PUSHERR (0002, 'CALCA2') ! WARNING ERROR: NO CONVERGENCE
8823 ! *** CONVERGED ; RETURN **********************************************
8829 ! *** END OF SUBROUTINE CALCA2 ****************************************
8831 END SUBROUTINE CALCA2
8835 !=======================================================================
8837 ! *** ISORROPIA CODE
8838 ! *** FUNCTION FUNCA2
8840 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE A2 ;
8841 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCA2.
8843 !=======================================================================
8845 REAL(KIND=8) FUNCTION FUNCA2 (OMEGI)
8848 REAL(KIND=8) LAMDA, PSI, A1, A2, A3, ZETA, DENOM
8852 ! *** SETUP PARAMETERS ************************************************
8856 PSI = W(2) ! INITIAL AMOUNT OF (NH4)2SO4 IN SOLUTION
8858 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8861 A1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
8862 A2 = XK2*R*TEMP/XKW*(GAMA(8)/GAMA(9))**2.
8863 A3 = XKW*RH*WATER*WATER
8865 LAMDA = PSI/(A1/OMEGI+ONE)
8868 ! *** SPECIATION & WATER CONTENT ***************************************
8870 MOLAL (1) = OMEGI ! HI
8871 MOLAL (3) = W(3)/(ONE/A2/OMEGI + ONE) ! NH4I
8872 MOLAL (5) = MAX(PSI-LAMDA,TINY) ! SO4I
8873 MOLAL (6) = LAMDA ! HSO4I
8874 GNH3 = MAX (W(3)-MOLAL(3), TINY) ! NH3GI
8877 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8879 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8886 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
8888 20 DENOM = (2.0*MOLAL(5)+MOLAL(6))
8889 FUNCA2= (MOLAL(3)/DENOM - ONE) + MOLAL(1)/DENOM
8892 ! *** END OF FUNCTION FUNCA2 ********************************************
8897 !=======================================================================
8899 ! *** ISORROPIA CODE
8900 ! *** SUBROUTINE CALCA1
8903 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8904 ! 1. SULFATE POOR (SULRAT > 2.0)
8905 ! 2. SOLID AEROSOL ONLY
8906 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
8908 ! A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
8909 ! IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
8912 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8913 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8914 ! *** WRITTEN BY ATHANASIOS NENES
8915 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8917 !=======================================================================
8923 GNH3 = MAX (W(3)-2.0*CNH42S4, ZERO)
8926 ! *** END OF SUBROUTINE CALCA1 ******************************************
8928 END SUBROUTINE CALCA1
8932 !=======================================================================
8934 ! *** ISORROPIA CODE
8935 ! *** SUBROUTINE CALCB4
8938 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8939 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
8940 ! 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
8942 ! FOR CALCULATIONS, A BISECTION IS PERFORMED WITH RESPECT TO H+.
8943 ! THE OBJECTIVE FUNCTION IS THE DIFFERENCE BETWEEN THE ESTIMATED H+
8944 ! AND THAT CALCULATED FROM ELECTRONEUTRALITY.
8946 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8947 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
8948 ! *** WRITTEN BY ATHANASIOS NENES
8949 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
8951 !=======================================================================
8955 REAL(KIND=8) ALF, BET, GAM, AK1, BB, CC, DD
8958 ! *** SOLVE EQUATIONS **************************************************
8964 ! *** CALCULATE WATER CONTENT ******************************************
8966 CALL CALCB1A ! GET DRY SALT CONTENT, AND USE FOR WATER.
8973 WATER = MOLALR(13)/M0(13)+MOLALR(9)/M0(9)+MOLALR(4)/M0(4)
8975 MOLAL(3) = W(3) ! NH4I
8978 AK1 = XK1*((GAMA(8)/GAMA(7))**2.)*(WATER/GAMA(7))
8982 BB = BET + AK1 - GAM
8984 DD = BB*BB - 4.D0*CC
8986 ! *** SPECIATION & WATER CONTENT ***************************************
8988 MOLAL (5) = MAX(TINY,MIN(0.5*(-BB + SQRT(DD)), W(2))) ! SO4I
8989 MOLAL (6) = MAX(TINY,MIN(W(2)-MOLAL(5),W(2))) ! HSO4I
8990 MOLAL (1) = MAX(TINY,MIN(AK1*MOLAL(6)/MOLAL(5),W(2))) ! HI
8991 CALL CALCMR ! Water content
8993 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8995 IF (.NOT.CALAIN) GOTO 30
9001 ! *** END OF SUBROUTINE CALCB4 ******************************************
9003 END SUBROUTINE CALCB4
9004 !=======================================================================
9006 ! *** ISORROPIA CODE
9007 ! *** SUBROUTINE CALCB3
9010 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9011 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
9012 ! 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
9013 ! 3. SOLIDS POSSIBLE: (NH4)2SO4
9015 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9016 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9017 ! *** WRITTEN BY ATHANASIOS NENES
9018 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9020 !=======================================================================
9024 REAL(KIND=8) X,Y,TLC,TNH42S4, TNH4HS4
9026 ! *** CALCULATE EQUIVALENT AMOUNT OF HSO4 AND SO4 ***********************
9028 X = MAX(2*W(2)-W(3), ZERO) ! Equivalent NH4HSO4
9029 Y = MAX(W(3) -W(2), ZERO) ! Equivalent NH42SO4
9031 ! *** CALCULATE SPECIES ACCORDING TO RELATIVE ABUNDANCE OF HSO4 *********
9033 IF (X.LT.Y) THEN ! LC is the MIN (x,y)
9034 SCASE = 'B3 ; SUBCASE 1'
9037 CALL CALCB3A (TLC,TNH42S4) ! LC + (NH4)2SO4
9039 SCASE = 'B3 ; SUBCASE 2'
9042 CALL CALCB3B (TLC,TNH4HS4) ! LC + NH4HSO4
9047 ! *** END OF SUBROUTINE CALCB3 ******************************************
9049 END SUBROUTINE CALCB3
9052 !=======================================================================
9054 ! *** ISORROPIA CODE
9055 ! *** SUBROUTINE CALCB3A
9056 ! *** CASE B3 ; SUBCASE 1
9058 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9059 ! 1. SULFATE RICH (1.0 < SULRAT < 2.0)
9060 ! 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
9061 ! 3. SOLIDS POSSIBLE: (NH4)2SO4
9063 ! FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS ZETA, THE
9064 ! AMOUNT OF SOLID (NH4)2SO4 DISSOLVED IN THE LIQUID PHASE.
9065 ! FOR EACH ESTIMATION OF ZETA, FUNCTION FUNCB3A CALCULATES THE
9066 ! AMOUNT OF H+ PRODUCED (BASED ON THE SO4 RELEASED INTO THE
9067 ! SOLUTION). THE SOLUBILITY PRODUCT OF (NH4)2SO4 IS USED AS THE
9068 ! OBJECTIVE FUNCTION.
9070 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9071 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9072 ! *** WRITTEN BY ATHANASIOS NENES
9073 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9075 !=======================================================================
9077 SUBROUTINE CALCB3A (TLC, TNH42S4)
9079 REAL(KIND=8) TLC, TNH42S4
9080 REAL(KIND=8) ZLO, ZHI, Z1, Z2, Z3, ZK, YLO, YHI, Y1, Y2, Y3, DZ
9083 CALAOU = .TRUE. ! Outer loop activity calculation flag
9084 ZLO = ZERO ! MIN DISSOLVED (NH4)2SO4
9085 ZHI = TNH42S4 ! MAX DISSOLVED (NH4)2SO4
9087 ! *** INITIAL VALUES FOR BISECTION (DISSOLVED (NH4)2SO4 ****************
9090 Y1 = FUNCB3A (Z1, TLC, TNH42S4)
9091 IF (ABS(Y1).LE.EPS) RETURN
9094 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
9096 DZ = (ZHI-ZLO)/FLOAT(NDIV)
9099 Y2 = FUNCB3A (Z2, TLC, TNH42S4)
9100 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9105 ! *** NO SUBDIVISION WITH SOLUTION FOUND
9107 YHI= Y1 ! Save Y-value at HI position
9108 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
9111 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC
9113 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
9118 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
9120 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
9125 CALL PUSHERR (0001, 'CALCB3A') ! WARNING ERROR: NO SOLUTION
9129 ! *** PERFORM BISECTION ***********************************************
9133 Y3 = FUNCB3A (Z3, TLC, TNH42S4)
9134 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9141 IF (ABS(Z2-Z1) .LE. EPS*Z1) GOTO 40
9143 CALL PUSHERR (0002, 'CALCB3A') ! WARNING ERROR: NO CONVERGENCE
9145 ! *** CONVERGED ; RETURN ************************************************
9148 Y3 = FUNCB3A (ZK, TLC, TNH42S4)
9152 ! *** END OF SUBROUTINE CALCB3A ******************************************
9154 END SUBROUTINE CALCB3A
9158 !=======================================================================
9160 ! *** ISORROPIA CODE
9161 ! *** FUNCTION FUNCB3A
9162 ! *** CASE B3 ; SUBCASE 1
9163 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE B3
9164 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCA3.
9166 !=======================================================================
9168 DOUBLE PRECISION FUNCTION FUNCB3A (ZK, Y, X)
9170 REAL(KIND=8) ZK, Y, X
9171 REAL(KIND=8) KK, GRAT1, DD
9174 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9179 GRAT1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9180 DD = SQRT( (ZK+GRAT1+Y)**2. + 4.0*Y*GRAT1)
9181 KK = 0.5*(-(ZK+GRAT1+Y) + DD )
9183 ! *** SPECIATION & WATER CONTENT ***************************************
9186 MOLAL (5) = KK+ZK+Y ! SO4I
9187 MOLAL (6) = MAX (Y-KK, TINY) ! HSO4I
9188 MOLAL (3) = 3.0*Y+2*ZK ! NH4I
9189 CNH42S4 = X-ZK ! Solid (NH4)2SO4
9190 CALL CALCMR ! Water content
9192 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9194 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9201 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
9203 !CC30 FUNCB3A= ( SO4I*NH4I**2.0 )/( XK7*(WATER/GAMA(4))**3.0 )
9204 30 FUNCB3A= MOLAL(5)*MOLAL(3)**2.0
9205 FUNCB3A= FUNCB3A/(XK7*(WATER/GAMA(4))**3.0) - ONE
9208 ! *** END OF FUNCTION FUNCB3A ********************************************
9210 END FUNCTION FUNCB3A
9214 !=======================================================================
9216 ! *** ISORROPIA CODE
9217 ! *** SUBROUTINE CALCB3B
9218 ! *** CASE B3 ; SUBCASE 2
9220 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9221 ! 1. SULFATE RICH (1.0 < SULRAT < 2.0)
9222 ! 2. LIQUID PHASE ONLY IS POSSIBLE
9224 ! SPECIATION CALCULATIONS IS BASED ON THE HSO4 <--> SO4 EQUILIBRIUM.
9226 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9227 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9228 ! *** WRITTEN BY ATHANASIOS NENES
9229 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9231 !=======================================================================
9233 SUBROUTINE CALCB3B (Y, X)
9236 REAL(KIND=8) KK, GRAT1, DD
9239 CALAOU = .FALSE. ! Outer loop activity calculation flag
9243 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9246 GRAT1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9247 DD = SQRT( (GRAT1+Y)**2. + 4.0*(X+Y)*GRAT1)
9248 KK = 0.5*(-(GRAT1+Y) + DD )
9250 ! *** SPECIATION & WATER CONTENT ***************************************
9253 MOLAL (5) = Y+KK ! SO4I
9254 MOLAL (6) = MAX (X+Y-KK, TINY) ! HSO4I
9255 MOLAL (3) = 3.0*Y+X ! NH4I
9256 CALL CALCMR ! Water content
9258 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9260 IF (.NOT.CALAIN) GOTO 30
9266 ! *** END OF SUBROUTINE CALCB3B ******************************************
9268 END SUBROUTINE CALCB3B
9269 !=======================================================================
9271 ! *** ISORROPIA CODE
9272 ! *** SUBROUTINE CALCB2
9275 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9276 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
9277 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
9278 ! 3. SOLIDS POSSIBLE : LC, (NH4)2SO4
9280 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON THE SULFATE RATIO:
9281 ! 1. WHEN BOTH LC AND (NH4)2SO4 ARE POSSIBLE (SUBROUTINE CALCB2A)
9282 ! 2. WHEN ONLY LC IS POSSIBLE (SUBROUTINE CALCB2B).
9284 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9285 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9286 ! *** WRITTEN BY ATHANASIOS NENES
9287 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9289 !=======================================================================
9295 ! *** CALCULATE EQUIVALENT AMOUNT OF HSO4 AND SO4 ***********************
9297 X = MAX(2*W(2)-W(3), TINY) ! Equivalent NH4HSO4
9298 Y = MAX(W(3) -W(2), TINY) ! Equivalent NH42SO4
9300 ! *** CALCULATE SPECIES ACCORDING TO RELATIVE ABUNDANCE OF HSO4 *********
9302 IF (X.LE.Y) THEN ! LC is the MIN (x,y)
9303 SCASE = 'B2 ; SUBCASE 1'
9304 CALL CALCB2A (X,Y-X) ! LC + (NH4)2SO4 POSSIBLE
9306 SCASE = 'B2 ; SUBCASE 2'
9307 CALL CALCB2B (Y,X-Y) ! LC ONLY POSSIBLE
9312 ! *** END OF SUBROUTINE CALCB2 ******************************************
9314 END SUBROUTINE CALCB2
9318 !=======================================================================
9320 ! *** ISORROPIA CODE
9321 ! *** SUBROUTINE CALCB2
9322 ! *** CASE B2 ; SUBCASE A.
9324 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9325 ! 1. SULFATE RICH (1.0 < SULRAT < 2.0)
9326 ! 2. SOLID PHASE ONLY POSSIBLE
9327 ! 3. SOLIDS POSSIBLE: LC, (NH4)2SO4
9329 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
9330 ! 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
9331 ! 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE
9333 ! FOR SOLID CALCULATIONS, A MATERIAL BALANCE BASED ON THE STOICHIMETRIC
9334 ! PROPORTION OF AMMONIUM AND SULFATE IS DONE TO CALCULATE THE AMOUNT
9335 ! OF LC AND (NH4)2SO4 IN THE SOLID PHASE.
9337 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9338 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9339 ! *** WRITTEN BY ATHANASIOS NENES
9340 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9342 !=======================================================================
9344 SUBROUTINE CALCB2A (TLC, TNH42S4)
9346 REAL(KIND=8) TLC, TNH42S4
9348 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
9350 IF (RH.LT.DRMLCAS) THEN
9351 SCASE = 'B2 ; SUBCASE A1' ! SOLIDS POSSIBLE ONLY
9354 SCASE = 'B2 ; SUBCASE A1'
9356 SCASE = 'B2 ; SUBCASE A2'
9357 CALL CALCB2A2 (TLC, TNH42S4) ! LIQUID & SOLID PHASE POSSIBLE
9358 SCASE = 'B2 ; SUBCASE A2'
9363 ! *** END OF SUBROUTINE CALCB2A *****************************************
9365 END SUBROUTINE CALCB2A
9369 !=======================================================================
9371 ! *** ISORROPIA CODE
9372 ! *** SUBROUTINE CALCB2A2
9373 ! *** CASE B2 ; SUBCASE A2.
9375 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9376 ! 1. SULFATE RICH (1.0 < SULRAT < 2.0)
9377 ! 2. SOLID PHASE ONLY POSSIBLE
9378 ! 3. SOLIDS POSSIBLE: LC, (NH4)2SO4
9380 ! THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
9381 ! DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
9382 ! SOLUTIONS ; THE SOLID PHASE ONLY (SUBROUTINE CALCB2A1) AND THE
9383 ! THE SOLID WITH LIQUID PHASE (SUBROUTINE CALCB3).
9385 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9386 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9387 ! *** WRITTEN BY ATHANASIOS NENES
9388 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9390 !=======================================================================
9392 SUBROUTINE CALCB2A2 (TLC, TNH42S4)
9394 REAL(KIND=8) TLC, TNH42S4
9395 REAL(KIND=8) WF, ONEMWF, CLCO, CNH42SO
9397 ! *** FIND WEIGHT FACTOR **********************************************
9399 IF (WFTYP.EQ.0) THEN
9401 ELSEIF (WFTYP.EQ.1) THEN
9404 WF = (DRLC-RH)/(DRLC-DRMLCAS)
9408 ! *** FIND FIRST SECTION ; DRY ONE ************************************
9410 CLCO = TLC ! FIRST (DRY) SOLUTION
9413 ! *** FIND SECOND SECTION ; DRY & LIQUID ******************************
9417 CALL CALCB3 ! SECOND (LIQUID) SOLUTION
9419 ! *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
9421 MOLAL(1)= ONEMWF*MOLAL(1) ! H+
9422 MOLAL(3)= ONEMWF*(2.D0*(CNH42SO-CNH42S4) + 3.D0*(CLCO-CLC)) ! NH4+
9423 MOLAL(5)= ONEMWF*(CNH42SO-CNH42S4 + CLCO-CLC) ! SO4--
9424 MOLAL(6)= ONEMWF*(CLCO-CLC) ! HSO4-
9426 WATER = ONEMWF*WATER
9428 CLC = WF*CLCO + ONEMWF*CLC
9429 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
9433 ! *** END OF SUBROUTINE CALCB2A2 ****************************************
9435 END SUBROUTINE CALCB2A2
9439 !=======================================================================
9441 ! *** ISORROPIA CODE
9442 ! *** SUBROUTINE CALCB2
9443 ! *** CASE B2 ; SUBCASE B
9445 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9446 ! 1. SULFATE RICH (1.0 < SULRAT < 2.0)
9447 ! 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
9448 ! 3. SOLIDS POSSIBLE: LC
9450 ! FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS ZETA, THE
9451 ! AMOUNT OF SOLID LC DISSOLVED IN THE LIQUID PHASE.
9452 ! FOR EACH ESTIMATION OF ZETA, FUNCTION FUNCB2A CALCULATES THE
9453 ! AMOUNT OF H+ PRODUCED (BASED ON THE HSO4, SO4 RELEASED INTO THE
9454 ! SOLUTION). THE SOLUBILITY PRODUCT OF LC IS USED AS THE OBJECTIVE
9457 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9458 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9459 ! *** WRITTEN BY ATHANASIOS NENES
9460 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9462 !=======================================================================
9464 SUBROUTINE CALCB2B (TLC,TNH4HS4)
9466 REAL(KIND=8) TLC, TNH4HS4
9467 REAL(KIND=8) ZLO, ZHI, YLO, YHI, DX, X1, X2, X3, Y1, Y2, Y3
9470 CALAOU = .TRUE. ! Outer loop activity calculation flag
9472 ZHI = TLC ! High limit: all of it in liquid phase
9474 ! *** INITIAL VALUES FOR BISECTION **************************************
9477 Y1 = FUNCB2B (X1,TNH4HS4,TLC)
9478 IF (ABS(Y1).LE.EPS) RETURN
9479 YHI= Y1 ! Save Y-value at Hi position
9481 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ************************
9486 Y2 = FUNCB2B (X2,TNH4HS4,TLC)
9487 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9492 ! *** NO SUBDIVISION WITH SOLUTION FOUND
9494 YLO= Y1 ! Save Y-value at LO position
9495 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
9498 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC
9500 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
9505 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
9507 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
9512 CALL PUSHERR (0001, 'CALCB2B') ! WARNING ERROR: NO SOLUTION
9516 ! *** PERFORM BISECTION *************************************************
9520 Y3 = FUNCB2B (X3,TNH4HS4,TLC)
9521 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9528 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9530 CALL PUSHERR (0002, 'CALCB2B') ! WARNING ERROR: NO CONVERGENCE
9532 ! *** CONVERGED ; RETURN ************************************************
9535 Y3 = FUNCB2B (X3,TNH4HS4,TLC)
9539 ! *** END OF SUBROUTINE CALCB2B *****************************************
9541 END SUBROUTINE CALCB2B
9545 !=======================================================================
9547 ! *** ISORROPIA CODE
9548 ! *** FUNCTION FUNCB2B
9550 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE B2 ; SUBCASE 2
9551 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCB2B.
9553 !=======================================================================
9555 DOUBLE PRECISION FUNCTION FUNCB2B (X,TNH4HS4,TLC)
9557 REAL(KIND=8) X,TNH4HS4,TLC
9558 REAL(KIND=8) GRAT2, PARM, DELTA, OMEGA
9561 ! *** SOLVE EQUATIONS **************************************************
9566 GRAT2 = XK1*WATER*(GAMA(8)/GAMA(7))**2./GAMA(7)
9568 DELTA = PARM*PARM + 4.0*(X+TNH4HS4)*GRAT2 ! Diakrinousa
9569 OMEGA = 0.5*(-PARM + SQRT(DELTA)) ! Thetiki riza (ie:H+>0)
9571 ! *** SPECIATION & WATER CONTENT ***************************************
9573 MOLAL (1) = OMEGA ! HI
9574 MOLAL (3) = 3.0*X+TNH4HS4 ! NH4I
9575 MOLAL (5) = X+OMEGA ! SO4I
9576 MOLAL (6) = MAX (X+TNH4HS4-OMEGA, TINY) ! HSO4I
9577 CLC = MAX(TLC-X,ZERO) ! Solid LC
9578 CALL CALCMR ! Water content
9580 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP ******************
9582 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9589 ! *** CALCULATE OBJECTIVE FUNCTION **************************************
9591 !CC30 FUNCB2B= ( NH4I**3.*SO4I*HSO4I )/( XK13*(WATER/GAMA(13))**5. )
9592 30 FUNCB2B= (MOLAL(3)**3.)*MOLAL(5)*MOLAL(6)
9593 FUNCB2B= FUNCB2B/(XK13*(WATER/GAMA(13))**5.) - ONE
9596 ! *** END OF FUNCTION FUNCB2B *******************************************
9598 END FUNCTION FUNCB2B
9601 !=======================================================================
9603 ! *** ISORROPIA CODE
9604 ! *** SUBROUTINE CALCB1
9607 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9608 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
9609 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
9610 ! 3. SOLIDS POSSIBLE : LC, (NH4)2SO4, NH4HSO4
9612 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
9613 ! 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
9614 ! 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCB1A)
9616 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9617 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9618 ! *** WRITTEN BY ATHANASIOS NENES
9619 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9621 !=======================================================================
9626 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
9628 IF (RH.LT.DRMLCAB) THEN
9629 SCASE = 'B1 ; SUBCASE 1'
9630 CALL CALCB1A ! SOLID PHASE ONLY POSSIBLE
9631 SCASE = 'B1 ; SUBCASE 1'
9633 SCASE = 'B1 ; SUBCASE 2'
9634 CALL CALCB1B ! LIQUID & SOLID PHASE POSSIBLE
9635 SCASE = 'B1 ; SUBCASE 2'
9640 ! *** END OF SUBROUTINE CALCB1 ******************************************
9642 END SUBROUTINE CALCB1
9646 !=======================================================================
9648 ! *** ISORROPIA CODE
9649 ! *** SUBROUTINE CALCB1A
9650 ! *** CASE B1 ; SUBCASE 1
9652 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9654 ! 2. THERE IS NO LIQUID PHASE
9655 ! 3. SOLIDS POSSIBLE: LC, { (NH4)2SO4 XOR NH4HSO4 } (ONE OF TWO
9658 ! A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE AMOUNT OF LC
9659 ! IS CALCULATED FROM THE (NH4)2SO4 AND NH4HSO4 WHICH IS LEAST
9660 ! ABUNDANT (STOICHIMETRICALLY). THE REMAINING EXCESS OF SALT
9661 ! IS MIXED WITH THE LC.
9663 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9664 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9665 ! *** WRITTEN BY ATHANASIOS NENES
9666 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9668 !=======================================================================
9674 ! *** SETUP PARAMETERS ************************************************
9676 X = 2*W(2)-W(3) ! Equivalent NH4HSO4
9677 Y = W(3)-W(2) ! Equivalent (NH4)2SO4
9679 ! *** CALCULATE COMPOSITION *******************************************
9681 IF (X.LE.Y) THEN ! LC is the MIN (x,y)
9682 CLC = X ! NH4HSO4 >= (NH4)2S04
9686 CLC = Y ! NH4HSO4 < (NH4)2S04
9692 ! *** END OF SUBROUTINE CALCB1 ******************************************
9694 END SUBROUTINE CALCB1A
9699 !=======================================================================
9701 ! *** ISORROPIA CODE
9702 ! *** SUBROUTINE CALCB1B
9703 ! *** CASE B1 ; SUBCASE 2
9705 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9707 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
9708 ! 3. SOLIDS POSSIBLE: LC, { (NH4)2SO4 XOR NH4HSO4 } (ONE OF TWO
9711 ! THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
9712 ! DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
9713 ! SOLUTIONS ; THE SOLID PHASE ONLY (SUBROUTINE CALCB1A) AND THE
9714 ! THE SOLID WITH LIQUID PHASE (SUBROUTINE CALCB2).
9716 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9717 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9718 ! *** WRITTEN BY ATHANASIOS NENES
9719 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9721 !=======================================================================
9725 REAL(KIND=8) WF, ONEMWF, CLCO, CNH42SO, CNH4HSO
9727 ! *** FIND WEIGHT FACTOR **********************************************
9729 IF (WFTYP.EQ.0) THEN
9731 ELSEIF (WFTYP.EQ.1) THEN
9734 WF = (DRNH4HS4-RH)/(DRNH4HS4-DRMLCAB)
9738 ! *** FIND FIRST SECTION ; DRY ONE ************************************
9741 CLCO = CLC ! FIRST (DRY) SOLUTION
9745 ! *** FIND SECOND SECTION ; DRY & LIQUID ******************************
9750 CALL CALCB2 ! SECOND (LIQUID) SOLUTION
9752 ! *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
9754 MOLAL(1)= ONEMWF*MOLAL(1) ! H+
9755 MOLAL(3)= ONEMWF*(2.D0*(CNH42SO-CNH42S4) + (CNH4HSO-CNH4HS4) &
9756 + 3.D0*(CLCO-CLC)) ! NH4+
9757 MOLAL(5)= ONEMWF*(CNH42SO-CNH42S4 + CLCO-CLC) ! SO4--
9758 MOLAL(6)= ONEMWF*(CNH4HSO-CNH4HS4 + CLCO-CLC) ! HSO4-
9760 WATER = ONEMWF*WATER
9762 CLC = WF*CLCO + ONEMWF*CLC
9763 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
9764 CNH4HS4 = WF*CNH4HSO + ONEMWF*CNH4HS4
9768 ! *** END OF SUBROUTINE CALCB1B *****************************************
9770 END SUBROUTINE CALCB1B
9773 !=======================================================================
9775 ! *** ISORROPIA CODE
9776 ! *** SUBROUTINE CALCC2
9779 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9780 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
9781 ! 2. THERE IS ONLY A LIQUID PHASE
9783 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9784 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9785 ! *** WRITTEN BY ATHANASIOS NENES
9786 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9788 !=======================================================================
9792 REAL(KIND=8) LAMDA, KAPA, PSI, PARM, BB, CC
9795 CALAOU =.TRUE. ! Outer loop activity calculation flag
9799 ! *** SOLVE EQUATIONS **************************************************
9801 LAMDA = W(3) ! NH4HSO4 INITIALLY IN SOLUTION
9802 PSI = W(2)-W(3) ! H2SO4 IN SOLUTION
9804 PARM = WATER*XK1/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9806 CC =-PARM*(LAMDA+PSI)
9807 KAPA = 0.5*(-BB+SQRT(BB*BB-4.0*CC))
9809 ! *** SPECIATION & WATER CONTENT ***************************************
9811 MOLAL(1) = PSI+KAPA ! HI
9812 MOLAL(3) = LAMDA ! NH4I
9813 MOLAL(5) = KAPA ! SO4I
9814 MOLAL(6) = MAX(LAMDA+PSI-KAPA, TINY) ! HSO4I
9815 CH2SO4 = MAX(MOLAL(5)+MOLAL(6)-MOLAL(3), ZERO) ! Free H2SO4
9816 CALL CALCMR ! Water content
9818 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9820 IF (.NOT.CALAIN) GOTO 30
9826 ! *** END OF SUBROUTINE CALCC2 *****************************************
9828 END SUBROUTINE CALCC2
9832 !=======================================================================
9834 ! *** ISORROPIA CODE
9835 ! *** SUBROUTINE CALCC1
9838 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9839 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
9840 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
9841 ! 3. SOLIDS POSSIBLE: NH4HSO4
9843 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9844 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9845 ! *** WRITTEN BY ATHANASIOS NENES
9846 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9848 !=======================================================================
9852 REAL(KIND=8) KLO, KHI, YLO, YHI, X1, X2, X3, Y1, Y2, Y3, DX
9855 CALAOU = .TRUE. ! Outer loop activity calculation flag
9859 ! *** INITIAL VALUES FOR BISECTION *************************************
9863 IF (ABS(Y1).LE.EPS) GOTO 50
9866 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
9868 DX = (KHI-KLO)/FLOAT(NDIV)
9872 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2) .LT. ZERO) GOTO 20 ! (Y1*Y2 .LT. ZERO)
9877 ! *** NO SUBDIVISION WITH SOLUTION FOUND
9879 YHI= Y2 ! Save Y-value at HI position
9880 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
9883 ! *** { YLO, YHI } < 0.0 SOLUTION IS ALWAYS UNDERSATURATED WITH NH4HS04
9885 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
9888 ! *** { YLO, YHI } > 0.0 SOLUTION IS ALWAYS SUPERSATURATED WITH NH4HS04
9890 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
9895 CALL PUSHERR (0001, 'CALCC1') ! WARNING ERROR: NO SOLUTION
9899 ! *** PERFORM BISECTION OF DISSOLVED NH4HSO4 **************************
9904 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9911 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9913 CALL PUSHERR (0002, 'CALCC1') ! WARNING ERROR: NO CONVERGENCE
9915 ! *** CONVERGED ; RETURN ***********************************************
9922 ! *** END OF SUBROUTINE CALCC1 *****************************************
9924 END SUBROUTINE CALCC1
9928 !=======================================================================
9930 ! *** ISORROPIA CODE
9931 ! *** FUNCTION FUNCC1
9933 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE C1
9934 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCC1.
9936 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9937 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
9938 ! *** WRITTEN BY ATHANASIOS NENES
9939 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
9941 !=======================================================================
9943 DOUBLE PRECISION FUNCTION FUNCC1 (KAPA)
9945 REAL(KIND=8) KAPA, LAMDA, PSI, PAR1, PAR2, BB, CC
9948 ! *** SOLVE EQUATIONS **************************************************
9955 PAR1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
9956 PAR2 = XK12*(WATER/GAMA(9))**2.0
9958 CC =-PAR1*(PSI+KAPA)
9959 LAMDA = 0.5*(-BB+SQRT(BB*BB-4*CC))
9961 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY *******************************
9963 MOLAL(1) = PSI+LAMDA ! HI
9964 MOLAL(3) = KAPA ! NH4I
9965 MOLAL(5) = LAMDA ! SO4I
9966 MOLAL(6) = MAX (ZERO, PSI+KAPA-LAMDA) ! HSO4I
9967 CNH4HS4 = MAX(W(3)-MOLAL(3), ZERO) ! Solid NH4HSO4
9968 CH2SO4 = MAX(PSI, ZERO) ! Free H2SO4
9969 CALL CALCMR ! Water content
9971 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9973 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9980 ! *** CALCULATE ZERO FUNCTION *******************************************
9982 !CC30 FUNCC1= (NH4I*HSO4I/PAR2) - ONE
9983 30 FUNCC1= (MOLAL(3)*MOLAL(6)/PAR2) - ONE
9986 ! *** END OF FUNCTION FUNCC1 ********************************************
9990 !=======================================================================
9992 ! *** ISORROPIA CODE
9993 ! *** SUBROUTINE CALCD3
9996 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9997 ! 1. SULFATE POOR (SULRAT > 2.0)
9998 ! 2. THERE IS OLNY A LIQUID PHASE
10000 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10001 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10002 ! *** WRITTEN BY ATHANASIOS NENES
10003 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10005 !=======================================================================
10009 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
10010 REAL(KIND=8) PSI4LO, PSI4HI, YLO, YHI, DX, P4, YY, DELTA
10013 ! *** FIND DRY COMPOSITION **********************************************
10017 ! *** SETUP PARAMETERS ************************************************
10019 CHI1 = CNH4NO3 ! Save from CALCD1 run
10024 PSI1 = CNH4NO3 ! ASSIGN INITIAL PSI's
10033 CALL CALCMR ! Initial water
10035 CALAOU = .TRUE. ! Outer loop activity calculation flag
10036 PSI4LO = TINY ! Low limit
10037 PSI4HI = CHI4 ! High limit
10039 ! *** INITIAL VALUES FOR BISECTION ************************************
10043 IF (ABS(Y1).LE.EPS) RETURN
10044 YLO= Y1 ! Save Y-value at HI position
10046 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10048 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
10052 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10057 ! *** NO SUBDIVISION WITH SOLUTION FOUND
10059 YHI= Y1 ! Save Y-value at Hi position
10060 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
10063 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
10064 ! Physically I dont know when this might happen, but I have put this
10065 ! branch in for completeness. I assume there is no solution; all NO3 goes to the
10068 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
10069 P4 = TINY ! PSI4LO ! CHI4
10073 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
10074 ! This happens when Sul.Rat. = 2.0, so some NH4+ from sulfate evaporates
10075 ! and goes to the gas phase ; so I redefine the LO and HI limits of PSI4
10076 ! and proceed again with root tracking.
10078 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
10080 PSI4LO = PSI4LO - 0.1*(PSI1+PSI2) ! No solution; some NH3 evaporates
10081 IF (PSI4LO.LT.-(PSI1+PSI2)) THEN
10082 CALL PUSHERR (0001, 'CALCD3') ! WARNING ERROR: NO SOLUTION
10089 CALL CALCMR ! Initial water
10090 GOTO 60 ! Redo root tracking
10094 ! *** PERFORM BISECTION ***********************************************
10099 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10106 IF (ABS(X2-X1) .LE. EPS*ABS(X1)) GOTO 40
10108 CALL PUSHERR (0002, 'CALCD3') ! WARNING ERROR: NO CONVERGENCE
10110 ! *** CONVERGED ; RETURN **********************************************
10112 40 X3 = 0.5*(X1+X2)
10115 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10118 IF (MOLAL(1).GT.TINY) THEN
10119 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10120 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10121 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10122 MOLAL(6) = DELTA ! HSO4 EFFECT
10126 ! *** END OF SUBROUTINE CALCD3 ******************************************
10128 END SUBROUTINE CALCD3
10130 !=======================================================================
10132 ! *** ISORROPIA CODE
10133 ! *** FUNCTION FUNCD3
10135 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D3 ;
10136 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCD3.
10138 !=======================================================================
10140 REAL(KIND=8) FUNCTION FUNCD3 (P4)
10143 REAL(KIND=8) BB, DENM, ABB, AHI
10146 ! *** SETUP PARAMETERS ************************************************
10152 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10155 A2 = XK7*(WATER/GAMA(4))**3.0
10156 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
10157 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10158 A7 = XKW *RH*WATER*WATER
10160 PSI3 = A3*A4*CHI3*(CHI4-PSI4) - PSI1*(2.D0*PSI2+PSI1+PSI4)
10161 PSI3 = PSI3/(A3*A4*(CHI4-PSI4) + 2.D0*PSI2+PSI1+PSI4)
10162 PSI3 = MIN(MAX(PSI3, ZERO), CHI3)
10165 !CCOLD AHI = 0.5*(-BB + SQRT(BB*BB + 4.d0*A7)) ! This is correct also
10166 !CC AHI =2.0*A7/(BB+SQRT(BB*BB + 4.d0*A7)) ! Avoid overflow when HI->0
10167 DENM = BB+SQRT(BB*BB + 4.d0*A7)
10168 IF (DENM.LE.TINY) THEN ! Avoid overflow when HI->0
10170 DENM = (BB+ABB) + 2.0*A7/ABB ! Taylor expansion of SQRT
10174 ! *** SPECIATION & WATER CONTENT ***************************************
10176 MOLAL (1) = AHI ! HI
10177 MOLAL (3) = PSI1 + PSI4 + 2.D0*PSI2 ! NH4I
10178 MOLAL (5) = PSI2 ! SO4I
10179 MOLAL (6) = ZERO ! HSO4I
10180 MOLAL (7) = PSI3 + PSI1 ! NO3I
10181 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
10182 CNH4NO3 = ZERO ! Solid NH4NO3
10183 GHNO3 = CHI3 - PSI3 ! Gas HNO3
10184 GNH3 = CHI4 - PSI4 ! Gas NH3
10185 CALL CALCMR ! Water content
10187 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10189 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10196 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
10199 !CC FUNCD3= NH4I/HI/MAX(GNH3,TINY)/A4 - ONE
10200 FUNCD3= MOLAL(3)/MOLAL(1)/MAX(GNH3,TINY)/A4 - ONE
10203 ! *** END OF FUNCTION FUNCD3 ********************************************
10205 END FUNCTION FUNCD3
10208 !=======================================================================
10210 ! *** ISORROPIA CODE
10211 ! *** SUBROUTINE CALCD2
10214 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10215 ! 1. SULFATE POOR (SULRAT > 2.0)
10216 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
10217 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
10219 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10220 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10221 ! *** WRITTEN BY ATHANASIOS NENES
10222 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10224 !=======================================================================
10228 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
10229 REAL(KIND=8) PSI4LO, PSI4HI, YLO, YHI, DX, P4, YY, DELTA
10234 ! *** FIND DRY COMPOSITION **********************************************
10238 ! *** SETUP PARAMETERS ************************************************
10240 CHI1 = CNH4NO3 ! Save from CALCD1 run
10245 PSI1 = CNH4NO3 ! ASSIGN INITIAL PSI's
10254 CALL CALCMR ! Initial water
10256 CALAOU = .TRUE. ! Outer loop activity calculation flag
10257 PSI4LO = TINY ! Low limit
10258 PSI4HI = CHI4 ! High limit
10260 ! *** INITIAL VALUES FOR BISECTION ************************************
10264 IF (ABS(Y1).LE.EPS) RETURN
10265 YLO= Y1 ! Save Y-value at HI position
10267 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10269 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
10273 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) THEN
10275 ! This is done, in case if Y(PSI4LO)>0, but Y(PSI4LO+DX) < 0 (i.e.undersat)
10277 IF (Y1 .LE. Y2) GOTO 20 ! (Y1*Y2.LT.ZERO)
10283 ! *** NO SUBDIVISION WITH SOLUTION FOUND
10285 YHI= Y1 ! Save Y-value at Hi position
10286 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
10289 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
10290 ! Physically I dont know when this might happen, but I have put this
10291 ! branch in for completeness. I assume there is no solution; all NO3 goes to the
10294 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
10295 P4 = TINY ! PSI4LO ! CHI4
10299 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
10300 ! This happens when Sul.Rat. = 2.0, so some NH4+ from sulfate evaporates
10301 ! and goes to the gas phase ; so I redefine the LO and HI limits of PSI4
10302 ! and proceed again with root tracking.
10304 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
10306 PSI4LO = PSI4LO - 0.1*(PSI1+PSI2) ! No solution; some NH3 evaporates
10307 IF (PSI4LO.LT.-(PSI1+PSI2)) THEN
10308 CALL PUSHERR (0001, 'CALCD2') ! WARNING ERROR: NO SOLUTION
10315 CALL CALCMR ! Initial water
10316 GOTO 60 ! Redo root tracking
10320 ! *** PERFORM BISECTION ***********************************************
10325 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10332 IF (ABS(X2-X1) .LE. EPS*ABS(X1)) GOTO 40
10334 CALL PUSHERR (0002, 'CALCD2') ! WARNING ERROR: NO CONVERGENCE
10336 ! *** CONVERGED ; RETURN **********************************************
10338 40 X3 = MIN(X1,X2) ! 0.5*(X1+X2) ! Get "low" side, it's acidic soln.
10341 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10344 IF (MOLAL(1).GT.TINY) THEN
10345 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10346 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10347 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10348 MOLAL(6) = DELTA ! HSO4 EFFECT
10352 ! *** END OF SUBROUTINE CALCD2 ******************************************
10354 END SUBROUTINE CALCD2
10356 !=======================================================================
10358 ! *** ISORROPIA CODE
10359 ! *** FUNCTION FUNCD2
10361 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D2 ;
10362 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCD2.
10364 !=======================================================================
10366 REAL(KIND=8) FUNCTION FUNCD2 (P4)
10369 REAL(KIND=8) BB, DENM, ABB, AHI, PSI4, PSI2, PSI3, PSI14
10374 ! *** SETUP PARAMETERS ************************************************
10376 CALL RSTGAM ! Reset activity coefficients to 0.1
10382 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10385 A2 = XK7*(WATER/GAMA(4))**3.0
10386 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
10387 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10388 A7 = XKW *RH*WATER*WATER
10390 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
10392 CALL POLY3 (PSI14,0.25*PSI14**2.,-A2/4.D0, PSI2, ISLV) ! PSI2
10393 IF (ISLV.EQ.0) THEN
10394 PSI2 = MIN (PSI2, CHI2)
10400 PSI3 = A3*A4*CHI3*(CHI4-PSI4) - PSI1*(2.D0*PSI2+PSI1+PSI4)
10401 PSI3 = PSI3/(A3*A4*(CHI4-PSI4) + 2.D0*PSI2+PSI1+PSI4)
10402 !cc PSI3 = MIN(MAX(PSI3, ZERO), CHI3)
10404 BB = PSI4-PSI3 ! (BB > 0, acidic solution, <0 alkaline)
10406 ! Do not change computation scheme for H+, all others did not work well.
10408 DENM = BB+SQRT(BB*BB + 4.d0*A7)
10409 IF (DENM.LE.TINY) THEN ! Avoid overflow when HI->0
10411 DENM = (BB+ABB) + 2.d0*A7/ABB ! Taylor expansion of SQRT
10415 ! *** SPECIATION & WATER CONTENT ***************************************
10417 MOLAL (1) = AHI ! HI
10418 MOLAL (3) = PSI1 + PSI4 + 2.D0*PSI2 ! NH4
10419 MOLAL (5) = PSI2 ! SO4
10420 MOLAL (6) = ZERO ! HSO4
10421 MOLAL (7) = PSI3 + PSI1 ! NO3
10422 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
10423 CNH4NO3 = ZERO ! Solid NH4NO3
10424 GHNO3 = CHI3 - PSI3 ! Gas HNO3
10425 GNH3 = CHI4 - PSI4 ! Gas NH3
10426 CALL CALCMR ! Water content
10428 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10430 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10437 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
10440 !CC FUNCD2= NH4I/HI/MAX(GNH3,TINY)/A4 - ONE
10441 FUNCD2= MOLAL(3)/MOLAL(1)/MAX(GNH3,TINY)/A4 - ONE
10444 ! *** END OF FUNCTION FUNCD2 ********************************************
10446 END FUNCTION FUNCD2
10448 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10449 ! 1. SULFATE POOR (SULRAT > 2.0)
10450 ! 2. SOLID AEROSOL ONLY
10451 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
10453 ! THERE ARE TWO REGIMES DEFINED BY RELATIVE HUMIDITY:
10454 ! 1. RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCD1A)
10455 ! 2. RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
10457 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10458 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10459 ! *** WRITTEN BY ATHANASIOS NENES
10460 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10462 !=======================================================================
10466 ! EXTERNAL CALCD1A, CALCD2
10468 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
10470 IF (RH.LT.DRMASAN) THEN
10471 SCASE = 'D1 ; SUBCASE 1' ! SOLID PHASE ONLY POSSIBLE
10473 SCASE = 'D1 ; SUBCASE 1'
10475 SCASE = 'D1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
10476 CALL CALCMDRH (RH, DRMASAN, DRNH4NO3, CALCD1A, CALCD2)
10477 SCASE = 'D1 ; SUBCASE 2'
10482 ! *** END OF SUBROUTINE CALCD1 ******************************************
10484 END SUBROUTINE CALCD1
10488 !=======================================================================
10490 ! *** ISORROPIA CODE
10491 ! *** SUBROUTINE CALCD1A
10492 ! *** CASE D1 ; SUBCASE 1
10494 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10495 ! 1. SULFATE POOR (SULRAT > 2.0)
10496 ! 2. SOLID AEROSOL ONLY
10497 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
10499 ! THE SOLID (NH4)2SO4 IS CALCULATED FROM THE SULFATES, WHILE NH4NO3
10500 ! IS CALCULATED FROM NH3-HNO3 EQUILIBRIUM. 'ZE' IS THE AMOUNT OF
10501 ! NH4NO3 THAT VOLATIZES WHEN ALL POSSILBE NH4NO3 IS INITIALLY IN
10504 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10505 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10506 ! *** WRITTEN BY ATHANASIOS NENES
10507 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10509 !=======================================================================
10513 REAL(KIND=8) PARM, X, PS, OM, OMPS, DIAK, ZE
10515 ! *** SETUP PARAMETERS ************************************************
10517 PARM = XK10/(R*TEMP)/(R*TEMP)
10519 ! *** CALCULATE NH4NO3 THAT VOLATIZES *********************************
10522 X = MAX(ZERO, MIN(W(3)-2.0*CNH42S4, W(4))) ! MAX NH4NO3
10523 PS = MAX(W(3) - X - 2.0*CNH42S4, ZERO)
10524 OM = MAX(W(4) - X, ZERO)
10527 DIAK = SQRT(OMPS*OMPS + 4.0*PARM) ! DIAKRINOUSA
10528 ZE = MIN(X, 0.5*(-OMPS + DIAK)) ! THETIKI RIZA
10530 ! *** SPECIATION *******************************************************
10532 CNH4NO3 = X - ZE ! Solid NH4NO3
10533 GNH3 = PS + ZE ! Gas NH3
10534 GHNO3 = OM + ZE ! Gas HNO3
10538 ! *** END OF SUBROUTINE CALCD1A *****************************************
10540 END SUBROUTINE CALCD1A
10541 !=======================================================================
10543 ! *** ISORROPIA CODE
10544 ! *** SUBROUTINE CALCG5
10547 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10548 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
10549 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
10550 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
10552 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10553 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10554 ! *** WRITTEN BY ATHANASIOS NENES
10555 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10557 !=======================================================================
10561 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DELTA
10565 ! *** SETUP PARAMETERS ************************************************
10569 CHI2 = MAX (W(2)-CHI1, ZERO)
10571 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
10578 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
10580 WATER = CHI2/M0(4) + CHI1/M0(2)
10582 ! *** INITIAL VALUES FOR BISECTION ************************************
10586 IF (CHI6.LE.TINY) GOTO 50
10587 ! IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
10588 ! IF (WATER .LE. TINY) RETURN ! No water
10590 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10592 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
10596 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10601 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
10603 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG5A (PSI6LO)
10606 ! *** PERFORM BISECTION ***********************************************
10611 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10618 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
10620 CALL PUSHERR (0002, 'CALCG5') ! WARNING ERROR: NO CONVERGENCE
10622 ! *** CONVERGED ; RETURN **********************************************
10624 40 X3 = 0.5*(X1+X2)
10627 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10630 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN ! If quadrat.called
10631 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10632 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10633 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10634 MOLAL(6) = DELTA ! HSO4 EFFECT
10639 ! *** END OF SUBROUTINE CALCG5 *******************************************
10641 END SUBROUTINE CALCG5
10646 !=======================================================================
10648 ! *** ISORROPIA CODE
10649 ! *** SUBROUTINE FUNCG5A
10652 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10653 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
10654 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
10655 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
10657 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10658 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10659 ! *** WRITTEN BY ATHANASIOS NENES
10660 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10662 !=======================================================================
10664 REAL(KIND=8) FUNCTION FUNCG5A (X)
10667 REAL(KIND=8) AKK, BB, CC, DD, SMIN, HI, OHI
10672 ! *** SETUP PARAMETERS ************************************************
10678 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10682 A1 = XK5 *(WATER/GAMA(2))**3.0
10683 A2 = XK7 *(WATER/GAMA(4))**3.0
10684 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10685 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
10686 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
10689 ! CALCULATE DISSOCIATION QUANTITIES
10691 IF (CHI5.GE.TINY) THEN
10692 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
10697 !CC IF(CHI4.GT.TINY) THEN
10698 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
10699 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
10700 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
10701 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
10702 PSI4 =0.5d0*(-BB - SQRT(DD))
10707 ! *** CALCULATE SPECIATION ********************************************
10709 MOLAL (2) = 2.0D0*PSI1 ! NAI
10710 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
10711 MOLAL (4) = PSI6 ! CLI
10712 MOLAL (5) = PSI2 + PSI1 ! SO4I
10714 MOLAL (7) = PSI5 ! NO3I
10716 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
10717 CALL CALCPH (SMIN, HI, OHI)
10720 GNH3 = MAX(CHI4 - PSI4, TINY) ! Gas NH3
10721 GHNO3 = MAX(CHI5 - PSI5, TINY) ! Gas HNO3
10722 GHCL = MAX(CHI6 - PSI6, TINY) ! Gas HCl
10724 CNH42S4 = ZERO ! Solid (NH4)2SO4
10725 CNH4NO3 = ZERO ! Solid NH4NO3
10726 CNH4CL = ZERO ! Solid NH4Cl
10728 CALL CALCMR ! Water content
10730 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10732 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10739 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
10741 20 FUNCG5A = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
10742 !CC FUNCG5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
10746 ! *** END OF FUNCTION FUNCG5A *******************************************
10748 END FUNCTION FUNCG5A
10750 !=======================================================================
10752 ! *** ISORROPIA CODE
10753 ! *** SUBROUTINE CALCG4
10756 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10757 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
10758 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
10759 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
10761 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10762 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10763 ! *** WRITTEN BY ATHANASIOS NENES
10764 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10766 !=======================================================================
10770 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
10771 REAL(KIND=8) PSI6LO, PSI6HI, DX, DELTA
10775 ! *** SETUP PARAMETERS ************************************************
10779 CHI2 = MAX (W(2)-CHI1, ZERO)
10781 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
10787 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
10789 WATER = CHI2/M0(4) + CHI1/M0(2)
10791 ! *** INITIAL VALUES FOR BISECTION ************************************
10795 IF (CHI6.LE.TINY) GOTO 50
10796 !CC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY .OR. WATER .LE. TINY) GOTO 50
10797 !CC IF (WATER .LE. TINY) RETURN ! No water
10799 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10801 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
10805 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10810 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
10812 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG4A (PSI6LO)
10815 ! *** PERFORM BISECTION ***********************************************
10820 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10827 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
10829 CALL PUSHERR (0002, 'CALCG4') ! WARNING ERROR: NO CONVERGENCE
10831 ! *** CONVERGED ; RETURN **********************************************
10833 40 X3 = 0.5*(X1+X2)
10836 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10839 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
10840 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10841 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10842 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10843 MOLAL(6) = DELTA ! HSO4 EFFECT
10848 ! *** END OF SUBROUTINE CALCG4 *******************************************
10850 END SUBROUTINE CALCG4
10853 !=======================================================================
10855 ! *** ISORROPIA CODE
10856 ! *** SUBROUTINE FUNCG4A
10859 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10860 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
10861 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
10862 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
10864 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10865 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10866 ! *** WRITTEN BY ATHANASIOS NENES
10867 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10869 !=======================================================================
10871 REAL(KIND=8) FUNCTION FUNCG4A (X)
10874 REAL(KIND=8) NAI, NH4I, NO3I
10875 REAL(KIND=8) HI, OHI
10877 ! *** SETUP PARAMETERS ************************************************
10884 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10888 A1 = XK5 *(WATER/GAMA(2))**3.0
10889 A2 = XK7 *(WATER/GAMA(4))**3.0
10890 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10891 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
10892 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
10894 ! CALCULATE DISSOCIATION QUANTITIES
10896 IF (CHI5.GE.TINY) THEN
10897 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
10902 !CC IF(CHI4.GT.TINY) THEN
10903 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
10904 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
10905 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
10906 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma shankar, 19/11/2001
10907 PSI4 =0.5d0*(-BB - SQRT(DD))
10912 ! CALCULATE CONCENTRATIONS
10914 NH4I = 2.0*PSI2 + PSI4
10920 CALL CALCPH(2.d0*SO4I+NO3I+CLI-NAI-NH4I, HI, OHI)
10922 ! *** Na2SO4 DISSOLUTION
10924 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
10925 CALL POLY3 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
10926 IF (ISLV.EQ.0) THEN
10927 PSI1 = MIN (PSI1, CHI1)
10935 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
10945 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10947 GNH3 = MAX(CHI4 - PSI4, TINY)
10948 GHNO3 = MAX(CHI5 - PSI5, TINY)
10949 GHCL = MAX(CHI6 - PSI6, TINY)
10954 CNA2SO4 = MAX(CHI1-PSI1,ZERO)
10956 ! *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
10960 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10962 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10969 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
10971 20 FUNCG4A = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
10972 !CC FUNCG4A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
10976 ! *** END OF FUNCTION FUNCG4A *******************************************
10978 END FUNCTION FUNCG4A
10980 !=======================================================================
10982 ! *** ISORROPIA CODE
10983 ! *** SUBROUTINE CALCG3
10986 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10987 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
10988 ! 2. LIQUID & SOLID PHASE ARE BOTH POSSIBLE
10989 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
10991 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10992 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
10993 ! *** WRITTEN BY ATHANASIOS NENES
10994 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
10996 !=======================================================================
10999 ! EXTERNAL CALCG1A, CALCG4
11001 ! *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
11003 IF (W(4).GT.TINY .AND. W(5).GT.TINY) THEN ! NO3,CL EXIST, WATER POSSIBLE
11004 SCASE = 'G3 ; SUBCASE 1'
11006 SCASE = 'G3 ; SUBCASE 1'
11007 ELSE ! NO3, CL NON EXISTANT
11008 SCASE = 'G1 ; SUBCASE 1'
11010 SCASE = 'G1 ; SUBCASE 1'
11013 IF (WATER.LE.TINY) THEN
11014 IF (RH.LT.DRMG3) THEN ! ONLY SOLIDS
11020 SCASE = 'G3 ; SUBCASE 2'
11023 SCASE = 'G3 ; SUBCASE 3' ! MDRH REGION (NA2SO4, NH42S4)
11024 CALL CALCMDRH (RH, DRMG3, DRNH42S4, CALCG1A, CALCG4)
11025 SCASE = 'G3 ; SUBCASE 3'
11031 ! *** END OF SUBROUTINE CALCG3 ******************************************
11033 END SUBROUTINE CALCG3
11037 !=======================================================================
11039 ! *** ISORROPIA CODE
11040 ! *** SUBROUTINE CALCG3A
11041 ! *** CASE G3 ; SUBCASE 1
11043 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11044 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11045 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11046 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11048 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11049 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11050 ! *** WRITTEN BY ATHANASIOS NENES
11051 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11053 !=======================================================================
11057 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DELTA
11058 REAL(KIND=8) CC, BB
11062 ! *** SETUP PARAMETERS ************************************************
11066 CHI2 = MAX (W(2)-CHI1, ZERO)
11068 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
11073 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
11077 ! *** INITIAL VALUES FOR BISECTION ************************************
11081 IF (CHI6.LE.TINY) GOTO 50
11082 !CC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY .OR. WATER .LE. TINY) GOTO 50
11083 !CC IF (WATER .LE. TINY) RETURN ! No water
11085 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11087 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11092 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11097 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11099 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG3A (PSI6LO)
11102 ! *** PERFORM BISECTION ***********************************************
11107 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11114 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11116 CALL PUSHERR (0002, 'CALCG3A') ! WARNING ERROR: NO CONVERGENCE
11118 ! *** CONVERGED ; RETURN **********************************************
11120 40 X3 = 0.5*(X1+X2)
11123 ! *** FINAL CALCULATIONS *************************************************
11127 ! *** Na2SO4 DISSOLUTION
11129 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
11130 CALL POLY3 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
11131 IF (ISLV.EQ.0) THEN
11132 PSI1 = MIN (PSI1, CHI1)
11139 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
11140 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
11141 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
11143 ! *** HSO4 equilibrium
11145 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11146 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11147 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
11148 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
11149 MOLAL(6) = DELTA ! HSO4 EFFECT
11154 ! *** END OF SUBROUTINE CALCG3A ******************************************
11156 END SUBROUTINE CALCG3A
11161 !=======================================================================
11163 ! *** ISORROPIA CODE
11164 ! *** SUBROUTINE FUNCG3A
11165 ! *** CASE G3 ; SUBCASE 1
11167 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11168 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11169 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11170 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11172 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11173 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11174 ! *** WRITTEN BY ATHANASIOS NENES
11175 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11177 !=======================================================================
11179 DOUBLE PRECISION FUNCTION FUNCG3A (X)
11182 REAL(KIND=8) SMIN, HI, OHI
11183 REAL(KIND=8) PSI20, BB, CC, DD
11188 ! *** SETUP PARAMETERS ************************************************
11195 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11199 A1 = XK5 *(WATER/GAMA(2))**3.0
11200 A2 = XK7 *(WATER/GAMA(4))**3.0
11201 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11202 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11203 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11205 ! CALCULATE DISSOCIATION QUANTITIES
11207 IF (CHI5.GE.TINY) THEN
11208 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
11213 !CC IF(CHI4.GT.TINY) THEN
11214 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
11215 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
11216 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
11217 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
11218 PSI4 =0.5d0*(-BB - SQRT(DD))
11223 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
11224 CALL POLY3 (PSI4, PSI4*PSI4/4.D0, -A2/4.D0, PSI20, ISLV)
11225 IF (ISLV.EQ.0) PSI2 = MIN (PSI20, CHI2)
11228 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
11230 MOLAL (2) = ZERO ! Na
11231 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
11232 MOLAL (4) = PSI6 ! CLI
11233 MOLAL (5) = PSI2 ! SO4I
11234 MOLAL (6) = ZERO ! HSO4
11235 MOLAL (7) = PSI5 ! NO3I
11237 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
11238 CALL CALCPH (SMIN, HI, OHI)
11241 GNH3 = MAX(CHI4 - PSI4, TINY) ! Gas NH3
11242 GHNO3 = MAX(CHI5 - PSI5, TINY) ! Gas HNO3
11243 GHCL = MAX(CHI6 - PSI6, TINY) ! Gas HCl
11245 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
11246 CNH4NO3 = ZERO ! Solid NH4NO3
11247 CNH4CL = ZERO ! Solid NH4Cl
11249 CALL CALCMR ! Water content
11251 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11253 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11260 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
11262 20 FUNCG3A = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
11263 !CC FUNCG3A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
11267 ! *** END OF FUNCTION FUNCG3A *******************************************
11269 END FUNCTION FUNCG3A
11271 !=======================================================================
11273 ! *** ISORROPIA CODE
11274 ! *** SUBROUTINE CALCG2
11277 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11278 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11279 ! 2. LIQUID & SOLID PHASE ARE BOTH POSSIBLE
11280 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11282 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11283 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11284 ! *** WRITTEN BY ATHANASIOS NENES
11285 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11287 !=======================================================================
11291 ! EXTERNAL CALCG1A, CALCG3A, CALCG4
11293 ! *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
11295 IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
11296 SCASE = 'G2 ; SUBCASE 1'
11298 SCASE = 'G2 ; SUBCASE 1'
11299 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
11300 SCASE = 'G1 ; SUBCASE 1'
11302 SCASE = 'G1 ; SUBCASE 1'
11305 ! *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
11307 IF (WATER.LE.TINY) THEN
11308 IF (RH.LT.DRMG2) THEN ! ONLY SOLIDS
11314 SCASE = 'G2 ; SUBCASE 2'
11316 IF (W(5).GT. TINY) THEN
11317 SCASE = 'G2 ; SUBCASE 3' ! MDRH (NH4CL, NA2SO4, NH42S4)
11318 CALL CALCMDRH (RH, DRMG2, DRNH4CL, CALCG1A, CALCG3A)
11319 SCASE = 'G2 ; SUBCASE 3'
11321 IF (WATER.LE.TINY .AND. RH.GE.DRMG3) THEN
11322 SCASE = 'G2 ; SUBCASE 4' ! MDRH (NA2SO4, NH42S4)
11323 CALL CALCMDRH (RH, DRMG3, DRNH42S4, CALCG1A, CALCG4)
11324 SCASE = 'G2 ; SUBCASE 4'
11331 SCASE = 'G2 ; SUBCASE 2'
11338 ! *** END OF SUBROUTINE CALCG2 ******************************************
11340 END SUBROUTINE CALCG2
11343 !=======================================================================
11345 ! *** ISORROPIA CODE
11346 ! *** SUBROUTINE CALCG2A
11347 ! *** CASE G2 ; SUBCASE 1
11349 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11350 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11351 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11352 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11354 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11355 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11356 ! *** WRITTEN BY ATHANASIOS NENES
11357 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11359 !=======================================================================
11363 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DELTA
11367 ! *** SETUP PARAMETERS ************************************************
11371 CHI2 = MAX (W(2)-CHI1, ZERO)
11373 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
11382 ! *** INITIAL VALUES FOR BISECTION ************************************
11386 IF (CHI6.LE.TINY) GOTO 50
11387 !CC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
11388 !CC IF (WATER .LE. TINY) GOTO 50 ! No water
11390 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11392 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11396 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11401 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11403 IF (ABS(Y2) .GT. EPS) WATER = TINY
11406 ! *** PERFORM BISECTION ***********************************************
11411 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11418 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11420 CALL PUSHERR (0002, 'CALCG2A') ! WARNING ERROR: NO CONVERGENCE
11422 ! *** CONVERGED ; RETURN **********************************************
11424 40 X3 = 0.5*(X1+X2)
11425 IF (X3.LE.TINY2) THEN ! PRACTICALLY NO NITRATES, SO DRY SOLUTION
11431 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
11435 ! *** Na2SO4 DISSOLUTION
11437 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
11438 CALL POLY3 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
11439 IF (ISLV.EQ.0) THEN
11440 PSI1 = MIN (PSI1, CHI1)
11447 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
11448 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
11449 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
11451 ! *** HSO4 equilibrium
11453 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11454 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11455 MOLAL(1) = MOLAL(1) - DELTA ! H+ AFFECT
11456 MOLAL(5) = MOLAL(5) - DELTA ! SO4 AFFECT
11457 MOLAL(6) = DELTA ! HSO4 AFFECT
11462 ! *** END OF SUBROUTINE CALCG2A ******************************************
11464 END SUBROUTINE CALCG2A
11469 !=======================================================================
11471 ! *** ISORROPIA CODE
11472 ! *** SUBROUTINE FUNCG2A
11475 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11476 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11477 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11478 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11480 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11481 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11482 ! *** WRITTEN BY ATHANASIOS NENES
11483 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11485 !=======================================================================
11487 REAL(KIND=8) FUNCTION FUNCG2A (X)
11491 REAL(KIND=8) SMIN, HI, OHI
11492 REAL(KIND=8) PSI31, PSI32, PSI20, BB, CC, DD, DELT
11493 REAL(KIND=8) ALF, BET, GAM, RTSQ, THETA1, THETA2
11498 ! *** SETUP PARAMETERS ************************************************
11506 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11510 A1 = XK5 *(WATER/GAMA(2))**3.0
11511 A2 = XK7 *(WATER/GAMA(4))**3.0
11512 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11513 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11514 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11516 DENO = MAX(CHI6-PSI6-PSI3, ZERO)
11517 PSI5 = CHI5/((A6/A5)*(DENO/PSI6) + ONE)
11519 PSI4 = MIN(PSI5+PSI6,CHI4)
11521 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
11522 CALL POLY3 (PSI4, PSI4*PSI4/4.D0, -A2/4.D0, PSI20, ISLV)
11523 IF (ISLV.EQ.0) PSI2 = MIN (PSI20, CHI2)
11526 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
11528 MOLAL (2) = ZERO ! NA
11529 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
11530 MOLAL (4) = PSI6 ! CLI
11531 MOLAL (5) = PSI2 ! SO4I
11532 MOLAL (6) = ZERO ! HSO4
11533 MOLAL (7) = PSI5 ! NO3I
11535 !CC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
11536 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
11537 CALL CALCPH (SMIN, HI, OHI)
11540 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
11542 GNH3 = MAX(CHI4 - PSI4, TINY)
11543 GHNO3 = MAX(CHI5 - PSI5, TINY)
11544 GHCL = MAX(CHI6 - PSI6, TINY)
11546 CNH42S4 = MAX(CHI2 - PSI2, ZERO)
11549 ! *** NH4Cl(s) calculations
11551 A3 = XK6 /(R*TEMP*R*TEMP)
11552 IF (GNH3*GHCL.GT.A3) THEN
11553 DELT = MIN(GNH3, GHCL)
11556 DD = BB*BB - 4.D0*CC
11557 PSI31 = 0.5D0*(-BB + SQRT(DD))
11558 PSI32 = 0.5D0*(-BB - SQRT(DD))
11559 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
11561 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
11570 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
11572 GNH3 = MAX(GNH3 - PSI3, TINY)
11573 GHCL = MAX(GHCL - PSI3, TINY)
11576 ! *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
11580 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11582 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11589 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
11591 20 IF (CHI4.LE.TINY) THEN
11592 FUNCG2A = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
11594 FUNCG2A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
11599 ! *** END OF FUNCTION FUNCG2A *******************************************
11601 END FUNCTION FUNCG2A
11603 !=======================================================================
11605 ! *** ISORROPIA CODE
11606 ! *** SUBROUTINE CALCG1
11609 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11610 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
11611 ! 2. SOLID AEROSOL ONLY
11612 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4CL, NA2SO4
11614 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
11615 ! 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
11616 ! 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCG1A)
11618 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11619 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11620 ! *** WRITTEN BY ATHANASIOS NENES
11621 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11623 !=======================================================================
11627 ! EXTERNAL CALCG1A, CALCG2A
11629 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
11631 IF (RH.LT.DRMG1) THEN
11632 SCASE = 'G1 ; SUBCASE 1'
11633 CALL CALCG1A ! SOLID PHASE ONLY POSSIBLE
11634 SCASE = 'G1 ; SUBCASE 1'
11636 SCASE = 'G1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
11637 CALL CALCMDRH (RH, DRMG1, DRNH4NO3, CALCG1A, CALCG2A)
11638 SCASE = 'G1 ; SUBCASE 2'
11643 ! *** END OF SUBROUTINE CALCG1 ******************************************
11645 END SUBROUTINE CALCG1
11648 !=======================================================================
11650 ! *** ISORROPIA CODE
11651 ! *** SUBROUTINE CALCG1A
11652 ! *** CASE G1 ; SUBCASE 1
11654 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11655 ! 1. SULFATE POOR (SULRAT > 2.0)
11656 ! 2. SOLID AEROSOL ONLY
11657 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
11659 ! SOLID (NH4)2SO4 IS CALCULATED FROM THE SULFATES, WHILE NH4NO3
11660 ! IS CALCULATED FROM NH3-HNO3 EQUILIBRIUM. 'ZE' IS THE AMOUNT OF
11661 ! NH4NO3 THAT VOLATIZES WHEN ALL POSSILBE NH4NO3 IS INITIALLY IN
11664 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11665 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11666 ! *** WRITTEN BY ATHANASIOS NENES
11667 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11669 !=======================================================================
11673 REAL(KIND=8) LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2
11674 REAL(KIND=8) ALF, BET, GAM, RTSQ, THETA1, THETA2
11675 REAL(KIND=8) SQDD, DD1, DD2, SQD1
11676 REAL(KIND=8) BB, CC, DD, SQDD1, SQDD2
11678 ! *** CALCULATE NON VOLATILE SOLIDS ***********************************
11681 CNH42S4 = W(2) - CNA2SO4
11683 ! *** CALCULATE VOLATILE SPECIES **************************************
11685 ALF = W(3) - 2.0*CNH42S4
11689 RTSQ = R*TEMP*R*TEMP
11693 THETA1 = GAM - BET*(A2/A1)
11696 ! QUADRATIC EQUATION SOLUTION
11698 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
11699 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
11700 DD = BB*BB - 4.0D0*CC
11701 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
11703 ! TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
11706 KAPA1 = 0.5D0*(-BB+SQDD)
11707 KAPA2 = 0.5D0*(-BB-SQDD)
11708 LAMDA1 = THETA1 + THETA2*KAPA1
11709 LAMDA2 = THETA1 + THETA2*KAPA2
11711 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
11712 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
11713 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
11720 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
11721 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
11722 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
11729 ! SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
11733 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
11734 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
11736 ! NH4CL EQUILIBRIUM
11738 IF (DD1.GE.ZERO) THEN
11740 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
11741 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
11743 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
11745 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
11752 ! NH4NO3 EQUILIBRIUM
11754 IF (DD2.GE.ZERO) THEN
11756 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
11757 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
11759 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
11761 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
11768 ! IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
11770 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
11771 IF (BET .LT. LAMDA/THETA1) THEN
11778 ! *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
11784 GNH3 = MAX(ALF - KAPA - LAMDA, ZERO)
11785 GHNO3 = MAX(GAM - LAMDA, ZERO)
11786 GHCL = MAX(BET - KAPA, ZERO)
11790 ! *** END OF SUBROUTINE CALCG1A *****************************************
11792 END SUBROUTINE CALCG1A
11794 !=======================================================================
11796 ! *** ISORROPIA CODE
11797 ! *** SUBROUTINE CALCH6
11800 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11801 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
11802 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11803 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11805 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11806 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11807 ! *** WRITTEN BY ATHANASIOS NENES
11808 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11810 !=======================================================================
11814 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DELTA
11822 ! *** SETUP PARAMETERS ************************************************
11825 CHI1 = W(2) ! CNA2SO4
11826 CHI2 = ZERO ! CNH42S4
11827 CHI3 = ZERO ! CNH4CL
11828 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
11829 CHI8 = MIN (FRNA, W(4)) ! CNANO3
11830 CHI4 = W(3) ! NH3(g)
11831 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
11832 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
11833 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
11836 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
11838 ! *** INITIAL VALUES FOR BISECTION ************************************
11842 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
11844 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11846 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11850 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11855 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11857 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH6A (PSI6LO)
11860 ! *** PERFORM BISECTION ***********************************************
11865 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11872 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11874 CALL PUSHERR (0002, 'CALCH6') ! WARNING ERROR: NO CONVERGENCE
11876 ! *** CONVERGED ; RETURN **********************************************
11878 40 X3 = 0.5*(X1+X2)
11881 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
11884 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11885 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11886 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
11887 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
11888 MOLAL(6) = DELTA ! HSO4 EFFECT
11893 ! *** END OF SUBROUTINE CALCH6 ******************************************
11895 END SUBROUTINE CALCH6
11900 !=======================================================================
11902 ! *** ISORROPIA CODE
11903 ! *** SUBROUTINE FUNCH6A
11906 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11907 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
11908 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
11909 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
11911 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11912 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
11913 ! *** WRITTEN BY ATHANASIOS NENES
11914 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
11916 !=======================================================================
11918 REAL(KIND=8) FUNCTION FUNCH6A (X)
11921 REAL(KIND=8) FRNA, A9
11922 REAL(KIND=8) BB, CC, DD, SMIN, HI, OHI
11929 ! *** SETUP PARAMETERS ************************************************
11940 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11944 A1 = XK5 *(WATER/GAMA(2))**3.0
11945 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11946 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11947 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11948 A7 = XK8 *(WATER/GAMA(1))**2.0
11949 A8 = XK9 *(WATER/GAMA(3))**2.0
11950 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
11952 ! CALCULATE DISSOCIATION QUANTITIES
11954 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
11955 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
11956 PSI5 = MAX(PSI5, TINY)
11958 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
11959 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
11960 CC = CHI4*(PSI5+PSI6)
11962 PSI4 =0.5d0*(-BB - SQRT(DD))
11963 PSI4 = MIN(PSI4,CHI4)
11968 ! *** CALCULATE SPECIATION ********************************************
11970 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
11971 MOLAL (3) = PSI4 ! NH4I
11972 MOLAL (4) = PSI6 + PSI7 ! CLI
11973 MOLAL (5) = PSI2 + PSI1 ! SO4I
11974 MOLAL (6) = ZERO ! HSO4I
11975 MOLAL (7) = PSI5 + PSI8 ! NO3I
11977 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
11978 CALL CALCPH (SMIN, HI, OHI)
11981 GNH3 = MAX(CHI4 - PSI4, TINY)
11982 GHNO3 = MAX(CHI5 - PSI5, TINY)
11983 GHCL = MAX(CHI6 - PSI6, TINY)
11987 CNACL = MAX(CHI7 - PSI7, ZERO)
11988 CNANO3 = MAX(CHI8 - PSI8, ZERO)
11989 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
11991 CALL CALCMR ! Water content
11993 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11995 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12002 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12004 20 FUNCH6A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12008 ! *** END OF FUNCTION FUNCH6A *******************************************
12010 END FUNCTION FUNCH6A
12012 !=======================================================================
12014 ! *** ISORROPIA CODE
12015 ! *** SUBROUTINE CALCH5
12018 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12019 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12020 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12021 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
12023 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12024 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12025 ! *** WRITTEN BY ATHANASIOS NENES
12026 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12028 !=======================================================================
12032 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DEL
12033 REAL(KIND=8) FRNA, DELTA
12037 ! *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
12039 IF (W(4).LE.TINY .AND. W(5).LE.TINY) THEN
12046 ! *** SETUP PARAMETERS ************************************************
12049 CHI1 = W(2) ! CNA2SO4
12050 CHI2 = ZERO ! CNH42S4
12051 CHI3 = ZERO ! CNH4CL
12052 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
12053 CHI8 = MIN (FRNA, W(4)) ! CNANO3
12054 CHI4 = W(3) ! NH3(g)
12055 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
12056 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
12057 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
12060 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12062 ! *** INITIAL VALUES FOR BISECTION ************************************
12066 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12068 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12070 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12074 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12079 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12081 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH5A (PSI6LO)
12084 ! *** PERFORM BISECTION ***********************************************
12089 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12096 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12098 CALL PUSHERR (0002, 'CALCH5') ! WARNING ERROR: NO CONVERGENCE
12100 ! *** CONVERGED ; RETURN **********************************************
12102 40 X3 = 0.5*(X1+X2)
12105 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12108 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12109 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12110 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFECT
12111 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12112 MOLAL(6) = DELTA ! HSO4 EFFECT
12118 ! *** END OF SUBROUTINE CALCH5 ******************************************
12120 END SUBROUTINE CALCH5
12125 !=======================================================================
12127 ! *** ISORROPIA CODE
12128 ! *** SUBROUTINE FUNCH5A
12131 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12132 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12133 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12134 ! 3. SOLIDS POSSIBLE : NONE
12136 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12137 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12138 ! *** WRITTEN BY ATHANASIOS NENES
12139 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12141 !=======================================================================
12143 REAL(KIND=8) FUNCTION FUNCH5A (X)
12146 REAL(KIND=8) FRNA, A9
12147 REAL(KIND=8) AA, BB, CC, DD, SMIN, HI, OHI
12153 ! *** SETUP PARAMETERS ************************************************
12164 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12169 A1 = XK5 *(WATER/GAMA(2))**3.0
12170 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12171 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12172 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12173 A7 = XK8 *(WATER/GAMA(1))**2.0
12174 A8 = XK9 *(WATER/GAMA(3))**2.0
12175 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
12177 ! CALCULATE DISSOCIATION QUANTITIES
12179 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
12180 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
12181 PSI5 = MAX(PSI5, TINY)
12183 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12184 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12185 CC = CHI4*(PSI5+PSI6)
12187 PSI4 =0.5d0*(-BB - SQRT(DD))
12188 PSI4 = MIN(PSI4,CHI4)
12193 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
12197 CALL POLY3 (AA, BB, CC, PSI1, ISLV)
12198 IF (ISLV.EQ.0) THEN
12199 PSI1 = MIN (PSI1, CHI1)
12205 ! *** CALCULATE SPECIATION ********************************************
12207 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
12208 MOLAL (3) = PSI4 ! NH4I
12209 MOLAL (4) = PSI6 + PSI7 ! CLI
12210 MOLAL (5) = PSI2 + PSI1 ! SO4I
12212 MOLAL (7) = PSI5 + PSI8 ! NO3I
12214 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
12215 CALL CALCPH (SMIN, HI, OHI)
12218 GNH3 = MAX(CHI4 - PSI4, TINY)
12219 GHNO3 = MAX(CHI5 - PSI5, TINY)
12220 GHCL = MAX(CHI6 - PSI6, TINY)
12224 CNACL = MAX(CHI7 - PSI7, ZERO)
12225 CNANO3 = MAX(CHI8 - PSI8, ZERO)
12226 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
12228 CALL CALCMR ! Water content
12230 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12232 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12239 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12241 20 FUNCH5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12245 ! *** END OF FUNCTION FUNCH5A *******************************************
12247 END FUNCTION FUNCH5A
12249 !=======================================================================
12251 ! *** ISORROPIA CODE
12252 ! *** SUBROUTINE CALCH4
12255 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12256 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12257 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12258 ! 3. SOLIDS POSSIBLE : NA2SO4
12260 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12261 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12262 ! *** WRITTEN BY ATHANASIOS NENES
12263 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12265 !=======================================================================
12269 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DEL
12270 REAL(KIND=8) FRNA, DELTA
12277 ! *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
12279 IF (W(4).LE.TINY .AND. W(5).LE.TINY) THEN
12286 ! *** SETUP PARAMETERS ************************************************
12289 CHI1 = W(2) ! CNA2SO4
12290 CHI2 = ZERO ! CNH42S4
12291 CHI3 = ZERO ! CNH4CL
12292 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
12293 CHI8 = MIN (FRNA, W(4)) ! CNANO3
12294 CHI4 = W(3) ! NH3(g)
12295 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
12296 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
12297 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
12300 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12302 ! *** INITIAL VALUES FOR BISECTION ************************************
12306 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12308 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12310 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12314 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12319 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12321 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH4A (PSI6LO)
12324 ! *** PERFORM BISECTION ***********************************************
12329 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12336 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12338 CALL PUSHERR (0002, 'CALCH4') ! WARNING ERROR: NO CONVERGENCE
12340 ! *** CONVERGED ; RETURN **********************************************
12342 40 X3 = 0.5*(X1+X2)
12345 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12348 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12349 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12350 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12351 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12352 MOLAL(6) = DELTA ! HSO4 EFFECT
12357 ! *** END OF SUBROUTINE CALCH4 ******************************************
12359 END SUBROUTINE CALCH4
12364 !=======================================================================
12366 ! *** ISORROPIA CODE
12367 ! *** SUBROUTINE FUNCH4A
12370 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12371 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12372 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12373 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
12375 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12376 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12377 ! *** WRITTEN BY ATHANASIOS NENES
12378 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12380 !=======================================================================
12382 REAL(KIND=8) FUNCTION FUNCH4A (X)
12385 REAL(KIND=8) A9, DELT, PSI31, PSI32
12386 REAL(KIND=8) AA, BB, CC, DD, SMIN, HI, OHI
12394 ! *** SETUP PARAMETERS ************************************************
12405 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12409 A1 = XK5 *(WATER/GAMA(2))**3.0
12410 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12411 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12412 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12413 A7 = XK8 *(WATER/GAMA(1))**2.0
12414 A8 = XK9 *(WATER/GAMA(3))**2.0
12415 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
12417 ! CALCULATE DISSOCIATION QUANTITIES
12419 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
12420 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
12421 PSI5 = MAX(PSI5, TINY)
12423 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12424 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12425 CC = CHI4*(PSI5+PSI6)
12427 PSI4 =0.5d0*(-BB - SQRT(DD))
12428 PSI4 = MIN(PSI4,CHI4)
12433 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
12437 CALL POLY3 (AA, BB, CC, PSI1, ISLV)
12438 IF (ISLV.EQ.0) THEN
12439 PSI1 = MIN (PSI1, CHI1)
12445 ! *** CALCULATE SPECIATION ********************************************
12447 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
12448 MOLAL (3) = PSI4 ! NH4I
12449 MOLAL (4) = PSI6 + PSI7 ! CLI
12450 MOLAL (5) = PSI2 + PSI1 ! SO4I
12452 MOLAL (7) = PSI5 + PSI8 ! NO3I
12454 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
12455 CALL CALCPH (SMIN, HI, OHI)
12458 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
12460 GNH3 = MAX(CHI4 - PSI4, TINY)
12461 GHNO3 = MAX(CHI5 - PSI5, TINY)
12462 GHCL = MAX(CHI6 - PSI6, TINY)
12466 CNACL = MAX(CHI7 - PSI7, ZERO)
12467 CNANO3 = MAX(CHI8 - PSI8, ZERO)
12468 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
12470 ! *** NH4Cl(s) calculations
12472 A3 = XK6 /(R*TEMP*R*TEMP)
12473 DELT = MIN(GNH3, GHCL)
12476 DD = BB*BB - 4.D0*CC
12477 PSI31 = 0.5D0*(-BB + SQRT(DD))
12478 PSI32 = 0.5D0*(-BB - SQRT(DD))
12479 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
12481 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
12487 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
12489 GNH3 = MAX(GNH3 - PSI3, TINY)
12490 GHCL = MAX(GHCL - PSI3, TINY)
12493 CALL CALCMR ! Water content
12495 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12497 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12504 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12506 20 FUNCH4A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12510 ! *** END OF FUNCTION FUNCH4A *******************************************
12512 END FUNCTION FUNCH4A
12515 !=======================================================================
12517 ! *** ISORROPIA CODE
12518 ! *** SUBROUTINE CALCH3
12521 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12522 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12523 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12524 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4
12526 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12527 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12528 ! *** WRITTEN BY ATHANASIOS NENES
12529 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12531 !=======================================================================
12536 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DELTA
12543 ! *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
12545 IF (W(4).LE.TINY) THEN ! NO3 NOT EXIST, WATER NOT POSSIBLE
12552 ! *** SETUP PARAMETERS ************************************************
12555 CHI1 = W(2) ! CNA2SO4
12556 CHI2 = ZERO ! CNH42S4
12557 CHI3 = ZERO ! CNH4CL
12558 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
12559 CHI8 = MIN (FRNA, W(4)) ! CNANO3
12560 CHI4 = W(3) ! NH3(g)
12561 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
12562 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
12563 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
12566 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12568 ! *** INITIAL VALUES FOR BISECTION ************************************
12572 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12574 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12576 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12580 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12585 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12587 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH3A (PSI6LO)
12590 ! *** PERFORM BISECTION ***********************************************
12595 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12602 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12604 CALL PUSHERR (0002, 'CALCH3') ! WARNING ERROR: NO CONVERGENCE
12606 ! *** CONVERGED ; RETURN **********************************************
12608 40 X3 = 0.5*(X1+X2)
12611 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12614 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12615 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12616 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12617 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12618 MOLAL(6) = DELTA ! HSO4 EFFECT
12623 ! *** END OF SUBROUTINE CALCH3 ******************************************
12625 END SUBROUTINE CALCH3
12630 !=======================================================================
12632 ! *** ISORROPIA CODE
12633 ! *** SUBROUTINE FUNCH3A
12636 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12637 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12638 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12639 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
12641 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12642 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12643 ! *** WRITTEN BY ATHANASIOS NENES
12644 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12646 !=======================================================================
12648 REAL(KIND=8) FUNCTION FUNCH3A (X)
12652 REAL(KIND=8) FRNA, A9
12653 REAL(KIND=8) AA, BB, CC, DD, SMIN, HI, OHI
12654 REAL(KIND=8) DIAK, PSI31, PSI32, DELT
12662 ! *** SETUP PARAMETERS ************************************************
12673 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12677 A1 = XK5 *(WATER/GAMA(2))**3.0
12678 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12679 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12680 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12681 A7 = XK8 *(WATER/GAMA(1))**2.0
12682 A8 = XK9 *(WATER/GAMA(3))**2.0
12683 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
12685 ! CALCULATE DISSOCIATION QUANTITIES
12687 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
12688 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
12689 PSI5 = MAX(PSI5, TINY)
12691 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12692 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12693 CC = CHI4*(PSI5+PSI6)
12695 PSI4 =0.5d0*(-BB - SQRT(DD))
12696 PSI4 = MIN(PSI4,CHI4)
12701 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
12702 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
12703 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
12704 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
12707 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
12711 CALL POLY3 (AA, BB, CC, PSI1, ISLV)
12712 IF (ISLV.EQ.0) THEN
12713 PSI1 = MIN (PSI1, CHI1)
12719 ! *** CALCULATE SPECIATION ********************************************
12721 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
12722 MOLAL (3) = PSI4 ! NH4I
12723 MOLAL (4) = PSI6 + PSI7 ! CLI
12724 MOLAL (5) = PSI2 + PSI1 ! SO4I
12726 MOLAL (7) = PSI5 + PSI8 ! NO3I
12728 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
12729 CALL CALCPH (SMIN, HI, OHI)
12732 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
12734 GNH3 = MAX(CHI4 - PSI4, TINY)
12735 GHNO3 = MAX(CHI5 - PSI5, TINY)
12736 GHCL = MAX(CHI6 - PSI6, TINY)
12740 CNACL = MAX(CHI7 - PSI7, ZERO)
12741 CNANO3 = MAX(CHI8 - PSI8, ZERO)
12742 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
12744 ! *** NH4Cl(s) calculations
12746 A3 = XK6 /(R*TEMP*R*TEMP)
12747 DELT = MIN(GNH3, GHCL)
12750 DD = BB*BB - 4.D0*CC
12751 PSI31 = 0.5D0*(-BB + SQRT(DD))
12752 PSI32 = 0.5D0*(-BB - SQRT(DD))
12753 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
12755 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
12761 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
12763 GNH3 = MAX(GNH3 - PSI3, TINY)
12764 GHCL = MAX(GHCL - PSI3, TINY)
12767 CALL CALCMR ! Water content
12769 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12771 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12778 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12780 20 FUNCH3A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12784 ! *** END OF FUNCTION FUNCH3A *******************************************
12786 END FUNCTION FUNCH3A
12788 !=======================================================================
12790 ! *** ISORROPIA CODE
12791 ! *** SUBROUTINE CALCH2
12794 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12795 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12796 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
12797 ! 3. SOLIDS POSSIBLE : NH4Cl, NA2SO4, NANO3, NACL
12799 ! THERE ARE THREE REGIMES IN THIS CASE:
12800 ! 1. NH4NO3(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCH2A)
12801 ! 2. NH4NO3(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
12802 ! 3. NH4NO3(s) NOT POSSIBLE, AND RH >= MDRH. (MDRH REGION)
12804 ! REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES H1A, H2B
12805 ! RESPECTIVELY (BECAUSE MDRH POINTS COINCIDE).
12807 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12808 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12809 ! *** WRITTEN BY ATHANASIOS NENES
12810 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12812 !=======================================================================
12816 ! EXTERNAL CALCH1A, CALCH3
12818 ! *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
12820 IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
12821 SCASE = 'H2 ; SUBCASE 1'
12823 SCASE = 'H2 ; SUBCASE 1'
12824 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
12825 SCASE = 'H2 ; SUBCASE 1'
12827 SCASE = 'H2 ; SUBCASE 1'
12830 IF (WATER.LE.TINY .AND. RH.LT.DRMH2) THEN ! DRY AEROSOL
12831 SCASE = 'H2 ; SUBCASE 2'
12833 ELSEIF (WATER.LE.TINY .AND. RH.GE.DRMH2) THEN ! MDRH OF H2
12834 SCASE = 'H2 ; SUBCASE 3'
12835 CALL CALCMDRH (RH, DRMH2, DRNANO3, CALCH1A, CALCH3)
12836 SCASE = 'H2 ; SUBCASE 3'
12841 ! *** END OF SUBROUTINE CALCH2 ******************************************
12843 END SUBROUTINE CALCH2
12848 !=======================================================================
12850 ! *** ISORROPIA CODE
12851 ! *** SUBROUTINE CALCH2A
12852 ! *** CASE H2 ; SUBCASE 1
12854 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12855 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12856 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12857 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4
12859 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12860 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12861 ! *** WRITTEN BY ATHANASIOS NENES
12862 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12864 !=======================================================================
12868 REAL(KIND=8) PSI6LO,PSI6HI ,X1, X2, X3, Y1, Y2, Y3, DX, DEL
12869 REAL(KIND=8) FRNA, DELTA
12877 ! *** SETUP PARAMETERS ************************************************
12880 CHI1 = W(2) ! CNA2SO4
12881 CHI2 = ZERO ! CNH42S4
12882 CHI3 = ZERO ! CNH4CL
12883 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
12884 CHI8 = MIN (FRNA, W(4)) ! CNANO3
12885 CHI4 = W(3) ! NH3(g)
12886 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
12887 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
12888 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
12891 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12893 ! *** INITIAL VALUES FOR BISECTION ************************************
12897 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12899 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12901 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12905 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12910 ! *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12912 IF (Y2 .GT. EPS) Y2 = FUNCH2A (PSI6LO)
12915 ! *** PERFORM BISECTION ***********************************************
12920 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12927 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12929 CALL PUSHERR (0002, 'CALCH2A') ! WARNING ERROR: NO CONVERGENCE
12931 ! *** CONVERGED ; RETURN **********************************************
12933 40 X3 = 0.5*(X1+X2)
12936 ! *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12939 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12940 CALL CALCHS4 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12941 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12942 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12943 MOLAL(6) = DELTA ! HSO4 EFFECT
12948 ! *** END OF SUBROUTINE CALCH2A ******************************************
12950 END SUBROUTINE CALCH2A
12955 !=======================================================================
12957 ! *** ISORROPIA CODE
12958 ! *** SUBROUTINE FUNCH2A
12959 ! *** CASE H2 ; SUBCASE 1
12961 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12962 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
12963 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
12964 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
12966 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12967 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12968 ! *** WRITTEN BY ATHANASIOS NENES
12969 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
12971 !=======================================================================
12973 REAL(KIND=8) FUNCTION FUNCH2A (X)
12976 REAL(KIND=8) A9, A64, DIAK, PSI31, PSI32, DELT, CLFR
12977 REAL(KIND=8) ALF, BET, GAM, RTSQ, THETA1, THETA2
12978 REAL(KIND=8) AA, BB, CC, DD, SMIN, HI, OHI
12986 ! *** SETUP PARAMETERS ************************************************
12997 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13001 A1 = XK5 *(WATER/GAMA(2))**3.0
13002 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
13003 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
13004 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
13005 A7 = XK8 *(WATER/GAMA(1))**2.0
13006 A8 = XK9 *(WATER/GAMA(3))**2.0
13007 A64 = (XK3*XK2/XKW)*(GAMA(10)/GAMA(5)/GAMA(11))**2.0
13008 A64 = A64*(R*TEMP*WATER)**2.0
13009 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
13011 ! CALCULATE DISSOCIATION QUANTITIES
13013 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
13014 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
13015 PSI5 = MAX(PSI5, TINY)
13017 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
13018 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
13019 CC = CHI4*(PSI5+PSI6)
13021 PSI4 =0.5d0*(-BB - SQRT(DD))
13022 PSI4 = MIN(PSI4,CHI4)
13027 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
13028 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
13029 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
13030 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
13033 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
13034 DIAK = (PSI7-PSI5)**2.D0 + 4.D0*A8
13035 PSI8 = 0.5D0*( -(PSI7+PSI5) + SQRT(DIAK) )
13036 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
13039 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
13043 CALL POLY3 (AA, BB, CC, PSI1, ISLV)
13044 IF (ISLV.EQ.0) THEN
13045 PSI1 = MIN (PSI1, CHI1)
13051 ! *** CALCULATE SPECIATION ********************************************
13053 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
13054 MOLAL (3) = PSI4 ! NH4I
13055 MOLAL (4) = PSI6 + PSI7 ! CLI
13056 MOLAL (5) = PSI2 + PSI1 ! SO4I
13057 MOLAL (6) = ZERO ! HSO4I
13058 MOLAL (7) = PSI5 + PSI8 ! NO3I
13060 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
13061 CALL CALCPH (SMIN, HI, OHI)
13064 GNH3 = MAX(CHI4 - PSI4, TINY)
13065 GHNO3 = MAX(CHI5 - PSI5, TINY)
13066 GHCL = MAX(CHI6 - PSI6, TINY)
13070 CNACL = MAX(CHI7 - PSI7, ZERO)
13071 CNANO3 = MAX(CHI8 - PSI8, ZERO)
13072 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
13074 ! *** NH4Cl(s) calculations
13076 A3 = XK6 /(R*TEMP*R*TEMP)
13077 DELT = MIN(GNH3, GHCL)
13080 DD = BB*BB - 4.D0*CC
13081 PSI31 = 0.5D0*(-BB + SQRT(DD))
13082 PSI32 = 0.5D0*(-BB - SQRT(DD))
13083 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
13085 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
13091 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
13093 GNH3 = MAX(GNH3 - PSI3, TINY)
13094 GHCL = MAX(GHCL - PSI3, TINY)
13097 CALL CALCMR ! Water content
13099 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13101 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13108 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
13110 20 FUNCH2A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A64 - ONE
13114 ! *** END OF FUNCTION FUNCH2A *******************************************
13116 END FUNCTION FUNCH2A
13119 !=======================================================================
13121 ! *** ISORROPIA CODE
13122 ! *** SUBROUTINE CALCH1
13125 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13126 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
13127 ! 2. SOLID AEROSOL ONLY
13128 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4
13130 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
13131 ! 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
13132 ! 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCH1A)
13134 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13135 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13136 ! *** WRITTEN BY ATHANASIOS NENES
13137 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13139 !=======================================================================
13143 ! EXTERNAL CALCH1A, CALCH2A
13145 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
13147 IF (RH.LT.DRMH1) THEN
13148 SCASE = 'H1 ; SUBCASE 1'
13149 CALL CALCH1A ! SOLID PHASE ONLY POSSIBLE
13150 SCASE = 'H1 ; SUBCASE 1'
13152 SCASE = 'H1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
13153 CALL CALCMDRH (RH, DRMH1, DRNH4NO3, CALCH1A, CALCH2A)
13154 SCASE = 'H1 ; SUBCASE 2'
13159 ! *** END OF SUBROUTINE CALCH1 ******************************************
13161 END SUBROUTINE CALCH1
13164 !=======================================================================
13166 ! *** ISORROPIA CODE
13167 ! *** SUBROUTINE CALCH1A
13168 ! *** CASE H1 ; SUBCASE 1
13170 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13171 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
13172 ! 2. SOLID AEROSOL ONLY
13173 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NANO3, NA2SO4
13175 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13176 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13177 ! *** WRITTEN BY ATHANASIOS NENES
13178 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13180 !=======================================================================
13184 REAL(KIND=8) LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2, NAFR,NO3FR, CLFR
13185 REAL(KIND=8) ALF, BET, GAM, RTSQ, THETA1, THETA2
13186 REAL(KIND=8) BB, CC, DD, SQDD, DD1, DD2, SQDD1, SQDD2
13188 ! *** CALCULATE NON VOLATILE SOLIDS ***********************************
13192 NAFR = MAX (W(1)-2*CNA2SO4, ZERO)
13193 CNANO3 = MIN (NAFR, W(4))
13194 NO3FR = MAX (W(4)-CNANO3, ZERO)
13195 CNACL = MIN (MAX(NAFR-CNANO3, ZERO), W(5))
13196 CLFR = MAX (W(5)-CNACL, ZERO)
13198 ! *** CALCULATE VOLATILE SPECIES **************************************
13200 ALF = W(3) ! FREE NH3
13201 BET = CLFR ! FREE CL
13202 GAM = NO3FR ! FREE NO3
13204 RTSQ = R*TEMP*R*TEMP
13208 THETA1 = GAM - BET*(A2/A1)
13211 ! QUADRATIC EQUATION SOLUTION
13213 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
13214 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
13215 DD = BB*BB - 4.0D0*CC
13216 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
13218 ! TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
13221 KAPA1 = 0.5D0*(-BB+SQDD)
13222 KAPA2 = 0.5D0*(-BB-SQDD)
13223 LAMDA1 = THETA1 + THETA2*KAPA1
13224 LAMDA2 = THETA1 + THETA2*KAPA2
13226 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
13227 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND.&
13228 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
13235 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
13236 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
13237 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
13244 ! SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
13248 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
13249 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
13251 ! NH4CL EQUILIBRIUM
13253 IF (DD1.GE.ZERO) THEN
13255 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
13256 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
13258 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
13260 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
13267 ! NH4NO3 EQUILIBRIUM
13269 IF (DD2.GE.ZERO) THEN
13271 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
13272 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
13274 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
13276 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
13283 ! IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
13285 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
13286 IF (BET .LT. LAMDA/THETA1) THEN
13293 ! *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
13299 GNH3 = ALF - KAPA - LAMDA
13300 GHNO3 = GAM - LAMDA
13305 ! *** END OF SUBROUTINE CALCH1A *****************************************
13307 END SUBROUTINE CALCH1A
13308 !=======================================================================
13310 ! *** ISORROPIA CODE
13311 ! *** SUBROUTINE CALCI6
13314 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13315 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13316 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13317 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
13319 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13320 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13321 ! *** WRITTEN BY ATHANASIOS NENES
13322 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13324 !=======================================================================
13328 REAL(KIND=8) BB, CC, DD
13333 ! *** FIND DRY COMPOSITION **********************************************
13337 ! *** SETUP PARAMETERS ************************************************
13339 CHI1 = CNH4HS4 ! Save from CALCI1 run
13345 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
13351 CALAOU = .TRUE. ! Outer loop activity calculation flag
13355 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13359 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
13361 ! CALCULATE DISSOCIATION QUANTITIES
13363 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
13364 CC =-A6*(PSI2 + PSI3 + PSI1)
13365 DD = BB*BB - 4.D0*CC
13366 PSI6 = 0.5D0*(-BB + SQRT(DD))
13368 ! *** CALCULATE SPECIATION ********************************************
13370 MOLAL (1) = PSI6 ! HI
13371 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
13372 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
13373 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
13374 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
13377 CNA2SO4 = CHI4 - PSI4
13380 CALL CALCMR ! Water content
13382 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13384 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13393 ! *** END OF SUBROUTINE CALCI6 *****************************************
13395 END SUBROUTINE CALCI6
13397 !=======================================================================
13399 ! *** ISORROPIA CODE
13400 ! *** SUBROUTINE CALCI5
13403 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13404 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13405 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13406 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
13408 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13409 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13410 ! *** WRITTEN BY ATHANASIOS NENES
13411 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13413 !=======================================================================
13417 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
13418 REAL(KIND=8) PSI4LO, PSI4HI, YLO, YHI, DX
13424 ! *** FIND DRY COMPOSITION **********************************************
13428 ! *** SETUP PARAMETERS ************************************************
13430 CHI1 = CNH4HS4 ! Save from CALCI1 run
13436 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
13442 CALAOU =.TRUE. ! Outer loop activity calculation flag
13443 PSI4LO = ZERO ! Low limit
13444 PSI4HI = CHI4 ! High limit
13446 ! *** IF NA2SO4(S) =0, CALL FUNCI5B FOR Y4=0 ***************************
13448 IF (CHI4.LE.TINY) THEN
13449 Y1 = FUNCI5A (ZERO)
13453 ! *** INITIAL VALUES FOR BISECTION ************************************
13457 YHI= Y1 ! Save Y-value at HI position
13459 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 **
13461 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
13463 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13465 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
13469 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13474 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH4CL
13476 YLO= Y1 ! Save Y-value at Hi position
13477 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
13478 Y3 = FUNCI5A (ZERO)
13480 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
13483 CALL PUSHERR (0001, 'CALCI5') ! WARNING ERROR: NO SOLUTION
13487 ! *** PERFORM BISECTION ***********************************************
13492 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13499 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13501 CALL PUSHERR (0002, 'CALCI5') ! WARNING ERROR: NO CONVERGENCE
13503 ! *** CONVERGED ; RETURN **********************************************
13505 40 X3 = 0.5*(X1+X2)
13510 ! *** END OF SUBROUTINE CALCI5 *****************************************
13512 END SUBROUTINE CALCI5
13517 !=======================================================================
13519 ! *** ISORROPIA CODE
13520 ! *** SUBROUTINE FUNCI5A
13523 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13524 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13525 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13526 ! 3. SOLIDS POSSIBLE : NA2SO4
13528 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13529 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13530 ! *** WRITTEN BY ATHANASIOS NENES
13531 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13533 !=======================================================================
13535 REAL(KIND=8) FUNCTION FUNCI5A (P4)
13538 REAL(KIND=8) BB, CC, DD
13543 ! *** SETUP PARAMETERS ************************************************
13545 PSI4 = P4 ! PSI3 already assigned in FUNCI5A
13549 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13553 A4 = XK5 *(WATER/GAMA(2))**3.0
13554 A5 = XK7 *(WATER/GAMA(4))**3.0
13555 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
13557 ! CALCULATE DISSOCIATION QUANTITIES
13559 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
13560 CC =-A6*(PSI2 + PSI3 + PSI1)
13561 DD = BB*BB - 4.D0*CC
13562 PSI6 = 0.5D0*(-BB + SQRT(DD))
13564 ! *** CALCULATE SPECIATION ********************************************
13566 MOLAL (1) = PSI6 ! HI
13567 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
13568 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
13569 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
13570 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
13573 CNA2SO4 = CHI4 - PSI4
13576 CALL CALCMR ! Water content
13578 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13580 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13587 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
13589 20 A4 = XK5 *(WATER/GAMA(2))**3.0
13590 FUNCI5A= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
13593 ! *** END OF FUNCTION FUNCI5A ********************************************
13595 END FUNCTION FUNCI5A
13597 !=======================================================================
13599 ! *** ISORROPIA CODE
13600 ! *** SUBROUTINE CALCI4
13603 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13604 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13605 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13606 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
13608 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13609 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13610 ! *** WRITTEN BY ATHANASIOS NENES
13611 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13613 !=======================================================================
13617 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
13618 REAL(KIND=8) PSI4LO, PSI4HI, YLO, YHI, DX, P4, YY, DELTA
13624 ! *** FIND DRY COMPOSITION **********************************************
13628 ! *** SETUP PARAMETERS ************************************************
13630 CHI1 = CNH4HS4 ! Save from CALCI1 run
13636 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
13642 CALAOU = .TRUE. ! Outer loop activity calculation flag
13643 PSI4LO = ZERO ! Low limit
13644 PSI4HI = CHI4 ! High limit
13646 ! *** IF NA2SO4(S) =0, CALL FUNCI4B FOR Y4=0 ***************************
13648 IF (CHI4.LE.TINY) THEN
13649 Y1 = FUNCI4A (ZERO)
13653 ! *** INITIAL VALUES FOR BISECTION ************************************
13657 YHI= Y1 ! Save Y-value at HI position
13659 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 **
13661 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
13663 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13665 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
13669 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13674 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH4CL
13676 YLO= Y1 ! Save Y-value at Hi position
13677 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
13678 Y3 = FUNCI4A (ZERO)
13680 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
13683 CALL PUSHERR (0001, 'CALCI4') ! WARNING ERROR: NO SOLUTION
13687 ! *** PERFORM BISECTION ***********************************************
13692 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13699 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13701 CALL PUSHERR (0002, 'CALCI4') ! WARNING ERROR: NO CONVERGENCE
13703 ! *** CONVERGED ; RETURN **********************************************
13705 40 X3 = 0.5*(X1+X2)
13710 ! *** END OF SUBROUTINE CALCI4 *****************************************
13712 END SUBROUTINE CALCI4
13717 !=======================================================================
13719 ! *** ISORROPIA CODE
13720 ! *** SUBROUTINE FUNCI4A
13723 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13724 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13725 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13726 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
13728 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13729 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13730 ! *** WRITTEN BY ATHANASIOS NENES
13731 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13733 !=======================================================================
13735 REAL(KIND=8) FUNCTION FUNCI4A (P4)
13737 REAL(KIND=8) BB, CC, DD
13744 ! *** SETUP PARAMETERS ************************************************
13746 PSI4 = P4 ! PSI3 already assigned in FUNCI4A
13750 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13754 A4 = XK5 *(WATER/GAMA(2))**3.0
13755 A5 = XK7 *(WATER/GAMA(4))**3.0
13756 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
13759 ! CALCULATE DISSOCIATION QUANTITIES
13761 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
13762 CC =-A6*(PSI2 + PSI3 + PSI1)
13763 DD = BB*BB - 4.D0*CC
13764 PSI6 = 0.5D0*(-BB + SQRT(DD))
13766 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
13767 PSI5 = MIN (PSI5, CHI5)
13769 ! *** CALCULATE SPECIATION ********************************************
13771 MOLAL (1) = PSI6 ! HI
13772 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
13773 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
13774 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
13775 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
13778 CNA2SO4 = CHI4 - PSI4
13779 CNH42S4 = CHI5 - PSI5
13781 CALL CALCMR ! Water content
13783 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13785 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13792 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
13794 20 A4 = XK5 *(WATER/GAMA(2))**3.0
13795 FUNCI4A= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
13798 ! *** END OF FUNCTION FUNCI4A ********************************************
13800 END FUNCTION FUNCI4A
13801 !=======================================================================
13803 ! *** ISORROPIA CODE
13804 ! *** SUBROUTINE CALCI3
13807 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13808 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13809 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13810 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
13812 ! THERE ARE THREE REGIMES IN THIS CASE:
13813 ! 1.(NA,NH4)HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCI3A)
13814 ! 2.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
13815 ! 3.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
13817 ! REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES I1A, I2B
13820 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13821 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13822 ! *** WRITTEN BY ATHANASIOS NENES
13823 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13825 !=======================================================================
13830 ! EXTERNAL CALCI1A, CALCI4
13832 ! *** FIND DRY COMPOSITION **********************************************
13836 ! *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
13838 IF (CNH4HS4.GT.TINY .OR. CNAHSO4.GT.TINY) THEN
13839 SCASE = 'I3 ; SUBCASE 1'
13840 CALL CALCI3A ! FULL SOLUTION
13841 SCASE = 'I3 ; SUBCASE 1'
13844 IF (WATER.LE.TINY) THEN
13845 IF (RH.LT.DRMI3) THEN ! SOLID SOLUTION
13851 SCASE = 'I3 ; SUBCASE 2'
13853 ELSEIF (RH.GE.DRMI3) THEN ! MDRH OF I3
13854 SCASE = 'I3 ; SUBCASE 3'
13855 CALL CALCMDRH (RH, DRMI3, DRLC, CALCI1A, CALCI4)
13856 SCASE = 'I3 ; SUBCASE 3'
13862 ! *** END OF SUBROUTINE CALCI3 ******************************************
13864 END SUBROUTINE CALCI3
13868 !=======================================================================
13870 ! *** ISORROPIA CODE
13871 ! *** SUBROUTINE CALCI3A
13872 ! *** CASE I3 ; SUBCASE 1
13874 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13875 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13876 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13877 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
13879 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13880 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13881 ! *** WRITTEN BY ATHANASIOS NENES
13882 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13884 !=======================================================================
13888 REAL(KIND=8) PSI2LO, PSI2HI
13889 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
13890 REAL(KIND=8) YLO, YHI, DX
13894 ! *** FIND DRY COMPOSITION **********************************************
13896 CALL CALCI1A ! Needed when called from CALCMDRH
13898 ! *** SETUP PARAMETERS ************************************************
13900 CHI1 = CNH4HS4 ! Save from CALCI1 run
13906 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
13912 CALAOU = .TRUE. ! Outer loop activity calculation flag
13913 PSI2LO = ZERO ! Low limit
13914 PSI2HI = CHI2 ! High limit
13916 ! *** INITIAL VALUES FOR BISECTION ************************************
13920 YHI= Y1 ! Save Y-value at HI position
13922 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
13924 IF (YHI.LT.EPS) GOTO 50
13926 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13928 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
13930 X2 = MAX(X1-DX, PSI2LO)
13932 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13937 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
13939 IF (Y2.GT.EPS) Y2 = FUNCI3A (ZERO)
13942 ! *** PERFORM BISECTION ***********************************************
13947 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13954 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13956 CALL PUSHERR (0002, 'CALCI3A') ! WARNING ERROR: NO CONVERGENCE
13958 ! *** CONVERGED ; RETURN **********************************************
13960 40 X3 = 0.5*(X1+X2)
13965 ! *** END OF SUBROUTINE CALCI3A *****************************************
13967 END SUBROUTINE CALCI3A
13969 !=======================================================================
13971 ! *** ISORROPIA CODE
13972 ! *** SUBROUTINE FUNCI3A
13973 ! *** CASE I3 ; SUBCASE 1
13975 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13976 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
13977 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
13978 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
13980 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13981 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
13982 ! *** WRITTEN BY ATHANASIOS NENES
13983 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
13985 !=======================================================================
13987 REAL(KIND=8) FUNCTION FUNCI3A (P2)
13991 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
13992 REAL(KIND=8) PSI4LO, PSI4HI, YLO, YHI, DX
13998 ! *** SETUP PARAMETERS ************************************************
14000 PSI2 = P2 ! Save PSI2 in COMMON BLOCK
14001 PSI4LO = ZERO ! Low limit for PSI4
14002 PSI4HI = CHI4 ! High limit for PSI4
14004 ! *** IF NH3 =0, CALL FUNCI3B FOR Y4=0 ********************************
14006 IF (CHI4.LE.TINY) THEN
14007 FUNCI3A = FUNCI3B (ZERO)
14011 ! *** INITIAL VALUES FOR BISECTION ************************************
14015 IF (ABS(Y1).LE.EPS) GOTO 50
14016 YHI= Y1 ! Save Y-value at HI position
14018 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *****
14020 IF (YHI.LT.ZERO) GOTO 50
14022 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14024 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
14026 X2 = MAX(X1-DX, PSI4LO)
14028 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14033 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4
14035 IF (Y2.GT.EPS) Y2 = FUNCI3B (PSI4LO)
14038 ! *** PERFORM BISECTION ***********************************************
14043 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14050 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14052 CALL PUSHERR (0004, 'FUNCI3A') ! WARNING ERROR: NO CONVERGENCE
14054 ! *** INNER LOOP CONVERGED **********************************************
14056 40 X3 = 0.5*(X1+X2)
14059 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
14061 50 A2 = XK13*(WATER/GAMA(13))**5.0
14062 FUNCI3A = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.D0/A2 - ONE
14065 ! *** END OF FUNCTION FUNCI3A *******************************************
14067 END FUNCTION FUNCI3A
14071 !=======================================================================
14073 ! *** ISORROPIA CODE
14074 ! *** FUNCTION FUNCI3B
14075 ! *** CASE I3 ; SUBCASE 2
14077 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14078 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14079 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
14080 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
14082 ! SOLUTION IS SAVED IN COMMON BLOCK /CASE/
14084 !=======================================================================
14086 REAL(KIND=8) FUNCTION FUNCI3B (P4)
14090 REAL(KIND=8) BB, CC, DD
14097 ! *** SETUP PARAMETERS ************************************************
14101 ! *** SETUP PARAMETERS ************************************************
14106 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14110 A4 = XK5*(WATER/GAMA(2))**3.0
14111 A5 = XK7*(WATER/GAMA(4))**3.0
14112 A6 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
14115 ! CALCULATE DISSOCIATION QUANTITIES
14117 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
14118 CC =-A6*(PSI2 + PSI3 + PSI1)
14119 DD = BB*BB - 4.D0*CC
14120 PSI6 = 0.5D0*(-BB + SQRT(DD))
14122 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
14123 PSI5 = MIN (PSI5, CHI5)
14125 ! *** CALCULATE SPECIATION ********************************************
14127 MOLAL(1) = PSI6 ! HI
14128 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
14129 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
14130 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
14131 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 - PSI6, TINY) ! HSO4I
14132 CLC = MAX(CHI2 - PSI2, ZERO)
14134 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
14135 CNH42S4 = MAX(CHI5 - PSI5, ZERO)
14137 CALL CALCMR ! Water content
14139 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14141 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14148 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
14150 20 A4 = XK5 *(WATER/GAMA(2))**3.0
14151 FUNCI3B= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
14154 ! *** END OF FUNCTION FUNCI3B ********************************************
14156 END FUNCTION FUNCI3B
14157 !=======================================================================
14159 ! *** ISORROPIA CODE
14160 ! *** SUBROUTINE CALCI2
14163 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14164 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14165 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
14166 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
14168 ! THERE ARE THREE REGIMES IN THIS CASE:
14169 ! 1. NH4HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCI2A)
14170 ! 2. NH4HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
14171 ! 3. NH4HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
14173 ! REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES I1A, I2B
14176 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14177 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14178 ! *** WRITTEN BY ATHANASIOS NENES
14179 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14181 !=======================================================================
14186 ! EXTERNAL CALCI1A, CALCI3A
14188 ! *** FIND DRY COMPOSITION **********************************************
14192 ! *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
14194 IF (CNH4HS4.GT.TINY) THEN
14195 SCASE = 'I2 ; SUBCASE 1'
14197 SCASE = 'I2 ; SUBCASE 1'
14200 IF (WATER.LE.TINY) THEN
14201 IF (RH.LT.DRMI2) THEN ! SOLID SOLUTION ONLY
14207 SCASE = 'I2 ; SUBCASE 2'
14209 ELSEIF (RH.GE.DRMI2) THEN ! MDRH OF I2
14210 SCASE = 'I2 ; SUBCASE 3'
14211 CALL CALCMDRH (RH, DRMI2, DRNAHSO4, CALCI1A, CALCI3A)
14212 SCASE = 'I2 ; SUBCASE 3'
14218 ! *** END OF SUBROUTINE CALCI2 ******************************************
14220 END SUBROUTINE CALCI2
14223 !=======================================================================
14225 ! *** ISORROPIA CODE
14226 ! *** SUBROUTINE CALCI2A
14227 ! *** CASE I2 ; SUBCASE A
14229 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14230 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14231 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
14232 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
14234 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14235 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14236 ! *** WRITTEN BY ATHANASIOS NENES
14237 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14239 !=======================================================================
14243 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
14244 REAL(KIND=8) PSI2LO, PSI2HI, YLO, YHI, DX
14249 ! *** FIND DRY COMPOSITION **********************************************
14251 CALL CALCI1A ! Needed when called from CALCMDRH
14253 ! *** SETUP PARAMETERS ************************************************
14255 CHI1 = CNH4HS4 ! Save from CALCI1 run
14261 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
14267 CALAOU = .TRUE. ! Outer loop activity calculation flag
14268 PSI2LO = ZERO ! Low limit
14269 PSI2HI = CHI2 ! High limit
14271 ! *** INITIAL VALUES FOR BISECTION ************************************
14275 YHI= Y1 ! Save Y-value at HI position
14277 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
14279 IF (YHI.LT.EPS) GOTO 50
14281 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14283 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
14285 X2 = MAX(X1-DX, PSI2LO)
14287 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14292 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
14294 IF (Y2.GT.EPS) Y2 = FUNCI3A (ZERO)
14297 ! *** PERFORM BISECTION ***********************************************
14302 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14309 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14311 CALL PUSHERR (0002, 'CALCI2A') ! WARNING ERROR: NO CONVERGENCE
14313 ! *** CONVERGED ; RETURN **********************************************
14315 40 X3 = 0.5*(X1+X2)
14320 ! *** END OF SUBROUTINE CALCI2A *****************************************
14322 END SUBROUTINE CALCI2A
14327 !=======================================================================
14329 ! *** ISORROPIA CODE
14330 ! *** SUBROUTINE FUNCI2A
14331 ! *** CASE I2 ; SUBCASE 1
14333 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14334 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14335 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
14336 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
14338 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14339 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14340 ! *** WRITTEN BY ATHANASIOS NENES
14341 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14343 !=======================================================================
14345 REAL(KIND=8) FUNCTION FUNCI2A (P2)
14348 REAL(KIND=8) AA, BB, CC, DD
14355 ! *** SETUP PARAMETERS ************************************************
14359 PSI2 = P2 ! Save PSI2 in COMMON BLOCK
14365 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14369 A3 = XK11*(WATER/GAMA(12))**2.0
14370 A4 = XK5 *(WATER/GAMA(2))**3.0
14371 A5 = XK7 *(WATER/GAMA(4))**3.0
14372 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
14375 ! CALCULATE DISSOCIATION QUANTITIES
14377 IF (CHI5.GT.TINY .AND. WATER.GT.TINY) THEN
14378 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
14379 PSI5 = MAX(MIN (PSI5, CHI5), TINY)
14382 IF (CHI4.GT.TINY .AND. WATER.GT.TINY) THEN
14383 AA = PSI2+PSI5+PSI6+PSI3
14385 CC = 0.25D0*(PSI3*PSI3*(PSI2+PSI5+PSI6)-A4)
14386 CALL POLY3 (AA, BB, CC, PSI4, ISLV)
14387 IF (ISLV.EQ.0) THEN
14388 PSI4 = MIN (PSI4, CHI4)
14394 IF (CHI3.GT.TINY .AND. WATER.GT.TINY) THEN
14395 AA = 2.D0*PSI4 + PSI2 + PSI1 - PSI6
14396 BB = 2.D0*PSI4*(PSI2 + PSI1 - PSI6) - A3
14398 CALL POLY3 (AA, BB, CC, PSI3, ISLV)
14399 IF (ISLV.EQ.0) THEN
14400 PSI3 = MIN (PSI3, CHI3)
14406 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
14407 CC =-A6*(PSI2 + PSI3 + PSI1)
14408 DD = BB*BB - 4.D0*CC
14409 PSI6 = 0.5D0*(-BB + SQRT(DD))
14411 ! *** CALCULATE SPECIATION ********************************************
14413 MOLAL (1) = PSI6 ! HI
14414 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
14415 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
14416 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
14417 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
14419 CNAHSO4 = CHI3 - PSI3
14420 CNA2SO4 = CHI4 - PSI4
14421 CNH42S4 = CHI5 - PSI5
14423 CALL CALCMR ! Water content
14425 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14427 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14434 ! *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
14436 20 A2 = XK13*(WATER/GAMA(13))**5.0
14437 FUNCI2A = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.D0/A2 - ONE
14440 ! *** END OF FUNCTION FUNCI2A *******************************************
14442 END FUNCTION FUNCI2A
14444 !=======================================================================
14446 ! *** ISORROPIA CODE
14447 ! *** SUBROUTINE CALCI1
14450 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14451 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14452 ! 2. SOLID AEROSOL ONLY
14453 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4
14455 ! THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
14456 ! 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
14457 ! 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCI1A)
14459 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14460 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14461 ! *** WRITTEN BY ATHANASIOS NENES
14462 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14464 !=======================================================================
14468 ! EXTERNAL CALCI1A, CALCI2A
14470 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
14472 IF (RH.LT.DRMI1) THEN
14473 SCASE = 'I1 ; SUBCASE 1'
14474 CALL CALCI1A ! SOLID PHASE ONLY POSSIBLE
14475 SCASE = 'I1 ; SUBCASE 1'
14477 SCASE = 'I1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
14478 CALL CALCMDRH (RH, DRMI1, DRNH4HS4, CALCI1A, CALCI2A)
14479 SCASE = 'I1 ; SUBCASE 2'
14482 ! *** AMMONIA IN GAS PHASE **********************************************
14488 ! *** END OF SUBROUTINE CALCI1 ******************************************
14490 END SUBROUTINE CALCI1
14493 !=======================================================================
14495 ! *** ISORROPIA CODE
14496 ! *** SUBROUTINE CALCI1A
14497 ! *** CASE I1 ; SUBCASE 1
14499 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14500 ! 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
14501 ! 2. SOLID AEROSOL ONLY
14502 ! 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
14504 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14505 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14506 ! *** WRITTEN BY ATHANASIOS NENES
14507 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14509 !=======================================================================
14514 ! *** CALCULATE NON VOLATILE SOLIDS ***********************************
14516 CNA2SO4 = 0.5D0*W(1)
14520 FRSO4 = MAX(W(2)-CNA2SO4, ZERO)
14522 CLC = MIN(W(3)/3.D0, FRSO4/2.D0)
14523 FRSO4 = MAX(FRSO4-2.D0*CLC, ZERO)
14524 FRNH4 = MAX(W(3)-3.D0*CLC, ZERO)
14526 IF (FRSO4.LE.TINY) THEN
14527 CLC = MAX(CLC - FRNH4, ZERO)
14528 CNH42S4 = 2.D0*FRNH4
14530 ELSEIF (FRNH4.LE.TINY) THEN
14531 CNH4HS4 = 3.D0*MIN(FRSO4, CLC)
14532 CLC = MAX(CLC-FRSO4, ZERO)
14533 IF (CNA2SO4.GT.TINY) THEN
14534 FRSO4 = MAX(FRSO4-CNH4HS4/3.D0, ZERO)
14535 CNAHSO4 = 2.D0*FRSO4
14536 CNA2SO4 = MAX(CNA2SO4-FRSO4, ZERO)
14540 ! *** CALCULATE GAS SPECIES *********************************************
14548 ! *** END OF SUBROUTINE CALCI1A *****************************************
14550 END SUBROUTINE CALCI1A
14551 !=======================================================================
14553 ! *** ISORROPIA CODE
14554 ! *** SUBROUTINE CALCJ3
14557 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14558 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
14559 ! 2. THERE IS ONLY A LIQUID PHASE
14561 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14562 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14563 ! *** WRITTEN BY ATHANASIOS NENES
14564 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14566 !=======================================================================
14572 REAL(KIND=8) BB, CC, DD
14575 ! *** SETUP PARAMETERS ************************************************
14577 CALAOU = .TRUE. ! Outer loop activity calculation flag
14581 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
14582 CHI1 = W(1) ! NA TOTAL as NaHSO4
14583 CHI2 = W(3) ! NH4 TOTAL as NH4HSO4
14585 PSI2 = CHI2 ! ALL NH4HSO4 DELIQUESCED
14587 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14591 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
14593 ! CALCULATE DISSOCIATION QUANTITIES
14595 BB = A3+LAMDA ! KAPA
14596 CC =-A3*(LAMDA + PSI1 + PSI2)
14598 KAPA = 0.5D0*(-BB+SQRT(DD))
14600 ! *** CALCULATE SPECIATION ********************************************
14602 MOLAL (1) = LAMDA + KAPA ! HI
14603 MOLAL (2) = PSI1 ! NAI
14604 MOLAL (3) = PSI2 ! NH4I
14605 MOLAL (4) = ZERO ! CLI
14606 MOLAL (5) = KAPA ! SO4I
14607 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
14608 MOLAL (7) = ZERO ! NO3I
14613 CALL CALCMR ! Water content
14615 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14617 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14626 ! *** END OF SUBROUTINE CALCJ3 ******************************************
14628 END SUBROUTINE CALCJ3
14629 !=======================================================================
14631 ! *** ISORROPIA CODE
14632 ! *** SUBROUTINE CALCJ2
14635 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14636 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
14637 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
14638 ! 3. SOLIDS POSSIBLE : NAHSO4
14640 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14641 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14642 ! *** WRITTEN BY ATHANASIOS NENES
14643 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14645 !=======================================================================
14649 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
14650 REAL(KIND=8) PSI1LO, PSI1HI, YLO, YHI, DX
14655 ! *** SETUP PARAMETERS ************************************************
14657 CALAOU = .TRUE. ! Outer loop activity calculation flag
14658 CHI1 = W(1) ! NA TOTAL
14659 CHI2 = W(3) ! NH4 TOTAL
14660 PSI1LO = TINY ! Low limit
14661 PSI1HI = CHI1 ! High limit
14663 ! *** INITIAL VALUES FOR BISECTION ************************************
14667 YHI= Y1 ! Save Y-value at HI position
14669 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH42SO4 ****
14671 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
14673 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14675 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
14679 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14684 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH42SO4
14686 YLO= Y1 ! Save Y-value at Hi position
14687 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
14690 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
14693 CALL PUSHERR (0001, 'CALCJ2') ! WARNING ERROR: NO SOLUTION
14697 ! *** PERFORM BISECTION ***********************************************
14702 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14709 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14711 CALL PUSHERR (0002, 'CALCJ2') ! WARNING ERROR: NO CONVERGENCE
14713 ! *** CONVERGED ; RETURN **********************************************
14715 40 X3 = 0.5*(X1+X2)
14720 ! *** END OF SUBROUTINE CALCJ2 ******************************************
14722 END SUBROUTINE CALCJ2
14727 !=======================================================================
14729 ! *** ISORROPIA CODE
14730 ! *** SUBROUTINE FUNCJ2
14733 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14734 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
14735 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
14736 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
14738 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14739 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14740 ! *** WRITTEN BY ATHANASIOS NENES
14741 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14743 !=======================================================================
14745 REAL(KIND=8) FUNCTION FUNCJ2 (P1)
14749 REAL(KIND=8) BB, CC, DD, KAPA
14753 ! *** SETUP PARAMETERS ************************************************
14758 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
14760 PSI2 = CHI2 ! ALL NH4HSO4 DELIQUESCED
14762 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14766 A1 = XK11 *(WATER/GAMA(12))**2.0
14767 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
14769 ! CALCULATE DISSOCIATION QUANTITIES
14771 BB = A3+LAMDA ! KAPA
14772 CC =-A3*(LAMDA + PSI1 + PSI2)
14774 KAPA = 0.5D0*(-BB+SQRT(DD))
14776 ! *** CALCULATE SPECIATION ********************************************
14778 MOLAL (1) = LAMDA + KAPA ! HI
14779 MOLAL (2) = PSI1 ! NAI
14780 MOLAL (3) = PSI2 ! NH4I
14781 MOLAL (4) = ZERO ! CLI
14782 MOLAL (5) = KAPA ! SO4I
14783 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
14784 MOLAL (7) = ZERO ! NO3I
14786 CNAHSO4 = MAX(CHI1-PSI1,ZERO)
14789 CALL CALCMR ! Water content
14791 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14793 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14800 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
14802 20 FUNCJ2 = MOLAL(2)*MOLAL(6)/A1 - ONE
14804 ! *** END OF FUNCTION FUNCJ2 *******************************************
14806 END FUNCTION FUNCJ2
14808 !=======================================================================
14810 ! *** ISORROPIA CODE
14811 ! *** SUBROUTINE CALCJ1
14814 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14815 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
14816 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
14817 ! 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4
14819 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14820 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14821 ! *** WRITTEN BY ATHANASIOS NENES
14822 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14824 !=======================================================================
14828 REAL(KIND=8) X1, X2, X3, Y1, Y2, Y3
14829 REAL(KIND=8) PSI1LO, PSI1HI, YLO, YHI, DX
14834 ! *** SETUP PARAMETERS ************************************************
14836 CALAOU =.TRUE. ! Outer loop activity calculation flag
14837 CHI1 = W(1) ! Total NA initially as NaHSO4
14838 CHI2 = W(3) ! Total NH4 initially as NH4HSO4
14840 PSI1LO = TINY ! Low limit
14841 PSI1HI = CHI1 ! High limit
14843 ! *** INITIAL VALUES FOR BISECTION ************************************
14847 YHI= Y1 ! Save Y-value at HI position
14849 ! *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH42SO4 ****
14851 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
14853 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14855 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
14859 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14864 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH42SO4
14866 YLO= Y1 ! Save Y-value at Hi position
14867 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
14870 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
14873 CALL PUSHERR (0001, 'CALCJ1') ! WARNING ERROR: NO SOLUTION
14877 ! *** PERFORM BISECTION ***********************************************
14882 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14889 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14891 CALL PUSHERR (0002, 'CALCJ1') ! WARNING ERROR: NO CONVERGENCE
14893 ! *** CONVERGED ; RETURN **********************************************
14895 40 X3 = 0.5*(X1+X2)
14900 ! *** END OF SUBROUTINE CALCJ1 ******************************************
14902 END SUBROUTINE CALCJ1
14907 !=======================================================================
14909 ! *** ISORROPIA CODE
14910 ! *** SUBROUTINE FUNCJ1
14913 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14914 ! 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
14915 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
14916 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
14918 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14919 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
14920 ! *** WRITTEN BY ATHANASIOS NENES
14921 ! *** UPDATED BY CHRISTOS FOUNTOUKIS
14923 !=======================================================================
14925 REAL(KIND=8) FUNCTION FUNCJ1 (P1)
14928 REAL(KIND=8) BB, CC, DD, KAPA
14931 ! *** SETUP PARAMETERS ************************************************
14936 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
14939 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14943 A1 = XK11 *(WATER/GAMA(12))**2.0
14944 A2 = XK12 *(WATER/GAMA(09))**2.0
14945 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
14947 PSI2 = 0.5*(-(LAMDA+PSI1) + SQRT((LAMDA+PSI1)**2.D0+4.D0*A2)) ! PSI2
14948 PSI2 = MIN (PSI2, CHI2)
14950 BB = A3+LAMDA ! KAPA
14951 CC =-A3*(LAMDA + PSI2 + PSI1)
14953 KAPA = 0.5D0*(-BB+SQRT(DD))
14955 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
14957 MOLAL (1) = LAMDA + KAPA ! HI
14958 MOLAL (2) = PSI1 ! NAI
14959 MOLAL (3) = PSI2 ! NH4I
14961 MOLAL (5) = KAPA ! SO4I
14962 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
14965 CNAHSO4 = MAX(CHI1-PSI1,ZERO)
14966 CNH4HS4 = MAX(CHI2-PSI2,ZERO)
14968 CALL CALCMR ! Water content
14970 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14972 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14979 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
14981 20 FUNCJ1 = MOLAL(2)*MOLAL(6)/A1 - ONE
14983 ! *** END OF FUNCTION FUNCJ1 *******************************************
14985 END FUNCTION FUNCJ1
14987 END module module_isrpia