1 !=======================================================================
4 ! *** SUBROUTINE ISRP1R
5 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
6 ! AN AMMONIUM-SULFATE AEROSOL SYSTEM.
7 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
8 ! THE AMBIENT RELATIVE HUMIDITY.
10 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
12 ! *** WRITTEN BY ATHANASIOS NENES
15 ! Original code was provided by Dr. ATHANASIOS NENES, Georgia Tech, in 2000
16 ! Revised by Y. Zhang, AER, Inc. to incorporate v1.5 into MADRID, 2000
17 ! Revised by Y. Zhang and Xiao-Ming Hu to incorporate it along with MADRID into WRF/Chem, 2005
18 ! Updated by Xiao-Ming Hu and Y. Zhang, NCSU to v. 1.7, Oct., 2007
19 !=======================================================================
21 SUBROUTINE ISRP1R (WI, RHI, TEMPI)
23 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
24 ! INCLUDE 'ISRPIA.INC'
27 ! *** INITIALIZE COMMON BLOCK VARIABLES *********************************
29 CALL INIT1 (WI, RHI, TEMPI)
31 ! *** CALCULATE SULFATE RATIO *******************************************
33 IF (RH.GE.DRNH42S4) THEN ! WET AEROSOL, NEED NH4 AT SRATIO=2.0
34 SULRATW = GETASR(WAER(2), RHI) ! AEROSOL SULFATE RATIO
36 SULRATW = 2.0D0 ! DRY AEROSOL SULFATE RATIO
38 SULRAT = WAER(3)/WAER(2) ! SULFATE RATIO
40 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
44 IF (SULRATW.LE.SULRAT) THEN
48 CALL CALCK2 ! Only liquid (metastable)
51 IF (RH.LT.DRNH42S4) THEN
53 CALL CALCK1 ! NH42SO4 ; case K1
55 ELSEIF (DRNH42S4.LE.RH) THEN
57 CALL CALCK2 ! Only liquid ; case K2
61 ! *** SULFATE RICH (NO ACID)
63 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
69 CALL CALCB4 ! Only liquid (metastable)
73 IF (RH.LT.DRNH4HS4) THEN
75 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case B1
78 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
80 CALL CALCB2 ! LC,NH42S4 ; case B2
83 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
85 CALL CALCB3 ! NH42S4 ; case B3
88 ELSEIF (DRNH42S4.LE.RH) THEN
90 CALL CALCB4 ! Only liquid ; case B4
95 CALL CALCNH3P ! Compute NH3(g)
97 ! *** SULFATE RICH (FREE ACID)
99 ELSEIF (SULRAT.LT.1.0) THEN
103 IF(METSTBL.EQ.1) THEN
105 CALL CALCC2 ! Only liquid (metastable)
109 IF (RH.LT.DRNH4HS4) THEN
111 CALL CALCC1 ! NH4HSO4 ; case C1
114 ELSEIF (DRNH4HS4.LE.RH) THEN
116 CALL CALCC2 ! Only liquid ; case C2
126 ! *** END OF SUBROUTINE ISRP1R *****************************************
128 END SUBROUTINE ISRP1R
130 !=======================================================================
133 ! *** SUBROUTINE ISRP2R
134 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
135 ! AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
136 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
137 ! THE AMBIENT RELATIVE HUMIDITY.
139 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
140 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
141 ! *** WRITTEN BY ATHANASIOS NENES
143 !=======================================================================
145 SUBROUTINE ISRP2R (WI, RHI, TEMPI)
147 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
148 ! INCLUDE 'ISRPIA.INC'
152 ! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
154 TRYLIQ = .TRUE. ! Assume liquid phase, sulfate poor limit
156 10 CALL INIT2 (WI, RHI, TEMPI)
158 ! *** CALCULATE SULFATE RATIO *******************************************
160 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! *** WET AEROSOL
161 SULRATW = GETASR(WAER(2), RHI) ! LIMITING SULFATE RATIO
163 SULRATW = 2.0D0 ! *** DRY AEROSOL
165 SULRAT = WAER(3)/WAER(2)
167 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
171 IF (SULRATW.LE.SULRAT) THEN
173 IF(METSTBL.EQ.1) THEN
175 CALL CALCN3 ! Only liquid (metastable)
178 IF (RH.LT.DRNH4NO3) THEN
180 CALL CALCN1 ! NH42SO4,NH4NO3 ; case N1
182 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH42S4) THEN
184 CALL CALCN2 ! NH42S4 ; case N2
186 ELSEIF (DRNH42S4.LE.RH) THEN
188 CALL CALCN3 ! Only liquid ; case N3
192 ! *** SULFATE RICH (NO ACID)
194 ! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
195 ! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
196 ! AEROSOL EQUILIBRIUM.
198 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
203 IF(METSTBL.EQ.1) THEN
205 CALL CALCB4 ! Only liquid (metastable)
209 IF (RH.LT.DRNH4HS4) THEN
211 CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case O1
214 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
216 CALL CALCB2 ! LC,NH42S4 ; case O2
219 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
221 CALL CALCB3 ! NH42S4 ; case O3
224 ELSEIF (DRNH42S4.LE.RH) THEN
226 CALL CALCB4 ! Only liquid ; case O4
231 ! *** Add the NO3 to the solution now and calculate partitioning.
233 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
234 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
235 CALL CALCNAP ! HNO3, NH3 dissolved
238 ! *** SULFATE RICH (FREE ACID)
240 ! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
241 ! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
242 ! AEROSOL EQUILIBRIUM.
244 ELSEIF (SULRAT.LT.1.0) THEN
249 IF(METSTBL.EQ.1) THEN
251 CALL CALCC2 ! Only liquid (metastable)
255 IF (RH.LT.DRNH4HS4) THEN
257 CALL CALCC1 ! NH4HSO4 ; case P1
260 ELSEIF (DRNH4HS4.LE.RH) THEN
262 CALL CALCC2 ! Only liquid ; case P2
267 ! *** Add the NO3 to the solution now and calculate partitioning.
269 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
270 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
272 CALL CALCNAP ! HNO3, NH3 dissolved
276 ! *** IF SULRATW < SULRAT < 2.0 and WATER = 0 => SULFATE RICH CASE.
278 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 &
279 .AND. WATER.LE.TINY) THEN
286 ! *** END OF SUBROUTINE ISRP2R *****************************************
288 END SUBROUTINE ISRP2R
289 !=======================================================================
292 ! *** SUBROUTINE ISRP3R
293 ! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
294 ! AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
295 ! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
296 ! RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
298 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
299 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
300 ! *** WRITTEN BY ATHANASIOS NENES
302 !=======================================================================
304 SUBROUTINE ISRP3R (WI, RHI, TEMPI)
306 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
307 ! INCLUDE 'ISRPIA.INC'
311 !cC *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
313 !c WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
314 !c WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
316 ! *** INITIALIZE ALL VARIABLES ******************************************
318 TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
320 10 CALL ISOINIT3 (WI, RHI, TEMPI) ! COMMON block variables
322 !cC *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
324 !c REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
325 !c IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
326 !c WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
327 !c CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
330 ! *** CALCULATE SULFATE & SODIUM RATIOS *********************************
332 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! ** WET AEROSOL
333 FRSO4 = WAER(2) - WAER(1)/2.0D0 ! SULFATE UNBOUND BY SODIUM
334 FRSO4 = MAX(FRSO4, TINY)
335 SRI = GETASR(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
336 SULRATW = (WAER(1)+FRSO4*SRI)/WAER(2) ! LIMITING SULFATE RATIO
337 SULRATW = MIN (SULRATW, 2.0D0)
339 SULRATW = 2.0D0 ! ** DRY AEROSOL
341 SULRAT = (WAER(1)+WAER(3))/WAER(2)
342 SODRAT = WAER(1)/WAER(2)
344 ! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
346 ! *** SULFATE POOR ; SODIUM POOR
348 IF (SULRATW.LE.SULRAT .AND. SODRAT.LT.2.0) THEN
350 IF(METSTBL.EQ.1) THEN
352 CALL CALCQ5 ! Only liquid (metastable)
356 IF (RH.LT.DRNH4NO3) THEN
358 CALL CALCQ1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
360 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
362 CALL CALCQ2 ! NH42SO4,NH4CL,NA2SO4
364 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
366 CALL CALCQ3 ! NH42SO4,NA2SO4
368 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
373 ELSEIF (DRNA2SO4.LE.RH) THEN
375 CALL CALCQ5 ! Only liquid
380 ! *** SULFATE POOR ; SODIUM RICH
382 ELSE IF (SULRAT.GE.SULRATW .AND. SODRAT.GE.2.0) THEN
384 IF(METSTBL.EQ.1) THEN
386 CALL CALCR6 ! Only liquid (metastable)
390 IF (RH.LT.DRNH4NO3) THEN
392 CALL CALCR1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
394 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
396 CALL CALCR2 ! NH4CL,NA2SO4,NACL,NANO3
398 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
400 CALL CALCR3 ! NH4CL,NA2SO4,NACL
402 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4CL) THEN
404 CALL CALCR4 ! NH4CL,NA2SO4
406 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNA2SO4) THEN
411 ELSEIF (DRNA2SO4.LE.RH) THEN
413 CALL CALCR6 ! NO SOLID
418 ! *** SULFATE RICH (NO ACID)
420 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
425 IF(METSTBL.EQ.1) THEN
427 CALL CALCI6 ! Only liquid (metastable)
431 IF (RH.LT.DRNH4HS4) THEN
433 CALL CALCI1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
436 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
438 CALL CALCI2 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
441 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
443 CALL CALCI3 ! NA2SO4,(NH4)2SO4,LC
446 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
448 CALL CALCI4 ! NA2SO4,(NH4)2SO4
451 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
456 ELSEIF (DRNA2SO4.LE.RH) THEN
458 CALL CALCI6 ! NO SOLIDS
463 CALL CALCNHP ! HNO3, NH3, HCL in gas phase
466 ! *** SULFATE RICH (FREE ACID)
468 ELSEIF (SULRAT.LT.1.0) THEN
473 IF(METSTBL.EQ.1) THEN
475 CALL CALCJ3 ! Only liquid (metastable)
479 IF (RH.LT.DRNH4HS4) THEN
481 CALL CALCJ1 ! NH4HSO4,NAHSO4
484 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
489 ELSEIF (DRNAHSO4.LE.RH) THEN
496 CALL CALCNHP ! HNO3, NH3, HCL in gas phase
501 ! *** IF AFTER CALCULATIONS, SULRATW < SULRAT < 2.0
502 ! and WATER = 0 => SULFATE RICH CASE.
504 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 &
505 .AND. WATER.LE.TINY) THEN
512 ! *** END OF SUBROUTINE ISRP3R *****************************************
514 END SUBROUTINE ISRP3R
515 !=======================================================================
518 ! *** SUBROUTINE CALCK2
521 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
522 ! 1. SULFATE POOR (SULRAT > 2.0)
523 ! 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
525 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
526 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
527 ! *** WRITTEN BY ATHANASIOS NENES
529 !=======================================================================
533 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
534 ! INCLUDE 'ISRPIA.INC'
535 DOUBLE PRECISION NH4I, NH3GI, NH3AQ
537 ! *** SETUP PARAMETERS ************************************************
539 CALAOU =.TRUE. ! Outer loop activity calculation flag
543 ! *** CALCULATE WATER CONTENT *****************************************
545 MOLALR(4)= MIN(WAER(2), 0.5d0*WAER(3))
546 WATER = MOLALR(4)/M0(4) ! ZSR correlation
548 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
551 !C A21 = XK21*WATER*R*TEMP
552 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
553 AKW = XKW *RH*WATER*WATER
559 CALL CALCPH (2.D0*SO4I - NH4I, HI, OHI) ! Get pH
561 NH3AQ = ZERO ! AMMONIA EQUILIBRIUM
563 CALL CALCAMAQ (NH4I, OHI, DEL)
564 NH4I = MAX (NH4I-DEL, ZERO)
565 OHI = MAX (OHI -DEL, TINY)
570 CALL CALCHS4 (HI, SO4I, ZERO, DEL) ! SULFATE EQUILIBRIUM
575 NH3GI = NH4I/HI/A2 ! NH3AQ/A21
577 ! *** SPECIATION & WATER CONTENT ***************************************
587 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
589 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
598 ! *** END OF SUBROUTINE CALCK2 ****************************************
600 END SUBROUTINE CALCK2
601 !=======================================================================
604 ! *** SUBROUTINE CALCK1
607 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
608 ! 1. SULFATE POOR (SULRAT > 2.0)
609 ! 2. SOLID AEROSOL ONLY
610 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
612 ! A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
613 ! IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
616 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
617 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
618 ! *** WRITTEN BY ATHANASIOS NENES
620 !=======================================================================
624 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
625 ! INCLUDE 'ISRPIA.INC'
627 CNH42S4 = MIN(WAER(2),0.5d0*WAER(3)) ! For bad input problems
631 W(3) = 2.D0*CNH42S4 + GNH3
635 ! *** END OF SUBROUTINE CALCK1 ******************************************
637 END SUBROUTINE CALCK1
640 !=======================================================================
643 ! *** SUBROUTINE CALCN3
646 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
647 ! 1. SULFATE POOR (SULRAT > 2.0)
648 ! 2. THERE IS ONLY A LIQUID PHASE
650 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
651 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
652 ! *** WRITTEN BY ATHANASIOS NENES
654 !=======================================================================
659 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
660 ! INCLUDE 'ISRPIA.INC'
661 DOUBLE PRECISION NH4I, NO3I, NH3AQ, NO3AQ
662 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
663 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
664 ! A1, A2, A3, A4, A5, A6, A7, A8
666 ! *** SETUP PARAMETERS ************************************************
668 CALAOU =.TRUE. ! Outer loop activity calculation flag
672 ! *** AEROSOL WATER CONTENT
674 MOLALR(4) = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
675 AML5 = MAX(WAER(3)-2.D0*MOLALR(4),ZERO) ! "free" NH4
676 MOLALR(5) = MAX(MIN(AML5,WAER(4)), ZERO) ! NH4NO3=MIN("free",NO3)
677 WATER = MOLALR(4)/M0(4) + MOLALR(5)/M0(5)
678 WATER = MAX(WATER, TINY)
680 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
683 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
684 !C A21 = XK21*WATER*R*TEMP
685 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
686 A4 = XK7*(WATER/GAMA(4))**3.0
687 AKW = XKW *RH*WATER*WATER
696 CALL CALCPH (2.D0*SO4I + NO3I - NH4I, HI, OHI)
698 ! AMMONIA ASSOCIATION EQUILIBRIUM
702 GG = 2.D0*SO4I + NO3I - NH4I
704 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
708 CALL CALCNIAQ2 (GG, NO3I, HI, NO3AQ) ! HNO3
710 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
712 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
719 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
735 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
737 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP ******************
739 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
746 ! *** RETURN ***********************************************************
750 ! *** END OF SUBROUTINE CALCN3 *****************************************
752 END SUBROUTINE CALCN3
753 !=======================================================================
756 ! *** SUBROUTINE CALCN2
759 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
760 ! 1. SULFATE POOR (SULRAT > 2.0)
761 ! 2. THERE IS BOTH A LIQUID & SOLID PHASE
762 ! 3. SOLIDS POSSIBLE : (NH4)2SO4
764 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
765 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
766 ! *** WRITTEN BY ATHANASIOS NENES
768 !=======================================================================
773 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
774 ! INCLUDE 'ISRPIA.INC'
775 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
776 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
777 ! A1, A2, A3, A4, A5, A6, A7, A8
779 ! *** SETUP PARAMETERS ************************************************
781 CHI1 = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
782 CHI2 = MAX(WAER(3) - 2.D0*CHI1, ZERO) ! "Free" NH4+
783 CHI3 = MAX(WAER(4) - CHI2, ZERO) ! "Free" NO3
788 CALAOU = .TRUE. ! Outer loop activity calculation flag
789 PSI1LO = TINY ! Low limit
790 PSI1HI = CHI1 ! High limit
792 ! *** INITIAL VALUES FOR BISECTION ************************************
796 IF (Y1.LE.EPS) RETURN ! IF (ABS(Y1).LE.EPS .OR. Y1.LE.ZERO) RETURN
797 YHI= Y1 ! Save Y-value at HI position
799 ! *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
801 DX = (PSI1HI-PSI1LO)/REAL(NDIV)
803 X2 = MAX(X1-DX, ZERO)
805 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
810 ! *** NO SUBDIVISION WITH SOLUTION FOUND
812 YLO= Y1 ! Save Y-value at Hi position
813 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
816 ! *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
818 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
823 ! *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
825 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
830 CALL PUSHERR (0001, 'CALCN2') ! WARNING ERROR: NO SOLUTION
834 ! *** PERFORM BISECTION ***********************************************
839 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
846 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
848 CALL PUSHERR (0002, 'CALCN2') ! WARNING ERROR: NO CONVERGENCE
850 ! *** CONVERGED ; RETURN **********************************************
857 ! *** END OF SUBROUTINE CALCN2 ******************************************
859 END SUBROUTINE CALCN2
863 !======================================================================
866 ! *** FUNCTION FUNCN2
868 ! FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D2 ;
869 ! AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCN2.
871 !=======================================================================
873 DOUBLE PRECISION FUNCTION FUNCN2 (P1)
876 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
877 ! INCLUDE 'ISRPIA.INC'
878 DOUBLE PRECISION NH4I, NO3I, NH3AQ, NO3AQ
879 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
880 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
881 ! A1, A2, A3, A4, A5, A6, A7, A8
883 ! *** SETUP PARAMETERS ************************************************
889 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
892 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
893 !C A21 = XK21*WATER*R*TEMP
894 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
895 A4 = XK7*(WATER/GAMA(4))**3.0
896 AKW = XKW *RH*WATER*WATER
900 NH4I = 2.D0*PSI1 + PSI2
905 CALL CALCPH (2.D0*SO4I + NO3I - NH4I, HI, OHI)
907 ! AMMONIA ASSOCIATION EQUILIBRIUM
911 GG = 2.D0*SO4I + NO3I - NH4I
913 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
917 CALL CALCNIAQ2 (GG, NO3I, HI, NO3AQ) ! HNO3
919 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
921 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
928 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
937 CNH42S4 = CHI1 - PSI1
944 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
946 ! *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
950 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
952 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
959 ! *** CALCULATE OBJECTIVE FUNCTION ************************************
961 20 FUNCN2= NH4I*NH4I*SO4I/A4 - ONE
964 ! *** END OF FUNCTION FUNCN2 ********************************************
967 !=======================================================================
970 ! *** SUBROUTINE CALCN1
973 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
974 ! 1. SULFATE POOR (SULRAT > 2.0)
975 ! 2. SOLID AEROSOL ONLY
976 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
978 ! THERE ARE TWO REGIMES DEFINED BY RELATIVE HUMIDITY:
979 ! 1. RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCN1A)
980 ! 2. RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
982 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
983 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
984 ! *** WRITTEN BY ATHANASIOS NENES
986 !=======================================================================
990 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
991 ! INCLUDE 'ISRPIA.INC'
992 EXTERNAL CALCN1A, CALCN2
994 ! *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
996 IF (RH.LT.DRMASAN) THEN
997 SCASE = 'N1 ; SUBCASE 1'
998 CALL CALCN1A ! SOLID PHASE ONLY POSSIBLE
999 SCASE = 'N1 ; SUBCASE 1'
1001 SCASE = 'N1 ; SUBCASE 2'
1002 CALL CALCMDRP (RH, DRMASAN, DRNH4NO3, CALCN1A, CALCN2)
1003 SCASE = 'N1 ; SUBCASE 2'
1008 ! *** END OF SUBROUTINE CALCN1 ******************************************
1010 END SUBROUTINE CALCN1
1014 !=======================================================================
1016 ! *** ISORROPIA CODE
1017 ! *** SUBROUTINE CALCN1A
1018 ! *** CASE N1 ; SUBCASE 1
1020 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1021 ! 1. SULFATE POOR (SULRAT > 2.0)
1022 ! 2. SOLID AEROSOL ONLY
1023 ! 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
1025 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1026 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1027 ! *** WRITTEN BY ATHANASIOS NENES
1029 !=======================================================================
1033 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1034 ! INCLUDE 'ISRPIA.INC'
1036 ! *** SETUP PARAMETERS *************************************************
1038 !CC A1 = XK10/R/TEMP/R/TEMP
1040 ! *** CALCULATE AEROSOL COMPOSITION ************************************
1042 !CC CHI1 = 2.D0*WAER(4) ! Free parameter ; arbitrary value.
1045 ! *** The following statment is here to avoid negative NH4+ values in
1046 ! CALCN? routines that call CALCN1A
1048 PSI2 = MAX(MIN(WAER(2),0.5d0*(WAER(3)-PSI1)),TINY)
1053 !CC GNH3 = CHI1 + PSI1 + 2.0*PSI2
1054 !CC GHNO3 = A1/(CHI1-PSI1) + PSI1
1059 W(3) = GNH3 + PSI1 + 2.0*PSI2
1064 ! *** END OF SUBROUTINE CALCN1A *****************************************
1066 END SUBROUTINE CALCN1A
1068 !=======================================================================
1070 ! *** ISORROPIA CODE
1071 ! *** SUBROUTINE CALCQ5
1074 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1075 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1076 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1078 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1079 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1080 ! *** WRITTEN BY ATHANASIOS NENES
1082 !=======================================================================
1087 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1088 ! INCLUDE 'ISRPIA.INC'
1090 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1091 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1092 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
1093 ! A1, A2, A3, A4, A5, A6, A7, A8
1095 ! *** SETUP PARAMETERS ************************************************
1101 ! *** CALCULATE INITIAL SOLUTION ***************************************
1105 PSI1 = CNA2SO4 ! SALTS DISSOLVED
1116 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1119 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1121 ! ION CONCENTRATIONS
1129 ! SOLUTION ACIDIC OR BASIC?
1131 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1132 IF (GG.GT.TINY) THEN ! H+ in excess
1135 DD = BB*BB - 4.D0*CC
1136 HI = 0.5D0*(-BB + SQRT(DD))
1138 ELSE ! OH- in excess
1141 DD = BB*BB - 4.D0*CC
1142 OHI= 0.5D0*(-BB + SQRT(DD))
1146 ! UNDISSOCIATED SPECIES EQUILIBRIA
1149 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
1153 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1154 GGCL = MAX(GG-GGNO3, ZERO)
1155 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
1156 IF (GGNO3.GT.TINY) THEN
1157 IF (GGCL.LE.TINY) HI = ZERO
1158 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1161 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1163 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
1170 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1180 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1182 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1188 !cc CALL PUSHERR (0002, 'CALCQ5') ! WARNING ERROR: NO CONVERGENCE
1190 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1192 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1193 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1194 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1213 ! *** END OF SUBROUTINE CALCQ5 ******************************************
1215 END SUBROUTINE CALCQ5
1216 !=======================================================================
1218 ! *** ISORROPIA CODE
1219 ! *** SUBROUTINE CALCQ4
1222 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1223 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1224 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1226 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1227 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1228 ! *** WRITTEN BY ATHANASIOS NENES
1230 !=======================================================================
1235 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1236 ! INCLUDE 'ISRPIA.INC'
1239 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1240 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1241 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
1242 ! A1, A2, A3, A4, A5, A6, A7, A8
1244 ! *** SETUP PARAMETERS ************************************************
1254 ! *** CALCULATE INITIAL SOLUTION ***************************************
1258 CHI1 = CNA2SO4 ! SALTS
1260 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
1267 NAI = WAER(1) ! LIQUID CONCENTRATIONS
1277 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1280 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
1281 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1285 IF (NAI*NAI*SO4I .GT. A5) THEN
1286 BB =-(WAER(2) + WAER(1))
1287 CC = WAER(1)*WAER(2) + 0.25*WAER(1)*WAER(1)
1288 DD =-0.25*(WAER(1)*WAER(1)*WAER(2) - A5)
1289 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
1290 IF (ISLV.NE.0) ROOT3 = TINY
1291 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2), CHI1)
1292 ROOT3 = MAX (ROOT3, ZERO)
1295 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
1298 ! ION CONCENTRATIONS ; CORRECTIONS
1300 NAI = WAER(1) - 2.D0*ROOT3
1301 SO4I= WAER(2) - ROOT3
1306 ! SOLUTION ACIDIC OR BASIC?
1308 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1309 IF (GG.GT.TINY) THEN ! H+ in excess
1312 DD = BB*BB - 4.D0*CC
1313 HI = 0.5D0*(-BB + SQRT(DD))
1315 ELSE ! OH- in excess
1318 DD = BB*BB - 4.D0*CC
1319 OHI= 0.5D0*(-BB + SQRT(DD))
1323 ! UNDISSOCIATED SPECIES EQUILIBRIA
1326 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
1330 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1331 GGCL = MAX(GG-GGNO3, ZERO)
1332 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
1333 IF (GGNO3.GT.TINY) THEN
1334 IF (GGCL.LE.TINY) HI = ZERO
1335 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1338 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1340 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
1347 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1357 ! *** CALCULATE WATER **************************************************
1361 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1363 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1366 IF (PSCONV1) GOTO 20
1369 !cc CALL PUSHERR (0002, 'CALCQ4') ! WARNING ERROR: NO CONVERGENCE
1371 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1373 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1374 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1375 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1390 CNA2SO4 = CHI1 - PSI1
1394 ! *** END OF SUBROUTINE CALCQ4 ******************************************
1396 END SUBROUTINE CALCQ4
1397 !=======================================================================
1399 ! *** ISORROPIA CODE
1400 ! *** SUBROUTINE CALCQ3
1403 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1404 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
1405 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
1406 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
1408 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1409 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1410 ! *** WRITTEN BY ATHANASIOS NENES
1412 !=======================================================================
1416 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1417 ! INCLUDE 'ISRPIA.INC'
1419 EXTERNAL CALCQ1A, CALCQ4
1421 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
1423 EXNO = WAER(4).GT.TINY
1424 EXCL = WAER(5).GT.TINY
1426 IF (EXNO .OR. EXCL) THEN ! *** NITRATE OR CHLORIDE EXISTS
1427 SCASE = 'Q3 ; SUBCASE 1'
1429 SCASE = 'Q3 ; SUBCASE 1'
1431 ELSE ! *** NO CHLORIDE AND NITRATE
1432 IF (RH.LT.DRMG3) THEN
1433 SCASE = 'Q3 ; SUBCASE 2'
1434 CALL CALCQ1A ! SOLID
1435 SCASE = 'Q3 ; SUBCASE 2'
1437 SCASE = 'Q3 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4
1438 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
1439 SCASE = 'Q3 ; SUBCASE 3'
1445 ! *** END OF SUBROUTINE CALCQ3 ******************************************
1447 END SUBROUTINE CALCQ3
1451 !=======================================================================
1453 ! *** ISORROPIA CODE
1454 ! *** SUBROUTINE CALCQ3A
1455 ! *** CASE Q3 ; SUBCASE A
1457 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1458 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1459 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1461 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1462 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1463 ! *** WRITTEN BY ATHANASIOS NENES
1465 !=======================================================================
1470 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1471 ! INCLUDE 'ISRPIA.INC'
1473 LOGICAL PSCONV1, PSCONV6
1474 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1475 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1476 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
1477 ! A1, A2, A3, A4, A5, A6, A7, A8
1479 ! *** SETUP PARAMETERS ************************************************
1494 ! *** CALCULATE INITIAL SOLUTION ***************************************
1498 CHI1 = CNA2SO4 ! SALTS
1502 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
1509 NAI = WAER(1) ! LIQUID CONCENTRATIONS
1519 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1522 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
1523 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> Na+
1524 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1528 IF (NAI*NAI*SO4I .GT. A5) THEN
1529 BB =-(WAER(2) + WAER(1) - ROOT1)
1530 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
1531 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
1532 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
1533 IF (ISLV.NE.0) ROOT3 = TINY
1534 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
1535 ROOT3 = MAX (ROOT3, ZERO)
1538 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
1543 IF (NH4I*NH4I*SO4I .GT. A4) THEN
1544 BB =-(WAER(2)+WAER(3)-ROOT3)
1545 CC = WAER(3)*(WAER(2)-ROOT3+0.5D0*WAER(3))
1546 DD =-((WAER(2)-ROOT3)*WAER(3)**2.D0 + A4)/4.D0
1547 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
1548 IF (ISLV.NE.0) ROOT1 = TINY
1549 ROOT1 = MIN(ROOT1, WAER(3), WAER(2)-ROOT3, CHI6)
1550 ROOT1 = MAX(ROOT1, ZERO)
1553 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
1556 ! ION CONCENTRATIONS
1558 NAI = WAER(1) - 2.D0*ROOT3
1559 SO4I= WAER(2) - ROOT1 - ROOT3
1560 NH4I= WAER(3) - 2.D0*ROOT1
1564 ! SOLUTION ACIDIC OR BASIC?
1566 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1567 IF (GG.GT.TINY) THEN ! H+ in excess
1570 DD = BB*BB - 4.D0*CC
1571 HI = 0.5D0*(-BB + SQRT(DD))
1573 ELSE ! OH- in excess
1576 DD = BB*BB - 4.D0*CC
1577 OHI= 0.5D0*(-BB + SQRT(DD))
1581 ! UNDISSOCIATED SPECIES EQUILIBRIA
1584 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
1588 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1589 GGCL = MAX(GG-GGNO3, ZERO)
1590 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
1591 IF (GGNO3.GT.TINY) THEN
1592 IF (GGCL.LE.TINY) HI = ZERO
1593 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1596 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1598 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
1605 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1615 ! *** CALCULATE WATER **************************************************
1619 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1621 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1624 IF (PSCONV1 .AND. PSCONV6) GOTO 20
1627 !cc CALL PUSHERR (0002, 'CALCQ3A') ! WARNING ERROR: NO CONVERGENCE
1629 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1631 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1632 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1633 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1643 CNH42S4 = CHI6 - PSI6
1648 CNA2SO4 = CHI1 - PSI1
1652 ! *** END OF SUBROUTINE CALCQ3A *****************************************
1654 END SUBROUTINE CALCQ3A
1655 !=======================================================================
1657 ! *** ISORROPIA CODE
1658 ! *** SUBROUTINE CALCQ2
1661 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1662 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
1663 ! 2. SOLID & LIQUID AEROSOL POSSIBLE
1664 ! 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
1666 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1667 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1668 ! *** WRITTEN BY ATHANASIOS NENES
1670 !=======================================================================
1674 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1675 ! INCLUDE 'ISRPIA.INC'
1677 EXTERNAL CALCQ1A, CALCQ3A, CALCQ4
1679 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
1681 EXNO = WAER(4).GT.TINY
1682 EXCL = WAER(5).GT.TINY
1684 IF (EXNO) THEN ! *** NITRATE EXISTS
1685 SCASE = 'Q2 ; SUBCASE 1'
1687 SCASE = 'Q2 ; SUBCASE 1'
1689 ELSEIF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
1690 IF (RH.LT.DRMG2) THEN
1691 SCASE = 'Q2 ; SUBCASE 2'
1692 CALL CALCQ1A ! SOLID
1693 SCASE = 'Q2 ; SUBCASE 2'
1695 SCASE = 'Q2 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
1696 CALL CALCMDRP (RH, DRMG2, DRNH4CL, CALCQ1A, CALCQ3A)
1697 SCASE = 'Q2 ; SUBCASE 3'
1700 ELSE ! *** NO CHLORIDE AND NITRATE
1701 IF (RH.LT.DRMG3) THEN
1702 SCASE = 'Q2 ; SUBCASE 2'
1703 CALL CALCQ1A ! SOLID
1704 SCASE = 'Q2 ; SUBCASE 2'
1706 SCASE = 'Q2 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4
1707 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
1708 SCASE = 'Q2 ; SUBCASE 4'
1714 ! *** END OF SUBROUTINE CALCQ2 ******************************************
1716 END SUBROUTINE CALCQ2
1719 !=======================================================================
1721 ! *** ISORROPIA CODE
1722 ! *** SUBROUTINE CALCQ2A
1723 ! *** CASE Q2 ; SUBCASE A
1725 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1726 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1727 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1729 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1730 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1731 ! *** WRITTEN BY ATHANASIOS NENES
1733 !=======================================================================
1738 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1739 ! INCLUDE 'ISRPIA.INC'
1741 LOGICAL PSCONV1, PSCONV4, PSCONV6
1742 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1743 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1744 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
1745 ! A1, A2, A3, A4, A5, A6, A7, A8
1747 ! *** SETUP PARAMETERS ************************************************
1765 ! *** CALCULATE INITIAL SOLUTION ***************************************
1769 CHI1 = CNA2SO4 ! SALTS
1773 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
1780 NAI = WAER(1) ! LIQUID CONCENTRATIONS
1790 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1793 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
1794 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
1795 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> Na+
1796 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1800 IF (NH4I*CLI .GT. A14) THEN
1801 BB =-(WAER(3) + WAER(5) - 2.D0*ROOT1)
1802 CC = WAER(5)*(WAER(3) - 2.D0*ROOT1) - A14
1803 DD = BB*BB - 4.D0*CC
1804 IF (DD.LT.ZERO) THEN
1808 ROOT2A= 0.5D0*(-BB+DD)
1809 ROOT2B= 0.5D0*(-BB-DD)
1810 IF (ZERO.LE.ROOT2A) THEN
1815 ROOT2 = MIN(ROOT2, WAER(5), WAER(3) - 2.D0*ROOT1, CHI4)
1816 ROOT2 = MAX(ROOT2, ZERO)
1820 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
1825 IF (NAI*NAI*SO4I .GT. A5) THEN
1826 BB =-(WAER(2) + WAER(1) - ROOT1)
1827 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
1828 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
1829 CALL POLY3(BB, CC, DD, ROOT3, ISLV)
1830 IF (ISLV.NE.0) ROOT3 = TINY
1831 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
1832 ROOT3 = MAX (ROOT3, ZERO)
1835 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
1840 IF (NH4I*NH4I*SO4I .GT. A4) THEN
1841 BB =-(WAER(2)+WAER(3)-ROOT2-ROOT3)
1842 CC = (WAER(3)-ROOT2)*(WAER(2)-ROOT3+0.5D0*(WAER(3)-ROOT2))
1843 DD =-((WAER(2)-ROOT3)*(WAER(3)-ROOT2)**2.D0 + A4)/4.D0
1844 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
1845 IF (ISLV.NE.0) ROOT1 = TINY
1846 ROOT1 = MIN(ROOT1, WAER(3)-ROOT2, WAER(2)-ROOT3, CHI6)
1847 ROOT1 = MAX(ROOT1, ZERO)
1850 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
1853 ! ION CONCENTRATIONS
1855 NAI = WAER(1) - 2.D0*ROOT3
1856 SO4I= WAER(2) - ROOT1 - ROOT3
1857 NH4I= WAER(3) - ROOT2 - 2.D0*ROOT1
1859 CLI = WAER(5) - ROOT2
1861 ! SOLUTION ACIDIC OR BASIC?
1863 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1864 IF (GG.GT.TINY) THEN ! H+ in excess
1867 DD = BB*BB - 4.D0*CC
1868 HI = 0.5D0*(-BB + SQRT(DD))
1870 ELSE ! OH- in excess
1873 DD = BB*BB - 4.D0*CC
1874 OHI= 0.5D0*(-BB + SQRT(DD))
1878 ! UNDISSOCIATED SPECIES EQUILIBRIA
1881 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
1885 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1886 GGCL = MAX(GG-GGNO3, ZERO)
1887 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
1888 IF (GGNO3.GT.TINY) THEN
1889 IF (GGCL.LE.TINY) HI = ZERO
1890 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1893 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1895 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
1902 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1912 ! *** CALCULATE WATER **************************************************
1916 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1918 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1921 IF (PSCONV1 .AND. PSCONV4 .AND. PSCONV6) GOTO 20
1924 !cc CALL PUSHERR (0002, 'CALCQ2A') ! WARNING ERROR: NO CONVERGENCE
1926 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1928 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1929 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1930 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1940 CNH42S4 = CHI6 - PSI6
1942 CNH4CL = CHI4 - PSI4
1945 CNA2SO4 = CHI1 - PSI1
1949 ! *** END OF SUBROUTINE CALCQ2A *****************************************
1951 END SUBROUTINE CALCQ2A
1952 !=======================================================================
1954 ! *** ISORROPIA CODE
1955 ! *** SUBROUTINE CALCQ1
1958 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1959 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
1960 ! 2. SOLID AEROSOL ONLY
1961 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
1963 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1964 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
1965 ! *** WRITTEN BY ATHANASIOS NENES
1967 !=======================================================================
1971 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
1972 ! INCLUDE 'ISRPIA.INC'
1974 EXTERNAL CALCQ1A, CALCQ2A, CALCQ3A, CALCQ4
1976 ! *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
1978 EXNO = WAER(4).GT.TINY
1979 EXCL = WAER(5).GT.TINY
1981 IF (EXNO .AND. EXCL) THEN ! *** NITRATE & CHLORIDE EXIST
1982 IF (RH.LT.DRMG1) THEN
1983 SCASE = 'Q1 ; SUBCASE 1'
1984 CALL CALCQ1A ! SOLID
1985 SCASE = 'Q1 ; SUBCASE 1'
1987 SCASE = 'Q1 ; SUBCASE 2' ! MDRH (NH4)2SO4, NA2SO4, NH4CL, NH4NO3
1988 CALL CALCMDRP (RH, DRMG1, DRNH4NO3, CALCQ1A, CALCQ2A)
1989 SCASE = 'Q1 ; SUBCASE 2'
1992 ELSE IF (EXNO .AND. .NOT.EXCL) THEN ! *** ONLY NITRATE EXISTS
1993 IF (RH.LT.DRMQ1) THEN
1994 SCASE = 'Q1 ; SUBCASE 1'
1995 CALL CALCQ1A ! SOLID
1996 SCASE = 'Q1 ; SUBCASE 1'
1998 SCASE = 'Q1 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4NO3
1999 CALL CALCMDRP (RH, DRMQ1, DRNH4NO3, CALCQ1A, CALCQ2A)
2000 SCASE = 'Q1 ; SUBCASE 3'
2003 ELSE IF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
2004 IF (RH.LT.DRMG2) THEN
2005 SCASE = 'Q1 ; SUBCASE 1'
2006 CALL CALCQ1A ! SOLID
2007 SCASE = 'Q1 ; SUBCASE 1'
2009 SCASE = 'Q1 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
2010 CALL CALCMDRP (RH, DRMG2, DRNH4CL, CALCQ1A, CALCQ3A)
2011 SCASE = 'Q1 ; SUBCASE 4'
2014 ELSE ! *** NO CHLORIDE AND NITRATE
2015 IF (RH.LT.DRMG3) THEN
2016 SCASE = 'Q1 ; SUBCASE 1'
2017 CALL CALCQ1A ! SOLID
2018 SCASE = 'Q1 ; SUBCASE 1'
2020 SCASE = 'Q1 ; SUBCASE 5' ! MDRH (NH4)2SO4, NA2SO4
2021 CALL CALCMDRP (RH, DRMG3, DRNH42S4, CALCQ1A, CALCQ4)
2022 SCASE = 'Q1 ; SUBCASE 5'
2028 ! *** END OF SUBROUTINE CALCQ1 ******************************************
2030 END SUBROUTINE CALCQ1
2033 !=======================================================================
2035 ! *** ISORROPIA CODE
2036 ! *** SUBROUTINE CALCQ1A
2037 ! *** CASE Q1 ; SUBCASE 1
2039 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2040 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2041 ! 2. SOLID AEROSOL ONLY
2042 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
2044 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2045 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2046 ! *** WRITTEN BY ATHANASIOS NENES
2048 !=======================================================================
2052 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2053 ! INCLUDE 'ISRPIA.INC'
2055 ! *** CALCULATE SOLIDS **************************************************
2057 CNA2SO4 = 0.5d0*WAER(1)
2058 FRSO4 = MAX (WAER(2)-CNA2SO4, ZERO)
2060 CNH42S4 = MAX (MIN(FRSO4,0.5d0*WAER(3)), TINY)
2061 FRNH3 = MAX (WAER(3)-2.D0*CNH42S4, ZERO)
2063 CNH4NO3 = MIN (FRNH3, WAER(4))
2064 !CC FRNO3 = MAX (WAER(4)-CNH4NO3, ZERO)
2065 FRNH3 = MAX (FRNH3-CNH4NO3, ZERO)
2067 CNH4CL = MIN (FRNH3, WAER(5))
2068 !CC FRCL = MAX (WAER(5)-CNH4CL, ZERO)
2069 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
2071 ! *** OTHER PHASES ******************************************************
2081 ! *** END OF SUBROUTINE CALCQ1A *****************************************
2083 END SUBROUTINE CALCQ1A
2084 !=======================================================================
2086 ! *** ISORROPIA CODE
2087 ! *** SUBROUTINE CALCR6
2090 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2091 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2092 ! 2. THERE IS ONLY A LIQUID PHASE
2094 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2095 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2096 ! *** WRITTEN BY ATHANASIOS NENES
2098 !=======================================================================
2103 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2104 ! INCLUDE 'ISRPIA.INC'
2106 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2107 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2108 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
2109 ! A1, A2, A3, A4, A5, A6, A7, A8
2111 ! *** SETUP PARAMETERS ************************************************
2125 ! *** CALCULATE WATER **************************************************
2129 ! *** SETUP LIQUID CONCENTRATIONS **************************************
2136 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2139 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2147 ! SOLUTION ACIDIC OR BASIC?
2149 GG = 2.D0*WAER(2) + NO3I + CLI - NAI - NH4I
2150 IF (GG.GT.TINY) THEN ! H+ in excess
2153 DD = BB*BB - 4.D0*CC
2154 HI = 0.5D0*(-BB + SQRT(DD))
2156 ELSE ! OH- in excess
2159 DD = BB*BB - 4.D0*CC
2160 OHI= 0.5D0*(-BB + SQRT(DD))
2164 ! UNDISSOCIATED SPECIES EQUILIBRIA
2167 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
2170 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2171 GGCL = MAX(GG-GGNO3, ZERO)
2172 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
2173 IF (GGNO3.GT.TINY) THEN
2174 IF (GGCL.LE.TINY) HI = ZERO
2175 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2178 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2180 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
2187 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2197 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2199 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2205 !cc CALL PUSHERR (0002, 'CALCR6') ! WARNING ERROR: NO CONVERGENCE
2207 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2209 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2210 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2211 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2230 ! *** END OF SUBROUTINE CALCR6 ******************************************
2232 END SUBROUTINE CALCR6
2233 !=======================================================================
2235 ! *** ISORROPIA CODE
2236 ! *** SUBROUTINE CALCR5
2239 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2240 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2241 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2243 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2244 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2245 ! *** WRITTEN BY ATHANASIOS NENES
2247 !=======================================================================
2252 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2253 ! INCLUDE 'ISRPIA.INC'
2256 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2257 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2258 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
2259 ! A1, A2, A3, A4, A5, A6, A7, A8
2261 LOGICAL NEAN, NEAC, NESN, NESC
2263 ! *** SETUP PARAMETERS ************************************************
2265 CALL CALCR1A ! DRY SOLUTION
2267 NEAN = CNH4NO3.LE.TINY ! NH4NO3 ! Water exists?
2268 NEAC = CNH4CL .LE.TINY ! NH4CL
2269 NESN = CNANO3 .LE.TINY ! NANO3
2270 NESC = CNACL .LE.TINY ! NACL
2271 IF (NEAN .AND. NEAC .AND. NESN .AND. NESC) RETURN
2283 ! *** CALCULATE WATER **************************************************
2292 ! *** SETUP LIQUID CONCENTRATIONS **************************************
2304 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2307 A5 = XK5*(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2308 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2313 IF (NAI*NAI*SO4I .GT. A5) THEN
2316 DD =-CHI1**3.0 + 0.25D0*A5
2317 CALL POLY3(BB, CC, DD, ROOT, ISLV)
2318 IF (ISLV.NE.0) ROOT = TINY
2319 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
2322 PSCONV = ABS(PSI1-PSIO) .LE. EPS*PSIO
2325 ! ION CONCENTRATIONS
2327 NAI = WAER(1) - 2.D0*ROOT
2328 SO4I = WAER(2) - ROOT
2333 ! SOLUTION ACIDIC OR BASIC?
2335 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2336 IF (GG.GT.TINY) THEN ! H+ in excess
2339 DD = BB*BB - 4.D0*CC
2340 HI = 0.5D0*(-BB + SQRT(DD))
2342 ELSE ! OH- in excess
2345 DD = BB*BB - 4.D0*CC
2346 OHI= 0.5D0*(-BB + SQRT(DD))
2350 ! UNDISSOCIATED SPECIES EQUILIBRIA
2353 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
2356 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2357 GGCL = MAX(GG-GGNO3, ZERO)
2358 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
2359 IF (GGNO3.GT.TINY) THEN
2360 IF (GGCL.LE.TINY) HI = ZERO
2361 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2364 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2366 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
2373 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2383 ! *** CALCULATE WATER **************************************************
2387 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2389 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2395 !cc CALL PUSHERR (0002, 'CALCR5') ! WARNING ERROR: NO CONVERGENCE
2397 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2399 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2400 !C A21 = XK21*WATER*R*TEMP
2401 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2402 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2404 GNH3 = NH4I/HI/A2 ! NH4I*OHI/A2/AKW
2417 CNA2SO4 = CHI1 - PSI1
2421 ! *** END OF SUBROUTINE CALCR5 ******************************************
2423 END SUBROUTINE CALCR5
2424 !=======================================================================
2426 ! *** ISORROPIA CODE
2427 ! *** SUBROUTINE CALCR4
2430 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2431 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
2432 ! 2. SOLID AEROSOL ONLY
2433 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
2435 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2436 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2437 ! *** WRITTEN BY ATHANASIOS NENES
2439 !=======================================================================
2443 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2444 ! INCLUDE 'ISRPIA.INC'
2445 LOGICAL EXAN, EXAC, EXSN, EXSC
2446 EXTERNAL CALCR1A, CALCR5
2448 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
2450 SCASE = 'R4 ; SUBCASE 2'
2451 CALL CALCR1A ! SOLID
2452 SCASE = 'R4 ; SUBCASE 2'
2454 EXAN = CNH4NO3.GT.TINY ! NH4NO3
2455 EXAC = CNH4CL .GT.TINY ! NH4CL
2456 EXSN = CNANO3 .GT.TINY ! NANO3
2457 EXSC = CNACL .GT.TINY ! NACL
2459 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
2461 IF (EXAN .OR. EXSN .OR. EXSC) THEN ! *** NH4NO3,NANO3 EXIST
2462 IF (RH.GE.DRMH1) THEN
2463 SCASE = 'R4 ; SUBCASE 1'
2465 SCASE = 'R4 ; SUBCASE 1'
2468 ELSE IF (EXAC) THEN ! *** NH4CL EXISTS ONLY
2469 IF (RH.GE.DRMR5) THEN
2470 SCASE = 'R4 ; SUBCASE 3'
2471 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR5)
2472 SCASE = 'R4 ; SUBCASE 3'
2478 ! *** END OF SUBROUTINE CALCR4 ******************************************
2480 END SUBROUTINE CALCR4
2484 !=======================================================================
2486 ! *** ISORROPIA CODE
2487 ! *** SUBROUTINE CALCR4A
2490 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2491 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2492 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2494 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2495 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2496 ! *** WRITTEN BY ATHANASIOS NENES
2498 !=======================================================================
2503 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2504 ! INCLUDE 'ISRPIA.INC'
2506 LOGICAL PSCONV1, PSCONV4
2507 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2508 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2509 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
2510 ! A1, A2, A3, A4, A5, A6, A7, A8
2512 ! *** SETUP PARAMETERS ************************************************
2522 ! *** CALCULATE INITIAL SOLUTION ***************************************
2526 CHI1 = CNA2SO4 ! SALTS
2537 NAI = WAER(1) ! LIQUID CONCENTRATIONS
2547 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2550 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2551 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
2552 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2557 IF (NAI*NAI*SO4I .GT. A5) THEN
2560 DD =-CHI1**3.0 + 0.25D0*A5
2561 CALL POLY3(BB, CC, DD, ROOT, ISLV)
2562 IF (ISLV.NE.0) ROOT = TINY
2563 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
2565 NAI = WAER(1) - 2.D0*ROOT
2566 SO4I = WAER(2) - ROOT
2568 PSCONV1 = ABS(PSI1-PSIO1) .LE. EPS*PSIO1
2574 IF (NH4I*CLI .GT. A14) THEN
2577 DD = BB*BB - 4.D0*CC
2578 ROOT = 0.5D0*(-BB-SQRT(DD))
2579 IF (ROOT.GT.TINY) THEN
2580 ROOT = MIN(ROOT, CHI4)
2582 NH4I = WAER(3) - ROOT
2583 CLI = WAER(5) - ROOT
2586 PSCONV4 = ABS(PSI4-PSIO4) .LE. EPS*PSIO4
2591 ! SOLUTION ACIDIC OR BASIC?
2593 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2594 IF (GG.GT.TINY) THEN ! H+ in excess
2597 DD = BB*BB - 4.D0*CC
2598 HI = 0.5D0*(-BB + SQRT(DD))
2600 ELSE ! OH- in excess
2603 DD = BB*BB - 4.D0*CC
2604 OHI= 0.5D0*(-BB + SQRT(DD))
2608 ! UNDISSOCIATED SPECIES EQUILIBRIA
2611 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
2614 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2615 GGCL = MAX(GG-GGNO3, ZERO)
2616 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
2617 IF (GGNO3.GT.TINY) THEN
2618 IF (GGCL.LE.TINY) HI = ZERO
2619 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2622 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2624 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
2631 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2641 ! *** CALCULATE WATER **************************************************
2645 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2647 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2650 IF (PSCONV1 .AND. PSCONV4) GOTO 20
2653 !cc CALL PUSHERR (0002, 'CALCR4A') ! WARNING ERROR: NO CONVERGENCE
2655 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2657 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2658 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2659 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2671 CNH4CL = CHI4 - PSI4
2674 CNA2SO4 = CHI1 - PSI1
2678 ! *** END OF SUBROUTINE CALCR4A *****************************************
2680 END SUBROUTINE CALCR4A
2681 !=======================================================================
2683 ! *** ISORROPIA CODE
2684 ! *** SUBROUTINE CALCR3
2687 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2688 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
2689 ! 2. SOLID AEROSOL ONLY
2690 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
2692 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2693 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2694 ! *** WRITTEN BY ATHANASIOS NENES
2696 !=======================================================================
2700 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2701 ! INCLUDE 'ISRPIA.INC'
2702 LOGICAL EXAN, EXAC, EXSN, EXSC
2703 EXTERNAL CALCR1A, CALCR4A, CALCR5
2705 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
2707 SCASE = 'R3 ; SUBCASE 2'
2708 CALL CALCR1A ! SOLID
2709 SCASE = 'R3 ; SUBCASE 2'
2711 EXAN = CNH4NO3.GT.TINY ! NH4NO3
2712 EXAC = CNH4CL .GT.TINY ! NH4CL
2713 EXSN = CNANO3 .GT.TINY ! NANO3
2714 EXSC = CNACL .GT.TINY ! NACL
2716 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
2718 IF (EXAN .OR. EXSN) THEN ! *** NH4NO3,NANO3 EXIST
2719 IF (RH.GE.DRMH1) THEN
2720 SCASE = 'R3 ; SUBCASE 1'
2722 SCASE = 'R3 ; SUBCASE 1'
2725 ELSE IF (.NOT.EXAN .AND. .NOT.EXSN) THEN ! *** NH4NO3,NANO3 = 0
2726 IF ( EXAC .AND. EXSC) THEN
2727 IF (RH.GE.DRMR4) THEN
2728 SCASE = 'R3 ; SUBCASE 3'
2729 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR4A)
2730 SCASE = 'R3 ; SUBCASE 3'
2733 ELSE IF (.NOT.EXAC .AND. EXSC) THEN
2734 IF (RH.GE.DRMR2) THEN
2735 SCASE = 'R3 ; SUBCASE 4'
2736 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR4A)
2737 SCASE = 'R3 ; SUBCASE 4'
2740 ELSE IF ( EXAC .AND. .NOT.EXSC) THEN
2741 IF (RH.GE.DRMR5) THEN
2742 SCASE = 'R3 ; SUBCASE 5'
2743 CALL CALCMDRP (RH, DRMR5, DRNACL, CALCR1A, CALCR5)
2744 SCASE = 'R3 ; SUBCASE 5'
2752 ! *** END OF SUBROUTINE CALCR3 ******************************************
2754 END SUBROUTINE CALCR3
2757 !=======================================================================
2759 ! *** ISORROPIA CODE
2760 ! *** SUBROUTINE CALCR3A
2763 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2764 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2765 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2767 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2768 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
2769 ! *** WRITTEN BY ATHANASIOS NENES
2771 !=======================================================================
2776 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
2777 ! INCLUDE 'ISRPIA.INC'
2779 LOGICAL PSCONV1, PSCONV3, PSCONV4
2780 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2781 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2782 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
2783 ! A1, A2, A3, A4, A5, A6, A7, A8
2785 ! *** SETUP PARAMETERS ************************************************
2800 ! *** CALCULATE INITIAL SOLUTION ***************************************
2804 CHI1 = CNA2SO4 ! SALTS
2816 NAI = WAER(1) ! LIQUID CONCENTRATIONS
2834 CALL CALCACT ! CALCULATE ACTIVITY COEFFICIENTS
2836 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2839 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2840 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
2841 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
2842 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2846 IF (NH4I*CLI .GT. A14) THEN
2847 BB =-(WAER(3) + WAER(5) - ROOT3)
2848 CC =-A14 + NH4I*(WAER(5) - ROOT3)
2849 DD = MAX(BB*BB - 4.D0*CC, ZERO)
2850 ROOT2A= 0.5D0*(-BB+SQRT(DD))
2851 ROOT2B= 0.5D0*(-BB-SQRT(DD))
2852 IF (ZERO.LE.ROOT2A) THEN
2857 ROOT2 = MIN(MAX(ZERO, ROOT2), MAX(WAER(5)-ROOT3,ZERO), &
2861 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
2866 IF (NAI*NAI*SO4I .GT. A5) THEN
2867 BB =-(CHI1 + WAER(1) - ROOT3)
2868 CC = 0.25D0*(WAER(1) - ROOT3)*(4.D0*CHI1+WAER(1)-ROOT3)
2869 DD =-0.25D0*(CHI1*(WAER(1)-ROOT3)**2.D0 - A5)
2870 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
2871 IF (ISLV.NE.0) ROOT1 = TINY
2872 ROOT1 = MIN (MAX(ROOT1,ZERO), MAX(WAER(1)-ROOT3,ZERO), &
2876 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
2879 ! ION CONCENTRATIONS
2881 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3)
2882 SO4I= WAER(2) - ROOT1
2883 NH4I= WAER(3) - ROOT2
2884 CLI = WAER(5) - (ROOT3 + ROOT2)
2887 ! SODIUM CHLORIDE ; To obtain new value for ROOT3
2889 IF (NAI*CLI .GT. A8) THEN
2890 BB =-((CHI1-2.D0*ROOT1) + (WAER(5) - ROOT2))
2891 CC = (CHI1-2.D0*ROOT1)*(WAER(5) - ROOT2) - A8
2892 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
2893 ROOT3A= 0.5D0*(-BB-SQRT(DD))
2894 ROOT3B= 0.5D0*(-BB+SQRT(DD))
2895 IF (ZERO.LE.ROOT3A) THEN
2900 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
2903 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
2906 ! SOLUTION ACIDIC OR BASIC?
2908 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2909 IF (GG.GT.TINY) THEN ! H+ in excess
2912 DD = BB*BB - 4.D0*CC
2913 HI = 0.5D0*(-BB + SQRT(DD))
2915 ELSE ! OH- in excess
2918 DD = BB*BB - 4.D0*CC
2919 OHI= 0.5D0*(-BB + SQRT(DD))
2923 ! UNDISSOCIATED SPECIES EQUILIBRIA
2926 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
2929 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2930 GGCL = MAX(GG-GGNO3, ZERO)
2931 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
2932 IF (GGNO3.GT.TINY) THEN
2933 IF (GGCL.LE.TINY) HI = ZERO
2934 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2937 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2939 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
2946 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2956 ! *** CALCULATE WATER **************************************************
2960 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2962 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2965 IF (PSCONV1.AND.PSCONV3.AND.PSCONV4) GOTO 20
2968 !cc CALL PUSHERR (0002, 'CALCR3A') ! WARNING ERROR: NO CONVERGENCE
2970 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2972 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
2981 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2982 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2983 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2995 CNH4CL = CHI4 - PSI4
2998 CNA2SO4 = CHI1 - PSI1
3003 ! *** END OF SUBROUTINE CALCR3A *****************************************
3005 END SUBROUTINE CALCR3A
3006 !=======================================================================
3008 ! *** ISORROPIA CODE
3009 ! *** SUBROUTINE CALCR2
3012 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3013 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3014 ! 2. SOLID AEROSOL ONLY
3015 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
3017 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3018 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3019 ! *** WRITTEN BY ATHANASIOS NENES
3021 !=======================================================================
3025 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
3026 ! INCLUDE 'ISRPIA.INC'
3027 LOGICAL EXAN, EXAC, EXSN, EXSC
3028 EXTERNAL CALCR1A, CALCR3A, CALCR4A, CALCR5
3030 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
3032 SCASE = 'R2 ; SUBCASE 2'
3033 CALL CALCR1A ! SOLID
3034 SCASE = 'R2 ; SUBCASE 2'
3036 EXAN = CNH4NO3.GT.TINY ! NH4NO3
3037 EXAC = CNH4CL .GT.TINY ! NH4CL
3038 EXSN = CNANO3 .GT.TINY ! NANO3
3039 EXSC = CNACL .GT.TINY ! NACL
3041 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
3043 IF (EXAN) THEN ! *** NH4NO3 EXISTS
3044 IF (RH.GE.DRMH1) THEN
3045 SCASE = 'R2 ; SUBCASE 1'
3047 SCASE = 'R2 ; SUBCASE 1'
3050 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
3051 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
3052 IF (RH.GE.DRMH2) THEN
3053 SCASE = 'R2 ; SUBCASE 3'
3054 CALL CALCMDRP (RH, DRMH2, DRNANO3, CALCR1A, CALCR3A)
3055 SCASE = 'R2 ; SUBCASE 3'
3058 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
3059 IF (RH.GE.DRMR1) THEN
3060 SCASE = 'R2 ; SUBCASE 4'
3061 CALL CALCMDRP (RH, DRMR1, DRNANO3, CALCR1A, CALCR3A)
3062 SCASE = 'R2 ; SUBCASE 4'
3065 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3066 IF (RH.GE.DRMR2) THEN
3067 SCASE = 'R2 ; SUBCASE 5'
3068 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR4A)
3069 SCASE = 'R2 ; SUBCASE 5'
3072 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3073 IF (RH.GE.DRMR3) THEN
3074 SCASE = 'R2 ; SUBCASE 6'
3075 CALL CALCMDRP (RH, DRMR3, DRNANO3, CALCR1A, CALCR3A)
3076 SCASE = 'R2 ; SUBCASE 6'
3079 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3080 IF (RH.GE.DRMR4) THEN
3081 SCASE = 'R2 ; SUBCASE 7'
3082 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR4A)
3083 SCASE = 'R2 ; SUBCASE 7'
3086 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3087 IF (RH.GE.DRMR5) THEN
3088 SCASE = 'R2 ; SUBCASE 8'
3089 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR5)
3090 SCASE = 'R2 ; SUBCASE 8'
3093 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3094 IF (RH.GE.DRMR6) THEN
3095 SCASE = 'R2 ; SUBCASE 9'
3096 CALL CALCMDRP (RH, DRMR6, DRNANO3, CALCR1A, CALCR3A)
3097 SCASE = 'R2 ; SUBCASE 9'
3105 ! *** END OF SUBROUTINE CALCR2 ******************************************
3107 END SUBROUTINE CALCR2
3110 !=======================================================================
3112 ! *** ISORROPIA CODE
3113 ! *** SUBROUTINE CALCR2A
3116 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3117 ! 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
3118 ! 2. LIQUID AND SOLID PHASES ARE POSSIBLE
3120 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3121 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3122 ! *** WRITTEN BY ATHANASIOS NENES
3124 !=======================================================================
3129 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
3130 ! INCLUDE 'ISRPIA.INC'
3132 LOGICAL PSCONV1, PSCONV2, PSCONV3, PSCONV4
3133 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
3134 ! COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3135 ! PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, PSI8, &
3136 ! A1, A2, A3, A4, A5, A6, A7, A8
3138 ! *** SETUP PARAMETERS ************************************************
3159 ! *** CALCULATE INITIAL SOLUTION ***************************************
3163 CHI1 = CNA2SO4 ! SALTS
3176 NAI = WAER(1) ! LIQUID CONCENTRATIONS
3194 CALL CALCACT ! CALCULATE ACTIVITY COEFFICIENTS
3196 ! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3199 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
3200 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
3201 A9 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
3202 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
3203 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
3207 IF (NH4I*CLI .GT. A14) THEN
3208 BB =-(WAER(3) + WAER(5) - ROOT3)
3209 CC = NH4I*(WAER(5) - ROOT3) - A14
3210 DD = MAX(BB*BB - 4.D0*CC, ZERO)
3212 ROOT2A= 0.5D0*(-BB+DD)
3213 ROOT2B= 0.5D0*(-BB-DD)
3214 IF (ZERO.LE.ROOT2A) THEN
3219 ROOT2 = MIN(MAX(ROOT2, ZERO), CHI4)
3222 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
3227 IF (NAI*NAI*SO4I .GT. A5) THEN
3228 BB =-(WAER(2) + WAER(1) - ROOT3 - ROOT4)
3229 CC = WAER(1)*(2.D0*ROOT3 + 2.D0*ROOT4 - 4.D0*WAER(2) - ONE) &
3230 -(ROOT3 + ROOT4)**2.0 + 4.D0*WAER(2)*(ROOT3 + ROOT4)
3232 DD = WAER(1)*WAER(2)*(ONE - 2.D0*ROOT3 - 2.D0*ROOT4) + &
3233 WAER(2)*(ROOT3 + ROOT4)**2.0 - A5
3235 CALL POLY3(BB, CC, DD, ROOT1, ISLV)
3236 IF (ISLV.NE.0) ROOT1 = TINY
3237 ROOT1 = MIN (MAX(ROOT1,ZERO), CHI1)
3240 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
3245 IF (NAI*NO3I .GT. A9) THEN
3246 BB =-(WAER(4) + WAER(1) - 2.D0*ROOT1 - ROOT3)
3247 CC = WAER(4)*(WAER(1) - 2.D0*ROOT1 - ROOT3) - A9
3248 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
3249 ROOT4A= 0.5D0*(-BB-DD)
3250 ROOT4B= 0.5D0*(-BB+DD)
3251 IF (ZERO.LE.ROOT4A) THEN
3256 ROOT4 = MIN(MAX(ROOT4, ZERO), CHI2)
3259 PSCONV2 = ABS(PSI2-PSI2O) .LE. EPS*PSI2O
3262 ! ION CONCENTRATIONS
3264 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3 + ROOT4)
3265 SO4I= WAER(2) - ROOT1
3266 NH4I= WAER(3) - ROOT2
3267 NO3I= WAER(4) - ROOT4
3268 CLI = WAER(5) - (ROOT3 + ROOT2)
3270 ! SODIUM CHLORIDE ; To obtain new value for ROOT3
3272 IF (NAI*CLI .GT. A8) THEN
3273 BB =-(WAER(1) - 2.D0*ROOT1 + WAER(5) - ROOT2 - ROOT4)
3274 CC = (WAER(5) + ROOT2)*(WAER(1) - 2.D0*ROOT1 - ROOT4) - A8
3275 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
3276 ROOT3A= 0.5D0*(-BB-DD)
3277 ROOT3B= 0.5D0*(-BB+DD)
3278 IF (ZERO.LE.ROOT3A) THEN
3283 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
3286 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
3289 ! SOLUTION ACIDIC OR BASIC?
3291 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
3292 IF (GG.GT.TINY) THEN ! H+ in excess
3295 DD = BB*BB - 4.D0*CC
3296 HI = 0.5D0*(-BB + SQRT(DD))
3298 ELSE ! OH- in excess
3301 DD = BB*BB - 4.D0*CC
3302 OHI= 0.5D0*(-BB + SQRT(DD))
3306 ! UNDISSOCIATED SPECIES EQUILIBRIA
3309 CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
3312 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
3313 GGCL = MAX(GG-GGNO3, ZERO)
3314 IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
3315 IF (GGNO3.GT.TINY) THEN
3316 IF (GGCL.LE.TINY) HI = ZERO
3317 CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
3320 ! CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
3322 CALL CALCHS4 (HI, SO4I, ZERO, DEL)
3329 ! *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
3339 ! *** CALCULATE WATER **************************************************
3343 ! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
3345 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3348 IF (PSCONV1.AND.PSCONV2.AND.PSCONV3.AND.PSCONV4) GOTO 20
3351 !cc CALL PUSHERR (0002, 'CALCR2A') ! WARNING ERROR: NO CONVERGENCE
3353 ! *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3355 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
3363 ELSE ! OK, aqueous phase present
3364 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
3365 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
3366 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
3378 CNH4CL = CHI4 - PSI4
3380 CNANO3 = CHI2 - PSI2
3381 CNA2SO4 = CHI1 - PSI1
3386 ! *** END OF SUBROUTINE CALCR2A *****************************************
3388 END SUBROUTINE CALCR2A
3389 !=======================================================================
3391 ! *** ISORROPIA CODE
3392 ! *** SUBROUTINE CALCR1
3395 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3396 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3397 ! 2. SOLID AEROSOL ONLY
3398 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
3400 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3401 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3402 ! *** WRITTEN BY ATHANASIOS NENES
3404 !=======================================================================
3408 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
3409 ! INCLUDE 'ISRPIA.INC'
3410 LOGICAL EXAN, EXAC, EXSN, EXSC
3411 EXTERNAL CALCR1A, CALCR2A, CALCR3A, CALCR4A, CALCR5
3413 ! *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
3415 SCASE = 'R1 ; SUBCASE 1'
3416 CALL CALCR1A ! SOLID
3417 SCASE = 'R1 ; SUBCASE 1'
3419 EXAN = CNH4NO3.GT.TINY ! NH4NO3
3420 EXAC = CNH4CL .GT.TINY ! NH4CL
3421 EXSN = CNANO3 .GT.TINY ! NANO3
3422 EXSC = CNACL .GT.TINY ! NACL
3424 ! *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
3426 IF (EXAN.AND.EXAC.AND.EXSC.AND.EXSN) THEN ! *** ALL EXIST
3427 IF (RH.GE.DRMH1) THEN
3428 SCASE = 'R1 ; SUBCASE 2' ! MDRH
3429 CALL CALCMDRP (RH, DRMH1, DRNH4NO3, CALCR1A, CALCR2A)
3430 SCASE = 'R1 ; SUBCASE 2'
3433 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
3434 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
3435 IF (RH.GE.DRMH2) THEN
3436 SCASE = 'R1 ; SUBCASE 3'
3437 CALL CALCMDRP (RH, DRMH2, DRNANO3, CALCR1A, CALCR3A)
3438 SCASE = 'R1 ; SUBCASE 3'
3441 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
3442 IF (RH.GE.DRMR1) THEN
3443 SCASE = 'R1 ; SUBCASE 4'
3444 CALL CALCMDRP (RH, DRMR1, DRNANO3, CALCR1A, CALCR3A)
3445 SCASE = 'R1 ; SUBCASE 4'
3448 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3449 IF (RH.GE.DRMR2) THEN
3450 SCASE = 'R1 ; SUBCASE 5'
3451 CALL CALCMDRP (RH, DRMR2, DRNACL, CALCR1A, CALCR3A) !, CALCR4A)
3452 SCASE = 'R1 ; SUBCASE 5'
3455 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3456 IF (RH.GE.DRMR3) THEN
3457 SCASE = 'R1 ; SUBCASE 6'
3458 CALL CALCMDRP (RH, DRMR3, DRNANO3, CALCR1A, CALCR3A)
3459 SCASE = 'R1 ; SUBCASE 6'
3462 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3463 IF (RH.GE.DRMR4) THEN
3464 SCASE = 'R1 ; SUBCASE 7'
3465 CALL CALCMDRP (RH, DRMR4, DRNACL, CALCR1A, CALCR3A) !, CALCR4A)
3466 SCASE = 'R1 ; SUBCASE 7'
3469 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3470 IF (RH.GE.DRMR5) THEN
3471 SCASE = 'R1 ; SUBCASE 8'
3472 CALL CALCMDRP (RH, DRMR5, DRNH4CL, CALCR1A, CALCR3A) !, CALCR5)
3473 SCASE = 'R1 ; SUBCASE 8'
3476 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3477 IF (RH.GE.DRMR6) THEN
3478 SCASE = 'R1 ; SUBCASE 9'
3479 CALL CALCMDRP (RH, DRMR6, DRNANO3, CALCR1A, CALCR3A)
3480 SCASE = 'R1 ; SUBCASE 9'
3484 ELSE IF (.NOT.EXAC) THEN ! *** NH4CL = 0
3485 IF ( EXAN .AND. EXSN .AND. EXSC) THEN
3486 IF (RH.GE.DRMR7) THEN
3487 SCASE = 'R1 ; SUBCASE 10'
3488 CALL CALCMDRP (RH, DRMR7, DRNH4NO3, CALCR1A, CALCR2A)
3489 SCASE = 'R1 ; SUBCASE 10'
3492 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. EXSC) THEN
3493 IF (RH.GE.DRMR8) THEN
3494 SCASE = 'R1 ; SUBCASE 11'
3495 CALL CALCMDRP (RH, DRMR8, DRNH4NO3, CALCR1A, CALCR2A)
3496 SCASE = 'R1 ; SUBCASE 11'
3499 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3500 IF (RH.GE.DRMR9) THEN
3501 SCASE = 'R1 ; SUBCASE 12'
3502 CALL CALCMDRP (RH, DRMR9, DRNH4NO3, CALCR1A, CALCR2A)
3503 SCASE = 'R1 ; SUBCASE 12'
3506 ELSE IF ( EXAN .AND. EXSN .AND. .NOT.EXSC) THEN
3507 IF (RH.GE.DRMR10) THEN
3508 SCASE = 'R1 ; SUBCASE 13'
3509 CALL CALCMDRP (RH, DRMR10, DRNH4NO3, CALCR1A, CALCR2A)
3510 SCASE = 'R1 ; SUBCASE 13'
3514 ELSE IF (.NOT.EXSN) THEN ! *** NANO3 = 0
3515 IF ( EXAN .AND. EXAC .AND. EXSC) THEN
3516 IF (RH.GE.DRMR11) THEN
3517 SCASE = 'R1 ; SUBCASE 14'
3518 CALL CALCMDRP (RH, DRMR11, DRNH4NO3, CALCR1A, CALCR2A)
3519 SCASE = 'R1 ; SUBCASE 14'
3522 ELSE IF ( EXAN .AND. EXAC .AND. .NOT.EXSC) THEN
3523 IF (RH.GE.DRMR12) THEN
3524 SCASE = 'R1 ; SUBCASE 15'
3525 CALL CALCMDRP (RH, DRMR12, DRNH4NO3, CALCR1A, CALCR2A)
3526 SCASE = 'R1 ; SUBCASE 15'
3530 ELSE IF (.NOT.EXSC) THEN ! *** NACL = 0
3531 IF ( EXAN .AND. EXAC .AND. EXSN) THEN
3532 IF (RH.GE.DRMR13) THEN
3533 SCASE = 'R1 ; SUBCASE 16'
3534 CALL CALCMDRP (RH, DRMR13, DRNH4NO3, CALCR1A, CALCR2A)
3535 SCASE = 'R1 ; SUBCASE 16'
3542 ! *** END OF SUBROUTINE CALCR1 ******************************************
3544 END SUBROUTINE CALCR1
3547 !=======================================================================
3549 ! *** ISORROPIA CODE
3550 ! *** SUBROUTINE CALCR1A
3551 ! *** CASE R1 ; SUBCASE 1
3553 ! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3554 ! 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3555 ! 2. SOLID AEROSOL ONLY
3556 ! 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NANO3, NA2SO4, NANO3, NACL
3558 ! *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3559 ! *** GEORGIA INSTITUTE OF TECHNOLOGY
3560 ! *** WRITTEN BY ATHANASIOS NENES
3562 !=======================================================================
3566 IMPLICIT DOUBLE PRECISION (A-H, O-Z)
3567 ! INCLUDE 'ISRPIA.INC'
3569 ! *** CALCULATE SOLIDS **************************************************
3572 FRNA = MAX (WAER(1)-2*CNA2SO4, ZERO)
3576 CNANO3 = MIN (FRNA, WAER(4))
3577 FRNO3 = MAX (WAER(4)-CNANO3, ZERO)
3578 FRNA = MAX (FRNA-CNANO3, ZERO)
3580 CNACL = MIN (FRNA, WAER(5))
3581 FRCL = MAX (WAER(5)-CNACL, ZERO)
3582 FRNA = MAX (FRNA-CNACL, ZERO)
3584 CNH4NO3 = MIN (FRNO3, WAER(3))
3585 FRNO3 = MAX (FRNO3-CNH4NO3, ZERO)
3586 FRNH3 = MAX (WAER(3)-CNH4NO3, ZERO)
3588 CNH4CL = MIN (FRCL, FRNH3)
3589 FRCL = MAX (FRCL-CNH4CL, ZERO)
3590 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
3592 ! *** OTHER PHASES ******************************************************
3602 ! *** END OF SUBROUTINE CALCR1A *****************************************
3604 END SUBROUTINE CALCR1A