2 !C=======================================================================
5 !C *** SUBROUTINE ISRP1R
6 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
7 !C AN AMMONIUM-SULFATE AEROSOL SYSTEM.
8 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
9 !C THE AMBIENT RELATIVE HUMIDITY.
11 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13 !C *** WRITTEN BY ATHANASIOS NENES
15 !C=======================================================================
17 SUBROUTINE ISRP1R2p1 (WI, RHI, TEMPI)
18 INCLUDE 'module_isrpia_inc.F'
21 !C *** INITIALIZE COMMON BLOCK VARIABLES *********************************
23 CALL INIT12p1 (WI, RHI, TEMPI)
25 !C *** CALCULATE SULFATE RATIO *******************************************
27 IF (RH.GE.DRNH42S4) THEN ! WET AEROSOL, NEED NH4 AT SRATIO=2.0
28 SULRATW = GETASR2p1(WAER(2), RHI) ! AEROSOL SULFATE RATIO
30 SULRATW = 2.0D0 ! DRY AEROSOL SULFATE RATIO
32 SULRAT = WAER(3)/WAER(2) ! SULFATE RATIO
34 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
38 IF (SULRATW.LE.SULRAT) THEN
42 CALL CALCS22p1 ! Only liquid (metastable)
45 IF (RH.LT.DRNH42S4) THEN
47 CALL CALCS12p1 ! NH42SO4 ; case K1
49 ELSEIF (DRNH42S4.LE.RH) THEN
51 CALL CALCS22p1 ! Only liquid ; case K2
55 !C *** SULFATE RICH (NO ACID)
57 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
63 CALL CALCB42p1 ! Only liquid (metastable)
67 IF (RH.LT.DRNH4HS4) THEN
69 CALL CALCB12p1 ! NH4HSO4,LC,NH42SO4 ; case B1
72 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
74 CALL CALCB22p1 ! LC,NH42S4 ; case B2
77 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
79 CALL CALCB32p1 ! NH42S4 ; case B3
82 ELSEIF (DRNH42S4.LE.RH) THEN
84 CALL CALCB42p1 ! Only liquid ; case B4
89 CALL CALCNH3P2p1 ! Compute NH3(g)
91 !C *** SULFATE RICH (FREE ACID)
93 ELSEIF (SULRAT.LT.1.0) THEN
99 CALL CALCC22p1 ! Only liquid (metastable)
103 IF (RH.LT.DRNH4HS4) THEN
105 CALL CALCC12p1 ! NH4HSO4 ; case C1
108 ELSEIF (DRNH4HS4.LE.RH) THEN
110 CALL CALCC22p1 ! Only liquid ; case C2
120 !C *** END OF SUBROUTINE ISRP1R *****************************************
124 !C=======================================================================
126 !C *** ISORROPIA CODE
127 !C *** SUBROUTINE ISRP2R
128 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
129 !C AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
130 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
131 !C THE AMBIENT RELATIVE HUMIDITY.
133 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
134 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
135 !C *** WRITTEN BY ATHANASIOS NENES
137 !C=======================================================================
139 SUBROUTINE ISRP2R2p1 (WI, RHI, TEMPI)
140 INCLUDE 'module_isrpia_inc.F'
144 !C *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
146 TRYLIQ = .TRUE. ! Assume liquid phase, sulfate poor limit
148 10 CALL INIT22p1 (WI, RHI, TEMPI)
150 !C *** CALCULATE SULFATE RATIO *******************************************
152 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! *** WET AEROSOL
153 SULRATW = GETASR2p1(WAER(2), RHI) ! LIMITING SULFATE RATIO
155 SULRATW = 2.0D0 ! *** DRY AEROSOL
157 SULRAT = WAER(3)/WAER(2)
159 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
163 IF (SULRATW.LE.SULRAT) THEN
165 IF(METSTBL.EQ.1) THEN
167 CALL CALCN32p1 ! Only liquid (metastable)
170 IF (RH.LT.DRNH4NO3) THEN
172 CALL CALCN12p1 ! NH42SO4,NH4NO3 ; case N1
174 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH42S4) THEN
176 CALL CALCN22p1 ! NH42S4 ; case N2
178 ELSEIF (DRNH42S4.LE.RH) THEN
180 CALL CALCN32p1 ! Only liquid ; case N3
184 !C *** SULFATE RICH (NO ACID)
186 !C FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
187 !C ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
188 !C AEROSOL EQUILIBRIUM.
190 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
195 IF(METSTBL.EQ.1) THEN
197 CALL CALCB42p1 ! Only liquid (metastable)
201 IF (RH.LT.DRNH4HS4) THEN
203 CALL CALCB12p1 ! NH4HSO4,LC,NH42SO4 ; case O1
206 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
208 CALL CALCB22p1 ! LC,NH42S4 ; case O2
211 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
213 CALL CALCB32p1 ! NH42S4 ; case O3
216 ELSEIF (DRNH42S4.LE.RH) THEN
218 CALL CALCB42p1 ! Only liquid ; case O4
223 !C *** Add the NO3 to the solution now and calculate partitioning.
225 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
226 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
227 CALL CALCNAP2p1 ! HNO3, NH3 dissolved
230 !C *** SULFATE RICH (FREE ACID)
232 !C FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
233 !C ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
234 !C AEROSOL EQUILIBRIUM.
236 ELSEIF (SULRAT.LT.1.0) THEN
241 IF(METSTBL.EQ.1) THEN
243 CALL CALCC22p1 ! Only liquid (metastable)
247 IF (RH.LT.DRNH4HS4) THEN
249 CALL CALCC12p1 ! NH4HSO4 ; case P1
252 ELSEIF (DRNH4HS4.LE.RH) THEN
254 CALL CALCC22p1 ! Only liquid ; case P2
259 !C *** Add the NO3 to the solution now and calculate partitioning.
261 MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
262 MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
264 CALL CALCNAP2p1 ! HNO3, NH3 dissolved
268 !C *** IF SULRATW < SULRAT < 2.0 and WATER = 0 => SULFATE RICH CASE.
270 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 &
271 .AND. WATER.LE.TINY) THEN
278 !C *** END OF SUBROUTINE ISRP2R *****************************************
281 !C=======================================================================
283 !C *** ISORROPIA CODE
284 !C *** SUBROUTINE ISRP3R
285 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
286 !C AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
287 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
288 !C RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
290 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
291 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
292 !C *** WRITTEN BY ATHANASIOS NENES
294 !C=======================================================================
296 SUBROUTINE ISRP3R2p1 (WI, RHI, TEMPI)
297 INCLUDE 'module_isrpia_inc.F'
301 !ccC *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
303 !cc WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
304 !cc WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
306 !C *** INITIALIZE ALL VARIABLES ******************************************
308 TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
310 10 CALL ISOINIT32p1 (WI, RHI, TEMPI) ! COMMON block variables
312 !ccC *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
314 !cc REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
315 !cc IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
316 !cc WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
317 !cc CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
320 !C *** CALCULATE SULFATE & SODIUM RATIOS *********************************
322 IF (TRYLIQ .AND. RH.GE.DRNH4NO3) THEN ! ** WET AEROSOL
323 FRSO4 = WAER(2) - WAER(1)/2.0D0 ! SULFATE UNBOUND BY SODIUM
324 FRSO4 = MAX(FRSO4, TINY)
325 SRI = GETASR2p1(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
326 SULRATW = (WAER(1)+FRSO4*SRI)/WAER(2) ! LIMITING SULFATE RATIO
327 SULRATW = MIN (SULRATW, 2.0D0)
329 SULRATW = 2.0D0 ! ** DRY AEROSOL
331 SULRAT = (WAER(1)+WAER(3))/WAER(2)
332 SODRAT = WAER(1)/WAER(2)
334 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
336 !C *** SULFATE POOR ; SODIUM POOR
338 IF (SULRATW.LE.SULRAT .AND. SODRAT.LT.2.0) THEN
340 IF(METSTBL.EQ.1) THEN
342 CALL CALCQ52p1 ! Only liquid (metastable)
346 IF (RH.LT.DRNH4NO3) THEN
348 CALL CALCQ12p1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
350 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
352 CALL CALCQ22p1 ! NH42SO4,NH4CL,NA2SO4
354 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
356 CALL CALCQ32p1 ! NH42SO4,NA2SO4
358 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
360 CALL CALCQ42p1 ! NA2SO4
363 ELSEIF (DRNA2SO4.LE.RH) THEN
365 CALL CALCQ52p1 ! Only liquid
370 !C *** SULFATE POOR ; SODIUM RICH
372 ELSE IF (SULRAT.GE.SULRATW .AND. SODRAT.GE.2.0) THEN
374 IF(METSTBL.EQ.1) THEN
376 CALL CALCR62p1 ! Only liquid (metastable)
380 IF (RH.LT.DRNH4NO3) THEN
382 CALL CALCR12p1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
384 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
386 CALL CALCR22p1 ! NH4CL,NA2SO4,NACL,NANO3
388 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
390 CALL CALCR32p1 ! NH4CL,NA2SO4,NACL
392 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4CL) THEN
394 CALL CALCR42p1 ! NH4CL,NA2SO4
396 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNA2SO4) THEN
398 CALL CALCR52p1 ! NA2SO4
401 ELSEIF (DRNA2SO4.LE.RH) THEN
403 CALL CALCR62p1 ! NO SOLID
408 !C *** SULFATE RICH (NO ACID)
410 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.SULRATW) THEN
415 IF(METSTBL.EQ.1) THEN
417 CALL CALCI62p1 ! Only liquid (metastable)
421 IF (RH.LT.DRNH4HS4) THEN
423 CALL CALCI12p1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
426 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
428 CALL CALCI22p1 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
431 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
433 CALL CALCI32p1 ! NA2SO4,(NH4)2SO4,LC
436 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
438 CALL CALCI42p1 ! NA2SO4,(NH4)2SO4
441 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
443 CALL CALCI52p1 ! NA2SO4
446 ELSEIF (DRNA2SO4.LE.RH) THEN
448 CALL CALCI62p1 ! NO SOLIDS
453 CALL CALCNHP2p1 ! HNO3, NH3, HCL in gas phase
456 !C *** SULFATE RICH (FREE ACID)
458 ELSEIF (SULRAT.LT.1.0) THEN
463 IF(METSTBL.EQ.1) THEN
465 CALL CALCJ32p1 ! Only liquid (metastable)
469 IF (RH.LT.DRNH4HS4) THEN
471 CALL CALCJ12p1 ! NH4HSO4,NAHSO4
474 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
476 CALL CALCJ22p1 ! NAHSO4
479 ELSEIF (DRNAHSO4.LE.RH) THEN
486 CALL CALCNHP2p1 ! HNO3, NH3, HCL in gas phase
491 !C *** IF AFTER CALCULATIONS, SULRATW < SULRAT < 2.0
492 !C and WATER = 0 => SULFATE RICH CASE.
494 IF (SULRATW.LE.SULRAT .AND. SULRAT.LT.2.0 &
495 .AND. WATER.LE.TINY) THEN
502 !C *** END OF SUBROUTINE ISRP3R *****************************************
506 !C=======================================================================
508 !C *** ISORROPIA CODE II
509 !C *** SUBROUTINE ISRP4R
510 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
511 !C AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM-CALCIUM-POTTASIUM-MAGNESIUM AEROSOL SYSTEM.
512 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
513 !C RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
515 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
516 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
517 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
519 !C=======================================================================
521 SUBROUTINE ISRP4R2p1 (WI, RHI, TEMPI)
522 INCLUDE 'module_isrpia_inc.F'
526 !ccC *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
528 !cc WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
529 !cc WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
531 !C *** INITIALIZE ALL VARIABLES ******************************************
533 TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
534 IPROB = 1 ! SOLVE REVERSE PROBLEM
537 10 CALL INIT42p1 (WI, RHI, TEMPI) ! COMMON block variables
539 !ccC *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
541 !cc REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
542 !cc IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
543 !cc WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
544 !cc CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
547 !C *** CALCULATE SULFATE, CRUSTAL & SODIUM RATIOS ***********************
549 IF (TRYLIQ) THEN ! ** WET AEROSOL
550 FRSO4 = WAER(2) - WAER(1)/2.0D0 &
551 - WAER(6) - WAER(7)/2.0D0 - WAER(8) ! SULFATE UNBOUND BY SODIUM,CALCIUM,POTTASIUM,MAGNESIUM
552 FRSO4 = MAX(FRSO4, TINY)
553 SRI = GETASR2p1(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
554 SULRATW = (WAER(1)+FRSO4*SRI+WAER(6) &
555 +WAER(7)+WAER(8))/WAER(2) ! LIMITING SULFATE RATIO
556 SULRATW = MIN (SULRATW, 2.0D0)
558 SULRATW = 2.0D0 ! ** DRY AEROSOL
560 SO4RAT = (WAER(1)+WAER(3)+WAER(6)+WAER(7)+WAER(8))/WAER(2)
561 CRNARAT = (WAER(1)+WAER(6)+WAER(7)+WAER(8))/WAER(2)
562 CRRAT = (WAER(6)+WAER(7)+WAER(8))/WAER(2)
564 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
566 !C *** SULFATE POOR ; SODIUM+CRUSTALS POOR
568 IF (SULRATW.LE.SO4RAT .AND. CRNARAT.LT.2.0) THEN
570 IF(METSTBL.EQ.1) THEN
572 CALL CALCV72p1 ! Only liquid (metastable)
575 IF (RH.LT.DRNH4NO3) THEN
577 CALL CALCV12p1 ! CaSO4, NH4NO3, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
579 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
581 CALL CALCV22p1 ! CaSO4, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
583 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
585 CALL CALCV32p1 ! CaSO4, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
587 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRMGSO4) THEN
589 CALL CALCV42p1 ! CaSO4, MGSO4, NA2SO4, K2SO4
591 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
593 CALL CALCV52p1 ! CaSO4, NA2SO4, K2SO4
595 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
597 CALL CALCV62p1 ! CaSO4, K2SO4
599 ELSEIF (DRK2SO4.LE.RH) THEN
601 CALL CALCV72p1 ! CaSO4
605 !C *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
607 ELSEIF (SO4RAT.GE.SULRATW .AND. CRNARAT.GE.2.0) THEN
609 IF (CRRAT.LE.2.0) THEN
611 IF(METSTBL.EQ.1) THEN
613 CALL CALCU82p1 ! Only liquid (metastable)
616 IF (RH.LT.DRNH4NO3) THEN
618 CALL CALCU12p1 ! CaSO4, NH4NO3, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
620 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
622 CALL CALCU22p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
624 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
626 CALL CALCU32p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL
628 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4Cl) THEN
630 CALL CALCU42p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4
632 ELSEIF (DRNH4Cl.LE.RH .AND. RH.LT.DRMGSO4) THEN
634 CALL CALCU52p1 ! CaSO4, MGSO4, NA2SO4, K2SO4
636 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
638 CALL CALCU62p1 ! CaSO4, NA2SO4, K2SO4
640 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
642 CALL CALCU72p1 ! CaSO4, K2SO4
644 ELSEIF (DRK2SO4.LE.RH) THEN
646 CALL CALCU82p1 ! CaSO4
650 !C *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
652 ELSEIF (CRRAT.GT.2.0) THEN
654 IF(METSTBL.EQ.1) THEN
656 CALL CALCW132p1 ! Only liquid (metastable)
659 IF (RH.LT.DRCACL2) THEN
661 CALL CALCW12p1 ! CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
662 !C ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
664 ELSEIF (DRCACL2.LE.RH .AND. RH.LT.DRMGCL2) THEN
666 CALL CALCW22p1 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
667 !C ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
669 ELSEIF (DRMGCL2.LE.RH .AND. RH.LT.DRCANO32) THEN
671 CALL CALCW32p1 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
672 !C ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
674 ELSEIF (DRCANO32.LE.RH .AND. RH.LT.DRMGNO32) THEN
676 CALL CALCW42p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
677 !C ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
679 ELSEIF (DRMGNO32.LE.RH .AND. RH.LT.DRNH4NO3) THEN
681 CALL CALCW52p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
682 !C ! NANO3, NACL, NH4NO3, NH4CL
684 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
686 CALL CALCW62p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NANO3, NACL, NH4CL
688 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
690 CALL CALCW72p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NACL, NH4CL
692 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4CL) THEN
694 CALL CALCW82p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NH4CL
696 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRKCL) THEN
698 CALL CALCW92p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4
700 ELSEIF (DRKCL.LE.RH .AND. RH.LT.DRMGSO4) THEN
702 CALL CALCW102p1 ! CaSO4, K2SO4, KNO3, MGSO4
704 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRKNO3) THEN
706 CALL CALCW112p1 ! CaSO4, K2SO4, KNO3
708 ELSEIF (DRKNO3.LE.RH .AND. RH.LT.DRK2SO4) THEN
710 CALL CALCW122p1 ! CaSO4, K2SO4
712 ELSEIF (DRK2SO4.LE.RH) THEN
714 CALL CALCW132p1 ! CaSO4
720 !C *** SULFATE RICH (NO ACID): 1<Rso4<2;
722 ELSEIF (1.0.LE.SO4RAT .AND. SO4RAT.LT.SULRATW) THEN
727 IF(METSTBL.EQ.1) THEN
729 CALL CALCL92p1 ! Only liquid (metastable)
732 IF (RH.LT.DRNH4HS4) THEN
734 CALL CALCL12p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
736 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
738 CALL CALCL22p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,LC
740 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
742 CALL CALCL32p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,LC
744 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
746 CALL CALCL42p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4
748 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRKHSO4) THEN
750 CALL CALCL52p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4
752 ELSEIF (DRKHSO4.LE.RH .AND. RH.LT.DRMGSO4) THEN
754 CALL CALCL62p1 ! CASO4,K2SO4,MGSO4,NA2SO4
756 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
758 CALL CALCL72p1 ! CASO4,K2SO4,NA2SO4
760 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
762 CALL CALCL82p1 ! CASO4,K2SO4
764 ELSEIF (DRK2SO4.LE.RH) THEN
766 CALL CALCL92p1 ! CaSO4
770 CALL CALCNHP2p1 ! MINOR SPECIES: HNO3, HCl
771 CALL CALCNH3P2p1 ! NH3
773 !C *** SULFATE SUPER RICH (FREE ACID): Rso4<1;
775 ELSEIF (SO4RAT.LT.1.0) THEN
780 IF(METSTBL.EQ.1) THEN
782 CALL CALCK42p1 ! Only liquid (metastable)
785 IF (RH.LT.DRNH4HS4) THEN ! RH < 0.4
787 CALL CALCK12p1 ! NH4HSO4,NAHSO4,KHSO4,CASO4
789 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
791 CALL CALCK22p1 ! NAHSO4,KHSO4,CASO4
793 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRKHSO4) THEN
795 CALL CALCK32p1 ! KHSO4,CASO4 0.52 < RH < 0.86
797 ELSEIF (DRKHSO4.LE.RH) THEN
799 CALL CALCK42p1 ! CASO4
803 CALL CALCNHP2p1 ! MINOR SPECIES: HNO3, HCl
804 CALL CALCNH3P2p1 ! NH3
808 !C *** IF AFTER CALCULATIONS, SULRATW < SO4RAT < 2.0
809 !C and WATER = 0 => SULFATE RICH CASE.
811 IF (SULRATW.LE.SO4RAT .AND. SO4RAT.LT.2.0 &
812 .AND. WATER.LE.TINY) THEN
819 !C *** END OF SUBROUTINE ISRP4R *****************************************
822 !C=======================================================================
824 !C *** ISORROPIA CODE
825 !C *** SUBROUTINE CALCS2
828 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
829 !C 1. SULFATE POOR (SULRAT > 2.0)
830 !C 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
832 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
833 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
834 !C *** WRITTEN BY ATHANASIOS NENES
836 !C=======================================================================
839 INCLUDE 'module_isrpia_inc.F'
840 DOUBLE PRECISION NH4I, NH3GI, NH3AQ
842 !C *** SETUP PARAMETERS ************************************************
844 CALAOU =.TRUE. ! Outer loop activity calculation flag
848 !C *** CALCULATE WATER CONTENT *****************************************
850 MOLALR(4)= MIN(WAER(2), 0.5d0*WAER(3))
851 WATER = MOLALR(4)/M0(4) ! ZSR correlation
853 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
856 !CC A21 = XK21*WATER*R*TEMP
857 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
858 AKW = XKW *RH*WATER*WATER
864 CALL CALCPH2p1 (2.D0*SO4I - NH4I, HI, OHI) ! Get pH
866 NH3AQ = ZERO ! AMMONIA EQUILIBRIUM
868 CALL CALCAMAQ2p1 (NH4I, OHI, DEL)
869 NH4I = MAX (NH4I-DEL, ZERO)
870 OHI = MAX (OHI -DEL, TINY)
875 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL) ! SULFATE EQUILIBRIUM
880 NH3GI = NH4I/HI/A2 ! NH3AQ/A21
882 !C *** SPECIATION & WATER CONTENT ***************************************
892 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
894 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
903 !C *** END OF SUBROUTINE CALCS2 ****************************************
906 !C=======================================================================
908 !C *** ISORROPIA CODE
909 !C *** SUBROUTINE CALCS1
912 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
913 !C 1. SULFATE POOR (SULRAT > 2.0)
914 !C 2. SOLID AEROSOL ONLY
915 !C 3. SOLIDS POSSIBLE : (NH4)2SO4
917 !C A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
918 !C IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
921 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
922 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
923 !C *** WRITTEN BY ATHANASIOS NENES
925 !C=======================================================================
928 INCLUDE 'module_isrpia_inc.F'
930 CNH42S4 = MIN(WAER(2),0.5d0*WAER(3)) ! For bad input problems
934 W(3) = 2.D0*CNH42S4 + GNH3
938 !C *** END OF SUBROUTINE CALCS1 ******************************************
943 !C=======================================================================
945 !C *** ISORROPIA CODE
946 !C *** SUBROUTINE CALCN3
949 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
950 !C 1. SULFATE POOR (SULRAT > 2.0)
951 !C 2. THERE IS ONLY A LIQUID PHASE
953 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
954 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
955 !C *** WRITTEN BY ATHANASIOS NENES
957 !C=======================================================================
960 INCLUDE 'module_isrpia_inc.F'
961 DOUBLE PRECISION NH4I, NO3I, NH3AQ, NO3AQ
963 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
964 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
965 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
966 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
967 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
968 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
970 !C *** SETUP PARAMETERS ************************************************
972 CALAOU =.TRUE. ! Outer loop activity calculation flag
976 !C *** AEROSOL WATER CONTENT
978 MOLALR(4) = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
979 AML5 = MAX(WAER(3)-2.D0*MOLALR(4),ZERO) ! "free" NH4
980 MOLALR(5) = MAX(MIN(AML5,WAER(4)), ZERO) ! NH4NO3=MIN("free",NO3)
981 WATER = MOLALR(4)/M0(4) + MOLALR(5)/M0(5)
982 WATER = MAX(WATER, TINY)
984 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
987 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
988 !CC A21 = XK21*WATER*R*TEMP
989 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
990 A4 = XK7*(WATER/GAMA(4))**3.0
991 AKW = XKW *RH*WATER*WATER
993 !C ION CONCENTRATIONS
1000 CALL CALCPH2p1 (2.D0*SO4I + NO3I - NH4I, HI, OHI)
1002 !C AMMONIA ASSOCIATION EQUILIBRIUM
1006 GG = 2.D0*SO4I + NO3I - NH4I
1008 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
1012 CALL CALCNIAQ22p1 (GG, NO3I, HI, NO3AQ) ! HNO3
1014 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1016 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
1023 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1039 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
1041 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP ******************
1043 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1050 !C *** RETURN ***********************************************************
1054 !C *** END OF SUBROUTINE CALCN3 *****************************************
1057 !C=======================================================================
1059 !C *** ISORROPIA CODE
1060 !C *** SUBROUTINE CALCN2
1063 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1064 !C 1. SULFATE POOR (SULRAT > 2.0)
1065 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
1066 !C 3. SOLIDS POSSIBLE : (NH4)2SO4
1068 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1069 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1070 !C *** WRITTEN BY ATHANASIOS NENES
1072 !C=======================================================================
1074 SUBROUTINE CALCN22p1
1075 INCLUDE 'module_isrpia_inc.F'
1077 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1078 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
1079 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
1080 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
1081 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
1082 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
1084 !C *** SETUP PARAMETERS ************************************************
1086 CHI1 = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
1087 CHI2 = MAX(WAER(3) - 2.D0*CHI1, ZERO) ! "Free" NH4+
1088 CHI3 = MAX(WAER(4) - CHI2, ZERO) ! "Free" NO3
1093 CALAOU = .TRUE. ! Outer loop activity calculation flag
1094 PSI1LO = TINY ! Low limit
1095 PSI1HI = CHI1 ! High limit
1097 !C *** INITIAL VALUES FOR BISECTION ************************************
1101 IF (Y1.LE.EPS) RETURN ! IF (ABS(Y1).LE.EPS .OR. Y1.LE.ZERO) RETURN
1102 YHI= Y1 ! Save Y-value at HI position
1104 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
1106 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
1108 X2 = MAX(X1-DX, ZERO)
1110 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
1115 !C *** NO SUBDIVISION WITH SOLUTION FOUND
1117 YLO= Y1 ! Save Y-value at Hi position
1118 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
1121 !C *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
1123 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
1128 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
1130 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
1135 CALL PUSHERR2p1 (0001, 'CALCN2') ! WARNING ERROR: NO SOLUTION
1139 !C *** PERFORM BISECTION ***********************************************
1144 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
1151 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
1153 CALL PUSHERR2p1 (0002, 'CALCN2') ! WARNING ERROR: NO CONVERGENCE
1155 !C *** CONVERGED ; RETURN **********************************************
1162 !C *** END OF SUBROUTINE CALCN2 ******************************************
1168 !C======================================================================
1170 !C *** ISORROPIA CODE
1171 !C *** FUNCTION FUNCN2
1173 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D2 ;
1174 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCN2.
1176 !C=======================================================================
1178 DOUBLE PRECISION FUNCTION FUNCN22p1 (P1)
1179 INCLUDE 'module_isrpia_inc.F'
1180 DOUBLE PRECISION NH4I, NO3I, NH3AQ, NO3AQ
1182 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1183 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
1184 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
1185 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
1186 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
1187 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
1189 !C *** SETUP PARAMETERS ************************************************
1195 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1198 A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
1199 !CC A21 = XK21*WATER*R*TEMP
1200 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
1201 A4 = XK7*(WATER/GAMA(4))**3.0
1202 AKW = XKW *RH*WATER*WATER
1204 !C ION CONCENTRATIONS
1206 NH4I = 2.D0*PSI1 + PSI2
1211 CALL CALCPH2p1 (2.D0*SO4I + NO3I - NH4I, HI, OHI)
1213 !C AMMONIA ASSOCIATION EQUILIBRIUM
1217 GG = 2.D0*SO4I + NO3I - NH4I
1219 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
1223 CALL CALCNIAQ22p1 (GG, NO3I, HI, NO3AQ) ! HNO3
1225 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1227 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
1234 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1243 CNH42S4 = CHI1 - PSI1
1250 GNH3 = NH4I/HI/A2 ! NH3AQ/A21
1252 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
1256 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1258 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1265 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
1267 20 FUNCN22p1= NH4I*NH4I*SO4I/A4 - ONE
1270 !C *** END OF FUNCTION FUNCN2 ********************************************
1273 !C=======================================================================
1275 !C *** ISORROPIA CODE
1276 !C *** SUBROUTINE CALCN1
1279 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1280 !C 1. SULFATE POOR (SULRAT > 2.0)
1281 !C 2. SOLID AEROSOL ONLY
1282 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
1284 !C THERE ARE TWO REGIMES DEFINED BY RELATIVE HUMIDITY:
1285 !C 1. RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCN1A)
1286 !C 2. RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
1288 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1289 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1290 !C *** WRITTEN BY ATHANASIOS NENES
1292 !C=======================================================================
1294 SUBROUTINE CALCN12p1
1295 INCLUDE 'module_isrpia_inc.F'
1296 EXTERNAL CALCN1A2p1, CALCN22p1
1298 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
1300 IF (RH.LT.DRMASAN) THEN
1301 SCASE = 'N1 ; SUBCASE 1'
1302 CALL CALCN1A2p1 ! SOLID PHASE ONLY POSSIBLE
1303 SCASE = 'N1 ; SUBCASE 1'
1305 SCASE = 'N1 ; SUBCASE 2'
1306 CALL CALCMDRP2p1 (RH, DRMASAN, DRNH4NO3, CALCN1A2p1, CALCN22p1)
1307 SCASE = 'N1 ; SUBCASE 2'
1312 !C *** END OF SUBROUTINE CALCN1 ******************************************
1318 !C=======================================================================
1320 !C *** ISORROPIA CODE
1321 !C *** SUBROUTINE CALCN1A
1322 !C *** CASE N1 ; SUBCASE 1
1324 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1325 !C 1. SULFATE POOR (SULRAT > 2.0)
1326 !C 2. SOLID AEROSOL ONLY
1327 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
1329 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1330 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1331 !C *** WRITTEN BY ATHANASIOS NENES
1333 !C=======================================================================
1335 SUBROUTINE CALCN1A2p1
1336 INCLUDE 'module_isrpia_inc.F'
1338 !C *** SETUP PARAMETERS *************************************************
1340 !CCC A1 = XK10/R/TEMP/R/TEMP
1342 !C *** CALCULATE AEROSOL COMPOSITION ************************************
1344 !CCC CHI1 = 2.D0*WAER(4) ! Free parameter ; arbitrary value.
1347 !C *** The following statment is here to avoid negative NH4+ values in
1348 !C CALCN? routines that call CALCN1A
1350 PSI2 = MAX(MIN(WAER(2),0.5d0*(WAER(3)-PSI1)),TINY)
1355 !CCC GNH3 = CHI1 + PSI1 + 2.0*PSI2
1356 !CCC GHNO3 = A1/(CHI1-PSI1) + PSI1
1361 W(3) = GNH3 + PSI1 + 2.0*PSI2
1366 !C *** END OF SUBROUTINE CALCN1A *****************************************
1370 !C=======================================================================
1372 !C *** ISORROPIA CODE
1373 !C *** SUBROUTINE CALCQ5
1376 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1377 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1378 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1380 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1381 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1382 !C *** WRITTEN BY ATHANASIOS NENES
1384 !C=======================================================================
1386 SUBROUTINE CALCQ52p1
1387 INCLUDE 'module_isrpia_inc.F'
1389 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1391 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1392 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
1393 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
1394 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
1395 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
1396 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
1398 !C *** SETUP PARAMETERS ************************************************
1404 !C *** CALCULATE INITIAL SOLUTION ***************************************
1408 PSI1 = CNA2SO4 ! SALTS DISSOLVED
1413 CALL CALCMR2p1 ! WATER
1419 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1422 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1424 !C ION CONCENTRATIONS
1432 !C SOLUTION ACIDIC OR BASIC?
1434 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1435 IF (GG.GT.TINY) THEN ! H+ in excess
1438 DD = BB*BB - 4.D0*CC
1439 HI = 0.5D0*(-BB + SQRT(DD))
1441 ELSE ! OH- in excess
1444 DD = BB*BB - 4.D0*CC
1445 OHI= 0.5D0*(-BB + SQRT(DD))
1449 !C UNDISSOCIATED SPECIES EQUILIBRIA
1452 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
1456 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1457 GGCL = MAX(GG-GGNO3, ZERO)
1458 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
1459 IF (GGNO3.GT.TINY) THEN
1460 IF (GGCL.LE.TINY) HI = ZERO
1461 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1464 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1466 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
1473 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1483 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1485 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1491 !ccc CALL PUSHERR (0002, 'CALCQ5') ! WARNING ERROR: NO CONVERGENCE
1493 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1495 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1496 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1497 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1516 !C *** END OF SUBROUTINE CALCQ5 ******************************************
1520 !C=======================================================================
1522 !C *** ISORROPIA CODE
1523 !C *** SUBROUTINE CALCQ4
1526 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1527 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1528 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1530 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1531 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1532 !C *** WRITTEN BY ATHANASIOS NENES
1534 !C=======================================================================
1536 SUBROUTINE CALCQ42p1
1537 INCLUDE 'module_isrpia_inc.F'
1540 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1542 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1543 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
1544 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
1545 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
1546 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
1547 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
1549 !C *** SETUP PARAMETERS ************************************************
1559 !C *** CALCULATE INITIAL SOLUTION ***************************************
1563 CHI1 = CNA2SO4 ! SALTS
1565 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
1570 CALL CALCMR2p1 ! WATER
1572 NAI = WAER(1) ! LIQUID CONCENTRATIONS
1582 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1585 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
1586 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1590 IF (NAI*NAI*SO4I .GT. A5) THEN
1591 BB =-(WAER(2) + WAER(1))
1592 CC = WAER(1)*WAER(2) + 0.25*WAER(1)*WAER(1)
1593 DD =-0.25*(WAER(1)*WAER(1)*WAER(2) - A5)
1594 CALL POLY32p1(BB, CC, DD, ROOT3, ISLV)
1595 IF (ISLV.NE.0) ROOT3 = TINY
1596 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2), CHI1)
1597 ROOT3 = MAX (ROOT3, ZERO)
1600 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
1603 !C ION CONCENTRATIONS ; CORRECTIONS
1605 NAI = WAER(1) - 2.D0*ROOT3
1606 SO4I= WAER(2) - ROOT3
1611 !C SOLUTION ACIDIC OR BASIC?
1613 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1614 IF (GG.GT.TINY) THEN ! H+ in excess
1617 DD = BB*BB - 4.D0*CC
1618 HI = 0.5D0*(-BB + SQRT(DD))
1620 ELSE ! OH- in excess
1623 DD = BB*BB - 4.D0*CC
1624 OHI= 0.5D0*(-BB + SQRT(DD))
1628 !C UNDISSOCIATED SPECIES EQUILIBRIA
1631 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
1635 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1636 GGCL = MAX(GG-GGNO3, ZERO)
1637 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
1638 IF (GGNO3.GT.TINY) THEN
1639 IF (GGCL.LE.TINY) HI = ZERO
1640 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1643 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1645 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
1652 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1662 !C *** CALCULATE WATER **************************************************
1666 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1668 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1671 IF (PSCONV1) GOTO 20
1674 !ccc CALL PUSHERR (0002, 'CALCQ4') ! WARNING ERROR: NO CONVERGENCE
1676 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1678 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1679 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1680 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1695 CNA2SO4 = CHI1 - PSI1
1699 !C *** END OF SUBROUTINE CALCQ4 ******************************************
1702 !C=======================================================================
1704 !C *** ISORROPIA CODE
1705 !C *** SUBROUTINE CALCQ3
1708 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1709 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
1710 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
1711 !C 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
1713 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1714 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1715 !C *** WRITTEN BY ATHANASIOS NENES
1717 !C=======================================================================
1719 SUBROUTINE CALCQ32p1
1720 INCLUDE 'module_isrpia_inc.F'
1722 EXTERNAL CALCQ1A2p1, CALCQ42p1
1724 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
1726 EXNO = WAER(4).GT.TINY
1727 EXCL = WAER(5).GT.TINY
1729 IF (EXNO .OR. EXCL) THEN ! *** NITRATE OR CHLORIDE EXISTS
1730 SCASE = 'Q3 ; SUBCASE 1'
1732 SCASE = 'Q3 ; SUBCASE 1'
1734 ELSE ! *** NO CHLORIDE AND NITRATE
1735 IF (RH.LT.DRMG3) THEN
1736 SCASE = 'Q3 ; SUBCASE 2'
1737 CALL CALCQ1A2p1 ! SOLID
1738 SCASE = 'Q3 ; SUBCASE 2'
1740 SCASE = 'Q3 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4
1741 CALL CALCMDRP2p1 (RH, DRMG3, DRNH42S4, CALCQ1A2p1, CALCQ42p1)
1742 SCASE = 'Q3 ; SUBCASE 3'
1748 !C *** END OF SUBROUTINE CALCQ3 ******************************************
1754 !C=======================================================================
1756 !C *** ISORROPIA CODE
1757 !C *** SUBROUTINE CALCQ3A
1758 !C *** CASE Q3 ; SUBCASE A
1760 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1761 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
1762 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
1764 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1765 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1766 !C *** WRITTEN BY ATHANASIOS NENES
1768 !C=======================================================================
1770 SUBROUTINE CALCQ3A2p1
1771 INCLUDE 'module_isrpia_inc.F'
1773 LOGICAL PSCONV1, PSCONV6
1774 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
1776 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
1777 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
1778 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
1779 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
1780 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
1781 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
1783 !C *** SETUP PARAMETERS ************************************************
1798 !C *** CALCULATE INITIAL SOLUTION ***************************************
1802 CHI1 = CNA2SO4 ! SALTS
1806 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
1811 CALL CALCMR2p1 ! WATER
1813 NAI = WAER(1) ! LIQUID CONCENTRATIONS
1823 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1826 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
1827 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> NH4+
1828 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
1832 IF (NAI*NAI*SO4I .GT. A5) THEN
1833 BB =-(WAER(2) + WAER(1) - ROOT1)
1834 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
1835 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
1836 CALL POLY32p1(BB, CC, DD, ROOT3, ISLV)
1837 IF (ISLV.NE.0) ROOT3 = TINY
1838 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
1839 ROOT3 = MAX (ROOT3, ZERO)
1842 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
1847 IF (NH4I*NH4I*SO4I .GT. A7) THEN
1848 BB =-(WAER(2)+WAER(3)-ROOT3)
1849 CC = WAER(3)*(WAER(2)-ROOT3+0.5D0*WAER(3))
1850 DD =-((WAER(2)-ROOT3)*WAER(3)**2.D0 + A7)/4.D0
1851 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
1852 IF (ISLV.NE.0) ROOT1 = TINY
1853 ROOT1 = MIN(ROOT1, WAER(3), WAER(2)-ROOT3, CHI6)
1854 ROOT1 = MAX(ROOT1, ZERO)
1857 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
1860 !C ION CONCENTRATIONS
1862 NAI = WAER(1) - 2.D0*ROOT3
1863 SO4I= WAER(2) - ROOT1 - ROOT3
1864 NH4I= WAER(3) - 2.D0*ROOT1
1868 !C SOLUTION ACIDIC OR BASIC?
1870 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
1871 IF (GG.GT.TINY) THEN ! H+ in excess
1874 DD = BB*BB - 4.D0*CC
1875 HI = 0.5D0*(-BB + SQRT(DD))
1877 ELSE ! OH- in excess
1880 DD = BB*BB - 4.D0*CC
1881 OHI= 0.5D0*(-BB + SQRT(DD))
1885 !C UNDISSOCIATED SPECIES EQUILIBRIA
1888 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
1892 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
1893 GGCL = MAX(GG-GGNO3, ZERO)
1894 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
1895 IF (GGNO3.GT.TINY) THEN
1896 IF (GGCL.LE.TINY) HI = ZERO
1897 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
1900 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
1902 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
1909 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
1919 !C *** CALCULATE WATER **************************************************
1923 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1925 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1928 IF (PSCONV1 .AND. PSCONV6) GOTO 20
1931 !ccc CALL PUSHERR (0002, 'CALCQ3A') ! WARNING ERROR: NO CONVERGENCE
1933 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
1935 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
1936 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
1937 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
1947 CNH42S4 = CHI6 - PSI6
1952 CNA2SO4 = CHI1 - PSI1
1956 !C *** END OF SUBROUTINE CALCQ3A *****************************************
1959 !C=======================================================================
1961 !C *** ISORROPIA CODE
1962 !C *** SUBROUTINE CALCQ2
1965 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1966 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
1967 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
1968 !C 3. SOLIDS POSSIBLE : NH4CL, NA2SO4, NANO3, NACL
1970 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1971 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1972 !C *** WRITTEN BY ATHANASIOS NENES
1974 !C=======================================================================
1976 SUBROUTINE CALCQ22p1
1977 INCLUDE 'module_isrpia_inc.F'
1979 EXTERNAL CALCQ1A2p1, CALCQ3A2p1, CALCQ42p1
1981 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
1983 EXNO = WAER(4).GT.TINY
1984 EXCL = WAER(5).GT.TINY
1986 IF (EXNO) THEN ! *** NITRATE EXISTS
1987 SCASE = 'Q2 ; SUBCASE 1'
1989 SCASE = 'Q2 ; SUBCASE 1'
1991 ELSEIF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
1992 IF (RH.LT.DRMG2) THEN
1993 SCASE = 'Q2 ; SUBCASE 2'
1994 CALL CALCQ1A2p1 ! SOLID
1995 SCASE = 'Q2 ; SUBCASE 2'
1997 SCASE = 'Q2 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
1998 CALL CALCMDRP2p1 (RH, DRMG2, DRNH4CL, CALCQ1A2p1, CALCQ3A2p1)
1999 SCASE = 'Q2 ; SUBCASE 3'
2002 ELSE ! *** NO CHLORIDE AND NITRATE
2003 IF (RH.LT.DRMG3) THEN
2004 SCASE = 'Q2 ; SUBCASE 2'
2005 CALL CALCQ1A2p1 ! SOLID
2006 SCASE = 'Q2 ; SUBCASE 2'
2008 SCASE = 'Q2 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4
2009 CALL CALCMDRP2p1 (RH, DRMG3, DRNH42S4, CALCQ1A2p1, CALCQ42p1)
2010 SCASE = 'Q2 ; SUBCASE 4'
2016 !C *** END OF SUBROUTINE CALCQ2 ******************************************
2021 !C=======================================================================
2023 !C *** ISORROPIA CODE
2024 !C *** SUBROUTINE CALCQ2A
2025 !C *** CASE Q2 ; SUBCASE A
2027 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2028 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM POOR (SODRAT < 2.0)
2029 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2031 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2032 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2033 !C *** WRITTEN BY ATHANASIOS NENES
2035 !C=======================================================================
2037 SUBROUTINE CALCQ2A2p1
2038 INCLUDE 'module_isrpia_inc.F'
2040 LOGICAL PSCONV1, PSCONV4, PSCONV6
2041 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2043 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2044 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2045 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2046 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2047 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2048 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2050 !C *** SETUP PARAMETERS ************************************************
2068 !C *** CALCULATE INITIAL SOLUTION ***************************************
2072 CHI1 = CNA2SO4 ! SALTS
2076 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
2081 CALL CALCMR2p1 ! WATER
2083 NAI = WAER(1) ! LIQUID CONCENTRATIONS
2093 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2096 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2097 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
2098 A7 = XK7 *(WATER/GAMA(4))**3. ! (NH4)2SO4 <==> Na+
2099 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2101 !C AMMONIUM CHLORIDE
2103 IF (NH4I*CLI .GT. A14) THEN
2104 BB =-(WAER(3) + WAER(5) - 2.D0*ROOT1)
2105 CC = WAER(5)*(WAER(3) - 2.D0*ROOT1) - A14
2106 DD = BB*BB - 4.D0*CC
2107 IF (DD.LT.ZERO) THEN
2111 ROOT2A= 0.5D0*(-BB+DD)
2112 ROOT2B= 0.5D0*(-BB-DD)
2113 IF (ZERO.LE.ROOT2A) THEN
2118 ROOT2 = MIN(ROOT2, WAER(5), WAER(3) - 2.D0*ROOT1, CHI4)
2119 ROOT2 = MAX(ROOT2, ZERO)
2123 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
2128 IF (NAI*NAI*SO4I .GT. A5) THEN
2129 BB =-(WAER(2) + WAER(1) - ROOT1)
2130 CC = WAER(1)*(WAER(2) - ROOT1) + 0.25*WAER(1)*WAER(1)
2131 DD =-0.25*(WAER(1)*WAER(1)*(WAER(2) - ROOT1) - A5)
2132 CALL POLY32p1(BB, CC, DD, ROOT3, ISLV)
2133 IF (ISLV.NE.0) ROOT3 = TINY
2134 ROOT3 = MIN (ROOT3, WAER(1)/2.0, WAER(2) - ROOT1, CHI1)
2135 ROOT3 = MAX (ROOT3, ZERO)
2138 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
2143 IF (NH4I*NH4I*SO4I .GT. A7) THEN
2144 BB =-(WAER(2)+WAER(3)-ROOT2-ROOT3)
2145 CC = (WAER(3)-ROOT2)*(WAER(2)-ROOT3+0.5D0*(WAER(3)-ROOT2))
2146 DD =-((WAER(2)-ROOT3)*(WAER(3)-ROOT2)**2.D0 + A7)/4.D0
2147 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
2148 IF (ISLV.NE.0) ROOT1 = TINY
2149 ROOT1 = MIN(ROOT1, WAER(3)-ROOT2, WAER(2)-ROOT3, CHI6)
2150 ROOT1 = MAX(ROOT1, ZERO)
2153 PSCONV6 = ABS(PSI6-PSI6O) .LE. EPS*PSI6O
2156 !C ION CONCENTRATIONS
2158 NAI = WAER(1) - 2.D0*ROOT3
2159 SO4I= WAER(2) - ROOT1 - ROOT3
2160 NH4I= WAER(3) - ROOT2 - 2.D0*ROOT1
2162 CLI = WAER(5) - ROOT2
2164 !C SOLUTION ACIDIC OR BASIC?
2166 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2167 IF (GG.GT.TINY) THEN ! H+ in excess
2170 DD = BB*BB - 4.D0*CC
2171 HI = 0.5D0*(-BB + SQRT(DD))
2173 ELSE ! OH- in excess
2176 DD = BB*BB - 4.D0*CC
2177 OHI= 0.5D0*(-BB + SQRT(DD))
2181 !C UNDISSOCIATED SPECIES EQUILIBRIA
2184 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
2188 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2189 GGCL = MAX(GG-GGNO3, ZERO)
2190 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
2191 IF (GGNO3.GT.TINY) THEN
2192 IF (GGCL.LE.TINY) HI = ZERO
2193 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2196 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2198 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
2205 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2215 !C *** CALCULATE WATER **************************************************
2219 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2221 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2224 IF (PSCONV1 .AND. PSCONV4 .AND. PSCONV6) GOTO 20
2227 !ccc CALL PUSHERR (0002, 'CALCQ2A') ! WARNING ERROR: NO CONVERGENCE
2229 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2231 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2232 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2233 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2243 CNH42S4 = CHI6 - PSI6
2245 CNH4CL = CHI4 - PSI4
2248 CNA2SO4 = CHI1 - PSI1
2252 !C *** END OF SUBROUTINE CALCQ2A *****************************************
2255 !C=======================================================================
2257 !C *** ISORROPIA CODE
2258 !C *** SUBROUTINE CALCQ1
2261 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2262 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2263 !C 2. SOLID AEROSOL ONLY
2264 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
2266 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2267 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2268 !C *** WRITTEN BY ATHANASIOS NENES
2270 !C=======================================================================
2272 SUBROUTINE CALCQ12p1
2273 INCLUDE 'module_isrpia_inc.F'
2275 EXTERNAL CALCQ1A2p1, CALCQ2A2p1, CALCQ3A2p1, CALCQ42p1
2277 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
2279 EXNO = WAER(4).GT.TINY
2280 EXCL = WAER(5).GT.TINY
2282 IF (EXNO .AND. EXCL) THEN ! *** NITRATE & CHLORIDE EXIST
2283 IF (RH.LT.DRMG1) THEN
2284 SCASE = 'Q1 ; SUBCASE 1'
2285 CALL CALCQ1A2p1 ! SOLID
2286 SCASE = 'Q1 ; SUBCASE 1'
2288 SCASE = 'Q1 ; SUBCASE 2' ! MDRH (NH4)2SO4, NA2SO4, NH4CL, NH4NO3
2289 CALL CALCMDRP2p1 (RH, DRMG1, DRNH4NO3, CALCQ1A2p1, CALCQ2A2p1)
2290 SCASE = 'Q1 ; SUBCASE 2'
2293 ELSE IF (EXNO .AND. .NOT.EXCL) THEN ! *** ONLY NITRATE EXISTS
2294 IF (RH.LT.DRMQ1) THEN
2295 SCASE = 'Q1 ; SUBCASE 1'
2296 CALL CALCQ1A2p1 ! SOLID
2297 SCASE = 'Q1 ; SUBCASE 1'
2299 SCASE = 'Q1 ; SUBCASE 3' ! MDRH (NH4)2SO4, NA2SO4, NH4NO3
2300 CALL CALCMDRP2p1 (RH, DRMQ1, DRNH4NO3, CALCQ1A2p1, CALCQ2A2p1)
2301 SCASE = 'Q1 ; SUBCASE 3'
2304 ELSE IF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
2305 IF (RH.LT.DRMG2) THEN
2306 SCASE = 'Q1 ; SUBCASE 1'
2307 CALL CALCQ1A2p1 ! SOLID
2308 SCASE = 'Q1 ; SUBCASE 1'
2310 SCASE = 'Q1 ; SUBCASE 4' ! MDRH (NH4)2SO4, NA2SO4, NH4CL
2311 CALL CALCMDRP2p1 (RH, DRMG2, DRNH4CL, CALCQ1A2p1, CALCQ3A2p1)
2312 SCASE = 'Q1 ; SUBCASE 4'
2315 ELSE ! *** NO CHLORIDE AND NITRATE
2316 IF (RH.LT.DRMG3) THEN
2317 SCASE = 'Q1 ; SUBCASE 1'
2318 CALL CALCQ1A2p1 ! SOLID
2319 SCASE = 'Q1 ; SUBCASE 1'
2321 SCASE = 'Q1 ; SUBCASE 5' ! MDRH (NH4)2SO4, NA2SO4
2322 CALL CALCMDRP2p1 (RH, DRMG3, DRNH42S4, CALCQ1A2p1, CALCQ42p1)
2323 SCASE = 'Q1 ; SUBCASE 5'
2329 !C *** END OF SUBROUTINE CALCQ1 ******************************************
2334 !C=======================================================================
2336 !C *** ISORROPIA CODE
2337 !C *** SUBROUTINE CALCQ1A
2338 !C *** CASE Q1 ; SUBCASE 1
2340 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2341 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2342 !C 2. SOLID AEROSOL ONLY
2343 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, (NH4)2SO4, NA2SO4
2345 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2346 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2347 !C *** WRITTEN BY ATHANASIOS NENES
2349 !C=======================================================================
2351 SUBROUTINE CALCQ1A2p1
2352 INCLUDE 'module_isrpia_inc.F'
2354 !C *** CALCULATE SOLIDS **************************************************
2356 CNA2SO4 = 0.5d0*WAER(1)
2357 FRSO4 = MAX (WAER(2)-CNA2SO4, ZERO)
2359 CNH42S4 = MAX (MIN(FRSO4,0.5d0*WAER(3)), TINY)
2360 FRNH3 = MAX (WAER(3)-2.D0*CNH42S4, ZERO)
2362 CNH4NO3 = MIN (FRNH3, WAER(4))
2363 !CCC FRNO3 = MAX (WAER(4)-CNH4NO3, ZERO)
2364 FRNH3 = MAX (FRNH3-CNH4NO3, ZERO)
2366 CNH4CL = MIN (FRNH3, WAER(5))
2367 !CCC FRCL = MAX (WAER(5)-CNH4CL, ZERO)
2368 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
2370 !C *** OTHER PHASES ******************************************************
2380 !C *** END OF SUBROUTINE CALCQ1A *****************************************
2383 !C=======================================================================
2385 !C *** ISORROPIA CODE
2386 !C *** SUBROUTINE CALCR6
2389 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2390 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2391 !C 2. THERE IS ONLY A LIQUID PHASE
2393 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2394 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2395 !C *** WRITTEN BY ATHANASIOS NENES
2397 !C=======================================================================
2399 SUBROUTINE CALCR62p1
2400 INCLUDE 'module_isrpia_inc.F'
2402 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2404 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2405 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2406 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2407 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2408 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2409 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2411 !C *** SETUP PARAMETERS ************************************************
2425 !C *** CALCULATE WATER **************************************************
2429 !C *** SETUP LIQUID CONCENTRATIONS **************************************
2436 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2439 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2447 !C SOLUTION ACIDIC OR BASIC?
2449 GG = 2.D0*WAER(2) + NO3I + CLI - NAI - NH4I
2450 IF (GG.GT.TINY) THEN ! H+ in excess
2453 DD = BB*BB - 4.D0*CC
2454 HI = 0.5D0*(-BB + SQRT(DD))
2456 ELSE ! OH- in excess
2459 DD = BB*BB - 4.D0*CC
2460 OHI= 0.5D0*(-BB + SQRT(DD))
2464 !C UNDISSOCIATED SPECIES EQUILIBRIA
2467 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
2470 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2471 GGCL = MAX(GG-GGNO3, ZERO)
2472 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
2473 IF (GGNO3.GT.TINY) THEN
2474 IF (GGCL.LE.TINY) HI = ZERO
2475 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2478 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2480 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
2487 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2497 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2499 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2505 !ccc CALL PUSHERR (0002, 'CALCR6') ! WARNING ERROR: NO CONVERGENCE
2507 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2509 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2510 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2511 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2530 !C *** END OF SUBROUTINE CALCR6 ******************************************
2533 !C=======================================================================
2535 !C *** ISORROPIA CODE
2536 !C *** SUBROUTINE CALCR5
2539 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2540 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2541 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2543 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2544 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2545 !C *** WRITTEN BY ATHANASIOS NENES
2547 !C=======================================================================
2549 SUBROUTINE CALCR52p1
2550 INCLUDE 'module_isrpia_inc.F'
2553 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2555 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2556 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2557 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2558 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2559 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2560 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2562 LOGICAL NEAN, NEAC, NESN, NESC
2564 !C *** SETUP PARAMETERS ************************************************
2566 CALL CALCR1A2p1 ! DRY SOLUTION
2568 NEAN = CNH4NO3.LE.TINY ! NH4NO3 ! Water exists?
2569 NEAC = CNH4CL .LE.TINY ! NH4CL
2570 NESN = CNANO3 .LE.TINY ! NANO3
2571 NESC = CNACL .LE.TINY ! NACL
2572 IF (NEAN .AND. NEAC .AND. NESN .AND. NESC) RETURN
2584 !C *** CALCULATE WATER **************************************************
2593 !C *** SETUP LIQUID CONCENTRATIONS **************************************
2605 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2608 A5 = XK5*(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2609 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2614 IF (NAI*NAI*SO4I .GT. A5) THEN
2617 DD =-CHI1**3.0 + 0.25D0*A5
2618 CALL POLY32p1(BB, CC, DD, ROOT, ISLV)
2619 IF (ISLV.NE.0) ROOT = TINY
2620 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
2623 PSCONV = ABS(PSI1-PSIO) .LE. EPS*PSIO
2626 !C ION CONCENTRATIONS
2628 NAI = WAER(1) - 2.D0*ROOT
2629 SO4I = WAER(2) - ROOT
2634 !C SOLUTION ACIDIC OR BASIC?
2636 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2637 IF (GG.GT.TINY) THEN ! H+ in excess
2640 DD = BB*BB - 4.D0*CC
2641 HI = 0.5D0*(-BB + SQRT(DD))
2643 ELSE ! OH- in excess
2646 DD = BB*BB - 4.D0*CC
2647 OHI= 0.5D0*(-BB + SQRT(DD))
2651 !C UNDISSOCIATED SPECIES EQUILIBRIA
2654 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
2657 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2658 GGCL = MAX(GG-GGNO3, ZERO)
2659 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
2660 IF (GGNO3.GT.TINY) THEN
2661 IF (GGCL.LE.TINY) HI = ZERO
2662 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2665 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2667 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
2674 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2684 !C *** CALCULATE WATER **************************************************
2688 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2690 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2696 !ccc CALL PUSHERR (0002, 'CALCR5') ! WARNING ERROR: NO CONVERGENCE
2698 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2700 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2701 !CC A21 = XK21*WATER*R*TEMP
2702 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2703 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2705 GNH3 = NH4I/HI/A2 ! NH4I*OHI/A2/AKW
2718 CNA2SO4 = CHI1 - PSI1
2722 !C *** END OF SUBROUTINE CALCR5 ******************************************
2725 !C=======================================================================
2727 !C *** ISORROPIA CODE
2728 !C *** SUBROUTINE CALCR4
2731 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2732 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
2733 !C 2. SOLID AEROSOL ONLY
2734 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
2736 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2737 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2738 !C *** WRITTEN BY ATHANASIOS NENES
2740 !C=======================================================================
2742 SUBROUTINE CALCR42p1
2743 INCLUDE 'module_isrpia_inc.F'
2744 LOGICAL EXAN, EXAC, EXSN, EXSC
2745 EXTERNAL CALCR1A2p1, CALCR52p1
2747 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
2749 SCASE = 'R4 ; SUBCASE 2'
2750 CALL CALCR1A2p1 ! SOLID
2751 SCASE = 'R4 ; SUBCASE 2'
2753 EXAN = CNH4NO3.GT.TINY ! NH4NO3
2754 EXAC = CNH4CL .GT.TINY ! NH4CL
2755 EXSN = CNANO3 .GT.TINY ! NANO3
2756 EXSC = CNACL .GT.TINY ! NACL
2758 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
2760 IF (EXAN .OR. EXSN .OR. EXSC) THEN ! *** NH4NO3,NANO3 EXIST
2761 IF (RH.GE.DRMH1) THEN
2762 SCASE = 'R4 ; SUBCASE 1'
2764 SCASE = 'R4 ; SUBCASE 1'
2767 ELSE IF (EXAC) THEN ! *** NH4CL EXISTS ONLY
2768 IF (RH.GE.DRMR5) THEN
2769 SCASE = 'R4 ; SUBCASE 3'
2770 CALL CALCMDRP2p1 (RH, DRMR5, DRNH4CL, CALCR1A2p1, CALCR52p1)
2771 SCASE = 'R4 ; SUBCASE 3'
2777 !C *** END OF SUBROUTINE CALCR4 ******************************************
2783 !C=======================================================================
2785 !C *** ISORROPIA CODE
2786 !C *** SUBROUTINE CALCR4A
2789 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2790 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
2791 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
2793 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2794 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2795 !C *** WRITTEN BY ATHANASIOS NENES
2797 !C=======================================================================
2799 SUBROUTINE CALCR4A2p1
2800 INCLUDE 'module_isrpia_inc.F'
2802 LOGICAL PSCONV1, PSCONV4
2803 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
2805 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2806 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2807 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2808 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2809 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2810 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2812 !C *** SETUP PARAMETERS ************************************************
2822 !C *** CALCULATE INITIAL SOLUTION ***************************************
2826 CHI1 = CNA2SO4 ! SALTS
2835 CALL CALCMR2p1 ! WATER
2837 NAI = WAER(1) ! LIQUID CONCENTRATIONS
2847 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2850 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
2851 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
2852 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
2857 IF (NAI*NAI*SO4I .GT. A5) THEN
2860 DD =-CHI1**3.0 + 0.25D0*A5
2861 CALL POLY32p1(BB, CC, DD, ROOT, ISLV)
2862 IF (ISLV.NE.0) ROOT = TINY
2863 ROOT = MIN (MAX(ROOT,ZERO), CHI1)
2865 NAI = WAER(1) - 2.D0*ROOT
2866 SO4I = WAER(2) - ROOT
2868 PSCONV1 = ABS(PSI1-PSIO1) .LE. EPS*PSIO1
2871 !C AMMONIUM CHLORIDE
2874 IF (NH4I*CLI .GT. A14) THEN
2877 DD = BB*BB - 4.D0*CC
2878 ROOT = 0.5D0*(-BB-SQRT(DD))
2879 IF (ROOT.GT.TINY) THEN
2880 ROOT = MIN(ROOT, CHI4)
2882 NH4I = WAER(3) - ROOT
2883 CLI = WAER(5) - ROOT
2886 PSCONV4 = ABS(PSI4-PSIO4) .LE. EPS*PSIO4
2891 !C SOLUTION ACIDIC OR BASIC?
2893 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
2894 IF (GG.GT.TINY) THEN ! H+ in excess
2897 DD = BB*BB - 4.D0*CC
2898 HI = 0.5D0*(-BB + SQRT(DD))
2900 ELSE ! OH- in excess
2903 DD = BB*BB - 4.D0*CC
2904 OHI= 0.5D0*(-BB + SQRT(DD))
2908 !C UNDISSOCIATED SPECIES EQUILIBRIA
2911 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
2914 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
2915 GGCL = MAX(GG-GGNO3, ZERO)
2916 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
2917 IF (GGNO3.GT.TINY) THEN
2918 IF (GGCL.LE.TINY) HI = ZERO
2919 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
2922 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
2924 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
2931 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2941 !C *** CALCULATE WATER **************************************************
2945 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2947 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2950 IF (PSCONV1 .AND. PSCONV4) GOTO 20
2953 !ccc CALL PUSHERR (0002, 'CALCR4A') ! WARNING ERROR: NO CONVERGENCE
2955 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2957 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
2958 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
2959 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
2971 CNH4CL = CHI4 - PSI4
2974 CNA2SO4 = CHI1 - PSI1
2978 !C *** END OF SUBROUTINE CALCR4A *****************************************
2981 !C=======================================================================
2983 !C *** ISORROPIA CODE
2984 !C *** SUBROUTINE CALCR3
2987 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2988 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
2989 !C 2. SOLID AEROSOL ONLY
2990 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
2992 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2993 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2994 !C *** WRITTEN BY ATHANASIOS NENES
2996 !C=======================================================================
2998 SUBROUTINE CALCR32p1
2999 INCLUDE 'module_isrpia_inc.F'
3000 LOGICAL EXAN, EXAC, EXSN, EXSC
3001 EXTERNAL CALCR1A2p1, CALCR4A2p1, CALCR52p1
3003 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
3005 SCASE = 'R3 ; SUBCASE 2'
3006 CALL CALCR1A2p1 ! SOLID
3007 SCASE = 'R3 ; SUBCASE 2'
3009 EXAN = CNH4NO3.GT.TINY ! NH4NO3
3010 EXAC = CNH4CL .GT.TINY ! NH4CL
3011 EXSN = CNANO3 .GT.TINY ! NANO3
3012 EXSC = CNACL .GT.TINY ! NACL
3014 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
3016 IF (EXAN .OR. EXSN) THEN ! *** NH4NO3,NANO3 EXIST
3017 IF (RH.GE.DRMH1) THEN
3018 SCASE = 'R3 ; SUBCASE 1'
3020 SCASE = 'R3 ; SUBCASE 1'
3023 ELSE IF (.NOT.EXAN .AND. .NOT.EXSN) THEN ! *** NH4NO3,NANO3 = 0
3024 IF ( EXAC .AND. EXSC) THEN
3025 IF (RH.GE.DRMR4) THEN
3026 SCASE = 'R3 ; SUBCASE 3'
3027 CALL CALCMDRP2p1 (RH, DRMR4, DRNACL, CALCR1A2p1, CALCR4A2p1)
3028 SCASE = 'R3 ; SUBCASE 3'
3031 ELSE IF (.NOT.EXAC .AND. EXSC) THEN
3032 IF (RH.GE.DRMR2) THEN
3033 SCASE = 'R3 ; SUBCASE 4'
3034 CALL CALCMDRP2p1 (RH, DRMR2, DRNACL, CALCR1A2p1, CALCR4A2p1)
3035 SCASE = 'R3 ; SUBCASE 4'
3038 ELSE IF ( EXAC .AND. .NOT.EXSC) THEN
3039 IF (RH.GE.DRMR5) THEN
3040 SCASE = 'R3 ; SUBCASE 5'
3041 CALL CALCMDRP2p1 (RH, DRMR5, DRNACL, CALCR1A2p1, CALCR52p1)
3042 SCASE = 'R3 ; SUBCASE 5'
3050 !C *** END OF SUBROUTINE CALCR3 ******************************************
3055 !C=======================================================================
3057 !C *** ISORROPIA CODE
3058 !C *** SUBROUTINE CALCR3A
3061 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3062 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
3063 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
3065 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3066 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3067 !C *** WRITTEN BY ATHANASIOS NENES
3069 !C=======================================================================
3071 SUBROUTINE CALCR3A2p1
3072 INCLUDE 'module_isrpia_inc.F'
3074 LOGICAL PSCONV1, PSCONV3, PSCONV4
3075 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
3077 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3078 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
3079 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
3080 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
3081 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6,&
3082 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
3084 !C *** SETUP PARAMETERS ************************************************
3099 !C *** CALCULATE INITIAL SOLUTION ***************************************
3103 CHI1 = CNA2SO4 ! SALTS
3113 CALL CALCMR2p1 ! WATER
3115 NAI = WAER(1) ! LIQUID CONCENTRATIONS
3133 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
3135 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3138 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
3139 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
3140 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
3141 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
3143 !C AMMONIUM CHLORIDE
3145 IF (NH4I*CLI .GT. A14) THEN
3146 BB =-(WAER(3) + WAER(5) - ROOT3)
3147 CC =-A14 + NH4I*(WAER(5) - ROOT3)
3148 DD = MAX(BB*BB - 4.D0*CC, ZERO)
3149 ROOT2A= 0.5D0*(-BB+SQRT(DD))
3150 ROOT2B= 0.5D0*(-BB-SQRT(DD))
3151 IF (ZERO.LE.ROOT2A) THEN
3156 ROOT2 = MIN(MAX(ZERO, ROOT2), MAX(WAER(5)-ROOT3,ZERO), &
3160 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
3165 IF (NAI*NAI*SO4I .GT. A5) THEN
3166 BB =-(CHI1 + WAER(1) - ROOT3)
3167 CC = 0.25D0*(WAER(1) - ROOT3)*(4.D0*CHI1+WAER(1)-ROOT3)
3168 DD =-0.25D0*(CHI1*(WAER(1)-ROOT3)**2.D0 - A5)
3169 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
3170 IF (ISLV.NE.0) ROOT1 = TINY
3171 ROOT1 = MIN (MAX(ROOT1,ZERO), MAX(WAER(1)-ROOT3,ZERO), &
3175 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
3178 !C ION CONCENTRATIONS
3180 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3)
3181 SO4I= WAER(2) - ROOT1
3182 NH4I= WAER(3) - ROOT2
3183 CLI = WAER(5) - (ROOT3 + ROOT2)
3186 !C SODIUM CHLORIDE ; To obtain new value for ROOT3
3188 IF (NAI*CLI .GT. A8) THEN
3189 BB =-((CHI1-2.D0*ROOT1) + (WAER(5) - ROOT2))
3190 CC = (CHI1-2.D0*ROOT1)*(WAER(5) - ROOT2) - A8
3191 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
3192 ROOT3A= 0.5D0*(-BB-SQRT(DD))
3193 ROOT3B= 0.5D0*(-BB+SQRT(DD))
3194 IF (ZERO.LE.ROOT3A) THEN
3199 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
3202 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
3205 !C SOLUTION ACIDIC OR BASIC?
3207 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
3208 IF (GG.GT.TINY) THEN ! H+ in excess
3211 DD = BB*BB - 4.D0*CC
3212 HI = 0.5D0*(-BB + SQRT(DD))
3214 ELSE ! OH- in excess
3217 DD = BB*BB - 4.D0*CC
3218 OHI= 0.5D0*(-BB + SQRT(DD))
3222 !C UNDISSOCIATED SPECIES EQUILIBRIA
3225 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
3228 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
3229 GGCL = MAX(GG-GGNO3, ZERO)
3230 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
3231 IF (GGNO3.GT.TINY) THEN
3232 IF (GGCL.LE.TINY) HI = ZERO
3233 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
3236 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
3238 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
3245 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
3255 !C *** CALCULATE WATER **************************************************
3259 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
3261 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3264 IF (PSCONV1.AND.PSCONV3.AND.PSCONV4) GOTO 20
3267 !ccc CALL PUSHERR (0002, 'CALCR3A') ! WARNING ERROR: NO CONVERGENCE
3269 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3271 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
3280 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
3281 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
3282 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
3294 CNH4CL = CHI4 - PSI4
3297 CNA2SO4 = CHI1 - PSI1
3302 !C *** END OF SUBROUTINE CALCR3A *****************************************
3305 !C=======================================================================
3307 !C *** ISORROPIA CODE
3308 !C *** SUBROUTINE CALCR2
3311 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3312 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3313 !C 2. SOLID AEROSOL ONLY
3314 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
3316 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3317 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3318 !C *** WRITTEN BY ATHANASIOS NENES
3320 !C=======================================================================
3322 SUBROUTINE CALCR22p1
3323 INCLUDE 'module_isrpia_inc.F'
3324 LOGICAL EXAN, EXAC, EXSN, EXSC
3325 EXTERNAL CALCR1A2p1, CALCR3A2p1, CALCR4A2p1, CALCR52p1
3327 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
3329 SCASE = 'R2 ; SUBCASE 2'
3330 CALL CALCR1A2p1 ! SOLID
3331 SCASE = 'R2 ; SUBCASE 2'
3333 EXAN = CNH4NO3.GT.TINY ! NH4NO3
3334 EXAC = CNH4CL .GT.TINY ! NH4CL
3335 EXSN = CNANO3 .GT.TINY ! NANO3
3336 EXSC = CNACL .GT.TINY ! NACL
3338 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
3340 IF (EXAN) THEN ! *** NH4NO3 EXISTS
3341 IF (RH.GE.DRMH1) THEN
3342 SCASE = 'R2 ; SUBCASE 1'
3344 SCASE = 'R2 ; SUBCASE 1'
3347 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
3348 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
3349 IF (RH.GE.DRMH2) THEN
3350 SCASE = 'R2 ; SUBCASE 3'
3351 CALL CALCMDRP2p1 (RH, DRMH2, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3352 SCASE = 'R2 ; SUBCASE 3'
3355 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
3356 IF (RH.GE.DRMR1) THEN
3357 SCASE = 'R2 ; SUBCASE 4'
3358 CALL CALCMDRP2p1 (RH, DRMR1, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3359 SCASE = 'R2 ; SUBCASE 4'
3362 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3363 IF (RH.GE.DRMR2) THEN
3364 SCASE = 'R2 ; SUBCASE 5'
3365 CALL CALCMDRP2p1 (RH, DRMR2, DRNACL, CALCR1A2p1, CALCR4A2p1)
3366 SCASE = 'R2 ; SUBCASE 5'
3369 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3370 IF (RH.GE.DRMR3) THEN
3371 SCASE = 'R2 ; SUBCASE 6'
3372 CALL CALCMDRP2p1 (RH, DRMR3, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3373 SCASE = 'R2 ; SUBCASE 6'
3376 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3377 IF (RH.GE.DRMR4) THEN
3378 SCASE = 'R2 ; SUBCASE 7'
3379 CALL CALCMDRP2p1 (RH, DRMR4, DRNACL, CALCR1A2p1, CALCR4A2p1)
3380 SCASE = 'R2 ; SUBCASE 7'
3383 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3384 IF (RH.GE.DRMR5) THEN
3385 SCASE = 'R2 ; SUBCASE 8'
3386 CALL CALCMDRP2p1 (RH, DRMR5, DRNH4CL, CALCR1A2p1, CALCR52p1)
3387 SCASE = 'R2 ; SUBCASE 8'
3390 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3391 IF (RH.GE.DRMR6) THEN
3392 SCASE = 'R2 ; SUBCASE 9'
3393 CALL CALCMDRP2p1 (RH, DRMR6, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3394 SCASE = 'R2 ; SUBCASE 9'
3402 !C *** END OF SUBROUTINE CALCR2 ******************************************
3407 !C=======================================================================
3409 !C *** ISORROPIA CODE
3410 !C *** SUBROUTINE CALCR2A
3413 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3414 !C 1. SULFATE POOR (SULRAT > 2.0); SODIUM RICH (SODRAT >= 2.0)
3415 !C 2. LIQUID AND SOLID PHASES ARE POSSIBLE
3417 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3418 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3419 !C *** WRITTEN BY ATHANASIOS NENES
3421 !C=======================================================================
3423 SUBROUTINE CALCR2A2p1
3424 INCLUDE 'module_isrpia_inc.F'
3426 LOGICAL PSCONV1, PSCONV2, PSCONV3, PSCONV4
3427 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ
3429 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3430 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
3431 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
3432 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
3433 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
3434 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
3436 !C *** SETUP PARAMETERS ************************************************
3457 !C *** CALCULATE INITIAL SOLUTION ***************************************
3461 CHI1 = CNA2SO4 ! SALTS
3472 CALL CALCMR2p1 ! WATER
3474 NAI = WAER(1) ! LIQUID CONCENTRATIONS
3492 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
3494 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3497 A5 = XK5 *(WATER/GAMA(2))**3. ! Na2SO4 <==> Na+
3498 A8 = XK8 *(WATER/GAMA(1))**2. ! NaCl <==> Na+
3499 A9 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
3500 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
3501 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
3503 !C AMMONIUM CHLORIDE
3505 IF (NH4I*CLI .GT. A14) THEN
3506 BB =-(WAER(3) + WAER(5) - ROOT3)
3507 CC = NH4I*(WAER(5) - ROOT3) - A14
3508 DD = MAX(BB*BB - 4.D0*CC, ZERO)
3510 ROOT2A= 0.5D0*(-BB+DD)
3511 ROOT2B= 0.5D0*(-BB-DD)
3512 IF (ZERO.LE.ROOT2A) THEN
3517 ROOT2 = MIN(MAX(ROOT2, ZERO), CHI4)
3520 PSCONV4 = ABS(PSI4-PSI4O) .LE. EPS*PSI4O
3525 IF (NAI*NAI*SO4I .GT. A5) THEN
3526 BB =-(WAER(2) + WAER(1) - ROOT3 - ROOT4)
3527 CC = WAER(1)*(2.D0*ROOT3 + 2.D0*ROOT4 - 4.D0*WAER(2) - ONE) &
3528 -(ROOT3 + ROOT4)**2.0 + 4.D0*WAER(2)*(ROOT3 + ROOT4)
3530 DD = WAER(1)*WAER(2)*(ONE - 2.D0*ROOT3 - 2.D0*ROOT4) + &
3531 WAER(2)*(ROOT3 + ROOT4)**2.0 - A5
3533 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
3534 IF (ISLV.NE.0) ROOT1 = TINY
3535 ROOT1 = MIN (MAX(ROOT1,ZERO), CHI1)
3538 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
3543 IF (NAI*NO3I .GT. A9) THEN
3544 BB =-(WAER(4) + WAER(1) - 2.D0*ROOT1 - ROOT3)
3545 CC = WAER(4)*(WAER(1) - 2.D0*ROOT1 - ROOT3) - A9
3546 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
3547 ROOT4A= 0.5D0*(-BB-DD)
3548 ROOT4B= 0.5D0*(-BB+DD)
3549 IF (ZERO.LE.ROOT4A) THEN
3554 ROOT4 = MIN(MAX(ROOT4, ZERO), CHI2)
3557 PSCONV2 = ABS(PSI2-PSI2O) .LE. EPS*PSI2O
3560 !C ION CONCENTRATIONS
3562 NAI = WAER(1) - (2.D0*ROOT1 + ROOT3 + ROOT4)
3563 SO4I= WAER(2) - ROOT1
3564 NH4I= WAER(3) - ROOT2
3565 NO3I= WAER(4) - ROOT4
3566 CLI = WAER(5) - (ROOT3 + ROOT2)
3568 !C SODIUM CHLORIDE ; To obtain new value for ROOT3
3570 IF (NAI*CLI .GT. A8) THEN
3571 BB =-(WAER(1) - 2.D0*ROOT1 + WAER(5) - ROOT2 - ROOT4)
3572 CC = (WAER(5) + ROOT2)*(WAER(1) - 2.D0*ROOT1 - ROOT4) - A8
3573 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
3574 ROOT3A= 0.5D0*(-BB-DD)
3575 ROOT3B= 0.5D0*(-BB+DD)
3576 IF (ZERO.LE.ROOT3A) THEN
3581 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
3584 PSCONV3 = ABS(PSI3-PSI3O) .LE. EPS*PSI3O
3587 !C SOLUTION ACIDIC OR BASIC?
3589 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I
3590 IF (GG.GT.TINY) THEN ! H+ in excess
3593 DD = BB*BB - 4.D0*CC
3594 HI = 0.5D0*(-BB + SQRT(DD))
3596 ELSE ! OH- in excess
3599 DD = BB*BB - 4.D0*CC
3600 OHI= 0.5D0*(-BB + SQRT(DD))
3604 !C UNDISSOCIATED SPECIES EQUILIBRIA
3607 CALL CALCAMAQ22p1 (-GG, NH4I, OHI, NH3AQ)
3610 GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I, ZERO)
3611 GGCL = MAX(GG-GGNO3, ZERO)
3612 IF (GGCL .GT.TINY) CALL CALCCLAQ22p1 (GGCL, CLI, HI, CLAQ) ! HCl
3613 IF (GGNO3.GT.TINY) THEN
3614 IF (GGCL.LE.TINY) HI = ZERO
3615 CALL CALCNIAQ22p1 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
3618 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
3620 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
3627 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
3637 !C *** CALCULATE WATER **************************************************
3641 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
3643 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3646 IF (PSCONV1.AND.PSCONV2.AND.PSCONV3.AND.PSCONV4) GOTO 20
3649 !ccc CALL PUSHERR (0002, 'CALCR2A') ! WARNING ERROR: NO CONVERGENCE
3651 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3653 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
3661 ELSE ! OK, aqueous phase present
3662 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
3663 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
3664 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
3676 CNH4CL = CHI4 - PSI4
3678 CNANO3 = CHI2 - PSI2
3679 CNA2SO4 = CHI1 - PSI1
3684 !C *** END OF SUBROUTINE CALCR2A *****************************************
3687 !C=======================================================================
3689 !C *** ISORROPIA CODE
3690 !C *** SUBROUTINE CALCR1
3693 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3694 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3695 !C 2. SOLID AEROSOL ONLY
3696 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4, NANO3, NACL
3698 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3699 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3700 !C *** WRITTEN BY ATHANASIOS NENES
3702 !C=======================================================================
3704 SUBROUTINE CALCR12p1
3705 INCLUDE 'module_isrpia_inc.F'
3706 LOGICAL EXAN, EXAC, EXSN, EXSC
3707 EXTERNAL CALCR1A2p1, CALCR2A2p1, CALCR3A2p1, CALCR4A2p1, CALCR52p1
3709 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
3711 SCASE = 'R1 ; SUBCASE 1'
3712 CALL CALCR1A2p1 ! SOLID
3713 SCASE = 'R1 ; SUBCASE 1'
3715 EXAN = CNH4NO3.GT.TINY ! NH4NO3
3716 EXAC = CNH4CL .GT.TINY ! NH4CL
3717 EXSN = CNANO3 .GT.TINY ! NANO3
3718 EXSC = CNACL .GT.TINY ! NACL
3720 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
3722 IF (EXAN.AND.EXAC.AND.EXSC.AND.EXSN) THEN ! *** ALL EXIST
3723 IF (RH.GE.DRMH1) THEN
3724 SCASE = 'R1 ; SUBCASE 2' ! MDRH
3725 CALL CALCMDRP2p1 (RH, DRMH1, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3726 SCASE = 'R1 ; SUBCASE 2'
3729 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
3730 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
3731 IF (RH.GE.DRMH2) THEN
3732 SCASE = 'R1 ; SUBCASE 3'
3733 CALL CALCMDRP2p1 (RH, DRMH2, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3734 SCASE = 'R1 ; SUBCASE 3'
3737 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
3738 IF (RH.GE.DRMR1) THEN
3739 SCASE = 'R1 ; SUBCASE 4'
3740 CALL CALCMDRP2p1 (RH, DRMR1, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3741 SCASE = 'R1 ; SUBCASE 4'
3744 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3745 IF (RH.GE.DRMR2) THEN
3746 SCASE = 'R1 ; SUBCASE 5'
3747 CALL CALCMDRP2p1 (RH, DRMR2, DRNACL, CALCR1A2p1, CALCR3A2p1) !, CALCR4A)
3748 SCASE = 'R1 ; SUBCASE 5'
3751 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3752 IF (RH.GE.DRMR3) THEN
3753 SCASE = 'R1 ; SUBCASE 6'
3754 CALL CALCMDRP2p1 (RH, DRMR3, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3755 SCASE = 'R1 ; SUBCASE 6'
3758 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
3759 IF (RH.GE.DRMR4) THEN
3760 SCASE = 'R1 ; SUBCASE 7'
3761 CALL CALCMDRP2p1 (RH, DRMR4, DRNACL, CALCR1A2p1, CALCR3A2p1) !, CALCR4A)
3762 SCASE = 'R1 ; SUBCASE 7'
3765 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3766 IF (RH.GE.DRMR5) THEN
3767 SCASE = 'R1 ; SUBCASE 8'
3768 CALL CALCMDRP2p1 (RH, DRMR5, DRNH4CL, CALCR1A2p1, CALCR3A2p1) !, CALCR5)
3769 SCASE = 'R1 ; SUBCASE 8'
3772 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
3773 IF (RH.GE.DRMR6) THEN
3774 SCASE = 'R1 ; SUBCASE 9'
3775 CALL CALCMDRP2p1 (RH, DRMR6, DRNANO3, CALCR1A2p1, CALCR3A2p1)
3776 SCASE = 'R1 ; SUBCASE 9'
3780 ELSE IF (.NOT.EXAC) THEN ! *** NH4CL = 0
3781 IF ( EXAN .AND. EXSN .AND. EXSC) THEN
3782 IF (RH.GE.DRMR7) THEN
3783 SCASE = 'R1 ; SUBCASE 10'
3784 CALL CALCMDRP2p1 (RH, DRMR7, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3785 SCASE = 'R1 ; SUBCASE 10'
3788 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. EXSC) THEN
3789 IF (RH.GE.DRMR8) THEN
3790 SCASE = 'R1 ; SUBCASE 11'
3791 CALL CALCMDRP2p1 (RH, DRMR8, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3792 SCASE = 'R1 ; SUBCASE 11'
3795 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
3796 IF (RH.GE.DRMR9) THEN
3797 SCASE = 'R1 ; SUBCASE 12'
3798 CALL CALCMDRP2p1 (RH, DRMR9, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3799 SCASE = 'R1 ; SUBCASE 12'
3802 ELSE IF ( EXAN .AND. EXSN .AND. .NOT.EXSC) THEN
3803 IF (RH.GE.DRMR10) THEN
3804 SCASE = 'R1 ; SUBCASE 13'
3805 CALL CALCMDRP2p1 (RH, DRMR10, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3806 SCASE = 'R1 ; SUBCASE 13'
3810 ELSE IF (.NOT.EXSN) THEN ! *** NANO3 = 0
3811 IF ( EXAN .AND. EXAC .AND. EXSC) THEN
3812 IF (RH.GE.DRMR11) THEN
3813 SCASE = 'R1 ; SUBCASE 14'
3814 CALL CALCMDRP2p1 (RH, DRMR11, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3815 SCASE = 'R1 ; SUBCASE 14'
3818 ELSE IF ( EXAN .AND. EXAC .AND. .NOT.EXSC) THEN
3819 IF (RH.GE.DRMR12) THEN
3820 SCASE = 'R1 ; SUBCASE 15'
3821 CALL CALCMDRP2p1 (RH, DRMR12, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3822 SCASE = 'R1 ; SUBCASE 15'
3826 ELSE IF (.NOT.EXSC) THEN ! *** NACL = 0
3827 IF ( EXAN .AND. EXAC .AND. EXSN) THEN
3828 IF (RH.GE.DRMR13) THEN
3829 SCASE = 'R1 ; SUBCASE 16'
3830 CALL CALCMDRP2p1 (RH, DRMR13, DRNH4NO3, CALCR1A2p1, CALCR2A2p1)
3831 SCASE = 'R1 ; SUBCASE 16'
3838 !C *** END OF SUBROUTINE CALCR1 ******************************************
3843 !C=======================================================================
3845 !C *** ISORROPIA CODE
3846 !C *** SUBROUTINE CALCR1A
3847 !C *** CASE R1 ; SUBCASE 1
3849 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3850 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3851 !C 2. SOLID AEROSOL ONLY
3852 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NANO3, NA2SO4, NANO3, NACL
3854 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3855 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3856 !C *** WRITTEN BY ATHANASIOS NENES
3858 !C=======================================================================
3860 SUBROUTINE CALCR1A2p1
3861 INCLUDE 'module_isrpia_inc.F'
3863 !C *** CALCULATE SOLIDS **************************************************
3866 FRNA = MAX (WAER(1)-2*CNA2SO4, ZERO)
3870 CNANO3 = MIN (FRNA, WAER(4))
3871 FRNO3 = MAX (WAER(4)-CNANO3, ZERO)
3872 FRNA = MAX (FRNA-CNANO3, ZERO)
3874 CNACL = MIN (FRNA, WAER(5))
3875 FRCL = MAX (WAER(5)-CNACL, ZERO)
3876 FRNA = MAX (FRNA-CNACL, ZERO)
3878 CNH4NO3 = MIN (FRNO3, WAER(3))
3879 FRNO3 = MAX (FRNO3-CNH4NO3, ZERO)
3880 FRNH3 = MAX (WAER(3)-CNH4NO3, ZERO)
3882 CNH4CL = MIN (FRCL, FRNH3)
3883 FRCL = MAX (FRCL-CNH4CL, ZERO)
3884 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
3886 !C *** OTHER PHASES ******************************************************
3896 !C *** END OF SUBROUTINE CALCR1A *****************************************
3899 !C=======================================================================
3901 !C *** ISORROPIA CODE II
3902 !C *** SUBROUTINE CALCV7
3905 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3906 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
3908 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3909 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3910 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
3912 !C=======================================================================
3914 SUBROUTINE CALCV72p1
3915 INCLUDE 'module_isrpia_inc.F'
3917 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
3919 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3920 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
3921 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
3922 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
3923 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
3924 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
3926 !C *** SETUP PARAMETERS ************************************************
3932 !C *** CALCULATE INITIAL SOLUTION ***************************************
3938 PSI1 = CNA2SO4 ! SALTS DISSOLVED
3946 CALL CALCMR2p1 ! WATER
3952 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3956 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
3958 !C ION CONCENTRATIONS
3961 SO4I = MAX (WAER(2) - WAER(6), ZERO)
3969 !C SOLUTION ACIDIC OR BASIC?
3971 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
3972 - 2.D0*CAI - KI - 2.D0*MGI
3973 IF (GG.GT.TINY) THEN ! H+ in excess
3976 DD = BB*BB - 4.D0*CC
3977 HI = 0.5D0*(-BB + SQRT(DD))
3979 ELSE ! OH- in excess
3982 DD = BB*BB - 4.D0*CC
3983 OHI= 0.5D0*(-BB + SQRT(DD))
3988 !C UNDISSOCIATED SPECIES EQUILIBRIA
3991 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
3995 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
3996 !C & - KI - 2.D0*MGI, ZERO)
3997 !C GGCL = MAX(GG-GGNO3, ZERO)
3998 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
3999 !C IF (GGNO3.GT.TINY) THEN
4000 !C IF (GGCL.LE.TINY) HI = ZERO
4001 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
4004 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
4006 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
4013 !C IF (HI.LE.TINY) HI = SQRT(AKW)
4016 IF (HI.LE.TINY) THEN
4021 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
4034 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4036 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4042 !ccc CALL PUSHERR (0002, 'CALCV7') ! WARNING ERROR: NO CONVERGENCE
4044 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4046 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
4047 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
4048 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
4064 CCASO4 = MIN (WAER(6), WAER(2))
4068 !C *** END OF SUBROUTINE CALCV7 ******************************************
4072 !C=======================================================================
4074 !C *** ISORROPIA CODE II
4075 !C *** SUBROUTINE CALCV6
4078 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4079 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
4080 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4081 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4
4082 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MGSO4, NA2SO4
4084 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4085 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4086 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
4088 !C=======================================================================
4090 SUBROUTINE CALCV62p1
4091 INCLUDE 'module_isrpia_inc.F'
4094 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
4096 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4097 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4098 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4099 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4100 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4101 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4103 !C *** SETUP PARAMETERS ************************************************
4110 PSI70 =-GREAT ! GREAT = 1.D10
4113 !C *** CALCULATE INITIAL SOLUTION ***************************************
4118 CHI7 = CK2SO4 ! SALTS
4120 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
4128 CALL CALCMR2p1 ! WATER
4130 NAI = WAER(1) ! LIQUID CONCENTRATIONS
4131 SO4I = MAX (WAER(2) - WAER(6), ZERO)
4144 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4148 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
4149 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
4151 !C POTASSIUM SULFATE
4153 IF (KI*KI*SO4I .GT. A7) THEN
4154 BB =-((WAER(2)-WAER(6)) + WAER(7))
4155 CC = WAER(7)*(WAER(2)-WAER(6)) + 0.25D0*WAER(7)*WAER(7)
4156 DD =-0.25*(WAER(7)*WAER(7)*WAER(2) - A7)
4157 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
4158 IF (ISLV.NE.0) ROOT7 = TINY
4159 ROOT7 = MIN (ROOT7,WAER(7)/2.0,MAX(WAER(2)-WAER(6),ZERO),CHI7)
4160 ROOT7 = MAX (ROOT7, ZERO)
4163 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
4166 !C ION CONCENTRATIONS ; CORRECTIONS
4168 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
4169 SO4I = MAX (WAER(2)-WAER(6) - ROOT7, ZERO)
4177 !C SOLUTION ACIDIC OR BASIC?
4179 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
4180 - 2.D0*CAI - KI - 2.D0*MGI
4181 IF (GG.GT.TINY) THEN ! H+ in excess
4184 DD = BB*BB - 4.D0*CC
4185 HI = 0.5D0*(-BB + SQRT(DD))
4187 ELSE ! OH- in excess
4190 DD = BB*BB - 4.D0*CC
4191 OHI= 0.5D0*(-BB + SQRT(DD))
4195 !C UNDISSOCIATED SPECIES EQUILIBRIA
4198 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
4202 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
4203 !C & - KI - 2.D0*MGI, ZERO)
4204 !C GGCL = MAX(GG-GGNO3, ZERO)
4205 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
4206 !C IF (GGNO3.GT.TINY) THEN
4207 !C IF (GGCL.LE.TINY) HI = ZERO
4208 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
4211 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
4213 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
4220 !C IF (HI.LE.TINY) HI = SQRT(AKW)
4223 IF (HI.LE.TINY) THEN
4228 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
4241 !C *** CALCULATE WATER **************************************************
4245 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4247 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4250 IF (PSCONV7) GOTO 20
4253 !ccc CALL PUSHERR (0002, 'CALCV6') ! WARNING ERROR: NO CONVERGENCE
4255 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4257 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
4258 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
4259 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
4274 CK2SO4 = CHI7 - PSI7
4275 CCASO4 = MIN (WAER(6), WAER(2))
4279 !C *** END OF SUBROUTINE CALCV6 ******************************************
4282 !C=======================================================================
4284 !C *** ISORROPIA CODE II
4285 !C *** SUBROUTINE CALCV5
4288 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4289 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
4290 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4291 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
4292 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MGSO4
4294 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4295 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4296 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
4298 !C=======================================================================
4300 SUBROUTINE CALCV52p1
4301 INCLUDE 'module_isrpia_inc.F'
4303 LOGICAL PSCONV7, PSCONV1
4304 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
4306 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4307 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4308 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4309 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4310 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4311 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4313 !C *** SETUP PARAMETERS ************************************************
4322 PSI70 =-GREAT ! GREAT = 1.D10
4328 !C *** CALCULATE INITIAL SOLUTION ***************************************
4333 CHI7 = CK2SO4 ! SALTS
4336 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
4344 CALL CALCMR2p1 ! WATER
4346 NAI = WAER(1) ! LIQUID CONCENTRATIONS
4347 SO4I = MAX (WAER(2) - WAER(6), ZERO)
4360 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4364 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
4365 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
4366 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
4368 !C POTASSIUM SULFATE
4370 IF (KI*KI*SO4I .GT. A7) THEN
4371 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
4372 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
4373 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
4374 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
4375 IF (ISLV.NE.0) ROOT7 = TINY
4376 ROOT7 = MAX (ROOT7, ZERO)
4377 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
4378 MAX(WAER(2)-WAER(6) - ROOT1, ZERO), CHI7)
4381 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
4386 IF (NAI*NAI*SO4I .GT. A1) THEN
4387 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7)
4388 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7) + 0.25*WAER(1)*WAER(1)
4389 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6)) - ROOT7) - A1)
4390 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
4391 IF (ISLV.NE.0) ROOT1 = TINY
4392 ROOT1 = MAX (ROOT1, ZERO)
4393 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
4394 MAX ((WAER(2)-WAER(6)) - ROOT7, ZERO), CHI1)
4397 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
4400 !C ION CONCENTRATIONS ; CORRECTIONS
4402 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
4403 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
4404 SO4I = MAX ((WAER(2)-WAER(6)) - ROOT7 - ROOT1, ZERO)
4411 !C SOLUTION ACIDIC OR BASIC?
4413 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
4414 - 2.D0*CAI - KI - 2.D0*MGI
4415 IF (GG.GT.TINY) THEN ! H+ in excess
4418 DD = BB*BB - 4.D0*CC
4419 HI = 0.5D0*(-BB + SQRT(DD))
4421 ELSE ! OH- in excess
4424 DD = BB*BB - 4.D0*CC
4425 OHI= 0.5D0*(-BB + SQRT(DD))
4429 !C UNDISSOCIATED SPECIES EQUILIBRIA
4432 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
4436 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
4437 !C & - KI - 2.D0*MGI, ZERO)
4438 !C GGCL = MAX(GG-GGNO3, ZERO)
4439 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
4440 !C IF (GGNO3.GT.TINY) THEN
4441 !C IF (GGCL.LE.TINY) HI = ZERO
4442 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
4445 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
4447 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
4454 !C IF (HI.LE.TINY) HI = SQRT(AKW)
4457 IF (HI.LE.TINY) THEN
4462 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
4475 !C *** CALCULATE WATER **************************************************
4479 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4481 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4484 IF (PSCONV7 .AND. PSCONV1) GOTO 20
4487 !ccc CALL PUSHERR (0002, 'CALCV5') ! WARNING ERROR: NO CONVERGENCE
4489 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4491 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
4492 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
4493 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
4506 CNA2SO4 = CHI1 - PSI1
4508 CK2SO4 = CHI7 - PSI7
4509 CCASO4 = MIN (WAER(6), WAER(2))
4513 !C *** END OF SUBROUTINE CALCV5******************************************
4517 !C=======================================================================
4519 !C *** ISORROPIA CODE II
4520 !C *** SUBROUTINE CALCV4
4523 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4524 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
4525 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4526 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4
4527 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4
4529 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4530 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4531 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
4533 !C=======================================================================
4535 SUBROUTINE CALCV42p1
4536 INCLUDE 'module_isrpia_inc.F'
4538 LOGICAL PSCONV7, PSCONV1
4539 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
4541 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4542 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4543 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4544 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4545 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4546 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4548 !C *** SETUP PARAMETERS ************************************************
4557 PSI70 =-GREAT ! GREAT = 1.D10
4563 !C *** CALCULATE INITIAL SOLUTION ***************************************
4568 CHI7 = CK2SO4 ! SALTS
4572 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
4580 CALL CALCMR2p1 ! WATER
4582 NAI = WAER(1) ! LIQUID CONCENTRATIONS
4596 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4600 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
4601 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
4602 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
4604 !C POTASSIUM SULFATE
4606 IF (KI*KI*SO4I .GT. A7) THEN
4607 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
4608 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
4609 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
4610 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
4611 IF (ISLV.NE.0) ROOT7 = TINY
4612 ROOT7 = MAX (ROOT7, ZERO)
4613 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
4614 MAX((WAER(2)-WAER(6)) - ROOT1, ZERO), CHI7)
4617 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
4622 IF (NAI*NAI*SO4I .GT. A1) THEN
4623 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7)
4624 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7) + 0.25*WAER(1)*WAER(1)
4625 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6)) - ROOT7) - A1)
4626 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
4627 IF (ISLV.NE.0) ROOT1 = TINY
4628 ROOT1 = MAX (ROOT1, ZERO)
4629 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
4630 MAX ((WAER(2)-WAER(6)) - ROOT7, ZERO), CHI1)
4633 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
4636 !C ION CONCENTRATIONS ; CORRECTIONS
4638 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
4639 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
4640 SO4I = MAX ((WAER(2)-WAER(6)) - ROOT7 - ROOT1, ZERO)
4647 !C SOLUTION ACIDIC OR BASIC?
4649 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
4650 - 2.D0*CAI - KI - 2.D0*MGI
4651 IF (GG.GT.TINY) THEN ! H+ in excess
4654 DD = BB*BB - 4.D0*CC
4655 HI = 0.5D0*(-BB + SQRT(DD))
4657 ELSE ! OH- in excess
4660 DD = BB*BB - 4.D0*CC
4661 OHI= 0.5D0*(-BB + SQRT(DD))
4665 !C UNDISSOCIATED SPECIES EQUILIBRIA
4668 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
4672 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
4673 !C & - KI - 2.D0*MGI, ZERO)
4674 !C GGCL = MAX(GG-GGNO3, ZERO)
4675 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
4676 !C IF (GGNO3.GT.TINY) THEN
4677 !C IF (GGCL.LE.TINY) HI = ZERO
4678 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
4681 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
4683 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
4690 !C IF (HI.LE.TINY) HI = SQRT(AKW)
4693 IF (HI.LE.TINY) THEN
4698 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
4711 !C *** CALCULATE WATER **************************************************
4715 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4717 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4720 IF (PSCONV7 .AND. PSCONV1) GOTO 20
4723 !ccc CALL PUSHERR (0002, 'CALCV4') ! WARNING ERROR: NO CONVERGENCE
4725 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4727 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
4728 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
4729 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
4742 CNA2SO4 = CHI1 - PSI1
4744 CK2SO4 = CHI7 - PSI7
4745 CCASO4 = MIN (WAER(6), WAER(2))
4749 !C *** END OF SUBROUTINE CALCV4******************************************
4753 !C=======================================================================
4755 !C *** ISORROPIA CODE II
4756 !C *** SUBROUTINE CALCV3
4759 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4760 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
4761 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4762 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, (NH4)2SO4
4764 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4765 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4766 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
4768 !C=======================================================================
4770 SUBROUTINE CALCV32p1
4771 INCLUDE 'module_isrpia_inc.F'
4773 EXTERNAL CALCV1A2p1, CALCV42p1
4775 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
4777 EXNO = WAER(4).GT.TINY
4778 EXCL = WAER(5).GT.TINY
4780 IF (EXNO .OR. EXCL) THEN ! *** NITRATE OR CHLORIDE EXISTS
4781 SCASE = 'V3 ; SUBCASE 1'
4783 SCASE = 'V3 ; SUBCASE 1'
4785 ELSE ! *** NO CHLORIDE AND NITRATE
4786 IF (RH.LT.DRMO3) THEN
4787 SCASE = 'V3 ; SUBCASE 2'
4788 CALL CALCV1A2p1 ! SOLID
4789 SCASE = 'V3 ; SUBCASE 2'
4791 SCASE = 'V3 ; SUBCASE 3' ! MDRH (CaSO4, (NH4)2SO4, MGSO4, NA2SO4, K2SO4)
4792 CALL CALCMDRPII2p1 (RH, DRMO3, DRNH42S4, CALCV1A2p1, CALCV42p1)
4793 SCASE = 'V3 ; SUBCASE 3'
4799 !C *** END OF SUBROUTINE CALCV3 ******************************************
4803 !C=======================================================================
4805 !C *** ISORROPIA CODE II
4806 !C *** SUBROUTINE CALCV3A
4809 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4810 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
4811 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4812 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, (NH4)2SO4
4813 !C 4. Completely dissolved: NH4NO3, NH4CL
4815 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4816 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4817 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
4819 !C=======================================================================
4821 SUBROUTINE CALCV3A2p1
4822 INCLUDE 'module_isrpia_inc.F'
4824 LOGICAL PSCONV7, PSCONV1, PSCONV6
4825 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
4827 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4828 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4829 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4830 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4831 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4832 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4834 !C *** SETUP PARAMETERS ************************************************
4844 PSI70 =-GREAT ! GREAT = 1.D10
4852 !C *** CALCULATE INITIAL SOLUTION ***************************************
4857 CHI7 = CK2SO4 ! SALTS
4862 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
4870 CALL CALCMR2p1 ! WATER
4872 NAI = WAER(1) ! LIQUID CONCENTRATIONS
4886 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4890 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
4891 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
4892 A6 = XK7 *(WATER/GAMA(4))**3.0 !(NH4)2SO4 <==> NH4+
4893 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
4895 !C POTASSIUM SULFATE
4897 IF (KI*KI*SO4I .GT. A7) THEN
4898 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1 - ROOT6)
4899 CC = WAER(7)*((WAER(2) - WAER(6)) - ROOT1 - ROOT6) + &
4900 0.25*WAER(7)*WAER(7)
4901 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6))-ROOT1-ROOT6)-A7)
4902 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
4903 IF (ISLV.NE.0) ROOT7 = TINY
4904 ROOT7 = MAX (ROOT7, ZERO)
4905 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
4906 MAX (WAER(2)-WAER(6)-ROOT1-ROOT6, ZERO), CHI7)
4909 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
4914 IF (NAI*NAI*SO4I .GT. A1) THEN
4915 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7 - ROOT6)
4916 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7 - ROOT6) + &
4917 0.25*WAER(1)*WAER(1)
4918 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6))-ROOT7-ROOT6)-A1)
4919 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
4920 IF (ISLV.NE.0) ROOT1 = TINY
4921 ROOT1 = MAX (ROOT1, ZERO)
4922 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
4923 MAX (WAER(2)-WAER(6)-ROOT7-ROOT6, ZERO), CHI1)
4926 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
4931 IF (NH4I*NH4I*SO4I .GT. A6) THEN
4932 BB =-((WAER(2)-WAER(6)) + WAER(3) - ROOT7 - ROOT1)
4933 CC = WAER(3)*((WAER(2)-WAER(6)) - ROOT7 - ROOT1) + &
4934 0.25*WAER(3)*WAER(3)
4935 DD =-0.25*(WAER(3)*WAER(3)*((WAER(2)-WAER(6))-ROOT7-ROOT1)-A6)
4936 CALL POLY32p1(BB, CC, DD, ROOT6, ISLV)
4937 IF (ISLV.NE.0) ROOT6 = TINY
4938 ROOT6 = MAX (ROOT6, ZERO)
4939 ROOT6 = MIN (ROOT6, WAER(3)/2.0, &
4940 MAX (WAER(2)-WAER(6)-ROOT7-ROOT1, ZERO), CHI6)
4943 PSCONV6 = ABS(PSI6-PSI60) .LE. EPS*PSI60
4945 !C ION CONCENTRATIONS ; CORRECTIONS
4947 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
4948 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
4949 SO4I = MAX (WAER(2)-WAER(6) - ROOT7 - ROOT1 - ROOT6, ZERO)
4950 NH4I = MAX (WAER(3) - 2.D0*ROOT6, ZERO)
4956 !C SOLUTION ACIDIC OR BASIC?
4958 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
4959 - 2.D0*CAI - KI - 2.D0*MGI
4960 IF (GG.GT.TINY) THEN ! H+ in excess
4963 DD = BB*BB - 4.D0*CC
4964 HI = 0.5D0*(-BB + SQRT(DD))
4966 ELSE ! OH- in excess
4969 DD = BB*BB - 4.D0*CC
4970 OHI= 0.5D0*(-BB + SQRT(DD))
4974 !C UNDISSOCIATED SPECIES EQUILIBRIA
4977 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
4981 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
4982 !C & - KI - 2.D0*MGI, ZERO)
4983 !C GGCL = MAX(GG-GGNO3, ZERO)
4984 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
4985 !C IF (GGNO3.GT.TINY) THEN
4986 !C IF (GGCL.LE.TINY) HI = ZERO
4987 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
4990 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
4992 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
4999 !C IF (HI.LE.TINY) HI = SQRT(AKW)
5002 IF (HI.LE.TINY) THEN
5007 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5020 !C *** CALCULATE WATER **************************************************
5024 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5026 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5029 IF (PSCONV7 .AND. PSCONV1 .AND. PSCONV6) GOTO 20
5032 !ccc CALL PUSHERR (0002, 'CALCV3') ! WARNING ERROR: NO CONVERGENCE
5034 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5036 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
5037 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
5038 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
5048 CNH42S4 = CHI6 - PSI6
5051 CNA2SO4 = CHI1 - PSI1
5053 CK2SO4 = CHI7 - PSI7
5054 CCASO4 = MIN (WAER(6), WAER(2))
5058 !C *** END OF SUBROUTINE CALCV3A******************************************
5062 !C=======================================================================
5064 !C *** ISORROPIA CODE
5065 !C *** SUBROUTINE CALCV2
5068 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5069 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
5070 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
5071 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, (NH4)2SO4, NH4CL
5073 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5074 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5075 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5077 !C=======================================================================
5079 SUBROUTINE CALCV22p1
5080 INCLUDE 'module_isrpia_inc.F'
5082 EXTERNAL CALCV1A2p1, CALCV3A2p1, CALCV42p1
5084 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
5086 EXNO = WAER(4).GT.TINY
5087 EXCL = WAER(5).GT.TINY
5089 IF (EXNO) THEN ! *** NITRATE EXISTS
5090 SCASE = 'V2 ; SUBCASE 1'
5092 SCASE = 'V2 ; SUBCASE 1'
5094 ELSEIF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
5095 IF (RH.LT.DRMO2) THEN
5096 SCASE = 'V2 ; SUBCASE 2'
5097 CALL CALCV1A2p1 ! SOLID
5098 SCASE = 'V2 ; SUBCASE 2'
5100 SCASE = 'V2 ; SUBCASE 3' ! MDRH CaSO4, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
5101 CALL CALCMDRPII2p1 (RH, DRMO2, DRNH4CL, CALCV1A2p1, CALCV3A2p1)
5102 SCASE = 'V2 ; SUBCASE 3'
5105 ELSE ! *** NO CHLORIDE AND NITRATE
5106 IF (RH.LT.DRMO3) THEN
5107 SCASE = 'V2 ; SUBCASE 2'
5108 CALL CALCV1A2p1 ! SOLID
5109 SCASE = 'V2 ; SUBCASE 2'
5111 SCASE = 'V2 ; SUBCASE 4' ! MDRH CaSO4, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
5112 CALL CALCMDRPII2p1 (RH, DRMO3, DRNH42S4, CALCV1A2p1, CALCV42p1)
5113 SCASE = 'V2 ; SUBCASE 4'
5119 !C *** END OF SUBROUTINE CALCV2 ******************************************
5123 !C=======================================================================
5125 !C *** ISORROPIA CODE II
5126 !C *** SUBROUTINE CALCV2A
5129 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5130 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
5131 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
5132 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, (NH4)2SO4, NH4CL
5133 !C 4. Completely dissolved: NH4NO3
5135 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5136 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5137 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5139 !C=======================================================================
5141 SUBROUTINE CALCV2A2p1
5142 INCLUDE 'module_isrpia_inc.F'
5144 LOGICAL PSCONV7, PSCONV1, PSCONV6, PSCONV4
5145 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
5147 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5148 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5149 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5150 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5151 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5152 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5154 !C *** SETUP PARAMETERS ************************************************
5165 PSI70 =-GREAT ! GREAT = 1.D10
5175 !C *** CALCULATE INITIAL SOLUTION ***************************************
5180 CHI7 = CK2SO4 ! SALTS
5186 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
5194 CALL CALCMR2p1 ! WATER
5196 NAI = WAER(1) ! LIQUID CONCENTRATIONS
5197 SO4I = MAX (WAER(2) - WAER(6), ZERO)
5210 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5214 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
5215 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
5216 A6 = XK7 *(WATER/GAMA(4))**3.0 ! (NH4)2SO4 <==> NH4+
5217 A14 = XK14*(WATER/GAMA(6))**2. ! NH4Cl <==> NH4+
5218 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
5220 !C AMMONIUM CHLORIDE
5222 IF (NH4I*CLI .GT. A14) THEN
5223 BB =-(WAER(3) + WAER(5) - 2.D0*ROOT6)
5224 CC = WAER(5)*(WAER(3) - 2.D0*ROOT6) - A14
5225 DD = BB*BB - 4.D0*CC
5226 IF (DD.LT.ZERO) THEN
5230 ROOT4A= 0.5D0*(-BB+DD)
5231 ROOT4B= 0.5D0*(-BB-DD)
5232 IF (ZERO.LE.ROOT4A) THEN
5237 ROOT4 = MAX(ROOT4, ZERO)
5238 ROOT4 = MIN(ROOT4, WAER(5), &
5239 MAX (WAER(3) - 2.D0*ROOT6, ZERO), CHI4)
5243 PSCONV4 = ABS(PSI4-PSI40) .LE. EPS*PSI40
5246 !C POTASSIUM SULFATE
5248 IF (KI*KI*SO4I .GT. A7) THEN
5249 BB =-((WAER(2) - WAER(6)) + WAER(7) - ROOT1 - ROOT6)
5250 CC = WAER(7)*((WAER(2) - WAER(6)) - ROOT1 - ROOT6) &
5251 + 0.25*WAER(7)*WAER(7)
5252 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6))-ROOT1-ROOT6)-A7)
5253 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
5254 IF (ISLV.NE.0) ROOT7 = TINY
5255 ROOT7 = MAX (ROOT7, ZERO)
5256 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
5257 MAX (WAER(2)-WAER(6)-ROOT1-ROOT6, ZERO), CHI7)
5260 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
5265 IF (NAI*NAI*SO4I .GT. A1) THEN
5266 BB =-((WAER(2) - WAER(6)) + WAER(1) - ROOT7 - ROOT6)
5267 CC = WAER(1)*((WAER(2) - WAER(6)) - ROOT7 - ROOT6) + &
5268 0.25*WAER(1)*WAER(1)
5269 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6))-ROOT7-ROOT6)-A1)
5270 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
5271 IF (ISLV.NE.0) ROOT1 = TINY
5272 ROOT1 = MAX (ROOT1, ZERO)
5273 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
5274 MAX (WAER(2)-WAER(6)-ROOT7-ROOT6, ZERO), CHI1)
5277 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
5282 IF (NH4I*NH4I*SO4I .GT. A6) THEN
5283 BB =-((WAER(2)-WAER(6)) + WAER(3) - ROOT7 - ROOT1 - ROOT4)
5284 CC = WAER(3)*((WAER(2)-WAER(6)) - ROOT7 - ROOT1) + 0.25* &
5285 (WAER(3)-ROOT4)**2.0 + ROOT4*(ROOT1+ROOT7-(WAER(2)-WAER(6)))
5286 DD =-0.25*((WAER(3)-ROOT4)**2.0 * &
5287 ((WAER(2)-WAER(6))-ROOT7-ROOT1) - A6)
5288 CALL POLY32p1(BB, CC, DD, ROOT6, ISLV)
5289 IF (ISLV.NE.0) ROOT6 = TINY
5290 ROOT6 = MAX (ROOT6, ZERO)
5291 ROOT6 = MIN (ROOT6, WAER(3)/2.0, &
5292 MAX (WAER(2)-WAER(6) - ROOT7 - ROOT1, ZERO), CHI6)
5295 PSCONV6 = ABS(PSI6-PSI60) .LE. EPS*PSI60
5298 !C ION CONCENTRATIONS ; CORRECTIONS
5300 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
5301 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
5302 SO4I = MAX (WAER(2)-WAER(6) - ROOT7 - ROOT1 - ROOT6, ZERO)
5303 NH4I = MAX (WAER(3) - 2.D0*ROOT6, ZERO)
5309 !C SOLUTION ACIDIC OR BASIC?
5311 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
5312 - 2.D0*CAI - KI - 2.D0*MGI
5313 IF (GG.GT.TINY) THEN ! H+ in excess
5316 DD = BB*BB - 4.D0*CC
5317 HI = 0.5D0*(-BB + SQRT(DD))
5319 ELSE ! OH- in excess
5322 DD = BB*BB - 4.D0*CC
5323 OHI= 0.5D0*(-BB + SQRT(DD))
5327 !C UNDISSOCIATED SPECIES EQUILIBRIA
5330 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5334 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
5335 !C & - KI - 2.D0*MGI, ZERO)
5336 !C GGCL = MAX(GG-GGNO3, ZERO)
5337 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
5338 !C IF (GGNO3.GT.TINY) THEN
5339 !C IF (GGCL.LE.TINY) HI = ZERO
5340 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
5343 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5345 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
5352 !C IF (HI.LE.TINY) HI = SQRT(AKW)
5355 IF (HI.LE.TINY) THEN
5360 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5373 !C *** CALCULATE WATER **************************************************
5377 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5379 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5382 IF (PSCONV7 .AND. PSCONV1 .AND. PSCONV6 .AND. PSCONV4) GOTO 20
5385 !ccc CALL PUSHERR (0002, 'CALCV2') ! WARNING ERROR: NO CONVERGENCE
5387 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5389 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
5390 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
5391 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
5401 CNH42S4 = CHI6 - PSI6
5403 CNH4CL = CHI4 - PSI4
5404 CNA2SO4 = CHI1 - PSI1
5406 CK2SO4 = CHI7 - PSI7
5407 CCASO4 = MIN (WAER(6), WAER(2))
5411 !C *** END OF SUBROUTINE CALCV2A******************************************
5415 !C=======================================================================
5417 !C *** ISORROPIA CODE II
5418 !C *** SUBROUTINE CALCV1
5421 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5422 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
5423 !C 2. SOLID AEROSOL ONLY
5424 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
5426 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5427 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5428 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5430 !C=======================================================================
5432 SUBROUTINE CALCV12p1
5433 INCLUDE 'module_isrpia_inc.F'
5435 EXTERNAL CALCV1A2p1, CALCV2A2p1, CALCV3A2p1, CALCV42p1
5437 !C *** REGIME DEPENDS ON AMBIENT RELATIVE HUMIDITY & POSSIBLE SPECIES ***
5439 EXNO = WAER(4).GT.TINY
5440 EXCL = WAER(5).GT.TINY
5442 IF (EXNO .AND. EXCL) THEN ! *** NITRATE & CHLORIDE EXIST
5443 IF (RH.LT.DRMO1) THEN
5444 SCASE = 'V1 ; SUBCASE 1'
5445 CALL CALCV1A2p1 ! SOLID
5446 SCASE = 'V1 ; SUBCASE 1'
5448 SCASE = 'V1 ; SUBCASE 2' ! MDRH (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
5449 CALL CALCMDRPII2p1 (RH, DRMO1, DRNH4NO3, CALCV1A2p1, CALCV2A2p1)
5450 SCASE = 'V1 ; SUBCASE 2'
5453 ELSE IF (EXNO .AND. .NOT.EXCL) THEN ! *** ONLY NITRATE EXISTS
5454 IF (RH.LT.DRMV1) THEN
5455 SCASE = 'V1 ; SUBCASE 1'
5456 CALL CALCV1A2p1 ! SOLID
5457 SCASE = 'V1 ; SUBCASE 1'
5459 SCASE = 'V1 ; SUBCASE 3' ! MDRH (NH4)2SO4, NH4NO3, NA2SO4, K2SO4, MGSO4, CASO4
5460 CALL CALCMDRPII2p1 (RH, DRMV1, DRNH4NO3, CALCV1A2p1, CALCV2A2p1)
5461 SCASE = 'V1 ; SUBCASE 3'
5464 ELSE IF (.NOT.EXNO .AND. EXCL) THEN ! *** ONLY CHLORIDE EXISTS
5465 IF (RH.LT.DRMO2) THEN
5466 SCASE = 'V1 ; SUBCASE 1'
5467 CALL CALCV1A2p1 ! SOLID
5468 SCASE = 'V1 ; SUBCASE 1'
5470 SCASE = 'V1 ; SUBCASE 4' ! MDRH (NH4)2SO4, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
5471 CALL CALCMDRPII2p1 (RH, DRMO2, DRNH4CL, CALCV1A2p1, CALCV3A2p1)
5472 SCASE = 'V1 ; SUBCASE 4'
5475 ELSE ! *** NO CHLORIDE AND NITRATE
5476 IF (RH.LT.DRMO3) THEN
5477 SCASE = 'V1 ; SUBCASE 1'
5478 CALL CALCV1A2p1 ! SOLID
5479 SCASE = 'V1 ; SUBCASE 1'
5481 SCASE = 'V1 ; SUBCASE 5' ! MDRH (NH4)2SO4, NA2SO4, K2SO4, MGSO4, CASO4
5482 CALL CALCMDRPII2p1 (RH, DRMO3, DRNH42S4, CALCV1A2p1, CALCV42p1)
5483 SCASE = 'V1 ; SUBCASE 5'
5489 !C IF (RH.LT.DRMO1) THEN
5490 !C SCASE = 'V1 ; SUBCASE 1'
5491 !C CALL CALCV1A ! SOLID PHASE ONLY POSSIBLE
5492 !C SCASE = 'V1 ; SUBCASE 1'
5494 !C SCASE = 'V1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
5495 !C CALL CALCMDRPII (RH, DRMO1, DRNH4NO3, CALCV1A, CALCV2A)
5496 !C SCASE = 'V1 ; SUBCASE 2'
5501 !C *** END OF SUBROUTINE CALCV1 ******************************************
5505 !C=======================================================================
5507 !C *** ISORROPIA CODE II
5508 !C *** SUBROUTINE CALCV1A
5511 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5512 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
5513 !C 2. SOLID AEROSOL ONLY
5514 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
5516 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5517 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5518 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5520 !C=======================================================================
5522 SUBROUTINE CALCV1A2p1
5523 INCLUDE 'module_isrpia_inc.F'
5525 !C *** CALCULATE SOLIDS **************************************************
5527 CCASO4 = MIN (WAER(6), WAER(2)) ! CCASO4
5528 SO4FR = MAX (WAER(2) - CCASO4, ZERO)
5529 CAFR = MAX (WAER(6) - CCASO4, ZERO)
5530 CK2SO4 = MIN (0.5D0*WAER(7), SO4FR) ! CK2SO4
5531 FRK = MAX (WAER(7) - 2.D0*CK2SO4, ZERO)
5532 SO4FR = MAX (SO4FR - CK2SO4, ZERO)
5533 CNA2SO4 = MIN (0.5D0*WAER(1), SO4FR) ! CNA2SO4
5534 NAFR = MAX (WAER(1) - 2.D0*CNA2SO4, ZERO)
5535 SO4FR = MAX (SO4FR - CNA2SO4, ZERO)
5536 CMGSO4 = MIN (WAER(8), SO4FR) ! CMGSO4
5537 FRMG = MAX(WAER(8) - CMGSO4, ZERO)
5538 SO4FR = MAX(SO4FR - CMGSO4, ZERO)
5539 CNH42S4 = MAX (MIN (SO4FR , 0.5d0*WAER(3)) , TINY)
5540 FRNH3 = MAX (WAER(3) - 2.D0*CNH42S4, ZERO)
5542 CNH4NO3 = MIN (FRNH3, WAER(4))
5543 !CCC FRNO3 = MAX (WAER(4) - CNH4NO3, ZERO)
5544 FRNH3 = MAX (FRNH3 - CNH4NO3, ZERO)
5546 CNH4CL = MIN (FRNH3, WAER(5))
5547 !CCC FRCL = MAX (WAER(5) - CNH4CL, ZERO)
5548 FRNH3 = MAX (FRNH3 - CNH4CL, ZERO)
5550 !C *** OTHER PHASES ******************************************************
5560 !C *** END OF SUBROUTINE CALCV1A *****************************************
5563 !C=======================================================================
5565 !C *** ISORROPIA CODE
5566 !C *** SUBROUTINE CALCU8
5569 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5570 !C 1. SULFATE POOR (SULRAT > 2.0); CRUSTAL+SODIUM RICH (CRNARAT >= 2.0); CRUSTAL POOR (CRRAT<2)
5571 !C 2. THERE IS ONLY A LIQUID PHASE
5573 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5574 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5575 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5577 !C=======================================================================
5579 SUBROUTINE CALCU82p1
5580 INCLUDE 'module_isrpia_inc.F'
5582 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
5584 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5585 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5586 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5587 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5588 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5589 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5591 !C *** SETUP PARAMETERS ************************************************
5595 CHI9 = CCASO4 ! SALTS
5610 !C *** CALCULATE WATER **************************************************
5614 !C *** SETUP LIQUID CONCENTRATIONS **************************************
5621 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5625 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
5628 SO4I = MAX(WAER(2) - WAER(6), ZERO)
5637 !C SOLUTION ACIDIC OR BASIC?
5639 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
5640 - 2.D0*CAI - KI - 2.D0*MGI
5641 IF (GG.GT.TINY) THEN ! H+ in excess
5644 DD = BB*BB - 4.D0*CC
5645 HI = 0.5D0*(-BB + SQRT(DD))
5647 ELSE ! OH- in excess
5650 DD = BB*BB - 4.D0*CC
5651 OHI= 0.5D0*(-BB + SQRT(DD))
5654 IF (HI.LE.TINY) HI = SQRT(AKW)
5657 !C UNDISSOCIATED SPECIES EQUILIBRIA
5660 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5664 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
5665 !C & - KI - 2.D0*MGI, ZERO)
5666 !C GGCL = MAX(GG-GGNO3, ZERO)
5667 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
5668 !C IF (GGNO3.GT.TINY) THEN
5669 !C IF (GGCL.LE.TINY) HI = ZERO
5670 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
5673 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5675 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
5682 !C IF (HI.LE.TINY) HI = SQRT(AKW)
5685 IF (HI.LE.TINY) THEN
5690 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5703 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5705 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5711 !ccc CALL PUSHERR (0002, 'CALCU8') ! WARNING ERROR: NO CONVERGENCE
5713 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5715 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
5716 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
5717 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
5735 CCASO4 = MIN (WAER(6), WAER(2))
5739 !C *** END OF SUBROUTINE CALCU8 ******************************************
5743 !C=======================================================================
5745 !C *** ISORROPIA CODE II
5746 !C *** SUBROUTINE CALCU7
5749 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5750 !C 1. SULFATE POOR (SO4RAT > 2.0), CRUSTAL+SODIUM RICH (CRNARAT >= 2.0); CRUSTAL POOR (CRRAT<2)
5751 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
5752 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4
5753 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MGSO4, NA2SO4
5755 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5756 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5757 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5759 !C=======================================================================
5761 SUBROUTINE CALCU72p1
5762 INCLUDE 'module_isrpia_inc.F'
5765 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
5767 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5768 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5769 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5770 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5771 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5772 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5774 !C *** SETUP PARAMETERS ************************************************
5781 PSI70 =-GREAT ! GREAT = 1.D10
5784 !C *** CALCULATE INITIAL SOLUTION ***************************************
5788 CHI7 = CK2SO4 ! SALTS
5801 CALL CALCMR2p1 ! WATER
5803 NAI = WAER(1) ! LIQUID CONCENTRATIONS
5804 SO4I = MAX (WAER(2) - WAER(6), ZERO)
5828 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
5830 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5834 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
5835 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
5837 !C POTASSIUM SULFATE
5839 IF (KI*KI*SO4I .GT. A7) THEN
5840 BB =-((WAER(2)-WAER(6)) + WAER(7))
5841 CC = WAER(7)*(WAER(2)-WAER(6)) + 0.25D0*WAER(7)*WAER(7)
5842 DD =-0.25*(WAER(7)*WAER(7)*(WAER(2)-WAER(6)) - A7)
5843 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
5844 IF (ISLV.NE.0) ROOT7 = TINY
5845 ROOT7 = MAX (ROOT7, ZERO)
5846 ROOT7 = MIN (ROOT7,WAER(7)/2.0,MAX(WAER(2)-WAER(6),ZERO),CHI7)
5849 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
5852 !C ION CONCENTRATIONS ; CORRECTIONS
5854 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
5855 SO4I = MAX (WAER(2) - WAER(6) - ROOT7, ZERO)
5863 !C SOLUTION ACIDIC OR BASIC?
5865 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
5866 - 2.D0*CAI - KI - 2.D0*MGI
5867 IF (GG.GT.TINY) THEN ! H+ in excess
5870 DD = BB*BB - 4.D0*CC
5871 HI = 0.5D0*(-BB + SQRT(DD))
5873 ELSE ! OH- in excess
5876 DD = BB*BB - 4.D0*CC
5877 OHI= 0.5D0*(-BB + SQRT(DD))
5880 !C IF (HI.LE.TINY) HI = SQRT(AKW)
5883 !C UNDISSOCIATED SPECIES EQUILIBRIA
5886 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
5890 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
5891 !C & - KI - 2.D0*MGI, ZERO)
5892 !C GGCL = MAX(GG-GGNO3, ZERO)
5893 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
5894 !C IF (GGNO3.GT.TINY) THEN
5895 !C IF (GGCL.LE.TINY) HI = ZERO
5896 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
5899 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
5901 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
5908 !C IF (HI.LE.TINY) HI = SQRT(AKW)
5911 IF (HI.LE.TINY) THEN
5916 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
5929 !C *** CALCULATE WATER **************************************************
5933 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5935 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5938 IF (PSCONV7) GOTO 20
5941 !ccc CALL PUSHERR (0002, 'CALCU7') ! WARNING ERROR: NO CONVERGENCE
5943 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5945 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
5946 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
5947 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
5964 CK2SO4 = CHI7 - PSI7
5965 CCASO4 = MIN (WAER(6), WAER(2))
5969 !C *** END OF SUBROUTINE CALCU7 ******************************************
5972 !C=======================================================================
5974 !C *** ISORROPIA CODE II
5975 !C *** SUBROUTINE CALCU6
5978 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5979 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
5980 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
5981 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
5982 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MGSO4
5984 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5985 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5986 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
5988 !C=======================================================================
5990 SUBROUTINE CALCU62p1
5991 INCLUDE 'module_isrpia_inc.F'
5993 LOGICAL PSCONV7, PSCONV1
5994 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
5996 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5997 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5998 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5999 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6000 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6001 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6003 !C *** SETUP PARAMETERS ************************************************
6012 PSI70 =-GREAT ! GREAT = 1.D10
6018 !C *** CALCULATE INITIAL SOLUTION ***************************************
6022 CHI1 = CNA2SO4 ! SALTS
6035 CALL CALCMR2p1 ! WATER
6037 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6038 SO4I = MAX (WAER(2) - WAER(6), ZERO)
6062 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
6064 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6068 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
6069 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
6070 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6072 !C POTASSIUM SULFATE
6074 IF (KI*KI*SO4I .GT. A7) THEN
6075 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
6076 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
6077 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
6078 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
6079 IF (ISLV.NE.0) ROOT7 = TINY
6080 ROOT7 = MAX (ROOT7, ZERO)
6081 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
6082 MAX((WAER(2)-WAER(6)) - ROOT1,ZERO), CHI7)
6086 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
6091 IF (NAI*NAI*SO4I .GT. A1) THEN
6092 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7)
6093 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7) + 0.25*WAER(1)*WAER(1)
6094 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6)) - ROOT7) - A1)
6095 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
6096 IF (ISLV.NE.0) ROOT1 = TINY
6097 ROOT1 = MAX (ROOT1, ZERO)
6098 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
6099 MAX((WAER(2)-WAER(6)) - ROOT7, ZERO) ,CHI1)
6102 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6105 !C ION CONCENTRATIONS ; CORRECTIONS
6107 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
6108 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
6109 SO4I = MAX (WAER(2) - WAER(6) - ROOT7 - ROOT1, ZERO)
6116 !C SOLUTION ACIDIC OR BASIC?
6118 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
6119 - 2.D0*CAI - KI - 2.D0*MGI
6120 IF (GG.GT.TINY) THEN ! H+ in excess
6123 DD = BB*BB - 4.D0*CC
6124 HI = 0.5D0*(-BB + SQRT(DD))
6126 ELSE ! OH- in excess
6129 DD = BB*BB - 4.D0*CC
6130 OHI= 0.5D0*(-BB + SQRT(DD))
6133 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6136 !C UNDISSOCIATED SPECIES EQUILIBRIA
6139 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6143 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
6144 !C & - KI - 2.D0*MGI, ZERO)
6145 !C GGCL = MAX(GG-GGNO3, ZERO)
6146 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6147 !C IF (GGNO3.GT.TINY) THEN
6148 !C IF (GGCL.LE.TINY) HI = ZERO
6149 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6152 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6154 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
6161 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6164 IF (HI.LE.TINY) THEN
6169 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6182 !C *** CALCULATE WATER **************************************************
6186 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6188 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6191 IF (PSCONV7 .AND. PSCONV1) GOTO 20
6194 !ccc CALL PUSHERR (0002, 'CALCU6') ! WARNING ERROR: NO CONVERGENCE
6196 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6198 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6199 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6200 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6215 CNA2SO4 = CHI1 - PSI1
6217 CK2SO4 = CHI7 - PSI7
6218 CCASO4 = MIN (WAER(6), WAER(2))
6222 !C *** END OF SUBROUTINE CALCU6******************************************
6225 !C=======================================================================
6227 !C *** ISORROPIA CODE II
6228 !C *** SUBROUTINE CALCU5
6231 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6232 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
6233 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6234 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4
6235 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL
6237 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6238 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6239 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
6241 !C=======================================================================
6243 SUBROUTINE CALCU52p1
6244 INCLUDE 'module_isrpia_inc.F'
6246 LOGICAL PSCONV7, PSCONV1
6247 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
6249 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6250 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6251 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6252 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6253 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6254 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6256 !C *** SETUP PARAMETERS ************************************************
6265 PSI70 =-GREAT ! GREAT = 1.D10
6271 !C *** CALCULATE INITIAL SOLUTION ***************************************
6275 CHI1 = CNA2SO4 ! SALTS
6289 CALL CALCMR2p1 ! WATER
6291 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6292 SO4I = MAX (WAER(2) - WAER(6), ZERO)
6316 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
6318 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6321 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
6322 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
6323 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6325 !C POTASSIUM SULFATE
6327 IF (KI*KI*SO4I .GT. A7) THEN
6328 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
6329 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
6330 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
6331 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
6332 IF (ISLV.NE.0) ROOT7 = TINY
6333 ROOT7 = MAX (ROOT7, ZERO)
6334 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
6335 MAX(WAER(2)-WAER(6)-ROOT1, ZERO),CHI7)
6338 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
6343 IF (NAI*NAI*SO4I .GT. A1) THEN
6344 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7)
6345 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7) + 0.25*WAER(1)*WAER(1)
6346 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6)) - ROOT7) - A1)
6347 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
6348 IF (ISLV.NE.0) ROOT1 = TINY
6349 ROOT1 = MAX (ROOT1, ZERO)
6350 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
6351 MAX(WAER(2)-WAER(6)-ROOT7, ZERO),CHI1)
6354 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6357 !C ION CONCENTRATIONS ; CORRECTIONS
6359 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
6360 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
6361 SO4I = MAX (WAER(2)-WAER(6) - ROOT7 - ROOT1, ZERO)
6368 !C SOLUTION ACIDIC OR BASIC?
6370 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
6371 - 2.D0*CAI - KI - 2.D0*MGI
6372 IF (GG.GT.TINY) THEN ! H+ in excess
6375 DD = BB*BB - 4.D0*CC
6376 HI = 0.5D0*(-BB + SQRT(DD))
6378 ELSE ! OH- in excess
6381 DD = BB*BB - 4.D0*CC
6382 OHI= 0.5D0*(-BB + SQRT(DD))
6385 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6388 !C UNDISSOCIATED SPECIES EQUILIBRIA
6391 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6395 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
6396 !C & - KI - 2.D0*MGI, ZERO)
6397 !C GGCL = MAX(GG-GGNO3, ZERO)
6398 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6399 !C IF (GGNO3.GT.TINY) THEN
6400 !C IF (GGCL.LE.TINY) HI = ZERO
6401 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6404 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6406 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
6413 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6416 IF (HI.LE.TINY) THEN
6421 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6434 !C *** CALCULATE WATER **************************************************
6438 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6440 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6443 IF (PSCONV7 .AND. PSCONV1) GOTO 20
6446 !ccc CALL PUSHERR (0002, 'CALCU5') ! WARNING ERROR: NO CONVERGENCE
6448 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6450 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6451 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6452 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6467 CNA2SO4 = CHI1 - PSI1
6469 CK2SO4 = CHI7 - PSI7
6470 CCASO4 = MIN (WAER(6), WAER(2))
6474 !C *** END OF SUBROUTINE CALCU5******************************************
6478 !C=======================================================================
6480 !C *** ISORROPIA CODE II
6481 !C *** SUBROUTINE CALCU4
6484 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6485 !C 1. SULFATE POOR (SO4RAT > 2.0), (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
6486 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6487 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL
6489 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6490 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6491 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
6493 !C=======================================================================
6495 SUBROUTINE CALCU42p1
6496 INCLUDE 'module_isrpia_inc.F'
6497 LOGICAL EXAN, EXAC, EXSN, EXSC
6498 EXTERNAL CALCU1A2p1, CALCU52p1
6500 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
6502 SCASE = 'U4 ; SUBCASE 2'
6503 CALL CALCU1A2p1 ! SOLID
6504 SCASE = 'U4 ; SUBCASE 2'
6506 EXAN = CNH4NO3.GT.TINY ! NH4NO3
6507 EXAC = CNH4CL .GT.TINY ! NH4CL
6508 EXSN = CNANO3 .GT.TINY ! NANO3
6509 EXSC = CNACL .GT.TINY ! NACL
6511 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
6513 IF (EXAN .OR. EXSN .OR. EXSC) THEN ! *** NH4NO3,NANO3 EXIST
6514 IF (RH.GE.DRMM1) THEN
6515 SCASE = 'U4 ; SUBCASE 1'
6517 SCASE = 'U4 ; SUBCASE 1'
6520 ELSE IF (EXAC) THEN ! *** NH4CL EXISTS ONLY
6521 IF (RH.GE.DRMR5) THEN
6522 SCASE = 'U4 ; SUBCASE 3'
6523 CALL CALCMDRPII2p1 (RH, DRMR5, DRNH4CL, CALCU1A2p1, CALCU52p1)
6524 SCASE = 'U4 ; SUBCASE 3'
6530 !C *** END OF SUBROUTINE CALCU4 ******************************************
6534 !C=======================================================================
6536 !C *** ISORROPIA CODE II
6537 !C *** SUBROUTINE CALCU4A
6540 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6541 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
6542 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6543 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL
6544 !C 4. Completely dissolved: NH4NO3, NANO3, NACL
6546 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6547 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6548 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
6550 !C=======================================================================
6552 SUBROUTINE CALCU4A2p1
6553 INCLUDE 'module_isrpia_inc.F'
6555 LOGICAL PSCONV7, PSCONV1, PSCONV4
6556 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
6558 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6559 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6560 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6561 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6562 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6563 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6565 !C *** SETUP PARAMETERS ************************************************
6575 PSI70 =-GREAT ! GREAT = 1.D10
6583 !C *** CALCULATE INITIAL SOLUTION ***************************************
6587 CHI1 = CNA2SO4 ! SALTS
6602 CALL CALCMR2p1 ! WATER
6604 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6605 SO4I = MAX (WAER(2) - WAER(6), ZERO)
6629 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
6631 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6635 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
6636 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
6637 A14 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
6638 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6640 !C POTASSIUM SULFATE
6642 IF (KI*KI*SO4I .GT. A7) THEN
6643 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
6644 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
6645 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
6646 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
6647 IF (ISLV.NE.0) ROOT7 = TINY
6648 ROOT7 = MAX (ROOT7, ZERO)
6649 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
6650 MAX(WAER(2)-WAER(6)-ROOT1, ZERO), CHI7)
6653 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
6658 IF (NAI*NAI*SO4I .GT. A1) THEN
6659 BB =-((WAER(2)-WAER(6)) + WAER(1) - ROOT7)
6660 CC = WAER(1)*((WAER(2)-WAER(6)) - ROOT7) + 0.25*WAER(1)*WAER(1)
6661 DD =-0.25*(WAER(1)*WAER(1)*((WAER(2)-WAER(6)) - ROOT7) - A1)
6662 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
6663 IF (ISLV.NE.0) ROOT1 = TINY
6664 ROOT1 = MAX (ROOT1, ZERO)
6665 ROOT1 = MIN (ROOT1, WAER(1)/2.0, &
6666 MAX (WAER(2)-WAER(6)-ROOT7, ZERO), CHI1)
6669 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
6672 !C AMMONIUM CHLORIDE
6674 IF (NH4I*CLI .GT. A14) THEN
6677 DD = BB*BB - 4.D0*CC
6678 ROOT4 = 0.5D0*(-BB-SQRT(DD))
6679 IF (ROOT4.GT.TINY) THEN
6680 ROOT4 = MIN(MAX (ROOT4, ZERO), CHI4)
6684 PSCONV4 = ABS(PSI4-PSI40) .LE. EPS*PSI40
6687 !C ION CONCENTRATIONS ; CORRECTIONS
6689 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
6690 NAI = MAX (WAER(1) - 2.D0*ROOT1, ZERO)
6691 SO4I = MAX (WAER(2) - WAER(6) - ROOT7 - ROOT1, ZERO)
6692 NH4I = MAX (WAER(3) - ROOT4, ZERO)
6694 CLI = MAX (WAER(5) - ROOT4, ZERO)
6698 !C SOLUTION ACIDIC OR BASIC?
6700 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
6701 - 2.D0*CAI - KI - 2.D0*MGI
6702 IF (GG.GT.TINY) THEN ! H+ in excess
6705 DD = BB*BB - 4.D0*CC
6706 HI = 0.5D0*(-BB + SQRT(DD))
6708 ELSE ! OH- in excess
6711 DD = BB*BB - 4.D0*CC
6712 OHI= 0.5D0*(-BB + SQRT(DD))
6715 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6718 !C UNDISSOCIATED SPECIES EQUILIBRIA
6721 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
6725 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
6726 !C & - KI - 2.D0*MGI, ZERO)
6727 !C GGCL = MAX(GG-GGNO3, ZERO)
6728 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
6729 !C IF (GGNO3.GT.TINY) THEN
6730 !C IF (GGCL.LE.TINY) HI = ZERO
6731 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
6734 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
6736 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
6743 !C IF (HI.LE.TINY) HI = SQRT(AKW)
6746 IF (HI.LE.TINY) THEN
6751 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6764 !C *** CALCULATE WATER **************************************************
6768 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6770 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6773 IF (PSCONV7 .AND. PSCONV1 .AND. PSCONV4) GOTO 20
6776 !ccc CALL PUSHERR (0002, 'CALCU4') ! WARNING ERROR: NO CONVERGENCE
6778 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
6780 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
6781 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
6782 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
6794 CNH4CL = CHI4 - PSI4
6797 CNA2SO4 = CHI1 - PSI1
6799 CK2SO4 = CHI7 - PSI7
6800 CCASO4 = MIN (WAER(6), WAER(2))
6804 !C *** END OF SUBROUTINE CALCU4A ****************************************
6808 !C=======================================================================
6810 !C *** ISORROPIA CODE II
6811 !C *** SUBROUTINE CALCU3
6814 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6815 !C 1. SULFATE POOR (SO4RAT > 2.0), (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
6816 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6817 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL, NANO3
6819 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6820 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6821 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
6823 !C=======================================================================
6825 SUBROUTINE CALCU32p1
6826 INCLUDE 'module_isrpia_inc.F'
6827 LOGICAL EXAN, EXAC, EXSN, EXSC
6828 EXTERNAL CALCU1A2p1, CALCU4A2p1, CALCU52p1
6830 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
6832 SCASE = 'U3 ; SUBCASE 2'
6833 CALL CALCU1A2p1 ! SOLID
6834 SCASE = 'U3 ; SUBCASE 2'
6836 EXAN = CNH4NO3.GT.TINY ! NH4NO3
6837 EXAC = CNH4CL .GT.TINY ! NH4CL
6838 EXSN = CNANO3 .GT.TINY ! NANO3
6839 EXSC = CNACL .GT.TINY ! NACL
6841 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
6843 IF (EXAN .OR. EXSN) THEN ! *** NH4NO3,NANO3 EXIST
6844 IF (RH.GE.DRMM1) THEN
6845 SCASE = 'U3 ; SUBCASE 1'
6847 SCASE = 'U3 ; SUBCASE 1'
6850 ELSE IF (.NOT.EXAN .AND. .NOT.EXSN) THEN ! *** NH4NO3,NANO3 = 0
6851 IF ( EXAC .AND. EXSC) THEN
6852 IF (RH.GE.DRMR4) THEN
6853 SCASE = 'U3 ; SUBCASE 3'
6854 CALL CALCMDRPII2p1 (RH, DRMR4, DRNACL, CALCU1A2p1, CALCU4A2p1)
6855 SCASE = 'U3 ; SUBCASE 3'
6858 ELSE IF (.NOT.EXAC .AND. EXSC) THEN
6859 IF (RH.GE.DRMR2) THEN
6860 SCASE = 'U3 ; SUBCASE 4'
6861 CALL CALCMDRPII2p1 (RH, DRMR2, DRNACL, CALCU1A2p1, CALCU4A2p1)
6862 SCASE = 'U3 ; SUBCASE 4'
6865 ELSE IF ( EXAC .AND. .NOT.EXSC) THEN
6866 IF (RH.GE.DRMR5) THEN
6867 SCASE = 'U3 ; SUBCASE 5'
6868 CALL CALCMDRPII2p1 (RH, DRMR5, DRNACL, CALCU1A2p1, CALCU52p1)
6869 SCASE = 'U3 ; SUBCASE 5'
6877 !C *** END OF SUBROUTINE CALCU3 ******************************************
6881 !C=======================================================================
6883 !C *** ISORROPIA CODE II
6884 !C *** SUBROUTINE CALCU3A
6887 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6888 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
6889 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6890 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL, NACL
6891 !C 4. Completely dissolved: NH4NO3, NANO3
6893 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6894 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6895 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
6897 !C=======================================================================
6899 SUBROUTINE CALCU3A2p1
6900 INCLUDE 'module_isrpia_inc.F'
6902 LOGICAL PSCONV7, PSCONV1, PSCONV4, PSCONV3
6903 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
6905 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6906 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6907 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6908 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6909 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6910 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6912 !C *** SETUP PARAMETERS ************************************************
6923 PSI70 =-GREAT ! GREAT = 1.D10
6933 !C *** CALCULATE INITIAL SOLUTION ***************************************
6937 CHI1 = CNA2SO4 ! SALTS
6944 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
6953 CALL CALCMR2p1 ! WATER
6955 NAI = WAER(1) ! LIQUID CONCENTRATIONS
6956 SO4I = MAX (WAER(2) - WAER(6), ZERO)
6980 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
6982 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6986 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
6987 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
6988 A14 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
6989 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
6990 A8 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
6992 !C POTASSIUM SULFATE
6994 IF (KI*KI*SO4I .GT. A7) THEN
6995 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
6996 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
6997 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
6998 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
6999 IF (ISLV.NE.0) ROOT7 = TINY
7000 ROOT7 = MAX (ROOT7, ZERO)
7001 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
7002 MAX(WAER(2)-WAER(6)-ROOT1, ZERO),CHI7)
7005 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
7010 IF (NAI*NAI*SO4I .GT. A1) THEN
7011 BB =-(((WAER(2)-WAER(6))-ROOT7)*(WAER(1) - ROOT3))
7012 CC = ((WAER(2) - WAER(6)) - ROOT7)*(WAER(1) - ROOT3) + &
7013 0.25D0*(WAER(1) - ROOT3)**2.
7014 DD =-0.25D0*(((WAER(2) - WAER(6)) - ROOT7)* &
7015 (WAER(1) - ROOT3)**2.D0 - A1)
7016 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
7017 IF (ISLV.NE.0) ROOT1 = TINY
7018 ROOT1 = MIN (MAX(ROOT1, ZERO), MAX(WAER(1) - ROOT3, ZERO), &
7019 CHI1, MAX(WAER(2)-WAER(6), ZERO))
7022 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
7025 !C AMMONIUM CHLORIDE
7027 IF (NH4I*CLI .GT. A14) THEN
7028 BB =-(WAER(3) + WAER(5) - ROOT4)
7029 CC =-A14 + NH4I*(WAER(5) - ROOT4)
7030 DD = MAX(BB*BB - 4.D0*CC, ZERO)
7031 ROOT4A= 0.5D0*(-BB+SQRT(DD))
7032 ROOT4B= 0.5D0*(-BB-SQRT(DD))
7033 IF (ZERO.LE.ROOT4A) THEN
7038 ROOT4 = MIN(MAX(ZERO, ROOT4), MAX(WAER(5)-ROOT3,ZERO), &
7042 PSCONV4 = ABS(PSI4-PSI40) .LE. EPS*PSI40
7045 !C SODIUM CHLORIDE ; To obtain new value for ROOT3
7047 IF (NAI*CLI .GT. A8) THEN
7048 BB =-((CHI1-2.D0*ROOT1) + (WAER(5) - ROOT4))
7049 CC = (CHI1-2.D0*ROOT1)*(WAER(5) - ROOT4) - A8
7050 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7051 ROOT3A= 0.5D0*(-BB-SQRT(DD))
7052 ROOT3B= 0.5D0*(-BB+SQRT(DD))
7053 IF (ZERO.LE.ROOT3A) THEN
7058 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
7061 PSCONV3 = ABS(PSI3-PSI30) .LE. EPS*PSI30
7064 !C ION CONCENTRATIONS ; CORRECTIONS
7066 KI = MAX (WAER(7) - 2.D0*ROOT7, ZERO)
7067 NAI = MAX (WAER(1) - 2.D0*ROOT1 - ROOT3, ZERO)
7068 SO4I = MAX (WAER(2)-WAER(6) - ROOT7 - ROOT1, ZERO)
7069 NH4I = MAX (WAER(3) - ROOT4, ZERO)
7071 CLI = MAX (WAER(5) - ROOT4 - ROOT3, ZERO)
7075 !C SOLUTION ACIDIC OR BASIC?
7077 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
7078 - 2.D0*CAI - KI - 2.D0*MGI
7079 IF (GG.GT.TINY) THEN ! H+ in excess
7082 DD = BB*BB - 4.D0*CC
7083 HI = 0.5D0*(-BB + SQRT(DD))
7085 ELSE ! OH- in excess
7088 DD = BB*BB - 4.D0*CC
7089 OHI= 0.5D0*(-BB + SQRT(DD))
7092 !C IF (HI.LE.TINY) HI = SQRT(AKW)
7095 !C UNDISSOCIATED SPECIES EQUILIBRIA
7098 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7102 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
7103 !C & - KI - 2.D0*MGI, ZERO)
7104 !C GGCL = MAX(GG-GGNO3, ZERO)
7105 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
7106 !C IF (GGNO3.GT.TINY) THEN
7107 !C IF (GGCL.LE.TINY) HI = ZERO
7108 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
7111 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
7113 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
7120 !C IF (HI.LE.TINY) HI = SQRT(AKW)
7123 IF (HI.LE.TINY) THEN
7128 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7141 !C *** CALCULATE WATER **************************************************
7145 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7147 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7150 IF (PSCONV7 .AND. PSCONV1 .AND. PSCONV4 .AND. PSCONV3) GOTO 20
7153 !ccc CALL PUSHERR (0002, 'CALCU3A') ! WARNING ERROR: NO CONVERGENCE
7155 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7157 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
7166 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
7167 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
7168 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
7180 CNH4CL = CHI4 - PSI4
7183 CNA2SO4 = CHI1 - PSI1
7185 CK2SO4 = CHI7 - PSI7
7186 CCASO4 = MIN (WAER(6), WAER(2))
7191 !C *** END OF SUBROUTINE CALCU3A*****************************************
7195 !C=======================================================================
7197 !C *** ISORROPIA CODE II
7198 !C *** SUBROUTINE CALCU2
7201 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7202 !C 1. SULFATE POOR (SO4RAT > 2.0), (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
7203 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7204 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL, NANO3, NACL
7206 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7207 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7208 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
7210 !C=======================================================================
7212 SUBROUTINE CALCU22p1
7213 INCLUDE 'module_isrpia_inc.F'
7214 LOGICAL EXAN, EXAC, EXSN, EXSC
7215 EXTERNAL CALCU1A2p1, CALCU3A2p1, CALCU4A2p1, CALCU52p1
7217 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
7219 SCASE = 'U2 ; SUBCASE 2'
7220 CALL CALCU1A2p1 ! SOLID
7221 SCASE = 'U2 ; SUBCASE 2'
7223 EXAN = CNH4NO3.GT.TINY ! NH4NO3
7224 EXAC = CNH4CL .GT.TINY ! NH4CL
7225 EXSN = CNANO3 .GT.TINY ! NANO3
7226 EXSC = CNACL .GT.TINY ! NACL
7228 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
7230 IF (EXAN) THEN ! *** NH4NO3 EXISTS
7231 IF (RH.GE.DRMM1) THEN
7232 SCASE = 'U2 ; SUBCASE 1'
7234 SCASE = 'U2 ; SUBCASE 1'
7237 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
7238 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
7239 IF (RH.GE.DRMM2) THEN
7240 SCASE = 'U2 ; SUBCASE 3'
7241 CALL CALCMDRPII2p1 (RH, DRMM2, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7242 SCASE = 'U2 ; SUBCASE 3'
7245 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
7246 IF (RH.GE.DRMR1) THEN
7247 SCASE = 'U2 ; SUBCASE 4'
7248 CALL CALCMDRPII2p1 (RH, DRMR1, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7249 SCASE = 'U2 ; SUBCASE 4'
7252 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7253 IF (RH.GE.DRMR2) THEN
7254 SCASE = 'U2 ; SUBCASE 5'
7255 CALL CALCMDRPII2p1 (RH, DRMR2, DRNACL, CALCU1A2p1, CALCU4A2p1)
7256 SCASE = 'U2 ; SUBCASE 5'
7259 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7260 IF (RH.GE.DRMR3) THEN
7261 SCASE = 'U2 ; SUBCASE 6'
7262 CALL CALCMDRPII2p1 (RH, DRMR3, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7263 SCASE = 'U2 ; SUBCASE 6'
7266 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7267 IF (RH.GE.DRMR4) THEN
7268 SCASE = 'U2 ; SUBCASE 7'
7269 CALL CALCMDRPII2p1 (RH, DRMR4, DRNACL, CALCU1A2p1, CALCU4A2p1)
7270 SCASE = 'U2 ; SUBCASE 7'
7273 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
7274 IF (RH.GE.DRMR5) THEN
7275 SCASE = 'U2 ; SUBCASE 8'
7276 CALL CALCMDRPII2p1 (RH, DRMR5, DRNH4CL, CALCU1A2p1, CALCU52p1)
7277 SCASE = 'U2 ; SUBCASE 8'
7280 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7281 IF (RH.GE.DRMR6) THEN
7282 SCASE = 'U2 ; SUBCASE 9'
7283 CALL CALCMDRPII2p1 (RH, DRMR6, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7284 SCASE = 'U2 ; SUBCASE 9'
7292 !C IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
7293 !C SCASE = 'U2 ; SUBCASE 1'
7295 !C SCASE = 'U2 ; SUBCASE 1'
7296 !C ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
7297 !C SCASE = 'U2 ; SUBCASE 1'
7299 !C SCASE = 'U2 ; SUBCASE 1'
7302 !C IF (WATER.LE.TINY .AND. RH.LT.DRMM2) THEN ! DRY AEROSOL
7303 !C SCASE = 'U2 ; SUBCASE 2'
7305 !C SCASE = 'U2 ; SUBCASE 1'
7307 !C ELSEIF (WATER.LE.TINY .AND. RH.GE.DRMM2) THEN ! MDRH OF M2
7308 !C SCASE = 'U2 ; SUBCASE 3'
7309 !C CALL CALCMDRPII (RH, DRMM2, DRNANO3, CALCU1A, CALCU3A)
7310 !C SCASE = 'U2 ; SUBCASE 3'
7315 !C *** END OF SUBROUTINE CALCU2 ******************************************
7319 !C=======================================================================
7321 !C *** ISORROPIA CODE II
7322 !C *** SUBROUTINE CALCU2A
7325 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7326 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
7327 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7328 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3
7329 !C 4. Completely dissolved: NH4NO3
7331 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7332 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7333 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
7335 !C=======================================================================
7337 SUBROUTINE CALCU2A2p1
7338 INCLUDE 'module_isrpia_inc.F'
7340 LOGICAL PSCONV7, PSCONV1, PSCONV4, PSCONV3, PSCONV5
7341 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
7343 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7344 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
7345 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
7346 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
7347 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
7348 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
7350 !C *** SETUP PARAMETERS ************************************************
7362 PSI70 =-GREAT ! GREAT = 1.D10
7374 !C *** CALCULATE INITIAL SOLUTION ***************************************
7378 CHI1 = CNA2SO4 ! SALTS
7386 PSI1 = CNA2SO4 ! AMOUNT DISSOLVED
7395 CALL CALCMR2p1 ! WATER
7397 NAI = WAER(1) ! LIQUID CONCENTRATIONS
7398 SO4I = MAX (WAER(2) - WAER(6), ZERO)
7422 CALL CALCACT2p1 ! CALCULATE ACTIVITY COEFFICIENTS
7424 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7428 A7 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
7429 A1 = XK5 *(WATER/GAMA(2))**3.0 ! NA2S04 <==> Na+
7430 A14 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
7431 A8 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
7432 A9 = XK9 *(WATER/GAMA(3))**2.0 ! NaNO3 <==> Na+
7433 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7435 !C POTASSIUM SULFATE
7437 IF (KI*KI*SO4I .GT. A7) THEN
7438 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT1)
7439 CC = WAER(7)*((WAER(2)-WAER(6)) - ROOT1) + 0.25*WAER(7)*WAER(7)
7440 DD =-0.25*(WAER(7)*WAER(7)*((WAER(2)-WAER(6)) - ROOT1) - A7)
7441 CALL POLY32p1(BB, CC, DD, ROOT7, ISLV)
7442 IF (ISLV.NE.0) ROOT7 = TINY
7443 ROOT7 = MAX (ROOT7, ZERO)
7444 ROOT7 = MIN (ROOT7, WAER(7)/2.0, &
7445 MAX(WAER(2)-WAER(6)-ROOT1, ZERO),CHI7)
7448 PSCONV7 = ABS(PSI7-PSI70) .LE. EPS*PSI70
7453 IF (NAI*NAI*SO4I .GT. A1) THEN
7454 BB =-(((WAER(2)-WAER(6))-ROOT7)*(WAER(1) - ROOT3 - ROOT5))
7455 CC = ((WAER(2)-WAER(6)) - ROOT7)*(WAER(1) - ROOT3 - ROOT5) + &
7456 0.25D0*(WAER(1) - ROOT3 - ROOT5)**2.0
7457 DD =-0.25D0*(((WAER(2) - WAER(6)) - ROOT7)* &
7458 (WAER(1) - ROOT3 - ROOT5)**2.D0 - A1)
7459 CALL POLY32p1(BB, CC, DD, ROOT1, ISLV)
7460 IF (ISLV.NE.0) ROOT1 = TINY
7461 ROOT1 = MIN (MAX(ROOT1,ZERO), MAX(WAER(1)-ROOT3-ROOT5,ZERO), &
7462 CHI1, MAX(WAER(2)-WAER(6),ZERO))
7465 PSCONV1 = ABS(PSI1-PSI1O) .LE. EPS*PSI1O
7468 !C AMMONIUM CHLORIDE
7470 IF (NH4I*CLI .GT. A14) THEN
7471 BB =-(WAER(3) + WAER(5) - ROOT4)
7472 CC =-A14 + NH4I*(WAER(5) - ROOT4)
7473 DD = MAX(BB*BB - 4.D0*CC, ZERO)
7474 ROOT4A= 0.5D0*(-BB+SQRT(DD))
7475 ROOT4B= 0.5D0*(-BB-SQRT(DD))
7476 IF (ZERO.LE.ROOT4A) THEN
7481 ROOT4 = MIN(MAX(ZERO, ROOT4), MAX(WAER(5)-ROOT3,ZERO), &
7485 PSCONV4 = ABS(PSI4-PSI40) .LE. EPS*PSI40
7488 !C SODIUM CHLORIDE ; To obtain new value for ROOT3
7490 IF (NAI*CLI .GT. A8) THEN
7491 BB =-((CHI1-2.D0*ROOT1-ROOT5) + (WAER(5) - ROOT4))
7492 CC = (CHI1-2.D0*ROOT1-ROOT5)*(WAER(5) - ROOT4) - A8
7493 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7494 ROOT3A= 0.5D0*(-BB-SQRT(DD))
7495 ROOT3B= 0.5D0*(-BB+SQRT(DD))
7496 IF (ZERO.LE.ROOT3A) THEN
7501 ROOT3 = MIN(MAX(ROOT3, ZERO), CHI3)
7504 PSCONV3 = ABS(PSI3-PSI30) .LE. EPS*PSI30
7509 IF (NAI*NO3I .GT. A9) THEN
7510 BB =-(WAER(4) + WAER(1) - 2.D0*ROOT1 - ROOT3)
7511 CC = WAER(4)*(WAER(1) - 2.D0*ROOT1 - ROOT3) - A9
7512 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
7513 ROOT5A= 0.5D0*(-BB-DD)
7514 ROOT5B= 0.5D0*(-BB+DD)
7515 IF (ZERO.LE.ROOT5A) THEN
7520 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI2)
7524 PSCONV5 = ABS(PSI2-PSI20) .LE. EPS*PSI20
7527 !C ION CONCENTRATIONS ; CORRECTIONS
7529 KI = MAX (WAER(7) - 2.0D0*ROOT7, ZERO)
7530 NAI = MAX (WAER(1) - 2.0D0*ROOT1 - ROOT3 - ROOT5, ZERO)
7531 SO4I = MAX (WAER(2) - WAER(6) - ROOT7 - ROOT1, ZERO)
7532 NH4I = MAX (WAER(3) - ROOT4, ZERO)
7533 NO3I = MAX (WAER(4) - ROOT5, ZERO)
7534 CLI = MAX (WAER(5) - ROOT4 - ROOT3, ZERO)
7538 !C SOLUTION ACIDIC OR BASIC?
7540 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
7541 - 2.D0*CAI - KI - 2.D0*MGI
7542 IF (GG.GT.TINY) THEN ! H+ in excess
7545 DD = BB*BB - 4.D0*CC
7546 HI = 0.5D0*(-BB + SQRT(DD))
7548 ELSE ! OH- in excess
7551 DD = BB*BB - 4.D0*CC
7552 OHI= 0.5D0*(-BB + SQRT(DD))
7555 !C IF (HI.LE.TINY) HI = SQRT(AKW)
7558 !C UNDISSOCIATED SPECIES EQUILIBRIA
7561 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7565 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
7566 !C & - KI - 2.D0*MGI, ZERO)
7567 !C GGCL = MAX(GG-GGNO3, ZERO)
7568 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
7569 !C IF (GGNO3.GT.TINY) THEN
7570 !C IF (GGCL.LE.TINY) HI = ZERO
7571 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
7574 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
7576 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
7583 !C IF (HI.LE.TINY) HI = SQRT(AKW)
7586 IF (HI.LE.TINY) THEN
7591 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7604 !C *** CALCULATE WATER **************************************************
7608 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7610 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7613 IF (PSCONV7 .AND. PSCONV1 .AND. PSCONV4 .AND. PSCONV3 &
7614 .AND. PSCONV5) GOTO 20
7617 !ccc CALL PUSHERR (0002, 'CALCU2A') ! WARNING ERROR: NO CONVERGENCE
7619 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7621 20 IF (CLI.LE.TINY .AND. WAER(5).GT.TINY) THEN !No disslv Cl-;solid only
7629 ELSE ! OK, aqueous phase present
7630 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
7631 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
7632 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
7644 CNH4CL = CHI4 - PSI4
7646 CNANO3 = CHI2 - PSI2
7647 CNA2SO4 = CHI1 - PSI1
7649 CK2SO4 = CHI7 - PSI7
7650 CCASO4 = MIN (WAER(6), WAER(2))
7655 !C *** END OF SUBROUTINE CALCU2A*****************************************
7659 !C=======================================================================
7661 !C *** ISORROPIA CODE II
7662 !C *** SUBROUTINE CALCU1
7665 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7666 !C 1. SULFATE POOR (SO4RAT > 2.0), (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
7667 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7668 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4, MGSO4, NH4CL, NANO3, NACL, NH4NO3
7670 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7671 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7672 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
7674 !C=======================================================================
7676 SUBROUTINE CALCU12p1
7677 INCLUDE 'module_isrpia_inc.F'
7678 LOGICAL EXAN, EXAC, EXSN, EXSC
7679 EXTERNAL CALCU1A2p1, CALCU2A2p1, CALCU3A2p1, CALCU4A2p1, CALCU52p1
7681 !C *** SOLVE FOR DRY CASE AND SEE WHICH SOLIDS ARE POSSIBLE **************
7683 SCASE = 'U1 ; SUBCASE 1'
7684 CALL CALCU1A2p1 ! SOLID
7685 SCASE = 'U1 ; SUBCASE 1'
7687 EXAN = CNH4NO3.GT.TINY ! NH4NO3
7688 EXAC = CNH4CL .GT.TINY ! NH4CL
7689 EXSN = CNANO3 .GT.TINY ! NANO3
7690 EXSC = CNACL .GT.TINY ! NACL
7692 !C *** REGIME DEPENDS ON RELATIVE HUMIDITY AND POSSIBLE SPECIES **********
7694 IF (EXAN.OR.EXAC.OR.EXSC.OR.EXSN) THEN ! *** WATER POSSIBLE
7695 IF (RH.GE.DRMM1) THEN
7696 SCASE = 'U1 ; SUBCASE 2' ! MDRH
7697 CALL CALCMDRPII2p1 (RH, DRMM1, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7698 SCASE = 'U1 ; SUBCASE 2'
7701 ELSE IF (.NOT.EXAN) THEN ! *** NH4NO3 = 0
7702 IF ( EXAC .AND. EXSN .AND. EXSC) THEN
7703 IF (RH.GE.DRMM2) THEN
7704 SCASE = 'U1 ; SUBCASE 3'
7705 CALL CALCMDRPII2p1 (RH, DRMM2, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7706 SCASE = 'U1 ; SUBCASE 3'
7709 ELSE IF (.NOT.EXAC .AND. EXSN .AND. EXSC) THEN
7710 IF (RH.GE.DRMR1) THEN
7711 SCASE = 'U1 ; SUBCASE 4'
7712 CALL CALCMDRPII2p1 (RH, DRMR1, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7713 SCASE = 'U1 ; SUBCASE 4'
7716 ELSE IF (.NOT.EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7717 IF (RH.GE.DRMR2) THEN
7718 SCASE = 'U1 ; SUBCASE 5'
7719 CALL CALCMDRPII2p1 (RH, DRMR2, DRNACL, CALCU1A2p1, CALCU3A2p1) !, CALCR4A)
7720 SCASE = 'U1 ; SUBCASE 5'
7723 ELSE IF (.NOT.EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7724 IF (RH.GE.DRMR3) THEN
7725 SCASE = 'U1 ; SUBCASE 6'
7726 CALL CALCMDRPII2p1 (RH, DRMR3, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7727 SCASE = 'U1 ; SUBCASE 6'
7730 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. EXSC) THEN
7731 IF (RH.GE.DRMR4) THEN
7732 SCASE = 'U1 ; SUBCASE 7'
7733 CALL CALCMDRPII2p1 (RH, DRMR4, DRNACL, CALCU1A2p1, CALCU3A2p1) !, CALCR4A)
7734 SCASE = 'U1 ; SUBCASE 7'
7737 ELSE IF ( EXAC .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
7738 IF (RH.GE.DRMR5) THEN
7739 SCASE = 'U1 ; SUBCASE 8'
7740 CALL CALCMDRPII2p1 (RH, DRMR5, DRNH4CL, CALCU1A2p1, CALCU3A2p1) !, CALCR5)
7741 SCASE = 'U1 ; SUBCASE 8'
7744 ELSE IF ( EXAC .AND. EXSN .AND. .NOT.EXSC) THEN
7745 IF (RH.GE.DRMR6) THEN
7746 SCASE = 'U1 ; SUBCASE 9'
7747 CALL CALCMDRPII2p1 (RH, DRMR6, DRNANO3, CALCU1A2p1, CALCU3A2p1)
7748 SCASE = 'U1 ; SUBCASE 9'
7752 ELSE IF (.NOT.EXAC) THEN ! *** NH4CL = 0
7753 IF ( EXAN .AND. EXSN .AND. EXSC) THEN
7754 IF (RH.GE.DRMR7) THEN
7755 SCASE = 'U1 ; SUBCASE 10'
7756 CALL CALCMDRPII2p1 (RH, DRMR7, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7757 SCASE = 'U1 ; SUBCASE 10'
7760 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. EXSC) THEN
7761 IF (RH.GE.DRMR8) THEN
7762 SCASE = 'U1 ; SUBCASE 11'
7763 CALL CALCMDRPII2p1 (RH, DRMR8, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7764 SCASE = 'U1 ; SUBCASE 11'
7767 ELSE IF ( EXAN .AND. .NOT.EXSN .AND. .NOT.EXSC) THEN
7768 IF (RH.GE.DRMR9) THEN
7769 SCASE = 'U1 ; SUBCASE 12'
7770 CALL CALCMDRPII2p1 (RH, DRMR9, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7771 SCASE = 'U1 ; SUBCASE 12'
7774 ELSE IF ( EXAN .AND. EXSN .AND. .NOT.EXSC) THEN
7775 IF (RH.GE.DRMR10) THEN
7776 SCASE = 'U1 ; SUBCASE 13'
7777 CALL CALCMDRPII2p1 (RH, DRMR10, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7778 SCASE = 'U1 ; SUBCASE 13'
7782 ELSE IF (.NOT.EXSN) THEN ! *** NANO3 = 0
7783 IF ( EXAN .AND. EXAC .AND. EXSC) THEN
7784 IF (RH.GE.DRMR11) THEN
7785 SCASE = 'U1 ; SUBCASE 14'
7786 CALL CALCMDRPII2p1 (RH, DRMR11, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7787 SCASE = 'U1 ; SUBCASE 14'
7790 ELSE IF ( EXAN .AND. EXAC .AND. .NOT.EXSC) THEN
7791 IF (RH.GE.DRMR12) THEN
7792 SCASE = 'U1 ; SUBCASE 15'
7793 CALL CALCMDRPII2p1 (RH, DRMR12, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7794 SCASE = 'U1 ; SUBCASE 15'
7798 ELSE IF (.NOT.EXSC) THEN ! *** NACL = 0
7799 IF ( EXAN .AND. EXAC .AND. EXSN) THEN
7800 IF (RH.GE.DRMR13) THEN
7801 SCASE = 'U1 ; SUBCASE 16'
7802 CALL CALCMDRPII2p1 (RH, DRMR13, DRNH4NO3, CALCU1A2p1, CALCU2A2p1)
7803 SCASE = 'U1 ; SUBCASE 16'
7811 !C IF (RH.LT.DRMM1) THEN
7812 !C SCASE = 'U1 ; SUBCASE 1'
7813 !C CALL CALCU1A ! SOLID PHASE ONLY POSSIBLE
7814 !C SCASE = 'U1 ; SUBCASE 1'
7816 !C SCASE = 'U1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
7817 !C CALL CALCMDRPII (RH, DRMM1, DRNH4NO3, CALCU1A, CALCU2A)
7818 !C SCASE = 'U1 ; SUBCASE 2'
7823 !C *** END OF SUBROUTINE CALCU1 ******************************************
7827 !C=======================================================================
7829 !C *** ISORROPIA CODE
7830 !C *** SUBROUTINE CALCU1A
7833 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7834 !C 1. SULFATE POOR (SULRAT > 2.0); CRUSTAL+SODIUM RICH (CRNARAT >= 2.0); CRUSTAL POOR (CRRAT<2)
7835 !C 2. THERE IS ONLY A SOLID PHASE
7837 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
7838 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7839 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
7841 !C=======================================================================
7843 SUBROUTINE CALCU1A2p1
7844 INCLUDE 'module_isrpia_inc.F'
7846 !C *** CALCULATE SOLIDS *************************************************
7848 CCASO4 = MIN (WAER(6), WAER(2)) ! CCASO4
7849 SO4FR = MAX(WAER(2) - CCASO4, ZERO)
7850 CAFR = MAX(WAER(6) - CCASO4, ZERO)
7851 CK2SO4 = MIN (0.5D0*WAER(7), SO4FR) ! CK2SO4
7852 FRK = MAX(WAER(7) - 2.D0*CK2SO4, ZERO)
7853 SO4FR = MAX(SO4FR - CK2SO4, ZERO)
7854 CMGSO4 = MIN (WAER(8), SO4FR) ! CMGSO4
7855 FRMG = MAX(WAER(8) - CMGSO4, ZERO)
7856 SO4FR = MAX(SO4FR - CMGSO4, ZERO)
7857 CNA2SO4 = MAX (SO4FR, ZERO) ! CNA2SO4
7858 FRNA = MAX (WAER(1) - 2.D0*CNA2SO4, ZERO)
7862 CNANO3 = MIN (FRNA, WAER(4))
7863 FRNO3 = MAX (WAER(4)-CNANO3, ZERO)
7864 FRNA = MAX (FRNA-CNANO3, ZERO)
7866 CNACL = MIN (FRNA, WAER(5))
7867 FRCL = MAX (WAER(5)-CNACL, ZERO)
7868 FRNA = MAX (FRNA-CNACL, ZERO)
7870 CNH4NO3 = MIN (FRNO3, WAER(3))
7871 FRNO3 = MAX (FRNO3-CNH4NO3, ZERO)
7872 FRNH3 = MAX (WAER(3)-CNH4NO3, ZERO)
7874 CNH4CL = MIN (FRCL, FRNH3)
7875 FRCL = MAX (FRCL-CNH4CL, ZERO)
7876 FRNH3 = MAX (FRNH3-CNH4CL, ZERO)
7878 !C *** OTHER PHASES ******************************************************
7888 !C *** END OF SUBROUTINE CALCU1A *****************************************
7892 !C=======================================================================
7894 !C *** ISORROPIA CODE II
7895 !C *** SUBROUTINE CALCW13
7898 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7899 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
7900 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7901 !C 3. SOLIDS POSSIBLE : CaSO4
7902 !C 4. Completely dissolved: CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
7903 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
7905 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7906 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7907 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7909 !C=======================================================================
7911 SUBROUTINE CALCW132p1
7912 INCLUDE 'module_isrpia_inc.F'
7914 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
7916 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7917 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
7918 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
7919 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
7920 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
7921 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
7923 !C *** SETUP PARAMETERS ************************************************
7929 !C *** CALCULATE INITIAL SOLUTION ***************************************
7935 PSI1 = CNA2SO4 ! SALTS DISSOLVED
7950 CALL CALCMR2p1 ! WATER
7956 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7960 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
7962 !C ION CONCENTRATIONS
7965 SO4I = MAX (WAER(2) - WAER(6), ZERO)
7973 !C SOLUTION ACIDIC OR BASIC?
7975 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
7976 - 2.D0*CAI - KI - 2.D0*MGI
7977 IF (GG.GT.TINY) THEN ! H+ in excess
7980 DD = BB*BB - 4.D0*CC
7981 HI = 0.5D0*(-BB + SQRT(DD))
7983 ELSE ! OH- in excess
7986 DD = BB*BB - 4.D0*CC
7987 OHI= 0.5D0*(-BB + SQRT(DD))
7991 !C UNDISSOCIATED SPECIES EQUILIBRIA
7994 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
7998 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
7999 !C & - KI - 2.D0*MGI, ZERO)
8000 !C GGCL = MAX(GG-GGNO3, ZERO)
8001 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
8002 !C IF (GGNO3.GT.TINY) THEN
8003 !C IF (GGCL.LE.TINY) HI = ZERO
8004 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
8007 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
8009 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
8016 !C IF (HI.LE.TINY) HI = SQRT(AKW)
8019 IF (HI.LE.TINY) THEN
8024 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8037 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8039 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8045 !ccc CALL PUSHERR (0002, 'CALCW13') ! WARNING ERROR: NO CONVERGENCE
8047 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8049 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
8050 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
8051 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
8068 CCASO4 = MIN (WAER(6), WAER(2))
8078 !C *** END OF SUBROUTINE CALCW13 ******************************************
8081 !C=======================================================================
8083 !C *** ISORROPIA CODE II
8084 !C *** SUBROUTINE CALCW12
8087 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8088 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
8089 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8090 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4
8091 !C 4. Completely dissolved: CA(NO3)2, CACL2, KNO3, KCL, MGSO4,
8092 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
8094 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8095 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8096 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8098 !C=======================================================================
8100 SUBROUTINE CALCW122p1
8101 INCLUDE 'module_isrpia_inc.F'
8104 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
8106 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8107 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
8108 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
8109 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
8110 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
8111 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
8113 !C *** SETUP PARAMETERS ************************************************
8120 PSI9O =-GREAT ! GREAT = 1.D10
8123 !C *** CALCULATE INITIAL SOLUTION ***************************************
8127 CHI9 = CK2SO4 ! SALTS
8130 PSI1 = CNA2SO4 ! SALTS DISSOLVED
8145 CALL CALCMR2p1 ! WATER
8147 NAI = WAER(1) ! LIQUID CONCENTRATIONS
8148 SO4I = MAX (WAER(2) - WAER(6), ZERO)
8161 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8165 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
8166 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
8168 !C POTASSIUM SULFATE
8170 IF (KI*KI*SO4I .GT. A9) THEN
8171 BB =-((WAER(2)-WAER(6)) + WAER(7))
8172 CC = WAER(7)*(WAER(2)-WAER(6)) + 0.25D0*WAER(7)*WAER(7)
8173 DD =-0.25*(WAER(7)*WAER(7)*(WAER(2)-WAER(6)) - A9)
8174 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
8175 IF (ISLV.NE.0) ROOT9 = TINY
8176 ROOT9 = MIN (ROOT9, WAER(7)/2.0, (WAER(2)-WAER(6)), CHI9)
8177 ROOT9 = MAX (ROOT9, ZERO)
8180 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
8183 !C ION CONCENTRATIONS ; CORRECTIONS
8185 KI = MAX (WAER(7) - 2.D0*ROOT9, ZERO)
8186 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
8194 !C SOLUTION ACIDIC OR BASIC?
8196 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
8197 - 2.D0*CAI - KI - 2.D0*MGI
8198 IF (GG.GT.TINY) THEN ! H+ in excess
8201 DD = BB*BB - 4.D0*CC
8202 HI = 0.5D0*(-BB + SQRT(DD))
8204 ELSE ! OH- in excess
8207 DD = BB*BB - 4.D0*CC
8208 OHI= 0.5D0*(-BB + SQRT(DD))
8212 !C UNDISSOCIATED SPECIES EQUILIBRIA
8215 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
8219 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
8220 !C & - KI - 2.D0*MGI, ZERO)
8221 !C GGCL = MAX(GG-GGNO3, ZERO)
8222 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
8223 !C IF (GGNO3.GT.TINY) THEN
8224 !C IF (GGCL.LE.TINY) HI = ZERO
8225 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
8228 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
8230 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
8237 !C IF (HI.LE.TINY) HI = SQRT(AKW)
8240 IF (HI.LE.TINY) THEN
8245 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8258 !C *** CALCULATE WATER **************************************************
8262 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8264 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8267 IF (PSCONV9) GOTO 20
8270 !ccc CALL PUSHERR (0002, 'CALCW12') ! WARNING ERROR: NO CONVERGENCE
8272 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8274 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
8275 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
8276 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
8292 CK2SO4 = CHI9 - PSI9
8293 CCASO4 = MIN (WAER(6), WAER(2))
8303 !C *** END OF SUBROUTINE CALCW12 ******************************************
8306 !C=======================================================================
8308 !C *** ISORROPIA CODE II
8309 !C *** SUBROUTINE CALCW11
8312 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8313 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
8314 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8315 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3
8316 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL, MGSO4,
8317 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
8319 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8320 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8321 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8323 !C=======================================================================
8325 SUBROUTINE CALCW112p1
8326 INCLUDE 'module_isrpia_inc.F'
8328 LOGICAL PSCONV9, PSCONV13
8329 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
8331 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8332 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
8333 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
8334 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
8335 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
8336 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
8338 !C *** SETUP PARAMETERS ************************************************
8348 PSI13O =-GREAT ! GREAT = 1.D10
8353 !C *** CALCULATE INITIAL SOLUTION ***************************************
8357 CHI9 = CK2SO4 ! SALTS
8361 PSI1 = CNA2SO4 ! SALTS DISSOLVED
8376 CALL CALCMR2p1 ! WATER
8378 NAI = WAER(1) ! LIQUID CONCENTRATIONS
8379 SO4I = MAX (WAER(2) - WAER(6), ZERO)
8392 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8396 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
8397 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
8398 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
8400 !C POTASSIUM SULFATE
8402 IF (KI*KI*SO4I .GT. A9) THEN
8403 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13)
8404 CC = (WAER(7)-ROOT13)*(WAER(2)-WAER(6)) + &
8405 0.25D0*(WAER(7)-ROOT13)**2.0
8406 DD =-0.25*((WAER(7)-ROOT13)**2.0*(WAER(2)-WAER(6)) - A9)
8407 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
8408 IF (ISLV.NE.0) ROOT9 = TINY
8409 ROOT9 = MIN (ROOT9,WAER(7)/2.0-ROOT13,(WAER(2)-WAER(6)),CHI9)
8410 ROOT9 = MAX (ROOT9, ZERO)
8413 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
8416 !C POTASSIUM NITRATE
8418 IF (KI*NO3I .GT. A13) THEN
8419 BB =-(WAER(4) + WAER(7) - 2.D0*ROOT9)
8420 CC = WAER(4)*(WAER(7) - 2.D0*ROOT9) - A13
8421 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
8422 ROOT13A= 0.5D0*(-BB-DD)
8423 ROOT13B= 0.5D0*(-BB+DD)
8424 IF (ZERO.LE.ROOT13A) THEN
8429 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
8430 PSI13 = CHI13-ROOT13
8432 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
8435 !C ION CONCENTRATIONS ; CORRECTIONS
8437 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13, ZERO)
8438 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
8440 NO3I = MAX (WAER(4) - ROOT13, ZERO)
8446 !C SOLUTION ACIDIC OR BASIC?
8448 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
8449 - 2.D0*CAI - KI - 2.D0*MGI
8450 IF (GG.GT.TINY) THEN ! H+ in excess
8453 DD = BB*BB - 4.D0*CC
8454 HI = 0.5D0*(-BB + SQRT(DD))
8456 ELSE ! OH- in excess
8459 DD = BB*BB - 4.D0*CC
8460 OHI= 0.5D0*(-BB + SQRT(DD))
8464 !C UNDISSOCIATED SPECIES EQUILIBRIA
8467 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
8471 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
8472 !C & - KI - 2.D0*MGI, ZERO)
8473 !C GGCL = MAX(GG-GGNO3, ZERO)
8474 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
8475 !C IF (GGNO3.GT.TINY) THEN
8476 !C IF (GGCL.LE.TINY) HI = ZERO
8477 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
8480 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
8482 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
8489 !C IF (HI.LE.TINY) HI = SQRT(AKW)
8492 IF (HI.LE.TINY) THEN
8497 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8510 !C *** CALCULATE WATER **************************************************
8514 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8516 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8519 IF (PSCONV9 .AND. PSCONV13) GOTO 20
8522 !ccc CALL PUSHERR (0002, 'CALCW11') ! WARNING ERROR: NO CONVERGENCE
8524 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8526 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
8527 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
8528 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
8544 CK2SO4 = CHI9 - PSI9
8545 CCASO4 = MIN (WAER(6), WAER(2))
8547 CKNO3 = CHI13 - PSI13
8555 !C *** END OF SUBROUTINE CALCW11 ******************************************
8558 !C=======================================================================
8560 !C *** ISORROPIA CODE II
8561 !C *** SUBROUTINE CALCW10
8564 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8565 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
8566 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8567 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4
8568 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL,
8569 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
8571 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8572 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8573 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8575 !C=======================================================================
8577 SUBROUTINE CALCW102p1
8578 INCLUDE 'module_isrpia_inc.F'
8580 LOGICAL PSCONV9, PSCONV13
8581 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
8583 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8584 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
8585 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
8586 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
8587 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
8588 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
8590 !C *** SETUP PARAMETERS ************************************************
8600 PSI13O =-GREAT ! GREAT = 1.D10
8605 !C *** CALCULATE INITIAL SOLUTION ***************************************
8610 CHI9 = CK2SO4 ! SALTS
8615 PSI1 = CNA2SO4 ! SALTS DISSOLVED
8630 CALL CALCMR2p1 ! WATER
8632 NAI = WAER(1) ! LIQUID CONCENTRATIONS
8633 SO4I = MAX (WAER(2) - WAER(6), ZERO)
8646 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8650 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
8651 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
8652 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
8654 !C POTASSIUM SULFATE
8656 IF (KI*KI*SO4I .GT. A9) THEN
8657 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13)
8658 CC = (WAER(7)-ROOT13)*(WAER(2)-WAER(6)) + &
8659 0.25D0*(WAER(7)-ROOT13)**2.0
8660 DD =-0.25*((WAER(7)-ROOT13)**2.0*(WAER(2)-WAER(6)) - A9)
8661 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
8662 IF (ISLV.NE.0) ROOT9 = TINY
8663 ROOT9 = MIN (ROOT9,WAER(7)/2.0-ROOT13,(WAER(2)-WAER(6)),CHI9)
8664 ROOT9 = MAX (ROOT9, ZERO)
8667 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
8670 !C POTASSIUM NITRATE
8672 IF (KI*NO3I .GT. A13) THEN
8673 BB =-(WAER(4) + WAER(7) - 2.D0*ROOT9)
8674 CC = WAER(4)*(WAER(7) - 2.D0*ROOT9) - A13
8675 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
8676 ROOT13A= 0.5D0*(-BB-DD)
8677 ROOT13B= 0.5D0*(-BB+DD)
8678 IF (ZERO.LE.ROOT13A) THEN
8683 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
8684 PSI13 = CHI13-ROOT13
8686 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
8689 !C ION CONCENTRATIONS ; CORRECTIONS
8691 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13, ZERO)
8692 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
8694 NO3I = MAX (WAER(4) - ROOT13, ZERO)
8700 !C SOLUTION ACIDIC OR BASIC?
8702 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
8703 - 2.D0*CAI - KI - 2.D0*MGI
8704 IF (GG.GT.TINY) THEN ! H+ in excess
8707 DD = BB*BB - 4.D0*CC
8708 HI = 0.5D0*(-BB + SQRT(DD))
8710 ELSE ! OH- in excess
8713 DD = BB*BB - 4.D0*CC
8714 OHI= 0.5D0*(-BB + SQRT(DD))
8718 !C UNDISSOCIATED SPECIES EQUILIBRIA
8721 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
8725 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
8726 !C & - KI - 2.D0*MGI, ZERO)
8727 !C GGCL = MAX(GG-GGNO3, ZERO)
8728 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
8729 !C IF (GGNO3.GT.TINY) THEN
8730 !C IF (GGCL.LE.TINY) HI = ZERO
8731 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
8734 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
8736 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
8743 !C IF (HI.LE.TINY) HI = SQRT(AKW)
8746 IF (HI.LE.TINY) THEN
8751 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8764 !C *** CALCULATE WATER **************************************************
8768 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8770 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8773 IF (PSCONV9 .AND. PSCONV13) GOTO 20
8776 !ccc CALL PUSHERR (0002, 'CALCW10') ! WARNING ERROR: NO CONVERGENCE
8778 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8780 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
8781 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
8782 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
8798 CK2SO4 = CHI9 - PSI9
8799 CCASO4 = MIN (WAER(6), WAER(2))
8801 CKNO3 = CHI13 - PSI13
8809 !C *** END OF SUBROUTINE CALCW10 ******************************************
8812 !C=======================================================================
8814 !C *** ISORROPIA CODE II
8815 !C *** SUBROUTINE CALCW9
8818 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8819 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
8820 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8821 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL
8822 !C 4. Completely dissolved: CA(NO3)2, CACL2,
8823 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
8825 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8826 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8827 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8829 !C=======================================================================
8831 SUBROUTINE CALCW92p1
8832 INCLUDE 'module_isrpia_inc.F'
8834 LOGICAL PSCONV9, PSCONV13, PSCONV14
8835 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
8837 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8838 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
8839 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
8840 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
8841 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
8842 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
8844 !C *** SETUP PARAMETERS ************************************************
8856 PSI14O =-GREAT ! GREAT = 1.D10
8862 !C *** CALCULATE INITIAL SOLUTION ***************************************
8866 CHI9 = CK2SO4 ! SALTS
8872 PSI1 = CNA2SO4 ! SALTS DISSOLVED
8887 CALL CALCMR2p1 ! WATER
8889 NAI = WAER(1) ! LIQUID CONCENTRATIONS
8890 SO4I = MAX (WAER(2) - WAER(6), ZERO)
8903 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8907 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
8908 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
8909 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
8910 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
8912 !C POTASSIUM SULFATE
8914 IF (KI*KI*SO4I .GT. A9) THEN
8915 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
8916 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
8917 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
8918 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
8919 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
8920 IF (ISLV.NE.0) ROOT9 = TINY
8921 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
8922 (WAER(2)-WAER(6)), CHI9)
8923 ROOT9 = MAX (ROOT9, ZERO)
8926 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
8929 !C POTASSIUM NITRATE
8931 IF (KI*NO3I .GT. A13) THEN
8932 BB =-(WAER(4) + WAER(7) - 2.D0*ROOT9 - ROOT14)
8933 CC = WAER(4)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
8934 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
8935 ROOT13A= 0.5D0*(-BB-DD)
8936 ROOT13B= 0.5D0*(-BB+DD)
8937 IF (ZERO.LE.ROOT13A) THEN
8942 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
8943 PSI13 = CHI13-ROOT13
8945 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
8948 !C POTASSIUM CLORIDE
8950 IF (KI*CLI .GT. A14) THEN
8951 BB =-(WAER(5) + WAER(7) - 2.D0*ROOT9 - ROOT13)
8952 CC = WAER(5)*(WAER(7) - 2.D0*ROOT9 - ROOT13) - A14
8953 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
8954 ROOT14A= 0.5D0*(-BB-DD)
8955 ROOT14B= 0.5D0*(-BB+DD)
8956 IF (ZERO.LE.ROOT14A) THEN
8961 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
8962 PSI14 = CHI14-ROOT14
8964 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
8967 !C ION CONCENTRATIONS ; CORRECTIONS
8969 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
8970 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
8972 NO3I = MAX (WAER(4) - ROOT13, ZERO)
8973 CLI = MAX (WAER(5) - ROOT14, ZERO)
8978 !C SOLUTION ACIDIC OR BASIC?
8980 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
8981 - 2.D0*CAI - KI - 2.D0*MGI
8982 IF (GG.GT.TINY) THEN ! H+ in excess
8985 DD = BB*BB - 4.D0*CC
8986 HI = 0.5D0*(-BB + SQRT(DD))
8988 ELSE ! OH- in excess
8991 DD = BB*BB - 4.D0*CC
8992 OHI= 0.5D0*(-BB + SQRT(DD))
8996 !C UNDISSOCIATED SPECIES EQUILIBRIA
8999 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
9003 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
9004 !C & - KI - 2.D0*MGI, ZERO)
9005 !C GGCL = MAX(GG-GGNO3, ZERO)
9006 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
9007 !C IF (GGNO3.GT.TINY) THEN
9008 !C IF (GGCL.LE.TINY) HI = ZERO
9009 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
9012 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
9014 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
9021 !C IF (HI.LE.TINY) HI = SQRT(AKW)
9024 IF (HI.LE.TINY) THEN
9029 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
9042 !C *** CALCULATE WATER **************************************************
9046 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9048 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9051 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14) GOTO 20
9054 !ccc CALL PUSHERR (0002, 'CALCW9') ! WARNING ERROR: NO CONVERGENCE
9056 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
9058 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
9059 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
9060 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
9076 CK2SO4 = CHI9 - PSI9
9077 CCASO4 = MIN (WAER(6), WAER(2))
9079 CKNO3 = CHI13 - PSI13
9087 !C *** END OF SUBROUTINE CALCW9 ******************************************
9090 !C=======================================================================
9092 !C *** ISORROPIA CODE II
9093 !C *** SUBROUTINE CALCW8
9096 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9097 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
9098 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9099 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL
9100 !C 4. Completely dissolved: CA(NO3)2, CACL2,
9101 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3
9103 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9104 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
9105 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9107 !C=======================================================================
9109 SUBROUTINE CALCW82p1
9110 INCLUDE 'module_isrpia_inc.F'
9112 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5
9113 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
9115 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9116 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9117 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9118 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9119 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9120 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9122 !C *** SETUP PARAMETERS ************************************************
9136 PSI5O =-GREAT ! GREAT = 1.D10
9143 !C *** CALCULATE INITIAL SOLUTION ***************************************
9147 CHI9 = CK2SO4 ! SALTS
9154 PSI1 = CNA2SO4 ! SALTS DISSOLVED
9169 CALL CALCMR2p1 ! WATER
9171 NAI = WAER(1) ! LIQUID CONCENTRATIONS
9172 SO4I = MAX (WAER(2) - WAER(6), ZERO)
9185 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9189 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
9190 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
9191 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
9192 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
9193 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
9195 !C POTASSIUM SULFATE
9197 IF (KI*KI*SO4I .GT. A9) THEN
9198 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
9199 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
9200 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
9201 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
9202 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
9203 IF (ISLV.NE.0) ROOT9 = TINY
9204 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
9205 (WAER(2)-WAER(6)), CHI9)
9206 ROOT9 = MAX (ROOT9, ZERO)
9209 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
9212 !C POTASSIUM NITRATE
9214 IF (KI*NO3I .GT. A13) THEN
9215 BB =-(WAER(4) + WAER(7) - 2.D0*ROOT9 - ROOT14)
9216 CC = WAER(4)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
9217 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
9218 ROOT13A= 0.5D0*(-BB-DD)
9219 ROOT13B= 0.5D0*(-BB+DD)
9220 IF (ZERO.LE.ROOT13A) THEN
9225 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
9226 PSI13 = CHI13-ROOT13
9228 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
9231 !C POTASSIUM CLORIDE
9233 IF (KI*CLI .GT. A14) THEN
9234 BB =-(WAER(5) - ROOT5 + WAER(7) - 2.D0*ROOT9 - ROOT13)
9235 CC = (WAER(5)-ROOT5)*(WAER(7) - 2.D0*ROOT9 - ROOT13) - A14
9236 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9237 ROOT14A= 0.5D0*(-BB-DD)
9238 ROOT14B= 0.5D0*(-BB+DD)
9239 IF (ZERO.LE.ROOT14A) THEN
9244 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
9245 PSI14 = CHI14-ROOT14
9247 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
9252 IF (NH4I*CLI .GT. A5) THEN
9253 BB =-(WAER(5) + WAER(3) - ROOT14)
9254 CC = (WAER(5)-ROOT14)*WAER(3) - A5
9255 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9256 ROOT5A = 0.5D0*(-BB-DD)
9257 ROOT5B = 0.5D0*(-BB+DD)
9258 IF (ZERO.LE.ROOT5A) THEN
9263 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
9266 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
9269 !C ION CONCENTRATIONS ; CORRECTIONS
9271 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
9272 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
9273 NH4I = MAX (WAER(3) - ROOT5, ZERO)
9274 NO3I = MAX (WAER(4) - ROOT13, ZERO)
9275 CLI = MAX (WAER(5) - ROOT14 - ROOT5, ZERO)
9280 !C SOLUTION ACIDIC OR BASIC?
9282 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
9283 - 2.D0*CAI - KI - 2.D0*MGI
9284 IF (GG.GT.TINY) THEN ! H+ in excess
9287 DD = BB*BB - 4.D0*CC
9288 HI = 0.5D0*(-BB + SQRT(DD))
9290 ELSE ! OH- in excess
9293 DD = BB*BB - 4.D0*CC
9294 OHI= 0.5D0*(-BB + SQRT(DD))
9298 !C UNDISSOCIATED SPECIES EQUILIBRIA
9301 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
9305 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
9306 !C & - KI - 2.D0*MGI, ZERO)
9307 !C GGCL = MAX(GG-GGNO3, ZERO)
9308 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
9309 !C IF (GGNO3.GT.TINY) THEN
9310 !C IF (GGCL.LE.TINY) HI = ZERO
9311 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
9314 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
9316 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
9323 !C IF (HI.LE.TINY) HI = SQRT(AKW)
9326 IF (HI.LE.TINY) THEN
9331 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
9344 !C *** CALCULATE WATER **************************************************
9348 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9350 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9353 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND.PSCONV5) GOTO 20
9356 !ccc CALL PUSHERR (0002, 'CALCW8') ! WARNING ERROR: NO CONVERGENCE
9358 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
9360 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
9361 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
9362 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
9374 CNH4CL = CHI5 - PSI5
9378 CK2SO4 = CHI9 - PSI9
9379 CCASO4 = MIN (WAER(6), WAER(2))
9381 CKNO3 = CHI13 - PSI13
9389 !C *** END OF SUBROUTINE CALCW8 ******************************************
9392 !C=======================================================================
9394 !C *** ISORROPIA CODE II
9395 !C *** SUBROUTINE CALCW7
9398 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9399 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
9400 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9401 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL
9402 !C 4. Completely dissolved: CA(NO3)2, CACL2,
9403 !C MG(NO3)2, MGCL2, NANO3, NH4NO3
9405 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9406 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
9407 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9409 !C=======================================================================
9411 SUBROUTINE CALCW72p1
9412 INCLUDE 'module_isrpia_inc.F'
9414 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7
9415 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
9417 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9418 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9419 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9420 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9421 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9422 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9424 !C *** SETUP PARAMETERS ************************************************
9440 PSI7O =-GREAT ! GREAT = 1.D10
9448 !C *** CALCULATE INITIAL SOLUTION ***************************************
9452 CHI9 = CK2SO4 ! SALTS
9460 PSI1 = CNA2SO4 ! SALTS DISSOLVED
9475 CALL CALCMR2p1 ! WATER
9477 NAI = WAER(1) ! LIQUID CONCENTRATIONS
9478 SO4I = MAX (WAER(2) - WAER(6), ZERO)
9491 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9495 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
9496 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
9497 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
9498 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
9499 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
9500 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
9502 !C POTASSIUM SULFATE
9504 IF (KI*KI*SO4I .GT. A9) THEN
9505 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
9506 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
9507 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
9508 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
9509 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
9510 IF (ISLV.NE.0) ROOT9 = TINY
9511 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
9512 (WAER(2)-WAER(6)), CHI9)
9513 ROOT9 = MAX (ROOT9, ZERO)
9516 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
9519 !C POTASSIUM NITRATE
9521 IF (KI*NO3I .GT. A13) THEN
9522 BB =-(WAER(4) + WAER(7) - 2.D0*ROOT9 - ROOT14)
9523 CC = WAER(4)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
9524 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
9525 ROOT13A= 0.5D0*(-BB-DD)
9526 ROOT13B= 0.5D0*(-BB+DD)
9527 IF (ZERO.LE.ROOT13A) THEN
9532 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
9533 PSI13 = CHI13-ROOT13
9535 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
9538 !C POTASSIUM CLORIDE
9540 IF (KI*CLI .GT. A14) THEN
9541 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
9542 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
9543 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9544 ROOT14A= 0.5D0*(-BB-DD)
9545 ROOT14B= 0.5D0*(-BB+DD)
9546 IF (ZERO.LE.ROOT14A) THEN
9551 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
9552 PSI14 = CHI14-ROOT14
9554 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
9559 IF (NH4I*CLI .GT. A5) THEN
9560 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
9561 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
9562 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9563 ROOT5A = 0.5D0*(-BB-DD)
9564 ROOT5B = 0.5D0*(-BB+DD)
9565 IF (ZERO.LE.ROOT5A) THEN
9570 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
9573 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
9578 IF (NAI*CLI .GT. A7) THEN
9579 BB =-(WAER(5) + WAER(1) - ROOT14 - ROOT5)
9580 CC = (WAER(5) - ROOT14 - ROOT5)*WAER(1) - A7
9581 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9582 ROOT7A = 0.5D0*(-BB-DD)
9583 ROOT7B = 0.5D0*(-BB+DD)
9584 IF (ZERO.LE.ROOT7A) THEN
9589 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
9592 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
9595 !C ION CONCENTRATIONS ; CORRECTIONS
9597 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
9598 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
9599 NH4I = MAX (WAER(3) - ROOT5, ZERO)
9600 NO3I = MAX (WAER(4) - ROOT13, ZERO)
9601 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
9603 NAI = MAX (WAER(1) - ROOT7, ZERO)
9606 !C SOLUTION ACIDIC OR BASIC?
9608 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
9609 - 2.D0*CAI - KI - 2.D0*MGI
9610 IF (GG.GT.TINY) THEN ! H+ in excess
9613 DD = BB*BB - 4.D0*CC
9614 HI = 0.5D0*(-BB + SQRT(DD))
9616 ELSE ! OH- in excess
9619 DD = BB*BB - 4.D0*CC
9620 OHI= 0.5D0*(-BB + SQRT(DD))
9624 !C UNDISSOCIATED SPECIES EQUILIBRIA
9627 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
9631 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
9632 !C & - KI - 2.D0*MGI, ZERO)
9633 !C GGCL = MAX(GG-GGNO3, ZERO)
9634 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
9635 !C IF (GGNO3.GT.TINY) THEN
9636 !C IF (GGCL.LE.TINY) HI = ZERO
9637 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
9640 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
9642 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
9649 !C IF (HI.LE.TINY) HI = SQRT(AKW)
9652 IF (HI.LE.TINY) THEN
9657 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
9670 !C *** CALCULATE WATER **************************************************
9674 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9676 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9679 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
9680 .AND. PSCONV7) GOTO 20
9683 !ccc CALL PUSHERR (0002, 'CALCW7') ! WARNING ERROR: NO CONVERGENCE
9685 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
9687 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
9688 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
9689 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
9701 CNH4CL = CHI5 - PSI5
9705 CK2SO4 = CHI9 - PSI9
9706 CCASO4 = MIN (WAER(6), WAER(2))
9708 CKNO3 = CHI13 - PSI13
9716 !C *** END OF SUBROUTINE CALCW7 ******************************************
9720 !C=======================================================================
9722 !C *** ISORROPIA CODE II
9723 !C *** SUBROUTINE CALCW6
9726 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9727 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
9728 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9729 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3
9730 !C 4. Completely dissolved: CA(NO3)2, CACL2,
9731 !C MG(NO3)2, MGCL2, NH4NO3
9733 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
9734 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
9735 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9737 !C=======================================================================
9739 SUBROUTINE CALCW62p1
9740 INCLUDE 'module_isrpia_inc.F'
9742 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7, PSCONV8
9743 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
9745 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9746 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9747 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9748 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9749 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9750 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9752 !C *** SETUP PARAMETERS ************************************************
9770 PSI8O =-GREAT ! GREAT = 1.D10
9779 !C *** CALCULATE INITIAL SOLUTION ***************************************
9783 CHI9 = CK2SO4 ! SALTS
9792 PSI1 = CNA2SO4 ! SALTS DISSOLVED
9807 CALL CALCMR2p1 ! WATER
9809 NAI = WAER(1) ! LIQUID CONCENTRATIONS
9810 SO4I = MAX (WAER(2) - WAER(6), ZERO)
9823 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9827 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
9828 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
9829 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
9830 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
9831 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
9832 A8 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
9833 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
9835 !C POTASSIUM SULFATE
9837 IF (KI*KI*SO4I .GT. A9) THEN
9838 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
9839 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
9840 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
9841 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
9842 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
9843 IF (ISLV.NE.0) ROOT9 = TINY
9844 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
9845 (WAER(2)-WAER(6)), CHI9)
9846 ROOT9 = MAX (ROOT9, ZERO)
9849 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
9852 !C POTASSIUM NITRATE
9854 IF (KI*NO3I .GT. A13) THEN
9855 BB =-(WAER(4) - ROOT8 + WAER(7) - 2.D0*ROOT9 - ROOT14)
9856 CC = (WAER(4)-ROOT8)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
9857 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
9858 ROOT13A= 0.5D0*(-BB-DD)
9859 ROOT13B= 0.5D0*(-BB+DD)
9860 IF (ZERO.LE.ROOT13A) THEN
9865 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
9866 PSI13 = CHI13-ROOT13
9868 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
9871 !C POTASSIUM CLORIDE
9873 IF (KI*CLI .GT. A14) THEN
9874 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
9875 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
9876 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9877 ROOT14A= 0.5D0*(-BB-DD)
9878 ROOT14B= 0.5D0*(-BB+DD)
9879 IF (ZERO.LE.ROOT14A) THEN
9884 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
9885 PSI14 = CHI14-ROOT14
9887 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
9892 IF (NH4I*CLI .GT. A5) THEN
9893 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
9894 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
9895 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9896 ROOT5A = 0.5D0*(-BB-DD)
9897 ROOT5B = 0.5D0*(-BB+DD)
9898 IF (ZERO.LE.ROOT5A) THEN
9903 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
9906 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
9911 IF (NAI*CLI .GT. A7) THEN
9912 BB =-(WAER(5) + WAER(1) - ROOT8 - ROOT14 - ROOT5)
9913 CC = (WAER(5) - ROOT14 - ROOT5)*(WAER(1)-ROOT8) - A7
9914 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9915 ROOT7A = 0.5D0*(-BB-DD)
9916 ROOT7B = 0.5D0*(-BB+DD)
9917 IF (ZERO.LE.ROOT7A) THEN
9922 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
9925 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
9930 IF (NAI*NO3I .GT. A8) THEN
9931 BB =-(WAER(4) - ROOT13 + WAER(1) - ROOT7)
9932 CC = (WAER(4) - ROOT13)*(WAER(1)-ROOT7) - A8
9933 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
9934 ROOT8A = 0.5D0*(-BB-DD)
9935 ROOT8B = 0.5D0*(-BB+DD)
9936 IF (ZERO.LE.ROOT8A) THEN
9941 ROOT8 = MIN(MAX(ROOT8, ZERO), CHI8)
9944 PSCONV8 = ABS(PSI8-PSI8O) .LE. EPS*PSI8O
9947 !C ION CONCENTRATIONS ; CORRECTIONS
9949 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
9950 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
9951 NH4I = MAX (WAER(3) - ROOT5, ZERO)
9952 NO3I = MAX (WAER(4) - ROOT13 - ROOT8, ZERO)
9953 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
9955 NAI = MAX (WAER(1) - ROOT7 - ROOT8, ZERO)
9958 !C SOLUTION ACIDIC OR BASIC?
9960 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
9961 - 2.D0*CAI - KI - 2.D0*MGI
9962 IF (GG.GT.TINY) THEN ! H+ in excess
9965 DD = BB*BB - 4.D0*CC
9966 HI = 0.5D0*(-BB + SQRT(DD))
9968 ELSE ! OH- in excess
9971 DD = BB*BB - 4.D0*CC
9972 OHI= 0.5D0*(-BB + SQRT(DD))
9976 !C UNDISSOCIATED SPECIES EQUILIBRIA
9979 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
9983 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
9984 !C & - KI - 2.D0*MGI, ZERO)
9985 !C GGCL = MAX(GG-GGNO3, ZERO)
9986 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
9987 !C IF (GGNO3.GT.TINY) THEN
9988 !C IF (GGCL.LE.TINY) HI = ZERO
9989 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
9992 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
9994 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
10001 !C IF (HI.LE.TINY) HI = SQRT(AKW)
10004 IF (HI.LE.TINY) THEN
10009 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
10022 !C *** CALCULATE WATER **************************************************
10026 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10028 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10031 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
10032 .AND. PSCONV7 .AND. PSCONV8) GOTO 20
10035 !ccc CALL PUSHERR (0002, 'CALCW6') ! WARNING ERROR: NO CONVERGENCE
10037 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10039 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
10040 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
10041 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
10053 CNH4CL = CHI5 - PSI5
10054 CNACL = CHI7 - PSI7
10055 CNANO3 = CHI8 - PSI8
10057 CK2SO4 = CHI9 - PSI9
10058 CCASO4 = MIN (WAER(6), WAER(2))
10060 CKNO3 = CHI13 - PSI13
10061 KCL = CHI14 - PSI14
10068 !C *** END OF SUBROUTINE CALCW6 ******************************************
10072 !C=======================================================================
10074 !C *** ISORROPIA CODE II
10075 !C *** SUBROUTINE CALCW5
10078 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10079 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10080 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10081 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3, NH4NO3
10082 !C 4. Completely dissolved: CA(NO3)2, CACL2,
10085 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10086 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10087 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10089 !C=======================================================================
10091 SUBROUTINE CALCW52p1
10092 INCLUDE 'module_isrpia_inc.F'
10094 EXTERNAL CALCW1A2p1, CALCW62p1
10096 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
10098 IF (WAER(4).GT.TINY) THEN ! NO3 EXIST, WATER POSSIBLE
10099 SCASE = 'W5 ; SUBCASE 1'
10101 SCASE = 'W5 ; SUBCASE 1'
10102 ELSE ! NO3, CL NON EXISTANT
10103 SCASE = 'W1 ; SUBCASE 1'
10105 SCASE = 'W1 ; SUBCASE 1'
10108 IF (WATER.LE.TINY) THEN
10109 IF (RH.LT.DRMP5) THEN ! ONLY SOLIDS
10115 SCASE = 'W5 ; SUBCASE 2'
10118 SCASE = 'W5 ; SUBCASE 3' ! MDRH REGION (CaSO4, K2SO4, KNO3, KCL, MGSO4,
10119 !C NANO3, NACL, NH4NO3, NH4CL)
10120 CALL CALCMDRPII2p1 (RH, DRMP5, DRNH4NO3, CALCW1A2p1, CALCW62p1)
10121 SCASE = 'W5 ; SUBCASE 3'
10127 !C *** END OF SUBROUTINE CALCW5 ******************************************
10131 !C=======================================================================
10133 !C *** ISORROPIA CODE II
10134 !C *** SUBROUTINE CALCW5A
10137 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10138 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10139 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10140 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
10142 !C 4. Completely dissolved: CA(NO3)2, CACL2, MG(NO3)2, MGCL2
10144 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10145 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10146 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10148 !C=======================================================================
10150 SUBROUTINE CALCW5A2p1
10151 INCLUDE 'module_isrpia_inc.F'
10153 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7, PSCONV8
10154 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
10156 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10157 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10158 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10159 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10160 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10161 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10163 !C *** SETUP PARAMETERS ************************************************
10181 PSI8O =-GREAT ! GREAT = 1.D10
10190 !C *** CALCULATE INITIAL SOLUTION ***************************************
10194 CHI9 = CK2SO4 ! SALTS
10204 PSI1 = CNA2SO4 ! SALTS DISSOLVED
10219 CALL CALCMR2p1 ! WATER
10221 NAI = WAER(1) ! LIQUID CONCENTRATIONS
10222 SO4I = MAX (WAER(2) - WAER(6), ZERO)
10235 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10239 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
10240 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
10241 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
10242 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
10243 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
10244 A8 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
10245 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
10247 !C POTASSIUM SULFATE
10249 IF (KI*KI*SO4I .GT. A9) THEN
10250 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
10251 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
10252 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
10253 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
10254 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
10255 IF (ISLV.NE.0) ROOT9 = TINY
10256 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
10257 (WAER(2)-WAER(6)), CHI9)
10258 ROOT9 = MAX (ROOT9, ZERO)
10259 PSI9 = CHI9 - ROOT9
10261 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
10264 !C POTASSIUM NITRATE
10266 IF (KI*NO3I .GT. A13) THEN
10267 BB =-(WAER(4) - ROOT8 + WAER(7) - 2.D0*ROOT9 - ROOT14)
10268 CC = (WAER(4)-ROOT8)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
10269 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
10270 ROOT13A= 0.5D0*(-BB-DD)
10271 ROOT13B= 0.5D0*(-BB+DD)
10272 IF (ZERO.LE.ROOT13A) THEN
10277 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
10278 PSI13 = CHI13-ROOT13
10280 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
10283 !C POTASSIUM CLORIDE
10285 IF (KI*CLI .GT. A14) THEN
10286 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
10287 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
10288 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10289 ROOT14A= 0.5D0*(-BB-DD)
10290 ROOT14B= 0.5D0*(-BB+DD)
10291 IF (ZERO.LE.ROOT14A) THEN
10296 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
10297 PSI14 = CHI14-ROOT14
10299 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
10302 !C AMMONIUM CLORIDE
10304 IF (NH4I*CLI .GT. A5) THEN
10305 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
10306 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
10307 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10308 ROOT5A = 0.5D0*(-BB-DD)
10309 ROOT5B = 0.5D0*(-BB+DD)
10310 IF (ZERO.LE.ROOT5A) THEN
10315 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
10318 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
10323 IF (NAI*CLI .GT. A7) THEN
10324 BB =-(WAER(5) + WAER(1) - ROOT8 - ROOT14 - ROOT5)
10325 CC = (WAER(5) - ROOT14 - ROOT5)*(WAER(1)-ROOT8) - A7
10326 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10327 ROOT7A = 0.5D0*(-BB-DD)
10328 ROOT7B = 0.5D0*(-BB+DD)
10329 IF (ZERO.LE.ROOT7A) THEN
10334 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
10337 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
10342 IF (NAI*NO3I .GT. A8) THEN
10343 BB =-(WAER(4) - ROOT13 + WAER(1) - ROOT7)
10344 CC = (WAER(4) - ROOT13)*(WAER(1)-ROOT7) - A8
10345 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10346 ROOT8A = 0.5D0*(-BB-DD)
10347 ROOT8B = 0.5D0*(-BB+DD)
10348 IF (ZERO.LE.ROOT8A) THEN
10353 ROOT8 = MIN(MAX(ROOT8, ZERO), CHI8)
10356 PSCONV8 = ABS(PSI8-PSI8O) .LE. EPS*PSI8O
10359 !C ION CONCENTRATIONS ; CORRECTIONS
10361 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
10362 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
10363 NH4I = MAX (WAER(3) - ROOT5, ZERO)
10364 NO3I = MAX (WAER(4) - ROOT13 - ROOT8, ZERO)
10365 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
10367 NAI = MAX (WAER(1) - ROOT7 - ROOT8, ZERO)
10370 !C SOLUTION ACIDIC OR BASIC?
10372 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
10373 - 2.D0*CAI - KI - 2.D0*MGI
10374 IF (GG.GT.TINY) THEN ! H+ in excess
10377 DD = BB*BB - 4.D0*CC
10378 HI = 0.5D0*(-BB + SQRT(DD))
10380 ELSE ! OH- in excess
10383 DD = BB*BB - 4.D0*CC
10384 OHI= 0.5D0*(-BB + SQRT(DD))
10388 !C UNDISSOCIATED SPECIES EQUILIBRIA
10390 IF (HI.GT.OHI) THEN
10391 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
10395 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
10396 !C & - KI - 2.D0*MGI, ZERO)
10397 !C GGCL = MAX(GG-GGNO3, ZERO)
10398 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
10399 !C IF (GGNO3.GT.TINY) THEN
10400 !C IF (GGCL.LE.TINY) HI = ZERO
10401 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
10404 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
10406 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
10413 !C IF (HI.LE.TINY) HI = SQRT(AKW)
10416 IF (HI.LE.TINY) THEN
10421 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
10434 !C *** CALCULATE WATER **************************************************
10438 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10440 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10443 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
10444 .AND. PSCONV7 .AND. PSCONV8) GOTO 20
10447 !ccc CALL PUSHERR (0002, 'CALCW5') ! WARNING ERROR: NO CONVERGENCE
10449 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10451 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
10452 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
10453 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
10465 CNH4CL = CHI5 - PSI5
10466 CNACL = CHI7 - PSI7
10467 CNANO3 = CHI8 - PSI8
10469 CK2SO4 = CHI9 - PSI9
10470 CCASO4 = MIN (WAER(6), WAER(2))
10472 CKNO3 = CHI13 - PSI13
10473 KCL = CHI14 - PSI14
10480 !C *** END OF SUBROUTINE CALCW5 ******************************************
10484 !C=======================================================================
10486 !C *** ISORROPIA CODE II
10487 !C *** SUBROUTINE CALCW4
10490 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10491 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10492 !C 2. SOLID AEROSOL ONLY
10493 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, KCL, MGSO4,
10494 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
10496 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10497 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10498 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10500 !C=======================================================================
10502 SUBROUTINE CALCW42p1
10503 INCLUDE 'module_isrpia_inc.F'
10504 EXTERNAL CALCW1A2p1, CALCW5A2p1
10506 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
10508 IF (WAER(4).GT.TINY) THEN ! NO3 EXIST, WATER POSSIBLE
10509 SCASE = 'W4 ; SUBCASE 1'
10511 SCASE = 'W4 ; SUBCASE 1'
10512 ELSE ! NO3, CL NON EXISTANT
10513 SCASE = 'W1 ; SUBCASE 1'
10515 SCASE = 'W1 ; SUBCASE 1'
10518 IF (WATER.LE.TINY) THEN
10519 IF (RH.LT.DRMP4) THEN ! ONLY SOLIDS
10525 SCASE = 'W4 ; SUBCASE 2'
10528 SCASE = 'W4 ; SUBCASE 3' ! MDRH REGION (CaSO4, K2SO4, KNO3, KCL, MGSO4,
10529 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
10530 CALL CALCMDRPII2p1 (RH, DRMP4, DRMGNO32, CALCW1A2p1, CALCW5A2p1)
10531 SCASE = 'W4 ; SUBCASE 3'
10537 !C *** END OF SUBROUTINE CALCW4 ******************************************
10541 !C=======================================================================
10543 !C *** ISORROPIA CODE II
10544 !C *** SUBROUTINE CALCW4A
10547 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10548 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10549 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10550 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
10551 !C NANO3, NH4NO3, MG(NO3)2
10552 !C 4. Completely dissolved: CA(NO3)2, CACL2, MGCL2
10554 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10555 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10556 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10558 !C=======================================================================
10560 SUBROUTINE CALCW4A2p1
10561 INCLUDE 'module_isrpia_inc.F'
10563 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7, PSCONV8
10564 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
10566 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10567 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10568 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10569 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10570 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10571 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10573 !C *** SETUP PARAMETERS ************************************************
10591 PSI8O =-GREAT ! GREAT = 1.D10
10600 !C *** CALCULATE INITIAL SOLUTION ***************************************
10604 CHI9 = CK2SO4 ! SALTS
10615 PSI1 = CNA2SO4 ! SALTS DISSOLVED
10630 CALL CALCMR2p1 ! WATER
10632 NAI = WAER(1) ! LIQUID CONCENTRATIONS
10633 SO4I = MAX (WAER(2) - WAER(6), ZERO)
10646 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10650 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
10651 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
10652 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
10653 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
10654 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
10655 A8 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
10656 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
10658 !C POTASSIUM SULFATE
10660 IF (KI*KI*SO4I .GT. A9) THEN
10661 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
10662 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
10663 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
10664 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
10665 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
10666 IF (ISLV.NE.0) ROOT9 = TINY
10667 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
10668 (WAER(2)-WAER(6)), CHI9)
10669 ROOT9 = MAX (ROOT9, ZERO)
10670 PSI9 = CHI9 - ROOT9
10672 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
10675 !C POTASSIUM NITRATE
10677 IF (KI*NO3I .GT. A13) THEN
10678 BB =-(WAER(4) - ROOT8 + WAER(7) - 2.D0*ROOT9 - ROOT14)
10679 CC = (WAER(4)-ROOT8)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
10680 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
10681 ROOT13A= 0.5D0*(-BB-DD)
10682 ROOT13B= 0.5D0*(-BB+DD)
10683 IF (ZERO.LE.ROOT13A) THEN
10688 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
10689 PSI13 = CHI13-ROOT13
10691 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
10694 !C POTASSIUM CLORIDE
10696 IF (KI*CLI .GT. A14) THEN
10697 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
10698 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
10699 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10700 ROOT14A= 0.5D0*(-BB-DD)
10701 ROOT14B= 0.5D0*(-BB+DD)
10702 IF (ZERO.LE.ROOT14A) THEN
10707 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
10708 PSI14 = CHI14-ROOT14
10710 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
10713 !C AMMONIUM CLORIDE
10715 IF (NH4I*CLI .GT. A5) THEN
10716 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
10717 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
10718 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10719 ROOT5A = 0.5D0*(-BB-DD)
10720 ROOT5B = 0.5D0*(-BB+DD)
10721 IF (ZERO.LE.ROOT5A) THEN
10726 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
10729 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
10734 IF (NAI*CLI .GT. A7) THEN
10735 BB =-(WAER(5) + WAER(1) - ROOT8 - ROOT14 - ROOT5)
10736 CC = (WAER(5) - ROOT14 - ROOT5)*(WAER(1)-ROOT8) - A7
10737 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10738 ROOT7A = 0.5D0*(-BB-DD)
10739 ROOT7B = 0.5D0*(-BB+DD)
10740 IF (ZERO.LE.ROOT7A) THEN
10745 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
10748 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
10753 IF (NAI*NO3I .GT. A8) THEN
10754 BB =-(WAER(4) - ROOT13 + WAER(1) - ROOT7)
10755 CC = (WAER(4) - ROOT13)*(WAER(1)-ROOT7) - A8
10756 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
10757 ROOT8A = 0.5D0*(-BB-DD)
10758 ROOT8B = 0.5D0*(-BB+DD)
10759 IF (ZERO.LE.ROOT8A) THEN
10764 ROOT8 = MIN(MAX(ROOT8, ZERO), CHI8)
10767 PSCONV8 = ABS(PSI8-PSI8O) .LE. EPS*PSI8O
10770 !C ION CONCENTRATIONS ; CORRECTIONS
10772 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
10773 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
10774 NH4I = MAX (WAER(3) - ROOT5, ZERO)
10775 NO3I = MAX (WAER(4) - ROOT13 - ROOT8, ZERO)
10776 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
10778 NAI = MAX (WAER(1) - ROOT7 - ROOT8, ZERO)
10781 !C SOLUTION ACIDIC OR BASIC?
10783 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
10784 - 2.D0*CAI - KI - 2.D0*MGI
10785 IF (GG.GT.TINY) THEN ! H+ in excess
10788 DD = BB*BB - 4.D0*CC
10789 HI = 0.5D0*(-BB + SQRT(DD))
10791 ELSE ! OH- in excess
10794 DD = BB*BB - 4.D0*CC
10795 OHI= 0.5D0*(-BB + SQRT(DD))
10799 !C UNDISSOCIATED SPECIES EQUILIBRIA
10801 IF (HI.GT.OHI) THEN
10802 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
10806 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
10807 !C & - KI - 2.D0*MGI, ZERO)
10808 !C GGCL = MAX(GG-GGNO3, ZERO)
10809 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
10810 !C IF (GGNO3.GT.TINY) THEN
10811 !C IF (GGCL.LE.TINY) HI = ZERO
10812 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
10815 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
10817 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
10824 !C IF (HI.LE.TINY) HI = SQRT(AKW)
10827 IF (HI.LE.TINY) THEN
10832 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
10845 !C *** CALCULATE WATER **************************************************
10849 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10851 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10854 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
10855 .AND. PSCONV7 .AND. PSCONV8) GOTO 20
10858 !ccc CALL PUSHERR (0002, 'CALCW4') ! WARNING ERROR: NO CONVERGENCE
10860 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10862 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
10863 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
10864 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
10876 CNH4CL = CHI5 - PSI5
10877 CNACL = CHI7 - PSI7
10878 CNANO3 = CHI8 - PSI8
10880 CK2SO4 = CHI9 - PSI9
10881 CCASO4 = MIN (WAER(6), WAER(2))
10883 CKNO3 = CHI13 - PSI13
10884 KCL = CHI14 - PSI14
10891 !C *** END OF SUBROUTINE CALCW4A ******************************************
10895 !C=======================================================================
10897 !C *** ISORROPIA CODE II
10898 !C *** SUBROUTINE CALCW3
10901 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10902 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10903 !C 2. SOLID AEROSOL ONLY
10904 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
10905 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
10907 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10908 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10909 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10911 !C=======================================================================
10913 SUBROUTINE CALCW32p1
10914 INCLUDE 'module_isrpia_inc.F'
10915 EXTERNAL CALCW1A2p1, CALCW4A2p1
10917 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
10919 !C IF (WAER(4).GT.TINY .AND. WAER(5).GT.TINY) THEN ! NO3,CL EXIST, WATER POSSIBLE
10920 !C SCASE = 'W3 ; SUBCASE 1'
10922 !C SCASE = 'W3 ; SUBCASE 1'
10923 !C ELSE ! NO3, CL NON EXISTANT
10924 !C SCASE = 'W1 ; SUBCASE 1'
10926 !C SCASE = 'W1 ; SUBCASE 1'
10931 IF (WATER.LE.TINY) THEN
10932 IF (RH.LT.DRMP3) THEN ! ONLY SOLIDS
10938 SCASE = 'W3 ; SUBCASE 2'
10941 SCASE = 'W3 ; SUBCASE 3' ! MDRH REGION (CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
10942 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
10943 CALL CALCMDRPII2p1 (RH, DRMP3, DRCANO32, CALCW1A2p1, CALCW4A2p1)
10944 SCASE = 'W3 ; SUBCASE 3'
10946 ELSE ! NO3, CL NON EXISTANT
10947 SCASE = 'W3 ; SUBCASE 1'
10949 SCASE = 'W3 ; SUBCASE 1'
10954 !C *** END OF SUBROUTINE CALCW3 ******************************************
10958 !C=======================================================================
10960 !C *** ISORROPIA CODE II
10961 !C *** SUBROUTINE CALCW3A
10964 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10965 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
10966 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10967 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
10968 !C NANO3, NH4NO3, CA(NO3)2, MG(NO3)2
10969 !C 4. Completely dissolved: CACL2, MGCL2
10971 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10972 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10973 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10975 !C=======================================================================
10977 SUBROUTINE CALCW3A2p1
10978 INCLUDE 'module_isrpia_inc.F'
10980 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7, PSCONV8
10981 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
10983 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10984 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10985 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10986 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10987 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10988 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10990 !C *** SETUP PARAMETERS ************************************************
11008 PSI8O =-GREAT ! GREAT = 1.D10
11017 !C *** CALCULATE INITIAL SOLUTION ***************************************
11021 CHI9 = CK2SO4 ! SALTS
11033 PSI1 = CNA2SO4 ! SALTS DISSOLVED
11048 CALL CALCMR2p1 ! WATER
11050 NAI = WAER(1) ! LIQUID CONCENTRATIONS
11051 SO4I = MAX (WAER(2) - WAER(6), ZERO)
11064 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11068 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
11069 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
11070 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
11071 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
11072 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
11073 A8 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
11074 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
11076 !C POTASSIUM SULFATE
11078 IF (KI*KI*SO4I .GT. A9) THEN
11079 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
11080 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
11081 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
11082 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
11083 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
11084 IF (ISLV.NE.0) ROOT9 = TINY
11085 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
11086 (WAER(2)-WAER(6)), CHI9)
11087 ROOT9 = MAX (ROOT9, ZERO)
11088 PSI9 = CHI9 - ROOT9
11090 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
11093 !C POTASSIUM NITRATE
11095 IF (KI*NO3I .GT. A13) THEN
11096 BB =-(WAER(4) - ROOT8 + WAER(7) - 2.D0*ROOT9 - ROOT14)
11097 CC = (WAER(4)-ROOT8)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
11098 DD = SQRT(MAX(BB*BB - 4.D0*CC, ZERO))
11099 ROOT13A= 0.5D0*(-BB-DD)
11100 ROOT13B= 0.5D0*(-BB+DD)
11101 IF (ZERO.LE.ROOT13A) THEN
11106 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
11107 PSI13 = CHI13-ROOT13
11109 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
11112 !C POTASSIUM CLORIDE
11114 IF (KI*CLI .GT. A14) THEN
11115 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
11116 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
11117 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11118 ROOT14A= 0.5D0*(-BB-DD)
11119 ROOT14B= 0.5D0*(-BB+DD)
11120 IF (ZERO.LE.ROOT14A) THEN
11125 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
11126 PSI14 = CHI14-ROOT14
11128 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
11131 !C AMMONIUM CLORIDE
11133 IF (NH4I*CLI .GT. A5) THEN
11134 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
11135 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
11136 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11137 ROOT5A = 0.5D0*(-BB-DD)
11138 ROOT5B = 0.5D0*(-BB+DD)
11139 IF (ZERO.LE.ROOT5A) THEN
11144 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
11147 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
11152 IF (NAI*CLI .GT. A7) THEN
11153 BB =-(WAER(5) + WAER(1) - ROOT8 - ROOT14 - ROOT5)
11154 CC = (WAER(5) - ROOT14 - ROOT5)*(WAER(1)-ROOT8) - A7
11155 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11156 ROOT7A = 0.5D0*(-BB-DD)
11157 ROOT7B = 0.5D0*(-BB+DD)
11158 IF (ZERO.LE.ROOT7A) THEN
11163 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
11166 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
11171 IF (NAI*NO3I .GT. A8) THEN
11172 BB =-(WAER(4) - ROOT13 + WAER(1) - ROOT7)
11173 CC = (WAER(4) - ROOT13)*(WAER(1)-ROOT7) - A8
11174 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11175 ROOT8A = 0.5D0*(-BB-DD)
11176 ROOT8B = 0.5D0*(-BB+DD)
11177 IF (ZERO.LE.ROOT8A) THEN
11182 ROOT8 = MIN(MAX(ROOT8, ZERO), CHI8)
11185 PSCONV8 = ABS(PSI8-PSI8O) .LE. EPS*PSI8O
11188 !C ION CONCENTRATIONS ; CORRECTIONS
11190 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
11191 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
11192 NH4I = MAX (WAER(3) - ROOT5, ZERO)
11193 NO3I = MAX (WAER(4) - ROOT13 - ROOT8, ZERO)
11194 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
11196 NAI = MAX (WAER(1) - ROOT7 - ROOT8, ZERO)
11199 !C SOLUTION ACIDIC OR BASIC?
11201 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
11202 - 2.D0*CAI - KI - 2.D0*MGI
11203 IF (GG.GT.TINY) THEN ! H+ in excess
11206 DD = BB*BB - 4.D0*CC
11207 HI = 0.5D0*(-BB + SQRT(DD))
11209 ELSE ! OH- in excess
11212 DD = BB*BB - 4.D0*CC
11213 OHI= 0.5D0*(-BB + SQRT(DD))
11217 !C UNDISSOCIATED SPECIES EQUILIBRIA
11219 IF (HI.GT.OHI) THEN
11220 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
11224 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
11225 !C & - KI - 2.D0*MGI, ZERO)
11226 !C GGCL = MAX(GG-GGNO3, ZERO)
11227 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
11228 !C IF (GGNO3.GT.TINY) THEN
11229 !C IF (GGCL.LE.TINY) HI = ZERO
11230 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
11233 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
11235 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
11242 !C IF (HI.LE.TINY) HI = SQRT(AKW)
11245 IF (HI.LE.TINY) THEN
11250 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
11263 !C *** CALCULATE WATER **************************************************
11267 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11269 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11272 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
11273 .AND. PSCONV7 .AND. PSCONV8) GOTO 20
11276 !ccc CALL PUSHERR (0002, 'CALCW3') ! WARNING ERROR: NO CONVERGENCE
11278 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
11280 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
11281 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
11282 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
11294 CNH4CL = CHI5 - PSI5
11295 CNACL = CHI7 - PSI7
11296 CNANO3 = CHI8 - PSI8
11298 CK2SO4 = CHI9 - PSI9
11299 CCASO4 = MIN (WAER(6), WAER(2))
11301 CKNO3 = CHI13 - PSI13
11302 KCL = CHI14 - PSI14
11309 !C *** END OF SUBROUTINE CALCW3A ******************************************
11313 !C=======================================================================
11315 !C *** ISORROPIA CODE II
11316 !C *** SUBROUTINE CALCW2
11319 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11320 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11321 !C 2. SOLID AEROSOL ONLY
11322 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
11323 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11325 !C THERE ARE THREE REGIMES IN THIS CASE:
11326 !C 1. CACL2(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCL2A)
11327 !C 2. CACL2(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
11328 !C 3. CACL2(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
11330 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES W1A, W2B
11332 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11333 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11334 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
11336 !C=======================================================================
11339 SUBROUTINE CALCW22p1
11340 INCLUDE 'module_isrpia_inc.F'
11341 EXTERNAL CALCW1A2p1, CALCW3A2p1, CALCW4A2p1, CALCW5A2p1, CALCW62p1
11343 !C *** FIND DRY COMPOSITION **********************************************
11347 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
11349 IF (CCACL2.GT.TINY) THEN
11350 SCASE = 'W2 ; SUBCASE 1'
11352 SCASE = 'W2 ; SUBCASE 1'
11355 IF (WATER.LE.TINY) THEN
11356 IF (RH.LT.DRMP2) THEN ! ONLY SOLIDS
11362 SCASE = 'W2 ; SUBCASE 2'
11364 IF (CMGCL2.GT. TINY) THEN
11365 SCASE = 'W2 ; SUBCASE 3' ! MDRH (CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4, MGCL2,
11366 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
11367 CALL CALCMDRPII2p1 (RH, DRMP2, DRMGCL2, CALCW1A2p1, CALCW3A2p1)
11368 SCASE = 'W2 ; SUBCASE 3'
11370 IF (WATER.LE.TINY .AND. RH.GE.DRMP3 .AND. RH.LT.DRMP4) THEN
11371 SCASE = 'W2 ; SUBCASE 4' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4, CANO32,
11372 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
11373 CALL CALCMDRPII2p1 (RH, DRMP3, DRCANO32, CALCW1A2p1, CALCW4A2p1)
11374 SCASE = 'W2 ; SUBCASE 4'
11376 IF (WATER.LE.TINY .AND. RH.GE.DRMP4 .AND. RH.LT.DRMP5) THEN
11377 SCASE = 'W2 ; SUBCASE 5' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4,
11378 !C MGNO32, NANO3, NACL, NH4NO3, NH4CL)
11379 CALL CALCMDRPII2p1 (RH, DRMP4, DRMGNO32, CALCW1A2p1, CALCW5A2p1)
11380 SCASE = 'W2 ; SUBCASE 5'
11382 IF (WATER.LE.TINY .AND. RH.GE.DRMP5) THEN
11383 SCASE = 'W2 ; SUBCASE 6' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4,
11384 !C NANO3, NACL, NH4NO3, NH4CL)
11385 CALL CALCMDRPII2p1 (RH, DRMP5, DRNH4NO3, CALCW1A2p1, CALCW62p1)
11386 SCASE = 'W2 ; SUBCASE 6'
11393 SCASE = 'W2 ; SUBCASE 2'
11400 !C *** END OF SUBROUTINE CALCW2 ******************************************
11404 !C=======================================================================
11406 !C *** ISORROPIA CODE II
11407 !C *** SUBROUTINE CALCW2A
11410 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11411 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11412 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11413 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
11414 !C NANO3, NH4NO3, CA(NO3)2, MG(NO3)2, MGCL2
11415 !C 4. Completely dissolved: CACL2
11417 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11418 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11419 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
11421 !C=======================================================================
11423 SUBROUTINE CALCW2A2p1
11424 INCLUDE 'module_isrpia_inc.F'
11426 LOGICAL PSCONV9, PSCONV13, PSCONV14, PSCONV5, PSCONV7, PSCONV8
11427 DOUBLE PRECISION NH4I, NAI, NO3I, NH3AQ, NO3AQ, CLAQ, CAI, KI, MGI
11429 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11430 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11431 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11432 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11433 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11434 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11436 !C *** SETUP PARAMETERS ************************************************
11454 PSI8O =-GREAT ! GREAT = 1.D10
11463 !C *** CALCULATE INITIAL SOLUTION ***************************************
11467 CHI9 = CK2SO4 ! SALTS
11480 PSI1 = CNA2SO4 ! SALTS DISSOLVED
11495 CALL CALCMR2p1 ! WATER
11497 NAI = WAER(1) ! LIQUID CONCENTRATIONS
11498 SO4I = MAX (WAER(2) - WAER(6), ZERO)
11511 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11515 A9 = XK17 *(WATER/GAMA(17))**3.0 ! K2SO4 <==> K+
11516 A13 = XK19 *(WATER/GAMA(19))**2.0 ! KNO3 <==> K+
11517 A14 = XK20 *(WATER/GAMA(20))**2.0 ! KCL <==> K+
11518 A5 = XK14*(WATER/GAMA(6))**2.0 ! NH4Cl <==> NH4+
11519 A7 = XK8 *(WATER/GAMA(1))**2.0 ! NaCl <==> Na+
11520 A8 = XK9 *(WATER/GAMA(3))**2. ! NaNO3 <==> Na+
11521 AKW = XKW*RH*WATER*WATER ! H2O <==> H+
11523 !C POTASSIUM SULFATE
11525 IF (KI*KI*SO4I .GT. A9) THEN
11526 BB =-((WAER(2)-WAER(6)) + WAER(7) - ROOT13 - ROOT14)
11527 CC = (WAER(7)-ROOT13-ROOT14)*(WAER(2)-WAER(6)) + &
11528 0.25D0*(WAER(7)-ROOT13-ROOT14)**2.0
11529 DD =-0.25*((WAER(7)-ROOT13-ROOT14)**2.0*(WAER(2)-WAER(6)) - A9)
11530 CALL POLY32p1(BB, CC, DD, ROOT9, ISLV)
11531 IF (ISLV.NE.0) ROOT9 = TINY
11532 ROOT9 = MIN (ROOT9, WAER(7)/2.0-ROOT13-ROOT14, &
11533 (WAER(2)-WAER(6)), CHI9)
11534 ROOT9 = MAX (ROOT9, ZERO)
11535 PSI9 = CHI9 - ROOT9
11537 PSCONV9 = ABS(PSI9-PSI9O) .LE. EPS*PSI9O
11540 !C POTASSIUM NITRATE
11542 IF (KI*NO3I .GT. A13) THEN
11543 BB =-(WAER(4) - ROOT8 + WAER(7) - 2.D0*ROOT9 - ROOT14)
11544 CC = (WAER(4)-ROOT8)*(WAER(7) - 2.D0*ROOT9 - ROOT14) - A13
11545 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11546 ROOT13A= 0.5D0*(-BB-DD)
11547 ROOT13B= 0.5D0*(-BB+DD)
11548 IF (ZERO.LE.ROOT13A) THEN
11553 ROOT13 = MIN(MAX(ROOT13, ZERO), CHI13)
11554 PSI13 = CHI13-ROOT13
11556 PSCONV13 = ABS(PSI13-PSI13O) .LE. EPS*PSI13O
11559 !C POTASSIUM CLORIDE
11561 IF (KI*CLI .GT. A14) THEN
11562 BB =-(WAER(5)-ROOT5-ROOT7 + WAER(7)-2.D0*ROOT9-ROOT13)
11563 CC = (WAER(5)-ROOT5-ROOT7)*(WAER(7)-2.D0*ROOT9-ROOT13)-A14
11564 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11565 ROOT14A= 0.5D0*(-BB-DD)
11566 ROOT14B= 0.5D0*(-BB+DD)
11567 IF (ZERO.LE.ROOT14A) THEN
11572 ROOT14 = MIN(MAX(ROOT14, ZERO), CHI14)
11573 PSI14 = CHI14-ROOT14
11575 PSCONV14 = ABS(PSI14-PSI14O) .LE. EPS*PSI14O
11578 !C AMMONIUM CLORIDE
11580 IF (NH4I*CLI .GT. A5) THEN
11581 BB =-(WAER(5) + WAER(3) - ROOT14 - ROOT7)
11582 CC = (WAER(5) - ROOT14 - ROOT7)*WAER(3) - A5
11583 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11584 ROOT5A = 0.5D0*(-BB-DD)
11585 ROOT5B = 0.5D0*(-BB+DD)
11586 IF (ZERO.LE.ROOT5A) THEN
11591 ROOT5 = MIN(MAX(ROOT5, ZERO), CHI5)
11594 PSCONV5 = ABS(PSI5-PSI5O) .LE. EPS*PSI5O
11599 IF (NAI*CLI .GT. A7) THEN
11600 BB =-(WAER(5) + WAER(1) - ROOT8 - ROOT14 - ROOT5)
11601 CC = (WAER(5) - ROOT14 - ROOT5)*(WAER(1)-ROOT8) - A7
11602 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11603 ROOT7A = 0.5D0*(-BB-DD)
11604 ROOT7B = 0.5D0*(-BB+DD)
11605 IF (ZERO.LE.ROOT7A) THEN
11610 ROOT7 = MIN(MAX(ROOT7, ZERO), CHI7)
11613 PSCONV7 = ABS(PSI7-PSI7O) .LE. EPS*PSI7O
11618 IF (NAI*NO3I .GT. A8) THEN
11619 BB =-(WAER(4) - ROOT13 + WAER(1) - ROOT7)
11620 CC = (WAER(4) - ROOT13)*(WAER(1)-ROOT7) - A8
11621 DD = SQRT(MAX(BB*BB - 4.D0*CC, TINY))
11622 ROOT8A = 0.5D0*(-BB-DD)
11623 ROOT8B = 0.5D0*(-BB+DD)
11624 IF (ZERO.LE.ROOT8A) THEN
11629 ROOT8 = MIN(MAX(ROOT8, ZERO), CHI8)
11632 PSCONV8 = ABS(PSI8-PSI8O) .LE. EPS*PSI8O
11635 !C ION CONCENTRATIONS ; CORRECTIONS
11637 KI = MAX (WAER(7) - 2.D0*ROOT9 - ROOT13 - ROOT14, ZERO)
11638 SO4I = MAX (WAER(2)-WAER(6) - ROOT9, ZERO)
11639 NH4I = MAX (WAER(3) - ROOT5, ZERO)
11640 NO3I = MAX (WAER(4) - ROOT13 - ROOT8, ZERO)
11641 CLI = MAX (WAER(5) - ROOT14 - ROOT5 - ROOT7, ZERO)
11643 NAI = MAX (WAER(1) - ROOT7 - ROOT8, ZERO)
11646 !C SOLUTION ACIDIC OR BASIC?
11648 GG = 2.D0*SO4I + NO3I + CLI - NAI - NH4I &
11649 - 2.D0*CAI - KI - 2.D0*MGI
11650 IF (GG.GT.TINY) THEN ! H+ in excess
11653 DD = BB*BB - 4.D0*CC
11654 HI = 0.5D0*(-BB + SQRT(DD))
11656 ELSE ! OH- in excess
11659 DD = BB*BB - 4.D0*CC
11660 OHI= 0.5D0*(-BB + SQRT(DD))
11664 !C UNDISSOCIATED SPECIES EQUILIBRIA
11666 IF (HI.GT.OHI) THEN
11667 !C CALL CALCAMAQ2 (-GG, NH4I, OHI, NH3AQ)
11671 !C GGNO3 = MAX(2.D0*SO4I + NO3I - NAI - NH4I - 2.D0*CAI
11672 !C & - KI - 2.D0*MGI, ZERO)
11673 !C GGCL = MAX(GG-GGNO3, ZERO)
11674 !C IF (GGCL .GT.TINY) CALL CALCCLAQ2 (GGCL, CLI, HI, CLAQ) ! HCl
11675 !C IF (GGNO3.GT.TINY) THEN
11676 !C IF (GGCL.LE.TINY) HI = ZERO
11677 !C CALL CALCNIAQ2 (GGNO3, NO3I, HI, NO3AQ) ! HNO3
11680 !C CONCENTRATION ADJUSTMENTS ; HSO4 minor species.
11682 CALL CALCHS42p1 (HI, SO4I, ZERO, DEL)
11689 !C IF (HI.LE.TINY) HI = SQRT(AKW)
11692 IF (HI.LE.TINY) THEN
11697 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
11710 !C *** CALCULATE WATER **************************************************
11714 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11716 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11719 IF (PSCONV9 .AND. PSCONV13 .AND. PSCONV14 .AND. PSCONV5 &
11720 .AND. PSCONV7 .AND. PSCONV8) GOTO 20
11723 !ccc CALL PUSHERR (0002, 'CALCW2') ! WARNING ERROR: NO CONVERGENCE
11725 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
11727 20 A2 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2. ! NH3 <==> NH4+
11728 A3 = XK4 *R*TEMP*(WATER/GAMA(10))**2. ! HNO3 <==> NO3-
11729 A4 = XK3 *R*TEMP*(WATER/GAMA(11))**2. ! HCL <==> CL-
11741 CNH4CL = CHI5 - PSI5
11742 CNACL = CHI7 - PSI7
11743 CNANO3 = CHI8 - PSI8
11745 CK2SO4 = CHI9 - PSI9
11746 CCASO4 = MIN (WAER(6), WAER(2))
11748 CKNO3 = CHI13 - PSI13
11749 KCL = CHI14 - PSI14
11756 !C *** END OF SUBROUTINE CALCW2A ******************************************
11760 !C=======================================================================
11762 !C *** ISORROPIA CODE II
11763 !C *** SUBROUTINE CALCW1
11766 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11767 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11768 !C 2. SOLID AEROSOL ONLY
11769 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
11770 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11772 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
11773 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
11774 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCP1A)
11776 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
11777 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11778 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
11780 !C=======================================================================
11782 SUBROUTINE CALCW12p1
11783 INCLUDE 'module_isrpia_inc.F'
11784 EXTERNAL CALCW1A2p1, CALCW2A2p1
11786 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
11788 IF (RH.LT.DRMP1) THEN
11789 SCASE = 'W1 ; SUBCASE 1'
11790 CALL CALCW1A2p1 ! SOLID PHASE ONLY POSSIBLE
11791 SCASE = 'W1 ; SUBCASE 1'
11793 SCASE = 'W1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
11794 CALL CALCMDRPII2p1 (RH, DRMP1, DRCACL2, CALCW1A2p1, CALCW2A2p1)
11795 SCASE = 'W1 ; SUBCASE 2'
11800 !C *** END OF SUBROUTINE CALCW1 ******************************************
11804 !C=======================================================================
11806 !C *** ISORROPIA CODE II
11807 !C *** SUBROUTINE CALCW1A
11810 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11811 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11812 !C 2. SOLID AEROSOL ONLY
11813 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
11814 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11816 !C *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11817 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11818 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11820 !C=======================================================================
11822 SUBROUTINE CALCW1A2p1
11823 INCLUDE 'module_isrpia_inc.F'
11825 !C *** CALCULATE SOLIDS **************************************************
11827 CCASO4 = MIN (WAER(2), WAER(6)) !SOLID CASO4
11828 CAFR = MAX (WAER(6) - CCASO4, ZERO)
11829 SO4FR = MAX (WAER(2) - CCASO4, ZERO)
11830 CK2SO4 = MIN (SO4FR, 0.5D0*WAER(7)) !SOLID K2SO4
11831 FRK = MAX (WAER(7) - 2.D0*CK2SO4, ZERO)
11832 SO4FR = MAX (SO4FR - CK2SO4, ZERO)
11833 CMGSO4 = SO4FR !SOLID MGSO4
11834 FRMG = MAX (WAER(8) - CMGSO4, ZERO)
11835 CNACL = MIN (WAER(1), WAER(5)) !SOLID NACL
11836 FRNA = MAX (WAER(1) - CNACL, ZERO)
11837 CLFR = MAX (WAER(5) - CNACL, ZERO)
11838 CCACL2 = MIN (CAFR, 0.5D0*CLFR) !SOLID CACL2
11839 CAFR = MAX (CAFR - CCACL2, ZERO)
11840 CLFR = MAX (WAER(5) - 2.D0*CCACL2, ZERO)
11841 CCANO32 = MIN (CAFR, 0.5D0*WAER(4)) !SOLID CA(NO3)2
11842 CAFR = MAX (CAFR - CCANO32, ZERO)
11843 FRNO3 = MAX (WAER(4) - 2.D0*CCANO32, ZERO)
11844 CMGCL2 = MIN (FRMG, 0.5D0*CLFR) !SOLID MGCL2
11845 FRMG = MAX (FRMG - CMGCL2, ZERO)
11846 CLFR = MAX (CLFR - 2.D0*CMGCL2, ZERO)
11847 CMGNO32 = MIN (FRMG, 0.5D0*FRNO3) !SOLID MG(NO3)2
11848 FRMG = MAX (FRMG - CMGNO32, ZERO)
11849 FRNO3 = MAX (FRNO3 - 2.D0*CMGNO32, ZERO)
11850 CNANO3 = MIN (FRNA, FRNO3) !SOLID NANO3
11851 FRNA = MAX (FRNA - CNANO3, ZERO)
11852 FRNO3 = MAX (FRNO3 - CNANO3, ZERO)
11853 CKCL = MIN (FRK, CLFR) !SOLID KCL
11854 FRK = MAX (FRK - CKCL, ZERO)
11855 CLFR = MAX (CLFR - CKCL, ZERO)
11856 CKNO3 = MIN (FRK, FRNO3) !SOLID KNO3
11857 FRK = MAX (FRK - CKNO3, ZERO)
11858 FRNO3 = MAX (FRNO3 - CKNO3, ZERO)
11860 !C *** OTHER PHASES ******************************************************
11870 !C *** END OF SUBROUTINE CALCW1A *****************************************