2 !CC=======================================================================
5 !C *** SUBROUTINE ISRP1F
6 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FOREWARD 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-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
12 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13 !C *** WRITTEN BY ATHANASIOS NENES
14 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
16 !C=======================================================================
18 SUBROUTINE ISRP1F2p1 (WI, RHI, TEMPI)
19 INCLUDE 'module_isrpia_inc.F'
23 ! write(*,*) 'running isrp1f'
26 !C *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
28 CALL INIT12p1 (WI, RHI, TEMPI)
30 !C *** CALCULATE SULFATE RATIO *******************************************
34 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
38 IF (2.0.LE.SULRAT) THEN
39 DC = W(3) - 2.001D0*W(2) ! For numerical stability
40 W(3) = W(3) + MAX(-DC, ZERO)
44 CALL CALCA22p1 ! Only liquid (metastable)
47 IF (RH.LT.DRNH42S4) THEN
49 CALL CALCA12p1 ! NH42SO4 ; case A1
51 ELSEIF (DRNH42S4.LE.RH) THEN
53 CALL CALCA22p1 ! Only liquid ; case A2
57 !C *** SULFATE RICH (NO ACID)
59 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
63 CALL CALCB42p1 ! Only liquid (metastable)
66 IF (RH.LT.DRNH4HS4) THEN
68 CALL CALCB12p1 ! NH4HSO4,LC,NH42SO4 ; case B1
70 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
72 CALL CALCB22p1 ! LC,NH42S4 ; case B2
74 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
76 CALL CALCB32p1 ! NH42S4 ; case B3
78 ELSEIF (DRNH42S4.LE.RH) THEN
80 CALL CALCB42p1 ! Only liquid ; case B4
85 !C *** SULFATE RICH (FREE ACID)
87 ELSEIF (SULRAT.LT.1.0) THEN
91 CALL CALCC22p1 ! Only liquid (metastable)
94 IF (RH.LT.DRNH4HS4) THEN
96 CALL CALCC12p1 ! NH4HSO4 ; case C1
98 ELSEIF (DRNH4HS4.LE.RH) THEN
100 CALL CALCC22p1 ! Only liquid ; case C2
111 !C *** END OF SUBROUTINE ISRP1F *****************************************
114 !C=======================================================================
116 !C *** ISORROPIA CODE
117 !C *** SUBROUTINE ISRP2F
118 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FOREWARD PROBLEM OF
119 !C AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
120 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
121 !C THE AMBIENT RELATIVE HUMIDITY.
123 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
124 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
125 !C *** WRITTEN BY ATHANASIOS NENES
126 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
128 !C=======================================================================
130 SUBROUTINE ISRP2F2p1 (WI, RHI, TEMPI)
131 INCLUDE 'module_isrpia_inc.F'
135 ! write(*,*) 'running isrp2f'
138 !C *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
140 CALL INIT22p1 (WI, RHI, TEMPI)
142 !C *** CALCULATE SULFATE RATIO *******************************************
146 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
150 IF (2.0.LE.SULRAT) THEN
152 IF(METSTBL.EQ.1) THEN
154 CALL CALCD32p1 ! Only liquid (metastable)
157 IF (RH.LT.DRNH4NO3) THEN
159 CALL CALCD12p1 ! NH42SO4,NH4NO3 ; case D1
161 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH42S4) THEN
163 CALL CALCD22p1 ! NH42S4 ; case D2
165 ELSEIF (DRNH42S4.LE.RH) THEN
167 CALL CALCD32p1 ! Only liquid ; case D3
171 !C *** SULFATE RICH (NO ACID)
172 !C FOR SOLVING THIS CASE, NITRIC ACID IS ASSUMED A MINOR SPECIES,
173 !C THAT DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM.
174 !C SUBROUTINES CALCB? ARE CALLED, AND THEN THE NITRIC ACID IS DISSOLVED
175 !C FROM THE HNO3(G) -> (H+) + (NO3-) EQUILIBRIUM.
177 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
179 IF(METSTBL.EQ.1) THEN
181 CALL CALCB42p1 ! Only liquid (metastable)
185 IF (RH.LT.DRNH4HS4) THEN
187 CALL CALCB12p1 ! NH4HSO4,LC,NH42SO4 ; case E1
190 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRLC) THEN
192 CALL CALCB22p1 ! LC,NH42S4 ; case E2
195 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
197 CALL CALCB32p1 ! NH42S4 ; case E3
200 ELSEIF (DRNH42S4.LE.RH) THEN
202 CALL CALCB42p1 ! Only liquid ; case E4
207 CALL CALCNA2p1 ! HNO3(g) DISSOLUTION
209 !C *** SULFATE RICH (FREE ACID)
210 !C FOR SOLVING THIS CASE, NITRIC ACID IS ASSUMED A MINOR SPECIES,
211 !C THAT DOES NOT SIGNIFICANTLY PERTURB THE HSO4-SO4 EQUILIBRIUM
212 !C SUBROUTINE CALCC? IS CALLED, AND THEN THE NITRIC ACID IS DISSOLVED
213 !C FROM THE HNO3(G) -> (H+) + (NO3-) EQUILIBRIUM.
215 ELSEIF (SULRAT.LT.1.0) THEN
217 IF(METSTBL.EQ.1) THEN
219 CALL CALCC22p1 ! Only liquid (metastable)
223 IF (RH.LT.DRNH4HS4) THEN
225 CALL CALCC12p1 ! NH4HSO4 ; case F1
228 ELSEIF (DRNH4HS4.LE.RH) THEN
230 CALL CALCC22p1 ! Only liquid ; case F2
235 CALL CALCNA2p1 ! HNO3(g) DISSOLUTION
242 !C *** END OF SUBROUTINE ISRP2F *****************************************
245 !C=======================================================================
247 !C *** ISORROPIA CODE
248 !C *** SUBROUTINE ISRP3F
249 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FORWARD PROBLEM OF
250 !C AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
251 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
252 !C RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
254 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
255 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
256 !C *** WRITTEN BY ATHANASIOS NENES
257 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
259 !C=======================================================================
261 SUBROUTINE ISRP3F2p1 (WI, RHI, TEMPI)
262 INCLUDE 'module_isrpia_inc.F'
268 !C *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
270 WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
271 WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
273 !C *** ADJUST FOR TOO LITTLE SODIUM, SULFATE AND NITRATE COMBINED ********
275 IF (WI(1)+WI(2)+WI(4) .LE. 1d-10) THEN
276 WI(1) = 1.D-10 ! Na+ : 1e-4 umoles/m3
277 WI(2) = 1.D-10 ! SO4- : 1e-4 umoles/m3
280 !C *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
282 CALL ISOINIT32p1 (WI, RHI, TEMPI)
284 !C *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
286 REST = 2.D0*W(2) + W(4) + W(5)
287 IF (W(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
288 W(1) = (ONE-1D-6)*REST ! Adjust Na amount
289 CALL PUSHERR2p1 (0050, 'ISRP3F') ! Warning error: Na adjusted
292 !C *** CALCULATE SULFATE & SODIUM RATIOS *********************************
294 SULRAT = (W(1)+W(3))/W(2)
297 !C *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
299 !C *** SULFATE POOR ; SODIUM POOR
301 IF (2.0.LE.SULRAT .AND. SODRAT.LT.2.0) THEN
303 IF(METSTBL.EQ.1) THEN
305 CALL CALCG52p1 ! Only liquid (metastable)
308 IF (RH.LT.DRNH4NO3) THEN
310 CALL CALCG12p1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
312 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
314 CALL CALCG22p1 ! NH42SO4,NH4CL,NA2SO4
316 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
318 CALL CALCG32p1 ! NH42SO4,NA2SO4
320 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
322 CALL CALCG42p1 ! NA2SO4
324 ELSEIF (DRNA2SO4.LE.RH) THEN
326 CALL CALCG52p1 ! Only liquid
330 !C *** SULFATE POOR ; SODIUM RICH
332 ELSE IF (SULRAT.GE.2.0 .AND. SODRAT.GE.2.0) THEN
334 IF(METSTBL.EQ.1) THEN
336 CALL CALCH62p1 ! Only liquid (metastable)
339 IF (RH.LT.DRNH4NO3) THEN
341 CALL CALCH12p1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
343 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
345 CALL CALCH22p1 ! NH4CL,NA2SO4,NACL,NANO3
347 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
349 CALL CALCH32p1 ! NH4CL,NA2SO4,NACL
351 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4Cl) THEN
353 CALL CALCH42p1 ! NH4CL,NA2SO4
355 ELSEIF (DRNH4Cl.LE.RH .AND. RH.LT.DRNA2SO4) THEN
357 CALL CALCH52p1 ! NA2SO4
359 ELSEIF (DRNA2SO4.LE.RH) THEN
361 CALL CALCH62p1 ! NO SOLID
365 !C *** SULFATE RICH (NO ACID)
367 ELSEIF (1.0.LE.SULRAT .AND. SULRAT.LT.2.0) THEN
369 IF(METSTBL.EQ.1) THEN
371 CALL CALCI62p1 ! Only liquid (metastable)
374 IF (RH.LT.DRNH4HS4) THEN
376 CALL CALCI12p1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
378 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
380 CALL CALCI22p1 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
382 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
384 CALL CALCI32p1 ! NA2SO4,(NH4)2SO4,LC
386 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
388 CALL CALCI42p1 ! NA2SO4,(NH4)2SO4
390 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
392 CALL CALCI52p1 ! NA2SO4
394 ELSEIF (DRNA2SO4.LE.RH) THEN
396 CALL CALCI62p1 ! NO SOLIDS
400 CALL CALCNHA2p1 ! MINOR SPECIES: HNO3, HCl
401 CALL CALCNH32p1 ! NH3
403 !C *** SULFATE RICH (FREE ACID)
405 ELSEIF (SULRAT.LT.1.0) THEN
407 IF(METSTBL.EQ.1) THEN
409 CALL CALCJ32p1 ! Only liquid (metastable)
412 IF (RH.LT.DRNH4HS4) THEN
414 CALL CALCJ12p1 ! NH4HSO4,NAHSO4
416 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
418 CALL CALCJ22p1 ! NAHSO4
420 ELSEIF (DRNAHSO4.LE.RH) THEN
426 CALL CALCNHA2p1 ! MINOR SPECIES: HNO3, HCl
427 CALL CALCNH32p1 ! NH3
434 !C *** END OF SUBROUTINE ISRP3F *****************************************
438 !C=======================================================================
440 !C *** ISORROPIA CODE II
441 !C *** SUBROUTINE ISRP4F
442 !C *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE FORWARD PROBLEM OF
443 !C AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM-CALCIUM-POTASSIUM-MAGNESIUM
445 !C THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
446 !C RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
448 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
449 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
450 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
452 !C=======================================================================
454 SUBROUTINE ISRP4F2p1 (WI, RHI, TEMPI)
455 INCLUDE 'module_isrpia_inc.F'
457 DOUBLE PRECISION NAFRI, NO3FRI
459 !C *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
461 !C WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
462 !C WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
464 !C *** ADJUST FOR TOO LITTLE SODIUM, SULFATE AND NITRATE COMBINED ********
466 !C IF (WI(1)+WI(2)+WI(4) .LE. 1d-10) THEN
467 !C WI(1) = 1.D-10 ! Na+ : 1e-4 umoles/m3
468 !C WI(2) = 1.D-10 ! SO4- : 1e-4 umoles/m3
471 !C *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
473 CALL INIT42p1 (WI, RHI, TEMPI)
475 !C *** CHECK IF TOO MUCH SODIUM+CRUSTALS ; ADJUST AND ISSUE ERROR MESSAGE
477 REST = 2.D0*W(2) + W(4) + W(5)
479 IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
481 CCASO4I = MIN (W(2),W(6))
482 FRSO4I = MAX (W(2) - CCASO4I, ZERO)
483 CAFRI = MAX (W(6) - CCASO4I, ZERO)
484 CCANO32I = MIN (CAFRI, 0.5D0*W(4))
485 CAFRI = MAX (CAFRI - CCANO32I, ZERO)
486 NO3FRI = MAX (W(4) - 2.D0*CCANO32I, ZERO)
487 CCACL2I = MIN (CAFRI, 0.5D0*W(5))
488 CLFRI = MAX (W(5) - 2.D0*CCACL2I, ZERO)
489 REST1 = 2.D0*FRSO4I + NO3FRI + CLFRI
491 CNA2SO4I = MIN (FRSO4I, 0.5D0*W(1))
492 FRSO4I = MAX (FRSO4I - CNA2SO4I, ZERO)
493 NAFRI = MAX (W(1) - 2.D0*CNA2SO4I, ZERO)
494 CNACLI = MIN (NAFRI, CLFRI)
495 NAFRI = MAX (NAFRI - CNACLI, ZERO)
496 CLFRI = MAX (CLFRI - CNACLI, ZERO)
497 CNANO3I = MIN (NAFRI, NO3FRI)
498 NO3FR = MAX (NO3FRI - CNANO3I, ZERO)
499 REST2 = 2.D0*FRSO4I + NO3FRI + CLFRI
501 CMGSO4I = MIN (FRSO4I, W(8))
502 FRMGI = MAX (W(8) - CMGSO4I, ZERO)
503 FRSO4I = MAX (FRSO4I - CMGSO4I, ZERO)
504 CMGNO32I = MIN (FRMGI, 0.5D0*NO3FRI)
505 FRMGI = MAX (FRMGI - CMGNO32I, ZERO)
506 NO3FRI = MAX (NO3FRI - 2.D0*CMGNO32I, ZERO)
507 CMGCL2I = MIN (FRMGI, 0.5D0*CLFRI)
508 CLFRI = MAX (CLFRI - 2.D0*CMGCL2I, ZERO)
509 REST3 = 2.D0*FRSO4I + NO3FRI + CLFRI
511 IF (W(6).GT.REST) THEN ! Ca > 2*SO4+CL+NO3 ?
512 W(6) = (ONE-1D-6)*REST ! Adjust Ca amount
513 W(1)= ZERO ! Adjust Na amount
514 W(7)= ZERO ! Adjust K amount
515 W(8)= ZERO ! Adjust Mg amount
516 CALL PUSHERR2p1 (0051, 'ISRP4F') ! Warning error: Ca, Na, K, Mg in excess
518 ELSE IF (W(1).GT.REST1) THEN ! Na > 2*FRSO4+FRCL+FRNO3 ?
519 W(1) = (ONE-1D-6)*REST1 ! Adjust Na amount
520 W(7)= ZERO ! Adjust K amount
521 W(8)= ZERO ! Adjust Mg amount
522 CALL PUSHERR2p1 (0052, 'ISRP4F') ! Warning error: Na, K, Mg in excess
524 ELSE IF (W(8).GT.REST2) THEN ! Mg > 2*FRSO4+FRCL+FRNO3 ?
525 W(8) = (ONE-1D-6)*REST2 ! Adjust Mg amount
526 W(7)= ZERO ! Adjust K amount
527 CALL PUSHERR2p1 (0053, 'ISRP4F') ! Warning error: K, Mg in excess
529 ELSE IF (W(7).GT.REST3) THEN ! K > 2*FRSO4+FRCL+FRNO3 ?
530 W(7) = (ONE-1D-6)*REST3 ! Adjust K amount
531 CALL PUSHERR2p1 (0054, 'ISRP4F') ! Warning error: K in excess
535 !C *** CALCULATE RATIOS *************************************************
537 SO4RAT = (W(1)+W(3)+W(6)+W(7)+W(8))/W(2)
538 CRNARAT = (W(1)+W(6)+W(7)+W(8))/W(2)
539 CRRAT = (W(6)+W(7)+W(8))/W(2)
541 !C *** FIND CALCULATION REGIME FROM (SO4RAT, CRNARAT, CRRAT, RRH) ********
543 !C *** SULFATE POOR: Rso4>2; (DUST + SODIUM) POOR: R(Cr+Na)<2
545 IF (2.0.LE.SO4RAT .AND. CRNARAT.LT.2.0) THEN
547 IF(METSTBL.EQ.1) THEN
549 CALL CALCO72p1 ! Only liquid (metastable)
552 IF (RH.LT.DRNH4NO3) THEN
554 CALL CALCO12p1 ! CaSO4, NH4NO3, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
556 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNH4CL) THEN
558 CALL CALCO22p1 ! CaSO4, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
560 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRNH42S4) THEN
562 CALL CALCO32p1 ! CaSO4, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
564 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRMGSO4) THEN
566 CALL CALCO42p1 ! CaSO4, MGSO4, NA2SO4, K2SO4
568 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
570 CALL CALCO52p1 ! CaSO4, NA2SO4, K2SO4
572 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
574 CALL CALCO62p1 ! CaSO4, K2SO4
576 ELSEIF (DRK2SO4.LE.RH) THEN
578 CALL CALCO72p1 ! CaSO4
582 !C *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
584 ELSEIF (SO4RAT.GE.2.0 .AND. CRNARAT.GE.2.0) THEN
586 IF (CRRAT.LE.2.0) THEN
588 IF(METSTBL.EQ.1) THEN
590 CALL CALCM82p1 ! Only liquid (metastable)
593 IF (RH.LT.DRNH4NO3) THEN
595 CALL CALCM12p1 ! CaSO4, NH4NO3, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
597 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
599 CALL CALCM22p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
601 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
603 CALL CALCM32p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL
605 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4Cl) THEN
607 CALL CALCM42p1 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4
609 ELSEIF (DRNH4Cl.LE.RH .AND. RH.LT.DRMGSO4) THEN
611 CALL CALCM52p1 ! CaSO4, MGSO4, NA2SO4, K2SO4
613 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
615 CALL CALCM62p1 ! CaSO4, NA2SO4, K2SO4
617 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
619 CALL CALCM72p1 ! CaSO4, K2SO4
621 ELSEIF (DRK2SO4.LE.RH) THEN
623 CALL CALCM82p1 ! CaSO4
628 !C *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
630 ELSEIF (CRRAT.GT.2.0) THEN
632 IF(METSTBL.EQ.1) THEN
634 CALL CALCP132p1 ! Only liquid (metastable)
637 IF (RH.LT.DRCACL2) THEN
639 CALL CALCP12p1 ! CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
640 !C ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
642 ELSEIF (DRCACL2.LE.RH .AND. RH.LT.DRMGCL2) THEN
644 CALL CALCP22p1 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
645 !C ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
647 ELSEIF (DRMGCL2.LE.RH .AND. RH.LT.DRCANO32) THEN
649 CALL CALCP32p1 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
650 !C ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
652 ELSEIF (DRCANO32.LE.RH .AND. RH.LT.DRMGNO32) THEN
654 CALL CALCP42p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
655 !C ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
657 ELSEIF (DRMGNO32.LE.RH .AND. RH.LT.DRNH4NO3) THEN
659 CALL CALCP52p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
660 !C ! NANO3, NACL, NH4NO3, NH4CL
662 ELSEIF (DRNH4NO3.LE.RH .AND. RH.LT.DRNANO3) THEN
664 CALL CALCP62p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NANO3, NACL, NH4CL
666 ELSEIF (DRNANO3.LE.RH .AND. RH.LT.DRNACL) THEN
668 CALL CALCP72p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NACL, NH4CL
670 ELSEIF (DRNACL.LE.RH .AND. RH.LT.DRNH4CL) THEN
672 CALL CALCP82p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NH4CL
674 ELSEIF (DRNH4CL.LE.RH .AND. RH.LT.DRKCL) THEN
676 CALL CALCP92p1 ! CaSO4, K2SO4, KNO3, KCL, MGSO4
678 ELSEIF (DRKCL.LE.RH .AND. RH.LT.DRMGSO4) THEN
680 CALL CALCP102p1 ! CaSO4, K2SO4, KNO3, MGSO4
682 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRKNO3) THEN
684 CALL CALCP112p1 ! CaSO4, K2SO4, KNO3
686 ELSEIF (DRKNO3.LE.RH .AND. RH.LT.DRK2SO4) THEN
688 CALL CALCP122p1 ! CaSO4, K2SO4
690 ELSEIF (DRK2SO4.LE.RH) THEN
692 CALL CALCP132p1 ! CaSO4
698 !C *** SULFATE RICH (NO ACID): 1<Rso4<2;
700 ELSEIF (1.0.LE.SO4RAT .AND. SO4RAT.LT.2.0) THEN
702 IF(METSTBL.EQ.1) THEN
704 CALL CALCL92p1 ! Only liquid (metastable)
707 IF (RH.LT.DRNH4HS4) THEN
709 CALL CALCL12p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
711 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
713 CALL CALCL22p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,LC
715 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRLC) THEN
717 CALL CALCL32p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,LC
719 ELSEIF (DRLC.LE.RH .AND. RH.LT.DRNH42S4) THEN
721 CALL CALCL42p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4
723 ELSEIF (DRNH42S4.LE.RH .AND. RH.LT.DRKHSO4) THEN
725 CALL CALCL52p1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4
727 ELSEIF (DRKHSO4.LE.RH .AND. RH.LT.DRMGSO4) THEN
729 CALL CALCL62p1 ! CASO4,K2SO4,MGSO4,NA2SO4
731 ELSEIF (DRMGSO4.LE.RH .AND. RH.LT.DRNA2SO4) THEN
733 CALL CALCL72p1 ! CASO4,K2SO4,NA2SO4
735 ELSEIF (DRNA2SO4.LE.RH .AND. RH.LT.DRK2SO4) THEN
737 CALL CALCL82p1 ! CASO4,K2SO4
739 ELSEIF (DRK2SO4.LE.RH) THEN
741 CALL CALCL92p1 ! CaSO4
745 CALL CALCNHA2p1 ! MINOR SPECIES: HNO3, HCl
746 CALL CALCNH32p1 ! NH3
748 !C *** SULFATE SUPER RICH (FREE ACID): Rso4<1;
750 ELSEIF (SO4RAT.LT.1.0) THEN
752 IF(METSTBL.EQ.1) THEN
754 CALL CALCK42p1 ! Only liquid (metastable)
757 IF (RH.LT.DRNH4HS4) THEN ! RH < 0.4
759 CALL CALCK12p1 ! NH4HSO4,NAHSO4,KHSO4,CASO4
761 ELSEIF (DRNH4HS4.LE.RH .AND. RH.LT.DRNAHSO4) THEN
763 CALL CALCK22p1 ! NAHSO4,KHSO4,CASO4
765 ELSEIF (DRNAHSO4.LE.RH .AND. RH.LT.DRKHSO4) THEN
767 CALL CALCK32p1 ! KHSO4,CASO4 0.52 < RH < 0.86
769 ELSEIF (DRKHSO4.LE.RH) THEN
771 CALL CALCK42p1 ! CASO4
775 CALL CALCNHA2p1 ! MINOR SPECIES: HNO3, HCl
776 CALL CALCNH32p1 ! NH3
783 !C=======================================================================
785 !C *** ISORROPIA CODE
786 !C *** SUBROUTINE CALCA2
789 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
790 !C 1. SULFATE POOR (SULRAT >= 2.0)
791 !C 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
793 !C FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS X, THE
794 !C AMOUNT OF HYDROGEN IONS (H+) FOUND IN THE LIQUID PHASE.
795 !C FOR EACH ESTIMATION OF H+, FUNCTION FUNCB2A CALCULATES THE
796 !C CONCENTRATION OF IONS FROM THE NH3(GAS) - NH4+(LIQ) EQUILIBRIUM.
797 !C ELECTRONEUTRALITY IS USED AS THE OBJECTIVE FUNCTION.
799 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
800 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
801 !C *** WRITTEN BY ATHANASIOS NENES
802 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
804 !C=======================================================================
807 INCLUDE 'module_isrpia_inc.F'
809 !C *** SETUP PARAMETERS ************************************************
811 CALAOU =.TRUE. ! Outer loop activity calculation flag
812 OMELO = TINY ! Low limit: SOLUTION IS VERY BASIC
813 OMEHI = 2.0D0*W(2) ! High limit: FROM NH4+ -> NH3(g) + H+(aq)
815 !C *** CALCULATE WATER CONTENT *****************************************
821 !C *** INITIAL VALUES FOR BISECTION ************************************
825 IF (ABS(Y1).LE.EPS) RETURN
827 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
829 DX = (OMEHI-OMELO)/FLOAT(NDIV)
831 X2 = MAX(X1-DX, OMELO)
833 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
837 IF (ABS(Y2).LE.EPS) THEN
840 CALL PUSHERR2p1 (0001, 'CALCA2') ! WARNING ERROR: NO SOLUTION
844 !C *** PERFORM BISECTION ***********************************************
849 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
856 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
858 CALL PUSHERR2p1 (0002, 'CALCA2') ! WARNING ERROR: NO CONVERGENCE
860 !C *** CONVERGED ; RETURN **********************************************
866 !C *** END OF SUBROUTINE CALCA2 ****************************************
872 !C=======================================================================
874 !C *** ISORROPIA CODE
875 !C *** FUNCTION FUNCA2
877 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE A2 ;
878 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCA2.
880 !C=======================================================================
882 DOUBLE PRECISION FUNCTION FUNCA22p1 (OMEGI)
883 INCLUDE 'module_isrpia_inc.F'
884 DOUBLE PRECISION LAMDA
886 !C *** SETUP PARAMETERS ************************************************
890 PSI = W(2) ! INITIAL AMOUNT OF (NH4)2SO4 IN SOLUTION
892 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
895 A1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
896 A2 = XK2*R*TEMP/XKW*(GAMA(8)/GAMA(9))**2.
897 A3 = XKW*RH*WATER*WATER
899 LAMDA = PSI/(A1/OMEGI+ONE)
902 !C *** SPECIATION & WATER CONTENT ***************************************
904 MOLAL (1) = OMEGI ! HI
905 MOLAL (5) = MAX(PSI-LAMDA,TINY) ! SO4I
906 MOLAL (3) = MAX(W(3)/(ONE/A2/OMEGI + ONE), 2.*MOLAL(5)) ! NH4I
907 MOLAL (6) = LAMDA ! HSO4I
908 GNH3 = MAX (W(3)-MOLAL(3), TINY) ! NH3GI
911 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
913 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
920 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
922 20 DENOM = (2.0*MOLAL(5)+MOLAL(6))
923 FUNCA22p1= (MOLAL(3)/DENOM - ONE) + MOLAL(1)/DENOM
926 !C *** END OF FUNCTION FUNCA2 ********************************************
929 !C=======================================================================
931 !C *** ISORROPIA CODE
932 !C *** SUBROUTINE CALCA1
935 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
936 !C 1. SULFATE POOR (SULRAT > 2.0)
937 !C 2. SOLID AEROSOL ONLY
938 !C 3. SOLIDS POSSIBLE : (NH4)2SO4
940 !C A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
941 !C IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
944 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
945 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
946 !C *** WRITTEN BY ATHANASIOS NENES
947 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
949 !C=======================================================================
952 INCLUDE 'module_isrpia_inc.F'
955 GNH3 = MAX (W(3)-2.0*CNH42S4, ZERO)
958 !C *** END OF SUBROUTINE CALCA1 ******************************************
964 !C=======================================================================
966 !C *** ISORROPIA CODE
967 !C *** SUBROUTINE CALCB4
970 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
971 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
972 !C 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
974 !C FOR CALCULATIONS, A BISECTION IS PERFORMED WITH RESPECT TO H+.
975 !C THE OBJECTIVE FUNCTION IS THE DIFFERENCE BETWEEN THE ESTIMATED H+
976 !C AND THAT CALCULATED FROM ELECTRONEUTRALITY.
978 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
979 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
980 !C *** WRITTEN BY ATHANASIOS NENES
981 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
983 !C=======================================================================
986 INCLUDE 'module_isrpia_inc.F'
988 !C *** SOLVE EQUATIONS **************************************************
994 !C *** CALCULATE WATER CONTENT ******************************************
996 CALL CALCB1A2p1 ! GET DRY SALT CONTENT, AND USE FOR WATER.
1003 WATER = MOLALR(13)/M0(13)+MOLALR(9)/M0(9)+MOLALR(4)/M0(4)
1005 MOLAL(3) = W(3) ! NH4I
1008 AK1 = XK1*((GAMA(8)/GAMA(7))**2.)*(WATER/GAMA(7))
1012 BB = BET + AK1 - GAM
1014 DD = BB*BB - 4.D0*CC
1016 !C *** SPECIATION & WATER CONTENT ***************************************
1018 MOLAL (5) = MAX(TINY,MIN(0.5*(-BB + SQRT(DD)), W(2))) ! SO4I
1019 MOLAL (6) = MAX(TINY,MIN(W(2)-MOLAL(5),W(2))) ! HSO4I
1020 MOLAL (1) = MAX(TINY,MIN(AK1*MOLAL(6)/MOLAL(5),W(2))) ! HI
1021 CALL CALCMR2p1 ! Water content
1023 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1025 IF (.NOT.CALAIN) GOTO 30
1031 !C *** END OF SUBROUTINE CALCB4 ******************************************
1034 !C=======================================================================
1036 !C *** ISORROPIA CODE
1037 !C *** SUBROUTINE CALCB3
1040 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1041 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
1042 !C 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
1043 !C 3. SOLIDS POSSIBLE: (NH4)2SO4
1045 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1046 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1047 !C *** WRITTEN BY ATHANASIOS NENES
1048 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1050 !C=======================================================================
1052 SUBROUTINE CALCB32p1
1053 INCLUDE 'module_isrpia_inc.F'
1055 !C *** CALCULATE EQUIVALENT AMOUNT OF HSO4 AND SO4 ***********************
1057 X = MAX(2*W(2)-W(3), ZERO) ! Equivalent NH4HSO4
1058 Y = MAX(W(3) -W(2), ZERO) ! Equivalent NH42SO4
1060 !C *** CALCULATE SPECIES ACCORDING TO RELATIVE ABUNDANCE OF HSO4 *********
1062 IF (X.LT.Y) THEN ! LC is the MIN (x,y)
1063 SCASE = 'B3 ; SUBCASE 1'
1066 CALL CALCB3A2p1 (TLC,TNH42S4) ! LC + (NH4)2SO4
1068 SCASE = 'B3 ; SUBCASE 2'
1071 CALL CALCB3B2p1 (TLC,TNH4HS4) ! LC + NH4HSO4
1076 !C *** END OF SUBROUTINE CALCB3 ******************************************
1081 !C=======================================================================
1083 !C *** ISORROPIA CODE
1084 !C *** SUBROUTINE CALCB3A
1085 !C *** CASE B3 ; SUBCASE 1
1087 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1088 !C 1. SULFATE RICH (1.0 < SULRAT < 2.0)
1089 !C 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
1090 !C 3. SOLIDS POSSIBLE: (NH4)2SO4
1092 !C FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS ZETA, THE
1093 !C AMOUNT OF SOLID (NH4)2SO4 DISSOLVED IN THE LIQUID PHASE.
1094 !C FOR EACH ESTIMATION OF ZETA, FUNCTION FUNCB3A CALCULATES THE
1095 !C AMOUNT OF H+ PRODUCED (BASED ON THE SO4 RELEASED INTO THE
1096 !C SOLUTION). THE SOLUBILITY PRODUCT OF (NH4)2SO4 IS USED AS THE
1097 !C OBJECTIVE FUNCTION.
1099 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1100 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1101 !C *** WRITTEN BY ATHANASIOS NENES
1102 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1104 !C=======================================================================
1106 SUBROUTINE CALCB3A2p1 (TLC, TNH42S4)
1107 INCLUDE 'module_isrpia_inc.F'
1109 CALAOU = .TRUE. ! Outer loop activity calculation flag
1110 ZLO = ZERO ! MIN DISSOLVED (NH4)2SO4
1111 ZHI = TNH42S4 ! MAX DISSOLVED (NH4)2SO4
1113 !C *** INITIAL VALUES FOR BISECTION (DISSOLVED (NH4)2SO4 ****************
1116 Y1 = FUNCB3A2p1 (Z1, TLC, TNH42S4)
1117 IF (ABS(Y1).LE.EPS) RETURN
1120 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
1122 DZ = (ZHI-ZLO)/FLOAT(NDIV)
1125 Y2 = FUNCB3A2p1 (Z2, TLC, TNH42S4)
1126 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
1131 !C *** NO SUBDIVISION WITH SOLUTION FOUND
1133 YHI= Y1 ! Save Y-value at HI position
1134 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
1137 !C *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC
1139 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
1144 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
1146 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
1151 CALL PUSHERR2p1 (0001, 'CALCB3A') ! WARNING ERROR: NO SOLUTION
1155 !C *** PERFORM BISECTION ***********************************************
1159 Y3 = FUNCB3A2p1 (Z3, TLC, TNH42S4)
1160 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
1167 IF (ABS(Z2-Z1) .LE. EPS*Z1) GOTO 40
1169 CALL PUSHERR2p1 (0002, 'CALCB3A') ! WARNING ERROR: NO CONVERGENCE
1171 !C *** CONVERGED ; RETURN ************************************************
1174 Y3 = FUNCB3A2p1 (ZK, TLC, TNH42S4)
1178 !C *** END OF SUBROUTINE CALCB3A ******************************************
1184 !C=======================================================================
1186 !C *** ISORROPIA CODE
1187 !C *** FUNCTION FUNCB3A
1188 !C *** CASE B3 ; SUBCASE 1
1189 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE B3
1190 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCA3.
1192 !C=======================================================================
1194 DOUBLE PRECISION FUNCTION FUNCB3A2p1 (ZK, Y, X)
1195 INCLUDE 'module_isrpia_inc.F'
1198 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1203 GRAT1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
1204 DD = SQRT( (ZK+GRAT1+Y)**2. + 4.0*Y*GRAT1)
1205 KK = 0.5*(-(ZK+GRAT1+Y) + DD )
1207 !C *** SPECIATION & WATER CONTENT ***************************************
1210 MOLAL (5) = KK+ZK+Y ! SO4I
1211 MOLAL (6) = MAX (Y-KK, TINY) ! HSO4I
1212 MOLAL (3) = 3.0*Y+2*ZK ! NH4I
1213 CNH42S4 = X-ZK ! Solid (NH4)2SO4
1214 CALL CALCMR2p1 ! Water content
1216 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1218 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1225 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
1227 !CCC30 FUNCB3A= ( SO4I*NH4I**2.0 )/( XK7*(WATER/GAMA(4))**3.0 )
1228 30 FUNCB3A2p1= MOLAL(5)*MOLAL(3)**2.0
1229 FUNCB3A2p1= FUNCB3A2p1/(XK7*(WATER/GAMA(4))**3.0) - ONE
1232 !C *** END OF FUNCTION FUNCB3A ********************************************
1238 !C=======================================================================
1240 !C *** ISORROPIA CODE
1241 !C *** SUBROUTINE CALCB3B
1242 !C *** CASE B3 ; SUBCASE 2
1244 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1245 !C 1. SULFATE RICH (1.0 < SULRAT < 2.0)
1246 !C 2. LIQUID PHASE ONLY IS POSSIBLE
1248 !C SPECIATION CALCULATIONS IS BASED ON THE HSO4 <--> SO4 EQUILIBRIUM.
1250 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1251 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1252 !C *** WRITTEN BY ATHANASIOS NENES
1253 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1255 !C=======================================================================
1257 SUBROUTINE CALCB3B2p1 (Y, X)
1258 INCLUDE 'module_isrpia_inc.F'
1261 CALAOU = .FALSE. ! Outer loop activity calculation flag
1265 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
1268 GRAT1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
1269 DD = SQRT( (GRAT1+Y)**2. + 4.0*(X+Y)*GRAT1)
1270 KK = 0.5*(-(GRAT1+Y) + DD )
1272 !C *** SPECIATION & WATER CONTENT ***************************************
1275 MOLAL (5) = Y+KK ! SO4I
1276 MOLAL (6) = MAX (X+Y-KK, TINY) ! HSO4I
1277 MOLAL (3) = 3.0*Y+X ! NH4I
1278 CALL CALCMR2p1 ! Water content
1280 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1282 IF (.NOT.CALAIN) GOTO 30
1288 !C *** END OF SUBROUTINE CALCB3B ******************************************
1291 !C=======================================================================
1293 !C *** ISORROPIA CODE
1294 !C *** SUBROUTINE CALCB2
1297 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1298 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
1299 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
1300 !C 3. SOLIDS POSSIBLE : LC, (NH4)2SO4
1302 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON THE SULFATE RATIO:
1303 !C 1. WHEN BOTH LC AND (NH4)2SO4 ARE POSSIBLE (SUBROUTINE CALCB2A)
1304 !C 2. WHEN ONLY LC IS POSSIBLE (SUBROUTINE CALCB2B).
1306 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1307 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1308 !C *** WRITTEN BY ATHANASIOS NENES
1309 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1311 !C=======================================================================
1313 SUBROUTINE CALCB22p1
1314 INCLUDE 'module_isrpia_inc.F'
1316 !C *** CALCULATE EQUIVALENT AMOUNT OF HSO4 AND SO4 ***********************
1318 X = MAX(2*W(2)-W(3), TINY) ! Equivalent NH4HSO4
1319 Y = MAX(W(3) -W(2), TINY) ! Equivalent NH42SO4
1321 !C *** CALCULATE SPECIES ACCORDING TO RELATIVE ABUNDANCE OF HSO4 *********
1323 IF (X.LE.Y) THEN ! LC is the MIN (x,y)
1324 SCASE = 'B2 ; SUBCASE 1'
1325 CALL CALCB2A2p1 (X,Y-X) ! LC + (NH4)2SO4 POSSIBLE
1327 SCASE = 'B2 ; SUBCASE 2'
1328 CALL CALCB2B2p1 (Y,X-Y) ! LC ONLY POSSIBLE
1333 !C *** END OF SUBROUTINE CALCB2 ******************************************
1339 !C=======================================================================
1341 !C *** ISORROPIA CODE
1342 !C *** SUBROUTINE CALCB2
1343 !C *** CASE B2 ; SUBCASE A.
1345 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1346 !C 1. SULFATE RICH (1.0 < SULRAT < 2.0)
1347 !C 2. SOLID PHASE ONLY POSSIBLE
1348 !C 3. SOLIDS POSSIBLE: LC, (NH4)2SO4
1350 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
1351 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
1352 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE
1354 !C FOR SOLID CALCULATIONS, A MATERIAL BALANCE BASED ON THE STOICHIMETRIC
1355 !C PROPORTION OF AMMONIUM AND SULFATE IS DONE TO CALCULATE THE AMOUNT
1356 !C OF LC AND (NH4)2SO4 IN THE SOLID PHASE.
1358 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1359 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1360 !C *** WRITTEN BY ATHANASIOS NENES
1361 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1363 !C=======================================================================
1365 SUBROUTINE CALCB2A2p1 (TLC, TNH42S4)
1366 INCLUDE 'module_isrpia_inc.F'
1368 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
1370 IF (RH.LT.DRMLCAS) THEN
1371 SCASE = 'B2 ; SUBCASE A1' ! SOLIDS POSSIBLE ONLY
1374 SCASE = 'B2 ; SUBCASE A1'
1376 SCASE = 'B2 ; SUBCASE A2'
1377 CALL CALCB2A22p1 (TLC, TNH42S4) ! LIQUID & SOLID PHASE POSSIBLE
1378 SCASE = 'B2 ; SUBCASE A2'
1383 !C *** END OF SUBROUTINE CALCB2A *****************************************
1389 !C=======================================================================
1391 !C *** ISORROPIA CODE
1392 !C *** SUBROUTINE CALCB2A2
1393 !C *** CASE B2 ; SUBCASE A2.
1395 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1396 !C 1. SULFATE RICH (1.0 < SULRAT < 2.0)
1397 !C 2. SOLID PHASE ONLY POSSIBLE
1398 !C 3. SOLIDS POSSIBLE: LC, (NH4)2SO4
1400 !C THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
1401 !C DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
1402 !C SOLUTIONS ; THE SOLID PHASE ONLY (SUBROUTINE CALCB2A1) AND THE
1403 !C THE SOLID WITH LIQUID PHASE (SUBROUTINE CALCB3).
1405 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1406 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1407 !C *** WRITTEN BY ATHANASIOS NENES
1408 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1410 !C=======================================================================
1412 SUBROUTINE CALCB2A22p1 (TLC, TNH42S4)
1413 INCLUDE 'module_isrpia_inc.F'
1415 !C *** FIND WEIGHT FACTOR **********************************************
1417 IF (WFTYP.EQ.0) THEN
1419 ELSEIF (WFTYP.EQ.1) THEN
1422 WF = (DRLC-RH)/(DRLC-DRMLCAS)
1426 !C *** FIND FIRST SECTION ; DRY ONE ************************************
1428 CLCO = TLC ! FIRST (DRY) SOLUTION
1431 !C *** FIND SECOND SECTION ; DRY & LIQUID ******************************
1435 CALL CALCB32p1 ! SECOND (LIQUID) SOLUTION
1437 !C *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
1439 MOLAL(1)= ONEMWF*MOLAL(1) ! H+
1440 MOLAL(3)= ONEMWF*(2.D0*(CNH42SO-CNH42S4) + 3.D0*(CLCO-CLC)) ! NH4+
1441 MOLAL(5)= ONEMWF*(CNH42SO-CNH42S4 + CLCO-CLC) ! SO4--
1442 MOLAL(6)= ONEMWF*(CLCO-CLC) ! HSO4-
1444 WATER = ONEMWF*WATER
1446 CLC = WF*CLCO + ONEMWF*CLC
1447 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
1451 !C *** END OF SUBROUTINE CALCB2A2 ****************************************
1457 !C=======================================================================
1459 !C *** ISORROPIA CODE
1460 !C *** SUBROUTINE CALCB2
1461 !C *** CASE B2 ; SUBCASE B
1463 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1464 !C 1. SULFATE RICH (1.0 < SULRAT < 2.0)
1465 !C 2. BOTH LIQUID & SOLID PHASE IS POSSIBLE
1466 !C 3. SOLIDS POSSIBLE: LC
1468 !C FOR CALCULATIONS, A BISECTION IS PERFORMED TOWARDS ZETA, THE
1469 !C AMOUNT OF SOLID LC DISSOLVED IN THE LIQUID PHASE.
1470 !C FOR EACH ESTIMATION OF ZETA, FUNCTION FUNCB2A CALCULATES THE
1471 !C AMOUNT OF H+ PRODUCED (BASED ON THE HSO4, SO4 RELEASED INTO THE
1472 !C SOLUTION). THE SOLUBILITY PRODUCT OF LC IS USED AS THE OBJECTIVE
1475 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1476 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1477 !C *** WRITTEN BY ATHANASIOS NENES
1478 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1480 !C=======================================================================
1482 SUBROUTINE CALCB2B2p1 (TLC,TNH4HS4)
1483 INCLUDE 'module_isrpia_inc.F'
1485 CALAOU = .TRUE. ! Outer loop activity calculation flag
1487 ZHI = TLC ! High limit: all of it in liquid phase
1489 !C *** INITIAL VALUES FOR BISECTION **************************************
1492 Y1 = FUNCB2B2p1 (X1,TNH4HS4,TLC)
1493 IF (ABS(Y1).LE.EPS) RETURN
1494 YHI= Y1 ! Save Y-value at Hi position
1496 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ************************
1501 Y2 = FUNCB2B2p1 (X2,TNH4HS4,TLC)
1502 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
1507 !C *** NO SUBDIVISION WITH SOLUTION FOUND
1509 YLO= Y1 ! Save Y-value at LO position
1510 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
1513 !C *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC
1515 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
1520 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
1522 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
1527 CALL PUSHERR2p1 (0001, 'CALCB2B') ! WARNING ERROR: NO SOLUTION
1531 !C *** PERFORM BISECTION *************************************************
1535 Y3 = FUNCB2B2p1 (X3,TNH4HS4,TLC)
1536 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
1543 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
1545 CALL PUSHERR2p1 (0002, 'CALCB2B') ! WARNING ERROR: NO CONVERGENCE
1547 !C *** CONVERGED ; RETURN ************************************************
1550 Y3 = FUNCB2B2p1 (X3,TNH4HS4,TLC)
1554 !C *** END OF SUBROUTINE CALCB2B *****************************************
1560 !C=======================================================================
1562 !C *** ISORROPIA CODE
1563 !C *** FUNCTION FUNCB2B
1565 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE B2 ; SUBCASE 2
1566 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCB2B.
1568 !C=======================================================================
1570 DOUBLE PRECISION FUNCTION FUNCB2B2p1 (X,TNH4HS4,TLC)
1571 INCLUDE 'module_isrpia_inc.F'
1573 !C *** SOLVE EQUATIONS **************************************************
1578 GRAT2 = XK1*WATER*(GAMA(8)/GAMA(7))**2./GAMA(7)
1580 DELTA = PARM*PARM + 4.0*(X+TNH4HS4)*GRAT2 ! Diakrinousa
1581 OMEGA = 0.5*(-PARM + SQRT(DELTA)) ! Thetiki riza (ie:H+>0)
1583 !C *** SPECIATION & WATER CONTENT ***************************************
1585 MOLAL (1) = OMEGA ! HI
1586 MOLAL (3) = 3.0*X+TNH4HS4 ! NH4I
1587 MOLAL (5) = X+OMEGA ! SO4I
1588 MOLAL (6) = MAX (X+TNH4HS4-OMEGA, TINY) ! HSO4I
1589 CLC = MAX(TLC-X,ZERO) ! Solid LC
1590 CALL CALCMR2p1 ! Water content
1592 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP ******************
1594 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1601 !C *** CALCULATE OBJECTIVE FUNCTION **************************************
1603 !CCC30 FUNCB2B= ( NH4I**3.*SO4I*HSO4I )/( XK13*(WATER/GAMA(13))**5. )
1604 30 FUNCB2B2p1= (MOLAL(3)**3.)*MOLAL(5)*MOLAL(6)
1605 FUNCB2B2p1= FUNCB2B2p1/(XK13*(WATER/GAMA(13))**5.) - ONE
1608 !C *** END OF FUNCTION FUNCB2B *******************************************
1613 !C=======================================================================
1615 !C *** ISORROPIA CODE
1616 !C *** SUBROUTINE CALCB1
1619 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1620 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
1621 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
1622 !C 3. SOLIDS POSSIBLE : LC, (NH4)2SO4, NH4HSO4
1624 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
1625 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
1626 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCB1A)
1628 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1629 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1630 !C *** WRITTEN BY ATHANASIOS NENES
1631 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1633 !C=======================================================================
1635 SUBROUTINE CALCB12p1
1636 INCLUDE 'module_isrpia_inc.F'
1638 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
1640 IF (RH.LT.DRMLCAB) THEN
1641 SCASE = 'B1 ; SUBCASE 1'
1642 CALL CALCB1A2p1 ! SOLID PHASE ONLY POSSIBLE
1643 SCASE = 'B1 ; SUBCASE 1'
1645 SCASE = 'B1 ; SUBCASE 2'
1646 CALL CALCB1B2p1 ! LIQUID & SOLID PHASE POSSIBLE
1647 SCASE = 'B1 ; SUBCASE 2'
1652 !C *** END OF SUBROUTINE CALCB1 ******************************************
1658 !C=======================================================================
1660 !C *** ISORROPIA CODE
1661 !C *** SUBROUTINE CALCB1A
1662 !C *** CASE B1 ; SUBCASE 1
1664 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1666 !C 2. THERE IS NO LIQUID PHASE
1667 !C 3. SOLIDS POSSIBLE: LC, { (NH4)2SO4 XOR NH4HSO4 } (ONE OF TWO
1670 !C A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE AMOUNT OF LC
1671 !C IS CALCULATED FROM THE (NH4)2SO4 AND NH4HSO4 WHICH IS LEAST
1672 !C ABUNDANT (STOICHIMETRICALLY). THE REMAINING EXCESS OF SALT
1673 !C IS MIXED WITH THE LC.
1675 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1676 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1677 !C *** WRITTEN BY ATHANASIOS NENES
1678 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1680 !C=======================================================================
1682 SUBROUTINE CALCB1A2p1
1683 INCLUDE 'module_isrpia_inc.F'
1685 !C *** SETUP PARAMETERS ************************************************
1687 X = 2*W(2)-W(3) ! Equivalent NH4HSO4
1688 Y = W(3)-W(2) ! Equivalent (NH4)2SO4
1690 !C *** CALCULATE COMPOSITION *******************************************
1692 IF (X.LE.Y) THEN ! LC is the MIN (x,y)
1693 CLC = X ! NH4HSO4 >= (NH4)2S04
1697 CLC = Y ! NH4HSO4 < (NH4)2S04
1703 !C *** END OF SUBROUTINE CALCB1 ******************************************
1710 !C=======================================================================
1712 !C *** ISORROPIA CODE
1713 !C *** SUBROUTINE CALCB1B
1714 !C *** CASE B1 ; SUBCASE 2
1716 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1718 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
1719 !C 3. SOLIDS POSSIBLE: LC, { (NH4)2SO4 XOR NH4HSO4 } (ONE OF TWO
1722 !C THIS IS THE CASE WHERE THE RELATIVE HUMIDITY IS IN THE MUTUAL
1723 !C DRH REGION. THE SOLUTION IS ASSUMED TO BE THE SUM OF TWO WEIGHTED
1724 !C SOLUTIONS ; THE SOLID PHASE ONLY (SUBROUTINE CALCB1A) AND THE
1725 !C THE SOLID WITH LIQUID PHASE (SUBROUTINE CALCB2).
1727 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1728 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1729 !C *** WRITTEN BY ATHANASIOS NENES
1730 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1732 !C=======================================================================
1734 SUBROUTINE CALCB1B2p1
1735 INCLUDE 'module_isrpia_inc.F'
1737 !C *** FIND WEIGHT FACTOR **********************************************
1739 IF (WFTYP.EQ.0) THEN
1741 ELSEIF (WFTYP.EQ.1) THEN
1744 WF = (DRNH4HS4-RH)/(DRNH4HS4-DRMLCAB)
1748 !C *** FIND FIRST SECTION ; DRY ONE ************************************
1751 CLCO = CLC ! FIRST (DRY) SOLUTION
1755 !C *** FIND SECOND SECTION ; DRY & LIQUID ******************************
1760 CALL CALCB22p1 ! SECOND (LIQUID) SOLUTION
1762 !C *** FIND SOLUTION AT MDRH BY WEIGHTING DRY & LIQUID SOLUTIONS.
1764 MOLAL(1)= ONEMWF*MOLAL(1) ! H+
1765 MOLAL(3)= ONEMWF*(2.D0*(CNH42SO-CNH42S4) + (CNH4HSO-CNH4HS4) &
1766 + 3.D0*(CLCO-CLC)) ! NH4+
1767 MOLAL(5)= ONEMWF*(CNH42SO-CNH42S4 + CLCO-CLC) ! SO4--
1768 MOLAL(6)= ONEMWF*(CNH4HSO-CNH4HS4 + CLCO-CLC) ! HSO4-
1770 WATER = ONEMWF*WATER
1772 CLC = WF*CLCO + ONEMWF*CLC
1773 CNH42S4 = WF*CNH42SO + ONEMWF*CNH42S4
1774 CNH4HS4 = WF*CNH4HSO + ONEMWF*CNH4HS4
1778 !C *** END OF SUBROUTINE CALCB1B *****************************************
1783 !C=======================================================================
1785 !C *** ISORROPIA CODE
1786 !C *** SUBROUTINE CALCC2
1789 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1790 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
1791 !C 2. THERE IS ONLY A LIQUID PHASE
1793 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1794 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1795 !C *** WRITTEN BY ATHANASIOS NENES
1796 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1798 !C=======================================================================
1800 SUBROUTINE CALCC22p1
1801 INCLUDE 'module_isrpia_inc.F'
1802 DOUBLE PRECISION LAMDA, KAPA
1804 CALAOU =.TRUE. ! Outer loop activity calculation flag
1808 !C *** SOLVE EQUATIONS **************************************************
1810 LAMDA = W(3) ! NH4HSO4 INITIALLY IN SOLUTION
1811 PSI = W(2)-W(3) ! H2SO4 IN SOLUTION
1813 PARM = WATER*XK1/GAMA(7)*(GAMA(8)/GAMA(7))**2.
1815 CC =-PARM*(LAMDA+PSI)
1816 KAPA = 0.5*(-BB+SQRT(BB*BB-4.0*CC))
1818 !C *** SPECIATION & WATER CONTENT ***************************************
1820 MOLAL(1) = PSI+KAPA ! HI
1821 MOLAL(3) = LAMDA ! NH4I
1822 MOLAL(5) = KAPA ! SO4I
1823 MOLAL(6) = MAX(LAMDA+PSI-KAPA, TINY) ! HSO4I
1824 CH2SO4 = MAX(MOLAL(5)+MOLAL(6)-MOLAL(3), ZERO) ! Free H2SO4
1825 CALL CALCMR2p1 ! Water content
1827 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1829 IF (.NOT.CALAIN) GOTO 30
1835 !C *** END OF SUBROUTINE CALCC2 *****************************************
1841 !C=======================================================================
1843 !C *** ISORROPIA CODE
1844 !C *** SUBROUTINE CALCC1
1847 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
1848 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
1849 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
1850 !C 3. SOLIDS POSSIBLE: NH4HSO4
1852 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1853 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1854 !C *** WRITTEN BY ATHANASIOS NENES
1855 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1857 !C=======================================================================
1859 SUBROUTINE CALCC12p1
1860 INCLUDE 'module_isrpia_inc.F'
1861 DOUBLE PRECISION KLO, KHI
1863 CALAOU = .TRUE. ! Outer loop activity calculation flag
1867 !C *** INITIAL VALUES FOR BISECTION *************************************
1871 IF (ABS(Y1).LE.EPS) GOTO 50
1874 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
1876 DX = (KHI-KLO)/FLOAT(NDIV)
1880 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2) .LT. ZERO) GOTO 20 ! (Y1*Y2 .LT. ZERO)
1885 !C *** NO SUBDIVISION WITH SOLUTION FOUND
1887 YHI= Y2 ! Save Y-value at HI position
1888 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
1891 !C *** { YLO, YHI } < 0.0 SOLUTION IS ALWAYS UNDERSATURATED WITH NH4HS04
1893 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
1896 !C *** { YLO, YHI } > 0.0 SOLUTION IS ALWAYS SUPERSATURATED WITH NH4HS04
1898 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
1903 CALL PUSHERR2p1 (0001, 'CALCC1') ! WARNING ERROR: NO SOLUTION
1907 !C *** PERFORM BISECTION OF DISSOLVED NH4HSO4 **************************
1912 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
1919 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
1921 CALL PUSHERR2p1 (0002, 'CALCC1') ! WARNING ERROR: NO CONVERGENCE
1923 !C *** CONVERGED ; RETURN ***********************************************
1930 !C *** END OF SUBROUTINE CALCC1 *****************************************
1936 !C=======================================================================
1938 !C *** ISORROPIA CODE
1939 !C *** FUNCTION FUNCC1
1941 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE C1
1942 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCC1.
1944 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
1945 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
1946 !C *** WRITTEN BY ATHANASIOS NENES
1947 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
1949 !C=======================================================================
1951 DOUBLE PRECISION FUNCTION FUNCC12p1 (KAPA)
1952 INCLUDE 'module_isrpia_inc.F'
1953 DOUBLE PRECISION KAPA, LAMDA
1955 !C *** SOLVE EQUATIONS **************************************************
1962 PAR1 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
1963 PAR2 = XK12*(WATER/GAMA(9))**2.0
1965 CC =-PAR1*(PSI+KAPA)
1966 LAMDA = 0.5*(-BB+SQRT(BB*BB-4*CC))
1968 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY *******************************
1970 MOLAL(1) = PSI+LAMDA ! HI
1971 MOLAL(3) = KAPA ! NH4I
1972 MOLAL(5) = LAMDA ! SO4I
1973 MOLAL(6) = MAX (ZERO, PSI+KAPA-LAMDA) ! HSO4I
1974 CNH4HS4 = MAX(W(3)-MOLAL(3), ZERO) ! Solid NH4HSO4
1975 CH2SO4 = MAX(PSI, ZERO) ! Free H2SO4
1976 CALL CALCMR2p1 ! Water content
1978 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
1980 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
1987 !C *** CALCULATE ZERO FUNCTION *******************************************
1989 !CCC30 FUNCC1= (NH4I*HSO4I/PAR2) - ONE
1990 30 FUNCC12p1= (MOLAL(3)*MOLAL(6)/PAR2) - ONE
1993 !C *** END OF FUNCTION FUNCC1 ********************************************
1997 !C=======================================================================
1999 !C *** ISORROPIA CODE
2000 !C *** SUBROUTINE CALCD3
2003 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2004 !C 1. SULFATE POOR (SULRAT > 2.0)
2005 !C 2. THERE IS OLNY A LIQUID PHASE
2007 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2008 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2009 !C *** WRITTEN BY ATHANASIOS NENES
2010 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2012 !C=======================================================================
2014 SUBROUTINE CALCD32p1
2015 INCLUDE 'module_isrpia_inc.F'
2017 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2018 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2019 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2020 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2021 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6,&
2022 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2024 !C *** FIND DRY COMPOSITION **********************************************
2028 !C *** SETUP PARAMETERS ************************************************
2030 CHI1 = CNH4NO3 ! Save from CALCD1 run
2035 PSI1 = CNH4NO3 ! ASSIGN INITIAL PSI's
2044 CALL CALCMR2p1 ! Initial water
2046 CALAOU = .TRUE. ! Outer loop activity calculation flag
2047 PSI4LO = TINY ! Low limit
2048 PSI4HI = CHI4 ! High limit
2050 !C *** INITIAL VALUES FOR BISECTION ************************************
2054 IF (ABS(Y1).LE.EPS) RETURN
2055 YLO= Y1 ! Save Y-value at HI position
2057 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
2059 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
2063 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
2068 !C *** NO SUBDIVISION WITH SOLUTION FOUND
2070 YHI= Y1 ! Save Y-value at Hi position
2071 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
2074 !C *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
2075 !C Physically I dont know when this might happen, but I have put this
2076 !C branch in for completeness. I assume there is no solution; all NO3 goes to the
2079 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
2080 P4 = TINY ! PSI4LO ! CHI4
2084 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
2085 !C This happens when Sul.Rat. = 2.0, so some NH4+ from sulfate evaporates
2086 !C and goes to the gas phase ; so I redefine the LO and HI limits of PSI4
2087 !C and proceed again with root tracking.
2089 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
2091 PSI4LO = PSI4LO - 0.1*(PSI1+PSI2) ! No solution; some NH3 evaporates
2092 IF (PSI4LO.LT.-(PSI1+PSI2)) THEN
2093 CALL PUSHERR2p1 (0001, 'CALCD3') ! WARNING ERROR: NO SOLUTION
2100 CALL CALCMR2p1 ! Initial water
2101 GOTO 60 ! Redo root tracking
2105 !C *** PERFORM BISECTION ***********************************************
2110 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
2117 IF (ABS(X2-X1) .LE. EPS*ABS(X1)) GOTO 40
2119 CALL PUSHERR2p1 (0002, 'CALCD3') ! WARNING ERROR: NO CONVERGENCE
2121 !C *** CONVERGED ; RETURN **********************************************
2126 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
2129 IF (MOLAL(1).GT.TINY) THEN
2130 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
2131 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
2132 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
2133 MOLAL(6) = DELTA ! HSO4 EFFECT
2137 !C *** END OF SUBROUTINE CALCD3 ******************************************
2143 !C=======================================================================
2145 !C *** ISORROPIA CODE
2146 !C *** FUNCTION FUNCD3
2148 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D3 ;
2149 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCD3.
2151 !C=======================================================================
2153 DOUBLE PRECISION FUNCTION FUNCD32p1 (P4)
2154 INCLUDE 'module_isrpia_inc.F'
2156 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2157 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2158 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2159 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2160 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6,&
2161 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2163 !C *** SETUP PARAMETERS ************************************************
2169 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2172 A2 = XK7*(WATER/GAMA(4))**3.0
2173 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
2174 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2175 A7 = XKW *RH*WATER*WATER
2177 PSI3 = A3*A4*CHI3*(CHI4-PSI4) - PSI1*(2.D0*PSI2+PSI1+PSI4)
2178 PSI3 = PSI3/(A3*A4*(CHI4-PSI4) + 2.D0*PSI2+PSI1+PSI4)
2179 PSI3 = MIN(MAX(PSI3, ZERO), CHI3)
2182 !CCCOLD AHI = 0.5*(-BB + SQRT(BB*BB + 4.d0*A7)) ! This is correct also
2183 !CCC AHI =2.0*A7/(BB+SQRT(BB*BB + 4.d0*A7)) ! Avoid overflow when HI->0
2184 DENM = BB+SQRT(BB*BB + 4.d0*A7)
2185 IF (DENM.LE.TINY) THEN ! Avoid overflow when HI->0
2187 DENM = (BB+ABB) + 2.0*A7/ABB ! Taylor expansion of SQRT
2191 !C *** SPECIATION & WATER CONTENT ***************************************
2193 MOLAL (1) = AHI ! HI
2194 MOLAL (3) = PSI1 + PSI4 + 2.D0*PSI2 ! NH4I
2195 MOLAL (5) = PSI2 ! SO4I
2196 MOLAL (6) = ZERO ! HSO4I
2197 MOLAL (7) = PSI3 + PSI1 ! NO3I
2198 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
2199 CNH4NO3 = ZERO ! Solid NH4NO3
2200 GHNO3 = CHI3 - PSI3 ! Gas HNO3
2201 GNH3 = CHI4 - PSI4 ! Gas NH3
2202 CALL CALCMR2p1 ! Water content
2204 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2206 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2213 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
2216 !CCC FUNCD3= NH4I/HI/MAX(GNH3,TINY)/A4 - ONE
2217 FUNCD32p1= MOLAL(3)/MOLAL(1)/MAX(GNH3,TINY)/A4 - ONE
2220 !C *** END OF FUNCTION FUNCD3 ********************************************
2223 !C=======================================================================
2225 !C *** ISORROPIA CODE
2226 !C *** SUBROUTINE CALCD2
2229 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2230 !C 1. SULFATE POOR (SULRAT > 2.0)
2231 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
2232 !C 3. SOLIDS POSSIBLE : (NH4)2SO4
2234 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2235 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2236 !C *** WRITTEN BY ATHANASIOS NENES
2237 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2239 !C=======================================================================
2241 SUBROUTINE CALCD22p1
2242 INCLUDE 'module_isrpia_inc.F'
2244 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2245 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2246 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2247 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2248 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2249 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2251 !C *** FIND DRY COMPOSITION **********************************************
2255 !C *** SETUP PARAMETERS ************************************************
2257 CHI1 = CNH4NO3 ! Save from CALCD1 run
2262 PSI1 = CNH4NO3 ! ASSIGN INITIAL PSI's
2271 CALL CALCMR2p1 ! Initial water
2273 CALAOU = .TRUE. ! Outer loop activity calculation flag
2274 PSI4LO = TINY ! Low limit
2275 PSI4HI = CHI4 ! High limit
2277 !C *** INITIAL VALUES FOR BISECTION ************************************
2281 IF (ABS(Y1).LE.EPS) RETURN
2282 YLO= Y1 ! Save Y-value at HI position
2284 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
2286 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
2290 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) THEN
2292 !C This is done, in case if Y(PSI4LO)>0, but Y(PSI4LO+DX) < 0 (i.e.undersat)
2294 IF (Y1 .LE. Y2) GOTO 20 ! (Y1*Y2.LT.ZERO)
2300 !C *** NO SUBDIVISION WITH SOLUTION FOUND
2302 YHI= Y1 ! Save Y-value at Hi position
2303 IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
2306 !C *** { YLO, YHI } < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH3
2307 !C Physically I dont know when this might happen, but I have put this
2308 !C branch in for completeness. I assume there is no solution; all NO3 goes to the
2311 ELSE IF (YLO.LT.ZERO .AND. YHI.LT.ZERO) THEN
2312 P4 = TINY ! PSI4LO ! CHI4
2316 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH3
2317 !C This happens when Sul.Rat. = 2.0, so some NH4+ from sulfate evaporates
2318 !C and goes to the gas phase ; so I redefine the LO and HI limits of PSI4
2319 !C and proceed again with root tracking.
2321 ELSE IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
2323 PSI4LO = PSI4LO - 0.1*(PSI1+PSI2) ! No solution; some NH3 evaporates
2324 IF (PSI4LO.LT.-(PSI1+PSI2)) THEN
2325 CALL PUSHERR2p1 (0001, 'CALCD2') ! WARNING ERROR: NO SOLUTION
2332 CALL CALCMR2p1 ! Initial water
2333 GOTO 60 ! Redo root tracking
2337 !C *** PERFORM BISECTION ***********************************************
2342 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
2349 IF (ABS(X2-X1) .LE. EPS*ABS(X1)) GOTO 40
2351 CALL PUSHERR2p1 (0002, 'CALCD2') ! WARNING ERROR: NO CONVERGENCE
2353 !C *** CONVERGED ; RETURN **********************************************
2355 40 X3 = MIN(X1,X2) ! 0.5*(X1+X2) ! Get "low" side, it's acidic soln.
2358 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
2361 IF (MOLAL(1).GT.TINY) THEN
2362 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
2363 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
2364 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
2365 MOLAL(6) = DELTA ! HSO4 EFFECT
2369 !C *** END OF SUBROUTINE CALCD2 ******************************************
2375 !C=======================================================================
2377 !C *** ISORROPIA CODE
2378 !C *** FUNCTION FUNCD2
2380 !C FUNCTION THAT SOLVES THE SYSTEM OF EQUATIONS FOR CASE D2 ;
2381 !C AND RETURNS THE VALUE OF THE ZEROED FUNCTION IN FUNCD2.
2383 !C=======================================================================
2385 DOUBLE PRECISION FUNCTION FUNCD22p1 (P4)
2386 INCLUDE 'module_isrpia_inc.F'
2388 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
2389 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
2390 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
2391 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
2392 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
2393 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
2395 !C *** SETUP PARAMETERS ************************************************
2397 CALL RSTGAM2p1 ! Reset activity coefficients to 0.1
2403 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2406 A2 = XK7*(WATER/GAMA(4))**3.0
2407 A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
2408 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2409 A7 = XKW *RH*WATER*WATER
2411 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
2413 CALL POLY32p1 (PSI14,0.25*PSI14**2.,-A2/4.D0, PSI2, ISLV) ! PSI2
2415 PSI2 = MIN (PSI2, CHI2)
2421 PSI3 = A3*A4*CHI3*(CHI4-PSI4) - PSI1*(2.D0*PSI2+PSI1+PSI4)
2422 PSI3 = PSI3/(A3*A4*(CHI4-PSI4) + 2.D0*PSI2+PSI1+PSI4)
2423 !ccc PSI3 = MIN(MAX(PSI3, ZERO), CHI3)
2425 BB = PSI4-PSI3 ! (BB > 0, acidic solution, <0 alkaline)
2427 !C Do not change computation scheme for H+, all others did not work well.
2429 DENM = BB+SQRT(BB*BB + 4.d0*A7)
2430 IF (DENM.LE.TINY) THEN ! Avoid overflow when HI->0
2432 DENM = (BB+ABB) + 2.d0*A7/ABB ! Taylor expansion of SQRT
2436 !C *** SPECIATION & WATER CONTENT ***************************************
2438 MOLAL (1) = AHI ! HI
2439 MOLAL (3) = PSI1 + PSI4 + 2.D0*PSI2 ! NH4
2440 MOLAL (5) = PSI2 ! SO4
2441 MOLAL (6) = ZERO ! HSO4
2442 MOLAL (7) = PSI3 + PSI1 ! NO3
2443 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
2444 CNH4NO3 = ZERO ! Solid NH4NO3
2445 GHNO3 = CHI3 - PSI3 ! Gas HNO3
2446 GNH3 = CHI4 - PSI4 ! Gas NH3
2447 CALL CALCMR2p1 ! Water content
2449 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2451 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2458 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
2461 !CCC FUNCD2= NH4I/HI/MAX(GNH3,TINY)/A4 - ONE
2462 FUNCD22p1= MOLAL(3)/MOLAL(1)/MAX(GNH3,TINY)/A4 - ONE
2465 !C *** END OF FUNCTION FUNCD2 ********************************************
2468 !C=======================================================================
2470 !C *** ISORROPIA CODE
2471 !C *** SUBROUTINE CALCD1
2474 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2475 !C 1. SULFATE POOR (SULRAT > 2.0)
2476 !C 2. SOLID AEROSOL ONLY
2477 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
2479 !C THERE ARE TWO REGIMES DEFINED BY RELATIVE HUMIDITY:
2480 !C 1. RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCD1A)
2481 !C 2. RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
2483 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2484 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2485 !C *** WRITTEN BY ATHANASIOS NENES
2486 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2488 !C=======================================================================
2490 SUBROUTINE CALCD12p1
2491 INCLUDE 'module_isrpia_inc.F'
2492 EXTERNAL CALCD1A2p1, CALCD22p1
2494 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
2496 IF (RH.LT.DRMASAN) THEN
2497 SCASE = 'D1 ; SUBCASE 1' ! SOLID PHASE ONLY POSSIBLE
2499 SCASE = 'D1 ; SUBCASE 1'
2501 SCASE = 'D1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
2502 CALL CALCMDRH2p1 (RH, DRMASAN, DRNH4NO3, CALCD1A2p1, CALCD22p1)
2503 SCASE = 'D1 ; SUBCASE 2'
2508 !C *** END OF SUBROUTINE CALCD1 ******************************************
2513 !C=======================================================================
2515 !C *** ISORROPIA CODE
2516 !C *** SUBROUTINE CALCD1A
2517 !C *** CASE D1 ; SUBCASE 1
2519 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2520 !C 1. SULFATE POOR (SULRAT > 2.0)
2521 !C 2. SOLID AEROSOL ONLY
2522 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
2524 !C THE SOLID (NH4)2SO4 IS CALCULATED FROM THE SULFATES, WHILE NH4NO3
2525 !C IS CALCULATED FROM NH3-HNO3 EQUILIBRIUM. 'ZE' IS THE AMOUNT OF
2526 !C NH4NO3 THAT VOLATIZES WHEN ALL POSSILBE NH4NO3 IS INITIALLY IN
2529 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2530 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2531 !C *** WRITTEN BY ATHANASIOS NENES
2532 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2534 !C=======================================================================
2536 SUBROUTINE CALCD1A2p1
2537 INCLUDE 'module_isrpia_inc.F'
2539 !C *** SETUP PARAMETERS ************************************************
2541 PARM = XK10/(R*TEMP)/(R*TEMP)
2543 !C *** CALCULATE NH4NO3 THAT VOLATIZES *********************************
2546 X = MAX(ZERO, MIN(W(3)-2.0*CNH42S4, W(4))) ! MAX NH4NO3
2547 PS = MAX(W(3) - X - 2.0*CNH42S4, ZERO)
2548 OM = MAX(W(4) - X, ZERO)
2551 DIAK = SQRT(OMPS*OMPS + 4.0*PARM) ! DIAKRINOUSA
2552 ZE = MIN(X, 0.5*(-OMPS + DIAK)) ! THETIKI RIZA
2554 !C *** SPECIATION *******************************************************
2556 CNH4NO3 = X - ZE ! Solid NH4NO3
2557 GNH3 = PS + ZE ! Gas NH3
2558 GHNO3 = OM + ZE ! Gas HNO3
2562 !C *** END OF SUBROUTINE CALCD1A *****************************************
2565 !C=======================================================================
2567 !C *** ISORROPIA CODE
2568 !C *** SUBROUTINE CALCG5
2571 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2572 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2573 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
2574 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
2576 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2577 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2578 !C *** WRITTEN BY ATHANASIOS NENES
2579 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2581 !C=======================================================================
2583 SUBROUTINE CALCG52p1
2584 INCLUDE 'module_isrpia_inc.F'
2586 DOUBLE PRECISION LAMDA
2587 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
2588 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
2589 A1, A2, A3, A4, A5, A6, A7
2591 !C *** SETUP PARAMETERS ************************************************
2595 CHI2 = MAX (W(2)-CHI1, ZERO)
2597 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
2604 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
2606 WATER = CHI2/M0(4) + CHI1/M0(2)
2608 !C *** INITIAL VALUES FOR BISECTION ************************************
2611 Y1 = FUNCG5A2p1 (X1)
2612 IF (CHI6.LE.TINY) GOTO 50
2613 !ccc IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
2614 !ccc IF (WATER .LE. TINY) RETURN ! No water
2616 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
2618 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
2621 Y2 = FUNCG5A2p1 (X2)
2622 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
2627 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
2629 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG5A2p1 (PSI6LO)
2632 !C *** PERFORM BISECTION ***********************************************
2636 Y3 = FUNCG5A2p1 (X3)
2637 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
2644 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
2646 CALL PUSHERR2p1 (0002, 'CALCG5') ! WARNING ERROR: NO CONVERGENCE
2648 !C *** CONVERGED ; RETURN **********************************************
2651 Y3 = FUNCG5A2p1 (X3)
2653 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
2656 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN ! If quadrat.called
2657 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
2658 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
2659 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
2660 MOLAL(6) = DELTA ! HSO4 EFFECT
2665 !C *** END OF SUBROUTINE CALCG5 *******************************************
2672 !C=======================================================================
2674 !C *** ISORROPIA CODE
2675 !C *** SUBROUTINE FUNCG5A
2678 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2679 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2680 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
2681 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
2683 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2684 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2685 !C *** WRITTEN BY ATHANASIOS NENES
2686 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2688 !C=======================================================================
2690 DOUBLE PRECISION FUNCTION FUNCG5A2p1 (X)
2691 INCLUDE 'module_isrpia_inc.F'
2693 DOUBLE PRECISION LAMDA
2694 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
2695 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
2696 A1, A2, A3, A4, A5, A6, A7
2698 !C *** SETUP PARAMETERS ************************************************
2704 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2708 A1 = XK5 *(WATER/GAMA(2))**3.0
2709 A2 = XK7 *(WATER/GAMA(4))**3.0
2710 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2711 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
2712 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
2715 !C CALCULATE DISSOCIATION QUANTITIES
2717 IF (CHI5.GE.TINY) THEN
2718 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
2723 !CCC IF(CHI4.GT.TINY) THEN
2724 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
2725 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
2726 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
2727 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
2728 PSI4 =0.5d0*(-BB - SQRT(DD))
2733 !C *** CALCULATE SPECIATION ********************************************
2735 MOLAL (2) = 2.0D0*PSI1 ! NAI
2736 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
2737 MOLAL (4) = PSI6 ! CLI
2738 MOLAL (5) = PSI2 + PSI1 ! SO4I
2740 MOLAL (7) = PSI5 ! NO3I
2742 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
2743 CALL CALCPH2p1 (SMIN, HI, OHI)
2746 GNH3 = MAX(CHI4 - PSI4, TINY) ! Gas NH3
2747 GHNO3 = MAX(CHI5 - PSI5, TINY) ! Gas HNO3
2748 GHCL = MAX(CHI6 - PSI6, TINY) ! Gas HCl
2750 CNH42S4 = ZERO ! Solid (NH4)2SO4
2751 CNH4NO3 = ZERO ! Solid NH4NO3
2752 CNH4CL = ZERO ! Solid NH4Cl
2754 CALL CALCMR2p1 ! Water content
2756 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2758 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
2765 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
2767 20 FUNCG5A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
2768 !CCC FUNCG5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
2772 !C *** END OF FUNCTION FUNCG5A *******************************************
2776 !C=======================================================================
2778 !C *** ISORROPIA CODE
2779 !C *** SUBROUTINE CALCG4
2782 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2783 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2784 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
2785 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
2787 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2788 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2789 !C *** WRITTEN BY ATHANASIOS NENES
2790 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2792 !C=======================================================================
2794 SUBROUTINE CALCG42p1
2795 INCLUDE 'module_isrpia_inc.F'
2797 DOUBLE PRECISION LAMDA
2798 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
2799 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
2800 A1, A2, A3, A4, A5, A6, A7
2802 !C *** SETUP PARAMETERS ************************************************
2806 CHI2 = MAX (W(2)-CHI1, ZERO)
2808 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
2814 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
2816 WATER = CHI2/M0(4) + CHI1/M0(2)
2818 !C *** INITIAL VALUES FOR BISECTION ************************************
2821 Y1 = FUNCG4A2p1 (X1)
2822 IF (CHI6.LE.TINY) GOTO 50
2823 !CCC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY .OR. WATER .LE. TINY) GOTO 50
2824 !CCC IF (WATER .LE. TINY) RETURN ! No water
2826 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
2828 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
2831 Y2 = FUNCG4A2p1 (X2)
2832 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
2837 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
2839 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG4A2p1 (PSI6LO)
2842 !C *** PERFORM BISECTION ***********************************************
2846 Y3 = FUNCG4A2p1 (X3)
2847 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
2854 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
2856 CALL PUSHERR2p1 (0002, 'CALCG4') ! WARNING ERROR: NO CONVERGENCE
2858 !C *** CONVERGED ; RETURN **********************************************
2861 Y3 = FUNCG4A2p1 (X3)
2863 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
2866 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
2867 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
2868 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
2869 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
2870 MOLAL(6) = DELTA ! HSO4 EFFECT
2875 !C *** END OF SUBROUTINE CALCG4 *******************************************
2882 !C=======================================================================
2884 !C *** ISORROPIA CODE
2885 !C *** SUBROUTINE FUNCG4A
2888 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
2889 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
2890 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
2891 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
2893 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
2894 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
2895 !C *** WRITTEN BY ATHANASIOS NENES
2896 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
2898 !C=======================================================================
2900 DOUBLE PRECISION FUNCTION FUNCG4A2p1 (X)
2901 INCLUDE 'module_isrpia_inc.F'
2903 DOUBLE PRECISION LAMDA, NAI, NH4I, NO3I
2904 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
2905 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
2906 A1, A2, A3, A4, A5, A6, A7
2908 !C *** SETUP PARAMETERS ************************************************
2915 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
2919 A1 = XK5 *(WATER/GAMA(2))**3.0
2920 A2 = XK7 *(WATER/GAMA(4))**3.0
2921 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
2922 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
2923 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
2925 !C CALCULATE DISSOCIATION QUANTITIES
2927 IF (CHI5.GE.TINY) THEN
2928 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
2933 !CCC IF(CHI4.GT.TINY) THEN
2934 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
2935 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
2936 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
2937 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma shankar, 19/11/2001
2938 PSI4 =0.5d0*(-BB - SQRT(DD))
2943 !C CALCULATE CONCENTRATIONS
2945 NH4I = 2.0*PSI2 + PSI4
2951 CALL CALCPH2p1(2.d0*SO4I+NO3I+CLI-NAI-NH4I, HI, OHI)
2953 !C *** Na2SO4 DISSOLUTION
2955 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
2956 CALL POLY32p1 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
2958 PSI1 = MIN (PSI1, CHI1)
2966 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
2976 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
2978 GNH3 = MAX(CHI4 - PSI4, TINY)
2979 GHNO3 = MAX(CHI5 - PSI5, TINY)
2980 GHCL = MAX(CHI6 - PSI6, TINY)
2985 CNA2SO4 = MAX(CHI1-PSI1,ZERO)
2987 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
2991 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
2993 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3000 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
3002 20 FUNCG4A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
3003 !CCC FUNCG4A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
3007 !C *** END OF FUNCTION FUNCG4A *******************************************
3011 !C=======================================================================
3013 !C *** ISORROPIA CODE
3014 !C *** SUBROUTINE CALCG3
3017 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3018 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3019 !C 2. LIQUID & SOLID PHASE ARE BOTH POSSIBLE
3020 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3022 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3023 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3024 !C *** WRITTEN BY ATHANASIOS NENES
3025 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3027 !C=======================================================================
3029 SUBROUTINE CALCG32p1
3030 INCLUDE 'module_isrpia_inc.F'
3031 EXTERNAL CALCG1A2p1, CALCG42p1
3033 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
3035 IF (W(4).GT.TINY .AND. W(5).GT.TINY) THEN ! NO3,CL EXIST, WATER POSSIBLE
3036 SCASE = 'G3 ; SUBCASE 1'
3038 SCASE = 'G3 ; SUBCASE 1'
3039 ELSE ! NO3, CL NON EXISTANT
3040 SCASE = 'G1 ; SUBCASE 1'
3042 SCASE = 'G1 ; SUBCASE 1'
3045 IF (WATER.LE.TINY) THEN
3046 IF (RH.LT.DRMG3) THEN ! ONLY SOLIDS
3052 SCASE = 'G3 ; SUBCASE 2'
3055 SCASE = 'G3 ; SUBCASE 3' ! MDRH REGION (NA2SO4, NH42S4)
3056 CALL CALCMDRH2p1 (RH, DRMG3, DRNH42S4, CALCG1A2p1, CALCG42p1)
3057 SCASE = 'G3 ; SUBCASE 3'
3063 !C *** END OF SUBROUTINE CALCG3 ******************************************
3068 !C=======================================================================
3070 !C *** ISORROPIA CODE
3071 !C *** SUBROUTINE CALCG3A
3072 !C *** CASE G3 ; SUBCASE 1
3074 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3075 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3076 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3077 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3079 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3080 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3081 !C *** WRITTEN BY ATHANASIOS NENES
3082 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3084 !C=======================================================================
3086 SUBROUTINE CALCG3A2p1
3087 INCLUDE 'module_isrpia_inc.F'
3089 DOUBLE PRECISION LAMDA
3090 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
3091 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
3092 A1, A2, A3, A4, A5, A6, A7
3094 !C *** SETUP PARAMETERS ************************************************
3098 CHI2 = MAX (W(2)-CHI1, ZERO)
3100 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
3105 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
3109 !C *** INITIAL VALUES FOR BISECTION ************************************
3112 Y1 = FUNCG3A2p1 (X1)
3113 IF (CHI6.LE.TINY) GOTO 50
3114 !CCC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY .OR. WATER .LE. TINY) GOTO 50
3115 !CCC IF (WATER .LE. TINY) RETURN ! No water
3117 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
3119 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
3122 Y2 = FUNCG3A2p1 (X2)
3124 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
3129 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
3131 IF (ABS(Y2) .GT. EPS) Y2 = FUNCG3A2p1 (PSI6LO)
3134 !C *** PERFORM BISECTION ***********************************************
3138 Y3 = FUNCG3A2p1 (X3)
3139 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
3146 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
3148 CALL PUSHERR2p1 (0002, 'CALCG3A') ! WARNING ERROR: NO CONVERGENCE
3150 !C *** CONVERGED ; RETURN **********************************************
3153 Y3 = FUNCG3A2p1 (X3)
3155 !C *** FINAL CALCULATIONS *************************************************
3159 !C *** Na2SO4 DISSOLUTION
3161 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
3162 CALL POLY32p1 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
3164 PSI1 = MIN (PSI1, CHI1)
3171 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
3172 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
3173 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
3175 !C *** HSO4 equilibrium
3177 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
3178 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
3179 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
3180 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
3181 MOLAL(6) = DELTA ! HSO4 EFFECT
3186 !C *** END OF SUBROUTINE CALCG3A ******************************************
3193 !C=======================================================================
3195 !C *** ISORROPIA CODE
3196 !C *** SUBROUTINE FUNCG3A
3197 !C *** CASE G3 ; SUBCASE 1
3199 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3200 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3201 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3202 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3204 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3205 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3206 !C *** WRITTEN BY ATHANASIOS NENES
3207 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3209 !C=======================================================================
3211 DOUBLE PRECISION FUNCTION FUNCG3A2p1 (X)
3212 INCLUDE 'module_isrpia_inc.F'
3214 DOUBLE PRECISION LAMDA
3215 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
3216 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
3217 A1, A2, A3, A4, A5, A6, A7
3219 !C *** SETUP PARAMETERS ************************************************
3226 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3230 A1 = XK5 *(WATER/GAMA(2))**3.0
3231 A2 = XK7 *(WATER/GAMA(4))**3.0
3232 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
3233 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
3234 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
3236 !C CALCULATE DISSOCIATION QUANTITIES
3238 IF (CHI5.GE.TINY) THEN
3239 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
3244 !CCC IF(CHI4.GT.TINY) THEN
3245 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
3246 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
3247 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
3248 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
3249 PSI4 =0.5d0*(-BB - SQRT(DD))
3254 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
3255 CALL POLY32p1 (PSI4, PSI4*PSI4/4.D0, -A2/4.D0, PSI20, ISLV)
3256 IF (ISLV.EQ.0) PSI2 = MIN (PSI20, CHI2)
3259 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3261 MOLAL (2) = ZERO ! Na
3262 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
3263 MOLAL (4) = PSI6 ! CLI
3264 MOLAL (5) = PSI2 ! SO4I
3265 MOLAL (6) = ZERO ! HSO4
3266 MOLAL (7) = PSI5 ! NO3I
3268 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
3269 CALL CALCPH2p1 (SMIN, HI, OHI)
3272 GNH3 = MAX(CHI4 - PSI4, TINY) ! Gas NH3
3273 GHNO3 = MAX(CHI5 - PSI5, TINY) ! Gas HNO3
3274 GHCL = MAX(CHI6 - PSI6, TINY) ! Gas HCl
3276 CNH42S4 = CHI2 - PSI2 ! Solid (NH4)2SO4
3277 CNH4NO3 = ZERO ! Solid NH4NO3
3278 CNH4CL = ZERO ! Solid NH4Cl
3280 CALL CALCMR2p1 ! Water content
3282 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
3284 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3291 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
3293 20 FUNCG3A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
3294 !CCC FUNCG3A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
3298 !C *** END OF FUNCTION FUNCG3A *******************************************
3302 !C=======================================================================
3304 !C *** ISORROPIA CODE
3305 !C *** SUBROUTINE CALCG2
3308 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3309 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3310 !C 2. LIQUID & SOLID PHASE ARE BOTH POSSIBLE
3311 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3313 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3314 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3315 !C *** WRITTEN BY ATHANASIOS NENES
3316 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3318 !C=======================================================================
3320 SUBROUTINE CALCG22p1
3321 INCLUDE 'module_isrpia_inc.F'
3322 EXTERNAL CALCG1A2p1, CALCG3A2p1, CALCG42p1
3324 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
3326 IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
3327 SCASE = 'G2 ; SUBCASE 1'
3329 SCASE = 'G2 ; SUBCASE 1'
3330 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
3331 SCASE = 'G1 ; SUBCASE 1'
3333 SCASE = 'G1 ; SUBCASE 1'
3336 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
3338 IF (WATER.LE.TINY) THEN
3339 IF (RH.LT.DRMG2) THEN ! ONLY SOLIDS
3345 SCASE = 'G2 ; SUBCASE 2'
3347 IF (W(5).GT. TINY) THEN
3348 SCASE = 'G2 ; SUBCASE 3' ! MDRH (NH4CL, NA2SO4, NH42S4)
3349 CALL CALCMDRH2p1 (RH, DRMG2, DRNH4CL, CALCG1A2p1, CALCG3A2p1)
3350 SCASE = 'G2 ; SUBCASE 3'
3352 IF (WATER.LE.TINY .AND. RH.GE.DRMG3) THEN
3353 SCASE = 'G2 ; SUBCASE 4' ! MDRH (NA2SO4, NH42S4)
3354 CALL CALCMDRH2p1 (RH, DRMG3, DRNH42S4, CALCG1A2p1, CALCG42p1)
3355 SCASE = 'G2 ; SUBCASE 4'
3362 SCASE = 'G2 ; SUBCASE 2'
3369 !C *** END OF SUBROUTINE CALCG2 ******************************************
3374 !C=======================================================================
3376 !C *** ISORROPIA CODE
3377 !C *** SUBROUTINE CALCG2A
3378 !C *** CASE G2 ; SUBCASE 1
3380 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3381 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3382 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3383 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3385 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3386 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3387 !C *** WRITTEN BY ATHANASIOS NENES
3388 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3390 !C=======================================================================
3392 SUBROUTINE CALCG2A2p1
3393 INCLUDE 'module_isrpia_inc.F'
3395 DOUBLE PRECISION LAMDA
3396 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
3397 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
3398 A1, A2, A3, A4, A5, A6, A7
3400 !C *** SETUP PARAMETERS ************************************************
3404 CHI2 = MAX (W(2)-CHI1, ZERO)
3406 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
3415 !C *** INITIAL VALUES FOR BISECTION ************************************
3418 Y1 = FUNCG2A2p1 (X1)
3419 IF (CHI6.LE.TINY) GOTO 50
3420 !CCC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
3421 !CCC IF (WATER .LE. TINY) GOTO 50 ! No water
3423 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
3425 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
3428 Y2 = FUNCG2A2p1 (X2)
3429 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
3434 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
3436 IF (ABS(Y2) .GT. EPS) WATER = TINY
3439 !C *** PERFORM BISECTION ***********************************************
3443 Y3 = FUNCG2A2p1 (X3)
3444 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
3451 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
3453 CALL PUSHERR2p1 (0002, 'CALCG2A') ! WARNING ERROR: NO CONVERGENCE
3455 !C *** CONVERGED ; RETURN **********************************************
3458 IF (X3.LE.TINY2) THEN ! PRACTICALLY NO NITRATES, SO DRY SOLUTION
3461 Y3 = FUNCG2A2p1 (X3)
3464 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
3468 !C *** Na2SO4 DISSOLUTION
3470 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
3471 CALL POLY32p1 (PSI2, ZERO, -A1/4.D0, PSI1, ISLV)
3473 PSI1 = MIN (PSI1, CHI1)
3480 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
3481 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
3482 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
3484 !C *** HSO4 equilibrium
3486 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
3487 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
3488 MOLAL(1) = MOLAL(1) - DELTA ! H+ AFFECT
3489 MOLAL(5) = MOLAL(5) - DELTA ! SO4 AFFECT
3490 MOLAL(6) = DELTA ! HSO4 AFFECT
3495 !C *** END OF SUBROUTINE CALCG2A ******************************************
3502 !C=======================================================================
3504 !C *** ISORROPIA CODE
3505 !C *** SUBROUTINE FUNCG2A
3508 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3509 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3510 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3511 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3513 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3514 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3515 !C *** WRITTEN BY ATHANASIOS NENES
3516 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3518 !C=======================================================================
3520 DOUBLE PRECISION FUNCTION FUNCG2A2p1 (X)
3521 INCLUDE 'module_isrpia_inc.F'
3523 DOUBLE PRECISION LAMDA
3524 COMMON /CASEG2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, LAMDA, &
3525 PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, PSI7, &
3526 A1, A2, A3, A4, A5, A6, A7
3528 !C *** SETUP PARAMETERS ************************************************
3536 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3540 A1 = XK5 *(WATER/GAMA(2))**3.0
3541 A2 = XK7 *(WATER/GAMA(4))**3.0
3542 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
3543 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
3544 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
3546 DENO = MAX(CHI6-PSI6-PSI3, ZERO)
3547 PSI5 = CHI5/((A6/A5)*(DENO/PSI6) + ONE)
3549 PSI4 = MIN(PSI5+PSI6,CHI4)
3551 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
3552 CALL POLY32p1 (PSI4, PSI4*PSI4/4.D0, -A2/4.D0, PSI20, ISLV)
3553 IF (ISLV.EQ.0) PSI2 = MIN (PSI20, CHI2)
3556 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
3558 MOLAL (2) = ZERO ! NA
3559 MOLAL (3) = 2.0*PSI2 + PSI4 ! NH4I
3560 MOLAL (4) = PSI6 ! CLI
3561 MOLAL (5) = PSI2 ! SO4I
3562 MOLAL (6) = ZERO ! HSO4
3563 MOLAL (7) = PSI5 ! NO3I
3565 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
3566 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
3567 CALL CALCPH2p1 (SMIN, HI, OHI)
3570 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3572 GNH3 = MAX(CHI4 - PSI4, TINY)
3573 GHNO3 = MAX(CHI5 - PSI5, TINY)
3574 GHCL = MAX(CHI6 - PSI6, TINY)
3576 CNH42S4 = MAX(CHI2 - PSI2, ZERO)
3579 !C *** NH4Cl(s) calculations
3581 A3 = XK6 /(R*TEMP*R*TEMP)
3582 IF (GNH3*GHCL.GT.A3) THEN
3583 DELT = MIN(GNH3, GHCL)
3586 DD = BB*BB - 4.D0*CC
3587 PSI31 = 0.5D0*(-BB + SQRT(DD))
3588 PSI32 = 0.5D0*(-BB - SQRT(DD))
3589 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
3591 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
3600 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
3602 GNH3 = MAX(GNH3 - PSI3, TINY)
3603 GHCL = MAX(GHCL - PSI3, TINY)
3606 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
3610 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
3612 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
3619 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
3621 20 IF (CHI4.LE.TINY) THEN
3622 FUNCG2A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
3624 FUNCG2A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
3629 !C *** END OF FUNCTION FUNCG2A *******************************************
3633 !C=======================================================================
3635 !C *** ISORROPIA CODE
3636 !C *** SUBROUTINE CALCG1
3639 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3640 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
3641 !C 2. SOLID AEROSOL ONLY
3642 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4CL, NA2SO4
3644 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
3645 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
3646 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCG1A)
3648 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3649 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3650 !C *** WRITTEN BY ATHANASIOS NENES
3651 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3653 !C=======================================================================
3655 SUBROUTINE CALCG12p1
3656 INCLUDE 'module_isrpia_inc.F'
3657 EXTERNAL CALCG1A2p1, CALCG2A2p1
3659 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
3661 IF (RH.LT.DRMG1) THEN
3662 SCASE = 'G1 ; SUBCASE 1'
3663 CALL CALCG1A2p1 ! SOLID PHASE ONLY POSSIBLE
3664 SCASE = 'G1 ; SUBCASE 1'
3666 SCASE = 'G1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
3667 CALL CALCMDRH2p1 (RH, DRMG1, DRNH4NO3, CALCG1A2p1, CALCG2A2p1)
3668 SCASE = 'G1 ; SUBCASE 2'
3673 !C *** END OF SUBROUTINE CALCG1 ******************************************
3678 !C=======================================================================
3680 !C *** ISORROPIA CODE
3681 !C *** SUBROUTINE CALCG1A
3682 !C *** CASE G1 ; SUBCASE 1
3684 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3685 !C 1. SULFATE POOR (SULRAT > 2.0)
3686 !C 2. SOLID AEROSOL ONLY
3687 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3
3689 !C SOLID (NH4)2SO4 IS CALCULATED FROM THE SULFATES, WHILE NH4NO3
3690 !C IS CALCULATED FROM NH3-HNO3 EQUILIBRIUM. 'ZE' IS THE AMOUNT OF
3691 !C NH4NO3 THAT VOLATIZES WHEN ALL POSSILBE NH4NO3 IS INITIALLY IN
3694 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3695 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3696 !C *** WRITTEN BY ATHANASIOS NENES
3697 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3699 !C=======================================================================
3701 SUBROUTINE CALCG1A2p1
3702 INCLUDE 'module_isrpia_inc.F'
3703 DOUBLE PRECISION LAMDA, LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2
3705 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
3707 CNA2SO4 = MIN (0.5*W(1), W(2))
3708 FRNA = MAX(W(1) - 2.D0*CNA2SO4, ZERO)
3709 SO4FR = MAX(W(2) - CNA2SO4, ZERO)
3710 !C CNH42S4 = W(2) - CNA2SO4
3711 CNH42S4 = MAX (SO4FR , ZERO) ! CNH42S4
3713 !C *** CALCULATE VOLATILE SPECIES **************************************
3715 ALF = W(3) - 2.0*CNH42S4
3719 RTSQ = R*TEMP*R*TEMP
3723 THETA1 = GAM - BET*(A2/A1)
3726 !C QUADRATIC EQUATION SOLUTION
3728 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
3729 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
3730 DD = BB*BB - 4.0D0*CC
3731 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
3733 !C TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
3736 KAPA1 = 0.5D0*(-BB+SQDD)
3737 KAPA2 = 0.5D0*(-BB-SQDD)
3738 LAMDA1 = THETA1 + THETA2*KAPA1
3739 LAMDA2 = THETA1 + THETA2*KAPA2
3741 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
3742 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
3743 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
3750 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
3751 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
3752 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
3759 !C SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
3763 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
3764 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
3766 !C NH4CL EQUILIBRIUM
3768 IF (DD1.GE.ZERO) THEN
3770 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
3771 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
3773 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
3775 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
3782 !C NH4NO3 EQUILIBRIUM
3784 IF (DD2.GE.ZERO) THEN
3786 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
3787 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
3789 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
3791 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
3798 !C IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
3800 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
3801 IF (BET .LT. LAMDA/THETA1) THEN
3808 !C *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
3814 GNH3 = MAX(ALF - KAPA - LAMDA, ZERO)
3815 GHNO3 = MAX(GAM - LAMDA, ZERO)
3816 GHCL = MAX(BET - KAPA, ZERO)
3820 !C *** END OF SUBROUTINE CALCG1A *****************************************
3823 !C=======================================================================
3825 !C *** ISORROPIA CODE
3826 !C *** SUBROUTINE CALCH6
3829 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3830 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3831 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3832 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3834 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3835 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3836 !C *** WRITTEN BY ATHANASIOS NENES
3837 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3839 !C=======================================================================
3841 SUBROUTINE CALCH62p1
3842 INCLUDE 'module_isrpia_inc.F'
3844 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3845 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
3846 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
3847 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
3848 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
3849 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
3851 !C *** SETUP PARAMETERS ************************************************
3854 CHI1 = W(2) ! CNA2SO4
3855 CHI2 = ZERO ! CNH42S4
3856 CHI3 = ZERO ! CNH4CL
3857 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
3858 CHI8 = MIN (FRNA, W(4)) ! CNANO3
3859 CHI4 = W(3) ! NH3(g)
3860 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
3861 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
3862 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
3865 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
3867 !C *** INITIAL VALUES FOR BISECTION ************************************
3870 Y1 = FUNCH6A2p1 (X1)
3871 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
3873 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
3875 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
3878 Y2 = FUNCH6A2p1 (X2)
3879 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
3884 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
3886 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH6A2p1 (PSI6LO)
3889 !C *** PERFORM BISECTION ***********************************************
3893 Y3 = FUNCH6A2p1 (X3)
3894 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
3901 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
3903 CALL PUSHERR2p1 (0002, 'CALCH6') ! WARNING ERROR: NO CONVERGENCE
3905 !C *** CONVERGED ; RETURN **********************************************
3908 Y3 = FUNCH6A2p1 (X3)
3910 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
3913 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
3914 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
3915 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
3916 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
3917 MOLAL(6) = DELTA ! HSO4 EFFECT
3922 !C *** END OF SUBROUTINE CALCH6 ******************************************
3929 !C=======================================================================
3931 !C *** ISORROPIA CODE
3932 !C *** SUBROUTINE FUNCH6A
3935 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
3936 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
3937 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
3938 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
3940 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
3941 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
3942 !C *** WRITTEN BY ATHANASIOS NENES
3943 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
3945 !C=======================================================================
3947 DOUBLE PRECISION FUNCTION FUNCH6A2p1 (X)
3948 INCLUDE 'module_isrpia_inc.F'
3950 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
3951 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
3952 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
3953 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
3954 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
3955 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
3957 !C *** SETUP PARAMETERS ************************************************
3968 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
3972 A1 = XK5 *(WATER/GAMA(2))**3.0
3973 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
3974 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
3975 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
3976 A7 = XK8 *(WATER/GAMA(1))**2.0
3977 A8 = XK9 *(WATER/GAMA(3))**2.0
3978 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
3980 !C CALCULATE DISSOCIATION QUANTITIES
3982 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
3983 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
3984 PSI5 = MAX(PSI5, TINY)
3986 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
3987 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
3988 CC = CHI4*(PSI5+PSI6)
3990 PSI4 =0.5d0*(-BB - SQRT(DD))
3991 PSI4 = MIN(PSI4,CHI4)
3996 !C *** CALCULATE SPECIATION ********************************************
3998 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
3999 MOLAL (3) = PSI4 ! NH4I
4000 MOLAL (4) = PSI6 + PSI7 ! CLI
4001 MOLAL (5) = PSI2 + PSI1 ! SO4I
4002 MOLAL (6) = ZERO ! HSO4I
4003 MOLAL (7) = PSI5 + PSI8 ! NO3I
4005 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
4006 CALL CALCPH2p1 (SMIN, HI, OHI)
4009 GNH3 = MAX(CHI4 - PSI4, TINY)
4010 GHNO3 = MAX(CHI5 - PSI5, TINY)
4011 GHCL = MAX(CHI6 - PSI6, TINY)
4015 CNACL = MAX(CHI7 - PSI7, ZERO)
4016 CNANO3 = MAX(CHI8 - PSI8, ZERO)
4017 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
4019 CALL CALCMR2p1 ! Water content
4021 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4023 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4030 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
4032 20 FUNCH6A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
4036 !C *** END OF FUNCTION FUNCH6A *******************************************
4040 !C=======================================================================
4042 !C *** ISORROPIA CODE
4043 !C *** SUBROUTINE CALCH5
4046 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4047 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4048 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4049 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
4051 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4052 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4053 !C *** WRITTEN BY ATHANASIOS NENES
4054 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4056 !C=======================================================================
4058 SUBROUTINE CALCH52p1
4059 INCLUDE 'module_isrpia_inc.F'
4061 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4062 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4063 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4064 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4065 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4066 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4068 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
4070 IF (W(4).LE.TINY .AND. W(5).LE.TINY) THEN
4077 !C *** SETUP PARAMETERS ************************************************
4080 CHI1 = W(2) ! CNA2SO4
4081 CHI2 = ZERO ! CNH42S4
4082 CHI3 = ZERO ! CNH4CL
4083 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
4084 CHI8 = MIN (FRNA, W(4)) ! CNANO3
4085 CHI4 = W(3) ! NH3(g)
4086 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
4087 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
4088 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
4091 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
4093 !C *** INITIAL VALUES FOR BISECTION ************************************
4096 Y1 = FUNCH5A2p1 (X1)
4097 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
4099 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
4101 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
4104 Y2 = FUNCH5A2p1 (X2)
4105 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
4110 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
4112 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH5A2p1 (PSI6LO)
4115 !C *** PERFORM BISECTION ***********************************************
4119 Y3 = FUNCH5A2p1 (X3)
4120 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
4127 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
4129 CALL PUSHERR2p1 (0002, 'CALCH5') ! WARNING ERROR: NO CONVERGENCE
4131 !C *** CONVERGED ; RETURN **********************************************
4134 Y3 = FUNCH5A2p1 (X3)
4136 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
4139 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
4140 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
4141 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFECT
4142 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
4143 MOLAL(6) = DELTA ! HSO4 EFFECT
4148 !C *** END OF SUBROUTINE CALCH5 ******************************************
4155 !C=======================================================================
4157 !C *** ISORROPIA CODE
4158 !C *** SUBROUTINE FUNCH5A
4161 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4162 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4163 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4164 !C 3. SOLIDS POSSIBLE : NONE
4166 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4167 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4168 !C *** WRITTEN BY ATHANASIOS NENES
4169 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4171 !C=======================================================================
4173 DOUBLE PRECISION FUNCTION FUNCH5A2p1 (X)
4174 INCLUDE 'module_isrpia_inc.F'
4176 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4177 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4178 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4179 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4180 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4181 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4183 !C *** SETUP PARAMETERS ************************************************
4194 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4198 A1 = XK5 *(WATER/GAMA(2))**3.0
4199 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
4200 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
4201 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
4202 A7 = XK8 *(WATER/GAMA(1))**2.0
4203 A8 = XK9 *(WATER/GAMA(3))**2.0
4204 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
4206 !C CALCULATE DISSOCIATION QUANTITIES
4208 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
4209 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
4210 PSI5 = MAX(PSI5, TINY)
4212 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
4213 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
4214 CC = CHI4*(PSI5+PSI6)
4216 PSI4 =0.5d0*(-BB - SQRT(DD))
4217 PSI4 = MIN(PSI4,CHI4)
4222 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
4226 CALL POLY32p1 (AA, BB, CC, PSI1, ISLV)
4228 PSI1 = MIN (PSI1, CHI1)
4234 !C *** CALCULATE SPECIATION ********************************************
4236 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
4237 MOLAL (3) = PSI4 ! NH4I
4238 MOLAL (4) = PSI6 + PSI7 ! CLI
4239 MOLAL (5) = PSI2 + PSI1 ! SO4I
4241 MOLAL (7) = PSI5 + PSI8 ! NO3I
4243 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
4244 CALL CALCPH2p1 (SMIN, HI, OHI)
4247 GNH3 = MAX(CHI4 - PSI4, TINY)
4248 GHNO3 = MAX(CHI5 - PSI5, TINY)
4249 GHCL = MAX(CHI6 - PSI6, TINY)
4253 CNACL = MAX(CHI7 - PSI7, ZERO)
4254 CNANO3 = MAX(CHI8 - PSI8, ZERO)
4255 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
4257 CALL CALCMR2p1 ! Water content
4259 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4261 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4268 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
4270 20 FUNCH5A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
4274 !C *** END OF FUNCTION FUNCH5A *******************************************
4278 !C=======================================================================
4280 !C *** ISORROPIA CODE
4281 !C *** SUBROUTINE CALCH4
4284 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4285 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4286 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4287 !C 3. SOLIDS POSSIBLE : NA2SO4
4289 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4290 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4291 !C *** WRITTEN BY ATHANASIOS NENES
4292 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4294 !C=======================================================================
4296 SUBROUTINE CALCH42p1
4297 INCLUDE 'module_isrpia_inc.F'
4299 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4300 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4301 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4302 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4303 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4304 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4306 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
4308 IF (W(4).LE.TINY .AND. W(5).LE.TINY) THEN
4315 !C *** SETUP PARAMETERS ************************************************
4318 CHI1 = W(2) ! CNA2SO4
4319 CHI2 = ZERO ! CNH42S4
4320 CHI3 = ZERO ! CNH4CL
4321 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
4322 CHI8 = MIN (FRNA, W(4)) ! CNANO3
4323 CHI4 = W(3) ! NH3(g)
4324 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
4325 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
4326 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
4329 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
4331 !C *** INITIAL VALUES FOR BISECTION ************************************
4334 Y1 = FUNCH4A2p1 (X1)
4335 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
4337 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
4339 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
4342 Y2 = FUNCH4A2p1 (X2)
4343 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
4348 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
4350 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH4A2p1 (PSI6LO)
4353 !C *** PERFORM BISECTION ***********************************************
4357 Y3 = FUNCH4A2p1 (X3)
4358 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
4365 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
4367 CALL PUSHERR2p1 (0002, 'CALCH4') ! WARNING ERROR: NO CONVERGENCE
4369 !C *** CONVERGED ; RETURN **********************************************
4372 Y3 = FUNCH4A2p1 (X3)
4374 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
4377 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
4378 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
4379 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
4380 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
4381 MOLAL(6) = DELTA ! HSO4 EFFECT
4386 !C *** END OF SUBROUTINE CALCH4 ******************************************
4393 !C=======================================================================
4395 !C *** ISORROPIA CODE
4396 !C *** SUBROUTINE FUNCH4A
4399 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4400 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4401 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4402 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
4404 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4405 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4406 !C *** WRITTEN BY ATHANASIOS NENES
4407 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4409 !C=======================================================================
4411 DOUBLE PRECISION FUNCTION FUNCH4A2p1 (X)
4412 INCLUDE 'module_isrpia_inc.F'
4414 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4415 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4416 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4417 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4418 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4419 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4421 !C *** SETUP PARAMETERS ************************************************
4432 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4436 A1 = XK5 *(WATER/GAMA(2))**3.0
4437 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
4438 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
4439 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
4440 A7 = XK8 *(WATER/GAMA(1))**2.0
4441 A8 = XK9 *(WATER/GAMA(3))**2.0
4442 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
4444 !C CALCULATE DISSOCIATION QUANTITIES
4446 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
4447 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
4448 PSI5 = MAX(PSI5, TINY)
4450 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
4451 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
4452 CC = CHI4*(PSI5+PSI6)
4454 PSI4 =0.5d0*(-BB - SQRT(DD))
4455 PSI4 = MIN(PSI4,CHI4)
4460 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
4464 CALL POLY32p1 (AA, BB, CC, PSI1, ISLV)
4466 PSI1 = MIN (PSI1, CHI1)
4472 !C *** CALCULATE SPECIATION ********************************************
4474 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
4475 MOLAL (3) = PSI4 ! NH4I
4476 MOLAL (4) = PSI6 + PSI7 ! CLI
4477 MOLAL (5) = PSI2 + PSI1 ! SO4I
4479 MOLAL (7) = PSI5 + PSI8 ! NO3I
4481 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
4482 CALL CALCPH2p1 (SMIN, HI, OHI)
4485 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4487 GNH3 = MAX(CHI4 - PSI4, TINY)
4488 GHNO3 = MAX(CHI5 - PSI5, TINY)
4489 GHCL = MAX(CHI6 - PSI6, TINY)
4493 CNACL = MAX(CHI7 - PSI7, ZERO)
4494 CNANO3 = MAX(CHI8 - PSI8, ZERO)
4495 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
4497 !C *** NH4Cl(s) calculations
4499 A3 = XK6 /(R*TEMP*R*TEMP)
4500 DELT = MIN(GNH3, GHCL)
4503 DD = BB*BB - 4.D0*CC
4504 PSI31 = 0.5D0*(-BB + SQRT(DD))
4505 PSI32 = 0.5D0*(-BB - SQRT(DD))
4506 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
4508 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
4514 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4516 GNH3 = MAX(GNH3 - PSI3, TINY)
4517 GHCL = MAX(GHCL - PSI3, TINY)
4520 CALL CALCMR2p1 ! Water content
4522 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4524 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4531 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
4533 20 FUNCH4A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
4537 !C *** END OF FUNCTION FUNCH4A *******************************************
4541 !C=======================================================================
4543 !C *** ISORROPIA CODE
4544 !C *** SUBROUTINE CALCH3
4547 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4548 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4549 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4550 !C 3. SOLIDS POSSIBLE : NH4CL, NA2SO4
4552 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4553 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4554 !C *** WRITTEN BY ATHANASIOS NENES
4555 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4557 !C=======================================================================
4559 SUBROUTINE CALCH32p1
4560 INCLUDE 'module_isrpia_inc.F'
4562 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4563 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4564 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4565 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4566 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4567 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4569 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
4571 IF (W(4).LE.TINY) THEN ! NO3 NOT EXIST, WATER NOT POSSIBLE
4578 !C *** SETUP PARAMETERS ************************************************
4581 CHI1 = W(2) ! CNA2SO4
4582 CHI2 = ZERO ! CNH42S4
4583 CHI3 = ZERO ! CNH4CL
4584 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
4585 CHI8 = MIN (FRNA, W(4)) ! CNANO3
4586 CHI4 = W(3) ! NH3(g)
4587 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
4588 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
4589 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
4592 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
4594 !C *** INITIAL VALUES FOR BISECTION ************************************
4597 Y1 = FUNCH3A2p1 (X1)
4598 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
4600 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
4602 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
4605 Y2 = FUNCH3A2p1 (X2)
4606 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
4611 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
4613 IF (ABS(Y2) .GT. EPS) Y2 = FUNCH3A2p1 (PSI6LO)
4616 !C *** PERFORM BISECTION ***********************************************
4620 Y3 = FUNCH3A2p1 (X3)
4621 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
4628 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
4630 CALL PUSHERR2p1 (0002, 'CALCH3') ! WARNING ERROR: NO CONVERGENCE
4632 !C *** CONVERGED ; RETURN **********************************************
4635 Y3 = FUNCH3A2p1 (X3)
4637 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
4640 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
4641 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
4642 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
4643 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
4644 MOLAL(6) = DELTA ! HSO4 EFFECT
4649 !C *** END OF SUBROUTINE CALCH3 ******************************************
4656 !C=======================================================================
4658 !C *** ISORROPIA CODE
4659 !C *** SUBROUTINE FUNCH3A
4662 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4663 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4664 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4665 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
4667 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4668 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4669 !C *** WRITTEN BY ATHANASIOS NENES
4670 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4672 !C=======================================================================
4674 DOUBLE PRECISION FUNCTION FUNCH3A2p1 (X)
4675 INCLUDE 'module_isrpia_inc.F'
4677 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4678 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4679 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4680 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4681 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4682 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4684 !C *** SETUP PARAMETERS ************************************************
4695 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
4699 A1 = XK5 *(WATER/GAMA(2))**3.0
4700 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
4701 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
4702 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
4703 A7 = XK8 *(WATER/GAMA(1))**2.0
4704 A8 = XK9 *(WATER/GAMA(3))**2.0
4705 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
4707 !C CALCULATE DISSOCIATION QUANTITIES
4709 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
4710 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
4711 PSI5 = MAX(PSI5, TINY)
4713 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
4714 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
4715 CC = CHI4*(PSI5+PSI6)
4717 PSI4 =0.5d0*(-BB - SQRT(DD))
4718 PSI4 = MIN(PSI4,CHI4)
4723 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
4724 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
4725 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
4726 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
4729 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
4733 CALL POLY32p1 (AA, BB, CC, PSI1, ISLV)
4735 PSI1 = MIN (PSI1, CHI1)
4741 !C *** CALCULATE SPECIATION ********************************************
4743 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
4744 MOLAL (3) = PSI4 ! NH4I
4745 MOLAL (4) = PSI6 + PSI7 ! CLI
4746 MOLAL (5) = PSI2 + PSI1 ! SO4I
4748 MOLAL (7) = PSI5 + PSI8 ! NO3I
4750 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
4751 CALL CALCPH2p1 (SMIN, HI, OHI)
4754 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4756 GNH3 = MAX(CHI4 - PSI4, TINY)
4757 GHNO3 = MAX(CHI5 - PSI5, TINY)
4758 GHCL = MAX(CHI6 - PSI6, TINY)
4762 CNACL = MAX(CHI7 - PSI7, ZERO)
4763 CNANO3 = MAX(CHI8 - PSI8, ZERO)
4764 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
4766 !C *** NH4Cl(s) calculations
4768 A3 = XK6 /(R*TEMP*R*TEMP)
4769 DELT = MIN(GNH3, GHCL)
4772 DD = BB*BB - 4.D0*CC
4773 PSI31 = 0.5D0*(-BB + SQRT(DD))
4774 PSI32 = 0.5D0*(-BB - SQRT(DD))
4775 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
4777 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
4783 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
4785 GNH3 = MAX(GNH3 - PSI3, TINY)
4786 GHCL = MAX(GHCL - PSI3, TINY)
4789 CALL CALCMR2p1 ! Water content
4791 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
4793 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
4800 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
4802 20 FUNCH3A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
4806 !C *** END OF FUNCTION FUNCH3A *******************************************
4810 !C=======================================================================
4812 !C *** ISORROPIA CODE
4813 !C *** SUBROUTINE CALCH2
4816 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4817 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4818 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
4819 !C 3. SOLIDS POSSIBLE : NH4Cl, NA2SO4, NANO3, NACL
4821 !C THERE ARE THREE REGIMES IN THIS CASE:
4822 !C 1. NH4NO3(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCH2A)
4823 !C 2. NH4NO3(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
4824 !C 3. NH4NO3(s) NOT POSSIBLE, AND RH >= MDRH. (MDRH REGION)
4826 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES H1A, H2B
4827 !C RESPECTIVELY (BECAUSE MDRH POINTS COINCIDE).
4829 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4830 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4831 !C *** WRITTEN BY ATHANASIOS NENES
4832 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4834 !C=======================================================================
4836 SUBROUTINE CALCH22p1
4837 INCLUDE 'module_isrpia_inc.F'
4838 EXTERNAL CALCH1A2p1, CALCH32p1
4840 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
4842 IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
4843 SCASE = 'H2 ; SUBCASE 1'
4845 SCASE = 'H2 ; SUBCASE 1'
4846 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
4847 SCASE = 'H2 ; SUBCASE 1'
4849 SCASE = 'H2 ; SUBCASE 1'
4852 IF (WATER.LE.TINY .AND. RH.LT.DRMH2) THEN ! DRY AEROSOL
4853 SCASE = 'H2 ; SUBCASE 2'
4855 ELSEIF (WATER.LE.TINY .AND. RH.GE.DRMH2) THEN ! MDRH OF H2
4856 SCASE = 'H2 ; SUBCASE 3'
4857 CALL CALCMDRH2p1 (RH, DRMH2, DRNANO3, CALCH1A2p1, CALCH32p1)
4858 SCASE = 'H2 ; SUBCASE 3'
4863 !C *** END OF SUBROUTINE CALCH2 ******************************************
4870 !C=======================================================================
4872 !C *** ISORROPIA CODE
4873 !C *** SUBROUTINE CALCH2A
4874 !C *** CASE H2 ; SUBCASE 1
4876 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4877 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4878 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4879 !C 3. SOLIDS POSSIBLE : NH4CL, NA2SO4
4881 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4882 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4883 !C *** WRITTEN BY ATHANASIOS NENES
4884 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4886 !C=======================================================================
4888 SUBROUTINE CALCH2A2p1
4889 INCLUDE 'module_isrpia_inc.F'
4891 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4892 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4893 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
4894 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
4895 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
4896 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
4898 !C *** SETUP PARAMETERS ************************************************
4901 CHI1 = W(2) ! CNA2SO4
4902 CHI2 = ZERO ! CNH42S4
4903 CHI3 = ZERO ! CNH4CL
4904 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
4905 CHI8 = MIN (FRNA, W(4)) ! CNANO3
4906 CHI4 = W(3) ! NH3(g)
4907 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
4908 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
4909 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
4912 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
4914 !C *** INITIAL VALUES FOR BISECTION ************************************
4917 Y1 = FUNCH2A2p1 (X1)
4918 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
4920 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
4922 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
4925 Y2 = FUNCH2A2p1 (X2)
4926 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
4931 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
4933 IF (Y2 .GT. EPS) Y2 = FUNCH2A2p1 (PSI6LO)
4936 !C *** PERFORM BISECTION ***********************************************
4940 Y3 = FUNCH2A2p1 (X3)
4941 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
4948 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
4950 CALL PUSHERR2p1 (0002, 'CALCH2A') ! WARNING ERROR: NO CONVERGENCE
4952 !C *** CONVERGED ; RETURN **********************************************
4955 Y3 = FUNCH2A2p1 (X3)
4957 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
4960 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
4961 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
4962 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
4963 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
4964 MOLAL(6) = DELTA ! HSO4 EFFECT
4969 !C *** END OF SUBROUTINE CALCH2A ******************************************
4976 !C=======================================================================
4978 !C *** ISORROPIA CODE
4979 !C *** SUBROUTINE FUNCH2A
4980 !C *** CASE H2 ; SUBCASE 1
4982 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
4983 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
4984 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
4985 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
4987 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
4988 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
4989 !C *** WRITTEN BY ATHANASIOS NENES
4990 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
4992 !C=======================================================================
4994 DOUBLE PRECISION FUNCTION FUNCH2A2p1 (X)
4995 INCLUDE 'module_isrpia_inc.F'
4997 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
4998 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
4999 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5000 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5001 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5002 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5004 !C *** SETUP PARAMETERS ************************************************
5015 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5019 A1 = XK5 *(WATER/GAMA(2))**3.0
5020 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
5021 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
5022 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
5023 A7 = XK8 *(WATER/GAMA(1))**2.0
5024 A8 = XK9 *(WATER/GAMA(3))**2.0
5025 A64 = (XK3*XK2/XKW)*(GAMA(10)/GAMA(5)/GAMA(11))**2.0
5026 A64 = A64*(R*TEMP*WATER)**2.0
5027 A9 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
5029 !C CALCULATE DISSOCIATION QUANTITIES
5031 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
5032 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
5033 PSI5 = MAX(PSI5, TINY)
5035 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
5036 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
5037 CC = CHI4*(PSI5+PSI6)
5039 PSI4 =0.5d0*(-BB - SQRT(DD))
5040 PSI4 = MIN(PSI4,CHI4)
5045 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
5046 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
5047 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
5048 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
5051 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
5052 DIAK = (PSI7-PSI5)**2.D0 + 4.D0*A8
5053 PSI8 = 0.5D0*( -(PSI7+PSI5) + SQRT(DIAK) )
5054 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
5057 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! NA2SO4 DISSOLUTION
5061 CALL POLY32p1 (AA, BB, CC, PSI1, ISLV)
5063 PSI1 = MIN (PSI1, CHI1)
5069 !C *** CALCULATE SPECIATION ********************************************
5071 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
5072 MOLAL (3) = PSI4 ! NH4I
5073 MOLAL (4) = PSI6 + PSI7 ! CLI
5074 MOLAL (5) = PSI2 + PSI1 ! SO4I
5075 MOLAL (6) = ZERO ! HSO4I
5076 MOLAL (7) = PSI5 + PSI8 ! NO3I
5078 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3)
5079 CALL CALCPH2p1 (SMIN, HI, OHI)
5082 GNH3 = MAX(CHI4 - PSI4, TINY)
5083 GHNO3 = MAX(CHI5 - PSI5, TINY)
5084 GHCL = MAX(CHI6 - PSI6, TINY)
5088 CNACL = MAX(CHI7 - PSI7, ZERO)
5089 CNANO3 = MAX(CHI8 - PSI8, ZERO)
5090 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
5092 !C *** NH4Cl(s) calculations
5094 A3 = XK6 /(R*TEMP*R*TEMP)
5095 DELT = MIN(GNH3, GHCL)
5098 DD = BB*BB - 4.D0*CC
5099 PSI31 = 0.5D0*(-BB + SQRT(DD))
5100 PSI32 = 0.5D0*(-BB - SQRT(DD))
5101 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
5103 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
5109 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
5111 GNH3 = MAX(GNH3 - PSI3, TINY)
5112 GHCL = MAX(GHCL - PSI3, TINY)
5115 CALL CALCMR2p1 ! Water content
5117 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5119 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5126 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
5128 20 FUNCH2A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A64 - ONE
5132 !C *** END OF FUNCTION FUNCH2A *******************************************
5137 !C=======================================================================
5139 !C *** ISORROPIA CODE
5140 !C *** SUBROUTINE CALCH1
5143 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5144 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
5145 !C 2. SOLID AEROSOL ONLY
5146 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4
5148 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
5149 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
5150 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCH1A)
5152 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5153 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5154 !C *** WRITTEN BY ATHANASIOS NENES
5155 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5157 !C=======================================================================
5159 SUBROUTINE CALCH12p1
5160 INCLUDE 'module_isrpia_inc.F'
5161 EXTERNAL CALCH1A2p1, CALCH2A2p1
5163 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
5165 IF (RH.LT.DRMH1) THEN
5166 SCASE = 'H1 ; SUBCASE 1'
5167 CALL CALCH1A2p1 ! SOLID PHASE ONLY POSSIBLE
5168 SCASE = 'H1 ; SUBCASE 1'
5170 SCASE = 'H1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
5171 CALL CALCMDRH2p1 (RH, DRMH1, DRNH4NO3, CALCH1A2p1, CALCH2A2p1)
5172 SCASE = 'H1 ; SUBCASE 2'
5177 !C *** END OF SUBROUTINE CALCH1 ******************************************
5182 !C=======================================================================
5184 !C *** ISORROPIA CODE
5185 !C *** SUBROUTINE CALCH1A
5186 !C *** CASE H1 ; SUBCASE 1
5188 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5189 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM RICH (SODRAT >= 2.0)
5190 !C 2. SOLID AEROSOL ONLY
5191 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NANO3, NA2SO4
5193 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5194 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5195 !C *** WRITTEN BY ATHANASIOS NENES
5196 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5198 !C=======================================================================
5200 SUBROUTINE CALCH1A2p1
5201 INCLUDE 'module_isrpia_inc.F'
5202 DOUBLE PRECISION LAMDA, LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2, NAFR, &
5205 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
5209 NAFR = MAX (W(1)-2*CNA2SO4, ZERO)
5210 CNANO3 = MIN (NAFR, W(4))
5211 NO3FR = MAX (W(4)-CNANO3, ZERO)
5212 CNACL = MIN (MAX(NAFR-CNANO3, ZERO), W(5))
5213 CLFR = MAX (W(5)-CNACL, ZERO)
5215 !C *** CALCULATE VOLATILE SPECIES **************************************
5217 ALF = W(3) ! FREE NH3
5218 BET = CLFR ! FREE CL
5219 GAM = NO3FR ! FREE NO3
5221 RTSQ = R*TEMP*R*TEMP
5225 THETA1 = GAM - BET*(A2/A1)
5228 !C QUADRATIC EQUATION SOLUTION
5230 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
5231 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
5232 DD = BB*BB - 4.0D0*CC
5233 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
5235 !C TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
5238 KAPA1 = 0.5D0*(-BB+SQDD)
5239 KAPA2 = 0.5D0*(-BB-SQDD)
5240 LAMDA1 = THETA1 + THETA2*KAPA1
5241 LAMDA2 = THETA1 + THETA2*KAPA2
5243 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
5244 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
5245 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
5252 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
5253 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
5254 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
5261 !C SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
5265 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
5266 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
5268 !C NH4CL EQUILIBRIUM
5270 IF (DD1.GE.ZERO) THEN
5272 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
5273 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
5275 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
5277 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
5284 !C NH4NO3 EQUILIBRIUM
5286 IF (DD2.GE.ZERO) THEN
5288 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
5289 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
5291 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
5293 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
5300 !C IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
5302 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
5303 IF (BET .LT. LAMDA/THETA1) THEN
5310 !C *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
5316 GNH3 = ALF - KAPA - LAMDA
5322 !C *** END OF SUBROUTINE CALCH1A *****************************************
5325 !C=======================================================================
5327 !C *** ISORROPIA CODE
5328 !C *** SUBROUTINE CALCI6
5331 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5332 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5333 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5334 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
5336 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5337 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5338 !C *** WRITTEN BY ATHANASIOS NENES
5339 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5341 !C=======================================================================
5343 SUBROUTINE CALCI62p1
5344 INCLUDE 'module_isrpia_inc.F'
5346 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5347 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5348 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5349 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5350 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5351 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5353 !C *** FIND DRY COMPOSITION **********************************************
5357 !C *** SETUP PARAMETERS ************************************************
5359 CHI1 = CNH4HS4 ! Save from CALCI1 run
5365 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
5371 CALAOU = .TRUE. ! Outer loop activity calculation flag
5375 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5379 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
5381 !C CALCULATE DISSOCIATION QUANTITIES
5383 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
5384 CC =-A6*(PSI2 + PSI3 + PSI1)
5385 DD = BB*BB - 4.D0*CC
5386 PSI6 = 0.5D0*(-BB + SQRT(DD))
5388 !C *** CALCULATE SPECIATION ********************************************
5390 MOLAL (1) = PSI6 ! HI
5391 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
5392 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
5393 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
5394 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
5397 CNA2SO4 = CHI4 - PSI4
5400 CALL CALCMR2p1 ! Water content
5402 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5404 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5413 !C *** END OF SUBROUTINE CALCI6 *****************************************
5417 !C=======================================================================
5419 !C *** ISORROPIA CODE
5420 !C *** SUBROUTINE CALCI5
5423 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5424 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5425 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5426 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
5428 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5429 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5430 !C *** WRITTEN BY ATHANASIOS NENES
5431 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5433 !C=======================================================================
5435 SUBROUTINE CALCI52p1
5436 INCLUDE 'module_isrpia_inc.F'
5438 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5439 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5440 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5441 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5442 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5443 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5445 !C *** FIND DRY COMPOSITION **********************************************
5449 !C *** SETUP PARAMETERS ************************************************
5451 CHI1 = CNH4HS4 ! Save from CALCI1 run
5457 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
5463 CALAOU =.TRUE. ! Outer loop activity calculation flag
5464 PSI4LO = ZERO ! Low limit
5465 PSI4HI = CHI4 ! High limit
5467 !C *** IF NA2SO4(S) =0, CALL FUNCI5B FOR Y4=0 ***************************
5469 IF (CHI4.LE.TINY) THEN
5470 Y1 = FUNCI5A2p1 (ZERO)
5474 !C *** INITIAL VALUES FOR BISECTION ************************************
5477 Y1 = FUNCI5A2p1 (X1)
5478 YHI= Y1 ! Save Y-value at HI position
5480 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 **
5482 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
5484 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
5486 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
5489 Y2 = FUNCI5A2p1 (X2)
5490 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
5495 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH4CL
5497 YLO= Y1 ! Save Y-value at Hi position
5498 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
5499 Y3 = FUNCI5A2p1 (ZERO)
5501 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
5504 CALL PUSHERR2p1 (0001, 'CALCI5') ! WARNING ERROR: NO SOLUTION
5508 !C *** PERFORM BISECTION ***********************************************
5512 Y3 = FUNCI5A2p1 (X3)
5513 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
5520 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
5522 CALL PUSHERR2p1 (0002, 'CALCI5') ! WARNING ERROR: NO CONVERGENCE
5524 !C *** CONVERGED ; RETURN **********************************************
5527 Y3 = FUNCI5A2p1 (X3)
5531 !C *** END OF SUBROUTINE CALCI5 *****************************************
5538 !C=======================================================================
5540 !C *** ISORROPIA CODE
5541 !C *** SUBROUTINE FUNCI5A
5544 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5545 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5546 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5547 !C 3. SOLIDS POSSIBLE : NA2SO4
5549 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5550 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5551 !C *** WRITTEN BY ATHANASIOS NENES
5552 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5554 !C=======================================================================
5556 DOUBLE PRECISION FUNCTION FUNCI5A2p1 (P4)
5557 INCLUDE 'module_isrpia_inc.F'
5559 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5560 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5561 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5562 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5563 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5564 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5566 !C *** SETUP PARAMETERS ************************************************
5568 PSI4 = P4 ! PSI3 already assigned in FUNCI5A
5572 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5576 A4 = XK5 *(WATER/GAMA(2))**3.0
5577 A5 = XK7 *(WATER/GAMA(4))**3.0
5578 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
5580 !C CALCULATE DISSOCIATION QUANTITIES
5582 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
5583 CC =-A6*(PSI2 + PSI3 + PSI1)
5584 DD = BB*BB - 4.D0*CC
5585 PSI6 = 0.5D0*(-BB + SQRT(DD))
5587 !C *** CALCULATE SPECIATION ********************************************
5589 MOLAL (1) = PSI6 ! HI
5590 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
5591 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
5592 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
5593 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
5596 CNA2SO4 = CHI4 - PSI4
5599 CALL CALCMR2p1 ! Water content
5601 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5603 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5610 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
5612 20 A4 = XK5 *(WATER/GAMA(2))**3.0
5613 FUNCI5A2p1= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
5616 !C *** END OF FUNCTION FUNCI5A ********************************************
5619 !C=======================================================================
5621 !C *** ISORROPIA CODE
5622 !C *** SUBROUTINE CALCI4
5625 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5626 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5627 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5628 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
5630 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5631 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5632 !C *** WRITTEN BY ATHANASIOS NENES
5633 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5635 !C=======================================================================
5637 SUBROUTINE CALCI42p1
5638 INCLUDE 'module_isrpia_inc.F'
5640 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5641 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5642 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5643 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5644 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5645 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5647 !C *** FIND DRY COMPOSITION **********************************************
5651 !C *** SETUP PARAMETERS ************************************************
5653 CHI1 = CNH4HS4 ! Save from CALCI1 run
5659 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
5665 CALAOU = .TRUE. ! Outer loop activity calculation flag
5666 PSI4LO = ZERO ! Low limit
5667 PSI4HI = CHI4 ! High limit
5669 !C *** IF NA2SO4(S) =0, CALL FUNCI4B FOR Y4=0 ***************************
5671 IF (CHI4.LE.TINY) THEN
5672 Y1 = FUNCI4A2p1 (ZERO)
5676 !C *** INITIAL VALUES FOR BISECTION ************************************
5679 Y1 = FUNCI4A2p1 (X1)
5680 YHI= Y1 ! Save Y-value at HI position
5682 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 **
5684 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
5686 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
5688 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
5691 Y2 = FUNCI4A2p1 (X2)
5692 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
5697 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH4CL
5699 YLO= Y1 ! Save Y-value at Hi position
5700 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
5701 Y3 = FUNCI4A2p1 (ZERO)
5703 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
5706 CALL PUSHERR2p1 (0001, 'CALCI4') ! WARNING ERROR: NO SOLUTION
5710 !C *** PERFORM BISECTION ***********************************************
5714 Y3 = FUNCI4A2p1 (X3)
5715 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
5722 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
5724 CALL PUSHERR2p1 (0002, 'CALCI4') ! WARNING ERROR: NO CONVERGENCE
5726 !C *** CONVERGED ; RETURN **********************************************
5729 Y3 = FUNCI4A2p1 (X3)
5733 !C *** END OF SUBROUTINE CALCI4 *****************************************
5740 !C=======================================================================
5742 !C *** ISORROPIA CODE
5743 !C *** SUBROUTINE FUNCI4A
5746 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5747 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5748 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5749 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4
5751 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5752 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5753 !C *** WRITTEN BY ATHANASIOS NENES
5754 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5756 !C=======================================================================
5758 DOUBLE PRECISION FUNCTION FUNCI4A2p1 (P4)
5759 INCLUDE 'module_isrpia_inc.F'
5761 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5762 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5763 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5764 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5765 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5766 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5768 !C *** SETUP PARAMETERS ************************************************
5770 PSI4 = P4 ! PSI3 already assigned in FUNCI4A
5774 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
5778 A4 = XK5 *(WATER/GAMA(2))**3.0
5779 A5 = XK7 *(WATER/GAMA(4))**3.0
5780 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
5783 !C CALCULATE DISSOCIATION QUANTITIES
5785 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
5786 CC =-A6*(PSI2 + PSI3 + PSI1)
5787 DD = BB*BB - 4.D0*CC
5788 PSI6 = 0.5D0*(-BB + SQRT(DD))
5790 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
5791 PSI5 = MAX (MIN (PSI5, CHI5), ZERO)
5793 !C *** CALCULATE SPECIATION ********************************************
5795 MOLAL (1) = PSI6 ! HI
5796 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
5797 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
5798 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
5799 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
5802 CNA2SO4 = CHI4 - PSI4
5803 CNH42S4 = CHI5 - PSI5
5805 CALL CALCMR2p1 ! Water content
5807 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
5809 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
5816 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
5818 20 A4 = XK5 *(WATER/GAMA(2))**3.0
5819 FUNCI4A2p1= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
5822 !C *** END OF FUNCTION FUNCI4A ********************************************
5825 !C=======================================================================
5827 !C *** ISORROPIA CODE
5828 !C *** SUBROUTINE CALCI3
5831 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5832 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5833 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5834 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
5836 !C THERE ARE THREE REGIMES IN THIS CASE:
5837 !C 1.(NA,NH4)HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCI3A)
5838 !C 2.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
5839 !C 3.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
5841 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES I1A, I2B
5844 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5845 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5846 !C *** WRITTEN BY ATHANASIOS NENES
5847 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5849 !C=======================================================================
5851 SUBROUTINE CALCI32p1
5852 INCLUDE 'module_isrpia_inc.F'
5853 EXTERNAL CALCI1A2p1, CALCI42p1
5855 !C *** FIND DRY COMPOSITION **********************************************
5859 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
5861 IF (CNH4HS4.GT.TINY .OR. CNAHSO4.GT.TINY) THEN
5862 SCASE = 'I3 ; SUBCASE 1'
5863 CALL CALCI3A2p1 ! FULL SOLUTION
5864 SCASE = 'I3 ; SUBCASE 1'
5867 IF (WATER.LE.TINY) THEN
5868 IF (RH.LT.DRMI3) THEN ! SOLID SOLUTION
5874 SCASE = 'I3 ; SUBCASE 2'
5876 ELSEIF (RH.GE.DRMI3) THEN ! MDRH OF I3
5877 SCASE = 'I3 ; SUBCASE 3'
5878 CALL CALCMDRH2p1 (RH, DRMI3, DRLC, CALCI1A2p1, CALCI42p1)
5879 SCASE = 'I3 ; SUBCASE 3'
5885 !C *** END OF SUBROUTINE CALCI3 ******************************************
5891 !C=======================================================================
5893 !C *** ISORROPIA CODE
5894 !C *** SUBROUTINE CALCI3A
5895 !C *** CASE I3 ; SUBCASE 1
5897 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
5898 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
5899 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
5900 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
5902 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
5903 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
5904 !C *** WRITTEN BY ATHANASIOS NENES
5905 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
5907 !C=======================================================================
5909 SUBROUTINE CALCI3A2p1
5910 INCLUDE 'module_isrpia_inc.F'
5912 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
5913 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
5914 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
5915 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
5916 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
5917 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
5919 !C *** FIND DRY COMPOSITION **********************************************
5921 CALL CALCI1A2p1 ! Needed when called from CALCMDRH
5923 !C *** SETUP PARAMETERS ************************************************
5925 CHI1 = CNH4HS4 ! Save from CALCI1 run
5931 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
5937 CALAOU = .TRUE. ! Outer loop activity calculation flag
5938 PSI2LO = ZERO ! Low limit
5939 PSI2HI = CHI2 ! High limit
5941 !C *** INITIAL VALUES FOR BISECTION ************************************
5944 Y1 = FUNCI3A2p1 (X1)
5945 YHI= Y1 ! Save Y-value at HI position
5947 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
5949 IF (YHI.LT.EPS) GOTO 50
5951 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
5953 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
5955 X2 = MAX(X1-DX, PSI2LO)
5956 Y2 = FUNCI3A2p1 (X2)
5957 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
5962 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
5964 IF (Y2.GT.EPS) Y2 = FUNCI3A2p1 (ZERO)
5967 !C *** PERFORM BISECTION ***********************************************
5971 Y3 = FUNCI3A2p1 (X3)
5972 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
5979 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
5981 CALL PUSHERR2p1 (0002, 'CALCI3A') ! WARNING ERROR: NO CONVERGENCE
5983 !C *** CONVERGED ; RETURN **********************************************
5986 Y3 = FUNCI3A2p1 (X3)
5990 !C *** END OF SUBROUTINE CALCI3A *****************************************
5994 !C=======================================================================
5996 !C *** ISORROPIA CODE
5997 !C *** SUBROUTINE FUNCI3A
5998 !C *** CASE I3 ; SUBCASE 1
6000 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6001 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6002 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
6003 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
6005 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6006 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6007 !C *** WRITTEN BY ATHANASIOS NENES
6008 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6010 !C=======================================================================
6012 DOUBLE PRECISION FUNCTION FUNCI3A2p1 (P2)
6013 INCLUDE 'module_isrpia_inc.F'
6015 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6016 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6017 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6018 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6019 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6020 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6022 !C *** SETUP PARAMETERS ************************************************
6024 PSI2 = P2 ! Save PSI2 in COMMON BLOCK
6025 PSI4LO = ZERO ! Low limit for PSI4
6026 PSI4HI = CHI4 ! High limit for PSI4
6028 !C *** IF NH3 =0, CALL FUNCI3B FOR Y4=0 ********************************
6030 IF (CHI4.LE.TINY) THEN
6031 FUNCI3A2p1 = FUNCI3B2p1 (ZERO)
6035 !C *** INITIAL VALUES FOR BISECTION ************************************
6038 Y1 = FUNCI3B2p1 (X1)
6039 IF (ABS(Y1).LE.EPS) GOTO 50
6040 YHI= Y1 ! Save Y-value at HI position
6042 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *****
6044 IF (YHI.LT.ZERO) GOTO 50
6046 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
6048 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
6050 X2 = MAX(X1-DX, PSI4LO)
6051 Y2 = FUNCI3B2p1 (X2)
6052 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
6057 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4
6059 IF (Y2.GT.EPS) Y2 = FUNCI3B2p1 (PSI4LO)
6062 !C *** PERFORM BISECTION ***********************************************
6066 Y3 = FUNCI3B2p1 (X3)
6067 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
6074 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
6076 CALL PUSHERR2p1 (0004, 'FUNCI3A2p1') ! WARNING ERROR: NO CONVERGENCE
6078 !C *** INNER LOOP CONVERGED **********************************************
6081 Y3 = FUNCI3B2p1 (X3)
6083 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
6085 50 A2 = XK13*(WATER/GAMA(13))**5.0
6086 FUNCI3A2p1 = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.D0/A2 - ONE
6089 !C *** END OF FUNCTION FUNCI3A *******************************************
6095 !C=======================================================================
6097 !C *** ISORROPIA CODE
6098 !C *** FUNCTION FUNCI3B
6099 !C *** CASE I3 ; SUBCASE 2
6101 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6102 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6103 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
6104 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, LC
6106 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
6108 !C=======================================================================
6110 DOUBLE PRECISION FUNCTION FUNCI3B2p1 (P4)
6111 INCLUDE 'module_isrpia_inc.F'
6113 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6114 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6115 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6116 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6117 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6118 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6120 !C *** SETUP PARAMETERS ************************************************
6124 !C *** SETUP PARAMETERS ************************************************
6129 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6133 A4 = XK5*(WATER/GAMA(2))**3.0
6134 A5 = XK7*(WATER/GAMA(4))**3.0
6135 A6 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
6138 !C CALCULATE DISSOCIATION QUANTITIES
6140 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
6141 CC =-A6*(PSI2 + PSI3 + PSI1)
6142 DD = BB*BB - 4.D0*CC
6143 PSI6 = 0.5D0*(-BB + SQRT(DD))
6145 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
6146 PSI5 = MAX (MIN (PSI5, CHI5), ZERO)
6148 !C *** CALCULATE SPECIATION ********************************************
6150 MOLAL(1) = PSI6 ! HI
6151 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
6152 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
6153 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
6154 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 - PSI6, TINY) ! HSO4I
6155 CLC = MAX(CHI2 - PSI2, ZERO)
6157 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
6158 CNH42S4 = MAX(CHI5 - PSI5, ZERO)
6160 CALL CALCMR2p1 ! Water content
6162 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6164 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6171 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
6173 20 A4 = XK5 *(WATER/GAMA(2))**3.0
6174 FUNCI3B2p1= MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
6177 !C *** END OF FUNCTION FUNCI3B ********************************************
6180 !C=======================================================================
6182 !C *** ISORROPIA CODE
6183 !C *** SUBROUTINE CALCI2
6186 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6187 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6188 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
6189 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
6191 !C THERE ARE THREE REGIMES IN THIS CASE:
6192 !C 1. NH4HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCI2A)
6193 !C 2. NH4HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
6194 !C 3. NH4HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
6196 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES I1A, I2B
6199 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6200 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6201 !C *** WRITTEN BY ATHANASIOS NENES
6202 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6204 !C=======================================================================
6206 SUBROUTINE CALCI22p1
6207 INCLUDE 'module_isrpia_inc.F'
6208 EXTERNAL CALCI1A2p1, CALCI3A2p1
6210 !C *** FIND DRY COMPOSITION **********************************************
6214 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
6216 IF (CNH4HS4.GT.TINY) THEN
6217 SCASE = 'I2 ; SUBCASE 1'
6219 SCASE = 'I2 ; SUBCASE 1'
6222 IF (WATER.LE.TINY) THEN
6223 IF (RH.LT.DRMI2) THEN ! SOLID SOLUTION ONLY
6229 SCASE = 'I2 ; SUBCASE 2'
6231 ELSEIF (RH.GE.DRMI2) THEN ! MDRH OF I2
6232 SCASE = 'I2 ; SUBCASE 3'
6233 CALL CALCMDRH2p1 (RH, DRMI2, DRNAHSO4, CALCI1A2p1, CALCI3A2p1)
6234 SCASE = 'I2 ; SUBCASE 3'
6240 !C *** END OF SUBROUTINE CALCI2 ******************************************
6245 !C=======================================================================
6247 !C *** ISORROPIA CODE
6248 !C *** SUBROUTINE CALCI2A
6249 !C *** CASE I2 ; SUBCASE A
6251 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6252 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6253 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
6254 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
6256 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6257 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6258 !C *** WRITTEN BY ATHANASIOS NENES
6259 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6261 !C=======================================================================
6263 SUBROUTINE CALCI2A2p1
6264 INCLUDE 'module_isrpia_inc.F'
6266 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6267 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6268 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6269 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6270 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
6271 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6273 !C *** FIND DRY COMPOSITION **********************************************
6275 CALL CALCI1A2p1 ! Needed when called from CALCMDRH
6277 !C *** SETUP PARAMETERS ************************************************
6279 CHI1 = CNH4HS4 ! Save from CALCI1 run
6285 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
6291 CALAOU = .TRUE. ! Outer loop activity calculation flag
6292 PSI2LO = ZERO ! Low limit
6293 PSI2HI = CHI2 ! High limit
6295 !C *** INITIAL VALUES FOR BISECTION ************************************
6298 Y1 = FUNCI2A2p1 (X1)
6299 YHI= Y1 ! Save Y-value at HI position
6301 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
6303 IF (YHI.LT.EPS) GOTO 50
6305 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
6307 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
6309 X2 = MAX(X1-DX, PSI2LO)
6310 Y2 = FUNCI2A2p1 (X2)
6311 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
6316 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
6318 IF (Y2.GT.EPS) Y2 = FUNCI2A2p1 (ZERO)
6321 !C *** PERFORM BISECTION ***********************************************
6325 Y3 = FUNCI2A2p1 (X3)
6326 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
6333 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
6335 CALL PUSHERR2p1 (0002, 'CALCI2A') ! WARNING ERROR: NO CONVERGENCE
6337 !C *** CONVERGED ; RETURN **********************************************
6340 Y3 = FUNCI2A2p1 (X3)
6344 !C *** END OF SUBROUTINE CALCI2A *****************************************
6351 !C=======================================================================
6353 !C *** ISORROPIA CODE
6354 !C *** SUBROUTINE FUNCI2A
6355 !C *** CASE I2 ; SUBCASE 1
6357 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6358 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6359 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
6360 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, NAHSO4, LC
6362 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6363 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6364 !C *** WRITTEN BY ATHANASIOS NENES
6365 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6367 !C=======================================================================
6369 DOUBLE PRECISION FUNCTION FUNCI2A2p1 (P2)
6370 INCLUDE 'module_isrpia_inc.F'
6372 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
6373 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
6374 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
6375 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
6376 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6,&
6377 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
6379 !C *** SETUP PARAMETERS ************************************************
6383 PSI2 = P2 ! Save PSI2 in COMMON BLOCK
6389 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6393 A3 = XK11*(WATER/GAMA(12))**2.0
6394 A4 = XK5 *(WATER/GAMA(2))**3.0
6395 A5 = XK7 *(WATER/GAMA(4))**3.0
6396 A6 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
6399 !C CALCULATE DISSOCIATION QUANTITIES
6401 IF (CHI5.GT.TINY .AND. WATER.GT.TINY) THEN
6402 PSI5 = (PSI3 + 2.D0*PSI4 - A7*(3.D0*PSI2 + PSI1))/2.D0/A7
6403 PSI5 = MAX(MIN (PSI5, CHI5), TINY)
6406 IF (CHI4.GT.TINY .AND. WATER.GT.TINY) THEN
6407 AA = PSI2+PSI5+PSI6+PSI3
6409 CC = 0.25D0*(PSI3*PSI3*(PSI2+PSI5+PSI6)-A4)
6410 CALL POLY32p1 (AA, BB, CC, PSI4, ISLV)
6412 PSI4 = MIN (PSI4, CHI4)
6418 IF (CHI3.GT.TINY .AND. WATER.GT.TINY) THEN
6419 AA = 2.D0*PSI4 + PSI2 + PSI1 - PSI6
6420 BB = 2.D0*PSI4*(PSI2 + PSI1 - PSI6) - A3
6422 CALL POLY32p1 (AA, BB, CC, PSI3, ISLV)
6424 PSI3 = MIN (PSI3, CHI3)
6430 BB = PSI2 + PSI4 + PSI5 + A6 ! PSI6
6431 CC =-A6*(PSI2 + PSI3 + PSI1)
6432 DD = BB*BB - 4.D0*CC
6433 PSI6 = 0.5D0*(-BB + SQRT(DD))
6435 !C *** CALCULATE SPECIATION ********************************************
6437 MOLAL (1) = PSI6 ! HI
6438 MOLAL (2) = 2.D0*PSI4 + PSI3 ! NAI
6439 MOLAL (3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
6440 MOLAL (5) = PSI2 + PSI4 + PSI5 + PSI6 ! SO4I
6441 MOLAL (6) = PSI2 + PSI3 + PSI1 - PSI6 ! HSO4I
6443 CNAHSO4 = CHI3 - PSI3
6444 CNA2SO4 = CHI4 - PSI4
6445 CNH42S4 = CHI5 - PSI5
6447 CALL CALCMR2p1 ! Water content
6449 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6451 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6458 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
6460 20 A2 = XK13*(WATER/GAMA(13))**5.0
6461 FUNCI2A2p1 = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.D0/A2 - ONE
6464 !C *** END OF FUNCTION FUNCI2A *******************************************
6468 !C=======================================================================
6470 !C *** ISORROPIA CODE
6471 !C *** SUBROUTINE CALCI1
6474 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6475 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6476 !C 2. SOLID AEROSOL ONLY
6477 !C 3. SOLIDS POSSIBLE : NH4NO3, NH4CL, NA2SO4
6479 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
6480 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
6481 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCI1A)
6483 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6484 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6485 !C *** WRITTEN BY ATHANASIOS NENES
6486 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6488 !C=======================================================================
6490 SUBROUTINE CALCI12p1
6491 INCLUDE 'module_isrpia_inc.F'
6492 EXTERNAL CALCI1A2p1, CALCI2A2p1
6494 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
6496 IF (RH.LT.DRMI1) THEN
6497 SCASE = 'I1 ; SUBCASE 1'
6498 CALL CALCI1A2p1 ! SOLID PHASE ONLY POSSIBLE
6499 SCASE = 'I1 ; SUBCASE 1'
6501 SCASE = 'I1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
6502 CALL CALCMDRH2p1 (RH, DRMI1, DRNH4HS4, CALCI1A2p1, CALCI2A2p1)
6503 SCASE = 'I1 ; SUBCASE 2'
6506 !C *** AMMONIA IN GAS PHASE **********************************************
6512 !C *** END OF SUBROUTINE CALCI1 ******************************************
6517 !C=======================================================================
6519 !C *** ISORROPIA CODE
6520 !C *** SUBROUTINE CALCI1A
6521 !C *** CASE I1 ; SUBCASE 1
6523 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6524 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
6525 !C 2. SOLID AEROSOL ONLY
6526 !C 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
6528 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6529 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6530 !C *** WRITTEN BY ATHANASIOS NENES
6531 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6533 !C=======================================================================
6535 SUBROUTINE CALCI1A2p1
6536 INCLUDE 'module_isrpia_inc.F'
6538 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
6540 CNA2SO4 = 0.5D0*W(1)
6544 FRSO4 = MAX(W(2)-CNA2SO4, ZERO)
6546 CLC = MIN(W(3)/3.D0, FRSO4/2.D0)
6547 FRSO4 = MAX(FRSO4-2.D0*CLC, ZERO)
6548 FRNH4 = MAX(W(3)-3.D0*CLC, ZERO)
6550 IF (FRSO4.LE.TINY) THEN
6551 CLC = MAX(CLC - FRNH4, ZERO)
6552 CNH42S4 = 2.D0*FRNH4
6554 ELSEIF (FRNH4.LE.TINY) THEN
6555 CNH4HS4 = 3.D0*MIN(FRSO4, CLC)
6556 CLC = MAX(CLC-FRSO4, ZERO)
6557 IF (CNA2SO4.GT.TINY) THEN
6558 FRSO4 = MAX(FRSO4-CNH4HS4/3.D0, ZERO)
6559 CNAHSO4 = 2.D0*FRSO4
6560 CNA2SO4 = MAX(CNA2SO4-FRSO4, ZERO)
6564 !C *** CALCULATE GAS SPECIES *********************************************
6572 !C *** END OF SUBROUTINE CALCI1A *****************************************
6575 !C=======================================================================
6577 !C *** ISORROPIA CODE
6578 !C *** SUBROUTINE CALCJ3
6581 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6582 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
6583 !C 2. THERE IS ONLY A LIQUID PHASE
6585 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6586 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6587 !C *** WRITTEN BY ATHANASIOS NENES
6588 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6590 !C=======================================================================
6592 SUBROUTINE CALCJ32p1
6593 INCLUDE 'module_isrpia_inc.F'
6595 DOUBLE PRECISION LAMDA, KAPA
6597 !C *** SETUP PARAMETERS ************************************************
6599 CALAOU = .TRUE. ! Outer loop activity calculation flag
6603 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
6604 CHI1 = W(1) ! NA TOTAL as NaHSO4
6605 CHI2 = W(3) ! NH4 TOTAL as NH4HSO4
6607 PSI2 = CHI2 ! ALL NH4HSO4 DELIQUESCED
6609 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6613 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
6615 !C CALCULATE DISSOCIATION QUANTITIES
6617 BB = A3+LAMDA ! KAPA
6618 CC =-A3*(LAMDA + PSI1 + PSI2)
6620 KAPA = 0.5D0*(-BB+SQRT(DD))
6622 !C *** CALCULATE SPECIATION ********************************************
6624 MOLAL (1) = LAMDA + KAPA ! HI
6625 MOLAL (2) = PSI1 ! NAI
6626 MOLAL (3) = PSI2 ! NH4I
6627 MOLAL (4) = ZERO ! CLI
6628 MOLAL (5) = KAPA ! SO4I
6629 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
6630 MOLAL (7) = ZERO ! NO3I
6635 CALL CALCMR2p1 ! Water content
6637 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6639 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6648 !C *** END OF SUBROUTINE CALCJ3 ******************************************
6651 !C=======================================================================
6653 !C *** ISORROPIA CODE
6654 !C *** SUBROUTINE CALCJ2
6657 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6658 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
6659 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6660 !C 3. SOLIDS POSSIBLE : NAHSO4
6662 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6663 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6664 !C *** WRITTEN BY ATHANASIOS NENES
6665 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6667 !C=======================================================================
6669 SUBROUTINE CALCJ22p1
6670 INCLUDE 'module_isrpia_inc.F'
6672 DOUBLE PRECISION LAMDA, KAPA
6673 COMMON /CASEJ2p1/ CHI1, CHI2, CHI3, LAMDA, KAPA, PSI1, PSI2, PSI3, &
6676 !C *** SETUP PARAMETERS ************************************************
6678 CALAOU = .TRUE. ! Outer loop activity calculation flag
6679 CHI1 = W(1) ! NA TOTAL
6680 CHI2 = W(3) ! NH4 TOTAL
6681 PSI1LO = TINY ! Low limit
6682 PSI1HI = CHI1 ! High limit
6684 !C *** INITIAL VALUES FOR BISECTION ************************************
6688 YHI= Y1 ! Save Y-value at HI position
6690 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH42SO4 ****
6692 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
6694 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
6696 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
6700 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
6705 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH42SO4
6707 YLO= Y1 ! Save Y-value at Hi position
6708 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
6709 Y3 = FUNCJ22p1 (ZERO)
6711 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
6714 CALL PUSHERR2p1 (0001, 'CALCJ2') ! WARNING ERROR: NO SOLUTION
6718 !C *** PERFORM BISECTION ***********************************************
6723 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
6730 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
6732 CALL PUSHERR2p1 (0002, 'CALCJ2') ! WARNING ERROR: NO CONVERGENCE
6734 !C *** CONVERGED ; RETURN **********************************************
6741 !C *** END OF SUBROUTINE CALCJ2 ******************************************
6748 !C=======================================================================
6750 !C *** ISORROPIA CODE
6751 !C *** SUBROUTINE FUNCJ2
6754 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6755 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
6756 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6757 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
6759 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6760 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6761 !C *** WRITTEN BY ATHANASIOS NENES
6762 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6764 !C=======================================================================
6766 DOUBLE PRECISION FUNCTION FUNCJ22p1 (P1)
6767 INCLUDE 'module_isrpia_inc.F'
6769 DOUBLE PRECISION LAMDA, KAPA
6770 COMMON /CASEJ2p1/ CHI1, CHI2, CHI3, LAMDA, KAPA, PSI1, PSI2, PSI3, &
6773 !C *** SETUP PARAMETERS ************************************************
6778 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
6780 PSI2 = CHI2 ! ALL NH4HSO4 DELIQUESCED
6782 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6786 A1 = XK11 *(WATER/GAMA(12))**2.0
6787 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
6789 !C CALCULATE DISSOCIATION QUANTITIES
6791 BB = A3+LAMDA ! KAPA
6792 CC =-A3*(LAMDA + PSI1 + PSI2)
6794 KAPA = 0.5D0*(-BB+SQRT(DD))
6796 !C *** CALCULATE SPECIATION ********************************************
6798 MOLAL (1) = LAMDA + KAPA ! HI
6799 MOLAL (2) = PSI1 ! NAI
6800 MOLAL (3) = PSI2 ! NH4I
6801 MOLAL (4) = ZERO ! CLI
6802 MOLAL (5) = KAPA ! SO4I
6803 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
6804 MOLAL (7) = ZERO ! NO3I
6806 CNAHSO4 = MAX(CHI1-PSI1,ZERO)
6809 CALL CALCMR2p1 ! Water content
6811 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6813 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6820 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
6822 20 FUNCJ22p1 = MOLAL(2)*MOLAL(6)/A1 - ONE
6824 !C *** END OF FUNCTION FUNCJ2 *******************************************
6828 !C=======================================================================
6830 !C *** ISORROPIA CODE
6831 !C *** SUBROUTINE CALCJ1
6834 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6835 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
6836 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6837 !C 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4
6839 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6840 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6841 !C *** WRITTEN BY ATHANASIOS NENES
6842 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6844 !C=======================================================================
6846 SUBROUTINE CALCJ12p1
6847 INCLUDE 'module_isrpia_inc.F'
6849 DOUBLE PRECISION LAMDA, KAPA
6850 COMMON /CASEJ2p1/ CHI1, CHI2, CHI3, LAMDA, KAPA, PSI1, PSI2, PSI3, &
6853 !C *** SETUP PARAMETERS ************************************************
6855 CALAOU =.TRUE. ! Outer loop activity calculation flag
6856 CHI1 = W(1) ! Total NA initially as NaHSO4
6857 CHI2 = W(3) ! Total NH4 initially as NH4HSO4
6859 PSI1LO = TINY ! Low limit
6860 PSI1HI = CHI1 ! High limit
6862 !C *** INITIAL VALUES FOR BISECTION ************************************
6866 YHI= Y1 ! Save Y-value at HI position
6868 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NH42SO4 ****
6870 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
6872 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
6874 DX = (PSI1HI-PSI1LO)/FLOAT(NDIV)
6878 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
6883 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NH42SO4
6885 YLO= Y1 ! Save Y-value at Hi position
6886 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
6887 Y3 = FUNCJ12p1 (ZERO)
6889 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
6892 CALL PUSHERR2p1 (0001, 'CALCJ1') ! WARNING ERROR: NO SOLUTION
6896 !C *** PERFORM BISECTION ***********************************************
6901 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
6908 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
6910 CALL PUSHERR2p1 (0002, 'CALCJ1') ! WARNING ERROR: NO CONVERGENCE
6912 !C *** CONVERGED ; RETURN **********************************************
6919 !C *** END OF SUBROUTINE CALCJ1 ******************************************
6926 !C=======================================================================
6928 !C *** ISORROPIA CODE
6929 !C *** SUBROUTINE FUNCJ1
6932 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
6933 !C 1. SULFATE RICH, FREE ACID (SULRAT < 1.0)
6934 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
6935 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
6937 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
6938 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
6939 !C *** WRITTEN BY ATHANASIOS NENES
6940 !C *** UPDATED BY CHRISTOS FOUNTOUKIS
6942 !C=======================================================================
6944 DOUBLE PRECISION FUNCTION FUNCJ12p1 (P1)
6945 INCLUDE 'module_isrpia_inc.F'
6946 DOUBLE PRECISION LAMDA, KAPA
6947 COMMON /CASEJ2p1/ CHI1, CHI2, CHI3, LAMDA, KAPA, PSI1, PSI2, PSI3, &
6950 !C *** SETUP PARAMETERS ************************************************
6955 LAMDA = MAX(W(2) - W(3) - W(1), TINY) ! FREE H2SO4
6958 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
6962 A1 = XK11 *(WATER/GAMA(12))**2.0
6963 A2 = XK12 *(WATER/GAMA(09))**2.0
6964 A3 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
6966 PSI2 = 0.5*(-(LAMDA+PSI1) + SQRT((LAMDA+PSI1)**2.D0+4.D0*A2)) ! PSI2
6967 PSI2 = MIN (PSI2, CHI2)
6969 BB = A3+LAMDA ! KAPA
6970 CC =-A3*(LAMDA + PSI2 + PSI1)
6972 KAPA = 0.5D0*(-BB+SQRT(DD))
6974 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
6976 MOLAL (1) = LAMDA + KAPA ! HI
6977 MOLAL (2) = PSI1 ! NAI
6978 MOLAL (3) = PSI2 ! NH4I
6980 MOLAL (5) = KAPA ! SO4I
6981 MOLAL (6) = LAMDA + PSI1 + PSI2 - KAPA ! HSO4I
6984 CNAHSO4 = MAX(CHI1-PSI1,ZERO)
6985 CNH4HS4 = MAX(CHI2-PSI2,ZERO)
6987 CALL CALCMR2p1 ! Water content
6989 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
6991 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
6998 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
7000 20 FUNCJ12p1 = MOLAL(2)*MOLAL(6)/A1 - ONE
7002 !C *** END OF FUNCTION FUNCJ1 *******************************************
7006 !C=======================================================================
7008 !C *** ISORROPIA CODE II
7009 !C *** SUBROUTINE CALCO7
7012 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7013 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7014 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7015 !C 3. SOLIDS POSSIBLE : CaSO4
7016 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MgSO4, NA2SO4, K2SO4
7017 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7018 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7019 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7021 !C=======================================================================
7023 SUBROUTINE CALCO72p1
7024 INCLUDE 'module_isrpia_inc.F'
7026 DOUBLE PRECISION LAMDA
7027 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7028 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7029 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7032 !C *** SETUP PARAMETERS ************************************************
7035 CHI9 = MIN (W(6), W(2)) ! CCASO4
7036 SO4FR = MAX (W(2)-CHI9, ZERO)
7037 CAFR = MAX (W(6)-CHI9, ZERO)
7038 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
7039 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
7040 SO4FR = MAX (SO4FR - CHI7, ZERO)
7041 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
7042 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
7043 SO4FR = MAX (SO4FR - CHI1, ZERO)
7044 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
7045 FRMG = MAX(W(8) - CHI8, ZERO)
7046 SO4FR = MAX(SO4FR - CHI8, ZERO)
7050 CHI2 = MAX (SO4FR, ZERO)
7051 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
7062 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
7064 WATER = CHI2/M0(4) + CHI1/M0(2) + CHI7/M0(17) + CHI8/M0(21)
7065 WATER = MAX (WATER , TINY)
7067 !C *** INITIAL VALUES FOR BISECTION ************************************
7071 IF (CHI6.LE.TINY) GOTO 50
7072 !ccc IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
7073 !ccc IF (WATER .LE. TINY) RETURN ! No water
7075 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
7077 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
7081 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
7086 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
7088 IF (ABS(Y2) .GT. EPS) Y2 = FUNCO72p1 (PSI6LO)
7091 !C *** PERFORM BISECTION ***********************************************
7096 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
7103 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
7105 CALL PUSHERR2p1 (0002, 'CALCO7') ! WARNING ERROR: NO CONVERGENCE
7107 !C *** CONVERGED ; RETURN **********************************************
7112 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7115 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN ! If quadrat.called
7116 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
7117 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
7118 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
7119 MOLAL(6) = DELTA ! HSO4 EFFECT
7124 !C *** END OF SUBROUTINE CALCO7 *******************************************
7128 !C=======================================================================
7130 !C *** ISORROPIA CODE II
7131 !C *** SUBROUTINE FUNCO7
7134 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7135 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7136 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7137 !C 3. SOLIDS POSSIBLE : CaSO4
7138 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MgSO4, NA2SO4, K2SO4
7139 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7140 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7141 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7143 !C=======================================================================
7145 DOUBLE PRECISION FUNCTION FUNCO72p1 (X)
7146 INCLUDE 'module_isrpia_inc.F'
7148 DOUBLE PRECISION LAMDA
7149 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7150 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7151 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7154 !C *** SETUP PARAMETERS ************************************************
7160 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7164 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
7165 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
7166 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
7169 IF (CHI5.GE.TINY) THEN
7170 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
7171 PSI5 = MIN (PSI5,CHI5)
7176 !CCC IF(CHI4.GT.TINY) THEN
7177 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
7178 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
7179 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
7180 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
7181 PSI4 =0.5d0*(-BB - SQRT(DD))
7182 PSI4 = MAX (MIN (PSI4,CHI4), ZERO)
7187 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7189 MOLAL (2) = 2.0D0*PSI1 ! Na+
7190 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
7191 MOLAL (4) = PSI6 ! CLI
7192 MOLAL (5) = PSI1+PSI2+PSI7+PSI8 ! SO4I
7193 MOLAL (6) = ZERO ! HSO4
7194 MOLAL (7) = PSI5 ! NO3I
7195 MOLAL (8) = ZERO ! CaI
7196 MOLAL (9) = 2.0D0*PSI7 ! KI
7197 MOLAL (10)= PSI8 ! Mg
7199 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7201 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
7202 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
7203 -MOLAL(9)-2.D0*MOLAL(10)
7204 CALL CALCPH2p1 (SMIN, HI, OHI)
7207 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7209 GNH3 = MAX(CHI4 - PSI4, TINY)
7210 GHNO3 = MAX(CHI5 - PSI5, TINY)
7211 GHCL = MAX(CHI6 - PSI6, TINY)
7221 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
7225 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7227 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7234 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
7236 20 FUNCO72p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
7237 !CCC FUNCG5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
7241 !C *** END OF FUNCTION FUNCO7 *******************************************
7245 !C=======================================================================
7247 !C *** ISORROPIA CODE II
7248 !C *** SUBROUTINE CALCO6
7251 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7252 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7253 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7254 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4
7255 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MGSO4, NA2SO4
7256 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7257 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7258 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7260 !C=======================================================================
7262 SUBROUTINE CALCO62p1
7263 INCLUDE 'module_isrpia_inc.F'
7265 DOUBLE PRECISION LAMDA
7266 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7267 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7268 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7271 !C *** SETUP PARAMETERS ************************************************
7274 CHI9 = MIN (W(6), W(2)) ! CCASO4
7275 SO4FR = MAX (W(2)-CHI9, ZERO)
7276 CAFR = MAX (W(6)-CHI9, ZERO)
7277 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
7278 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
7279 SO4FR = MAX (SO4FR - CHI7, ZERO)
7280 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
7281 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
7282 SO4FR = MAX (SO4FR - CHI1, ZERO)
7283 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
7284 FRMG = MAX(W(8) - CHI8, ZERO)
7285 SO4FR = MAX(SO4FR - CHI8, ZERO)
7289 CHI2 = MAX (SO4FR, ZERO)
7290 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
7299 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
7301 WATER = CHI2/M0(4) + CHI1/M0(2) + CHI7/M0(17) + CHI8/M0(21)
7302 WATER = MAX (WATER , TINY)
7304 !C *** INITIAL VALUES FOR BISECTION ************************************
7308 IF (CHI6.LE.TINY) GOTO 50
7309 !ccc IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
7310 !ccc IF (WATER .LE. TINY) RETURN ! No water
7312 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
7314 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
7318 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
7323 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
7325 IF (ABS(Y2) .GT. EPS) Y2 = FUNCO62p1 (PSI6LO)
7328 !C *** PERFORM BISECTION ***********************************************
7333 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
7340 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
7342 CALL PUSHERR2p1 (0002, 'CALCO6') ! WARNING ERROR: NO CONVERGENCE
7344 !C *** CONVERGED ; RETURN **********************************************
7349 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7352 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN ! If quadrat.called
7353 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
7354 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
7355 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
7356 MOLAL(6) = DELTA ! HSO4 EFFECT
7361 !C *** END OF SUBROUTINE CALCO6 *******************************************
7365 !C=======================================================================
7367 !C *** ISORROPIA CODE II
7368 !C *** SUBROUTINE FUNCO6
7371 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7372 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7373 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7374 !C 3. SOLIDS POSSIBLE : CaSO4 , K2SO4
7375 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MgSO4, NA2SO4
7376 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7377 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7378 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7380 !C=======================================================================
7382 DOUBLE PRECISION FUNCTION FUNCO62p1 (X)
7383 INCLUDE 'module_isrpia_inc.F'
7385 DOUBLE PRECISION LAMDA
7386 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7387 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7388 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7391 !C *** SETUP PARAMETERS ************************************************
7397 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7401 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
7402 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
7403 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
7404 A7 = XK17 *(WATER/GAMA(17))**3.0
7407 IF (CHI5.GE.TINY) THEN
7408 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
7409 PSI5 = MIN (PSI5,CHI5)
7414 !CCC IF(CHI4.GT.TINY) THEN
7415 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
7416 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
7417 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
7418 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
7419 PSI4 =0.5d0*(-BB - SQRT(DD))
7420 PSI4 = MAX (MIN (PSI4,CHI4), ZERO)
7425 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI7
7426 CALL POLY32p1 (PSI1+PSI2+PSI8, ZERO, -A7/4.D0, PSI7, ISLV)
7428 PSI7 = MAX (MIN (PSI7, CHI7), ZERO)
7437 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7439 MOLAL (2) = 2.0D0*PSI1 ! Na+
7440 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
7441 MOLAL (4) = PSI6 ! CLI
7442 MOLAL (5) = PSI1+PSI2+PSI7+PSI8 ! SO4I
7443 MOLAL (6) = ZERO ! HSO4
7444 MOLAL (7) = PSI5 ! NO3I
7445 MOLAL (8) = ZERO ! CaI
7446 MOLAL (9) = 2.0D0*PSI7 ! KI
7447 MOLAL (10)= PSI8 ! Mg
7450 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7453 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
7454 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
7455 -MOLAL(9)-2.D0*MOLAL(10)
7456 CALL CALCPH2p1 (SMIN, HI, OHI)
7459 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7461 GNH3 = MAX(CHI4 - PSI4, TINY)
7462 GHNO3 = MAX(CHI5 - PSI5, TINY)
7463 GHCL = MAX(CHI6 - PSI6, TINY)
7469 CK2SO4 = MAX(CHI7 - PSI7, TINY)
7473 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
7477 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7479 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7486 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
7488 20 FUNCO62p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
7489 !CCC FUNCG5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
7493 !C *** END OF FUNCTION FUNCO6 *******************************************
7498 !C=======================================================================
7500 !C *** ISORROPIA CODE II
7501 !C *** SUBROUTINE CALCO5
7504 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7505 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7506 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7507 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
7508 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MGSO4
7509 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7510 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7511 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7513 !C=======================================================================
7515 SUBROUTINE CALCO52p1
7516 INCLUDE 'module_isrpia_inc.F'
7518 DOUBLE PRECISION LAMDA
7519 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7520 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7521 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7524 !C *** SETUP PARAMETERS ************************************************
7527 CHI9 = MIN (W(6), W(2)) ! CCASO4
7528 SO4FR = MAX (W(2)-CHI9, ZERO)
7529 CAFR = MAX (W(6)-CHI9, ZERO)
7530 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
7531 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
7532 SO4FR = MAX (SO4FR - CHI7, ZERO)
7533 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
7534 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
7535 SO4FR = MAX (SO4FR - CHI1, ZERO)
7536 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
7537 FRMG = MAX(W(8) - CHI8, ZERO)
7538 SO4FR = MAX(SO4FR - CHI8, ZERO)
7542 CHI2 = MAX (SO4FR, ZERO)
7543 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
7551 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
7553 WATER = CHI2/M0(4) + CHI1/M0(2) + CHI7/M0(17) + CHI8/M0(21)
7554 WATER = MAX (WATER , TINY)
7556 !C *** INITIAL VALUES FOR BISECTION ************************************
7560 IF (CHI6.LE.TINY) GOTO 50
7561 !ccc IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
7562 !ccc IF (WATER .LE. TINY) RETURN ! No water
7564 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
7566 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
7570 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
7575 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
7577 IF (ABS(Y2) .GT. EPS) Y2 = FUNCO52p1 (PSI6LO)
7580 !C *** PERFORM BISECTION ***********************************************
7585 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
7592 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
7594 CALL PUSHERR2p1 (0002, 'CALCO5') ! WARNING ERROR: NO CONVERGENCE
7596 !C *** CONVERGED ; RETURN **********************************************
7601 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7604 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN ! If quadrat.called
7605 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
7606 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
7607 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
7608 MOLAL(6) = DELTA ! HSO4 EFFECT
7613 !C *** END OF SUBROUTINE CALCO5 *******************************************
7617 !C=======================================================================
7619 !C *** ISORROPIA CODE II
7620 !C *** SUBROUTINE FUNCO5
7623 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7624 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7625 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7626 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
7627 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4, MGSO4
7628 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7629 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7630 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7632 !C=======================================================================
7634 DOUBLE PRECISION FUNCTION FUNCO52p1 (X)
7635 INCLUDE 'module_isrpia_inc.F'
7637 DOUBLE PRECISION LAMDA
7638 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7639 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7640 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7643 !C *** SETUP PARAMETERS ************************************************
7649 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7653 A1 = XK5 *(WATER/GAMA(2))**3.0
7654 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
7655 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
7656 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
7657 A7 = XK17 *(WATER/GAMA(17))**3.0
7660 IF (CHI5.GE.TINY) THEN
7661 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
7662 PSI5 = MIN (PSI5,CHI5)
7667 !CCC IF(CHI4.GT.TINY) THEN
7668 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
7669 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
7670 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
7671 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
7672 PSI4 =0.5d0*(-BB - SQRT(DD))
7673 PSI4 = MAX (MIN (PSI4,CHI4), ZERO)
7678 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI7
7679 CALL POLY32p1 ((PSI2+PSI8)/(SQRT(A1/A7)+1.D0), ZERO, &
7680 -A7/4.D0/(SQRT(A1/A7)+1.D0), PSI7, ISLV)
7682 PSI7 = MAX (MIN (PSI7, CHI7), ZERO)
7690 IF (CHI1.GE.TINY) THEN ! PSI1
7691 PSI1 = SQRT(A1/A7)*PSI7
7692 PSI1 = MIN(PSI1,CHI1)
7698 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
7700 MOLAL (2) = 2.0D0*PSI1 ! NaI
7701 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
7702 MOLAL (4) = PSI6 ! CLI
7703 MOLAL (5) = PSI1+PSI2+PSI7+PSI8 ! SO4I
7704 MOLAL (6) = ZERO ! HSO4
7705 MOLAL (7) = PSI5 ! NO3I
7706 MOLAL (8) = ZERO ! CaI
7707 MOLAL (9) = 2.0D0*PSI7 ! KI
7708 MOLAL (10)= PSI8 ! Mg
7711 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7714 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
7715 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
7716 -MOLAL(9)-2.D0*MOLAL(10)
7717 CALL CALCPH2p1 (SMIN, HI, OHI)
7720 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7722 GNH3 = MAX(CHI4 - PSI4, TINY)
7723 GHNO3 = MAX(CHI5 - PSI5, TINY)
7724 GHCL = MAX(CHI6 - PSI6, TINY)
7726 CNA2SO4 = MAX(CHI1 - PSI1, TINY)
7730 CK2SO4 = MAX(CHI7 - PSI7, TINY)
7734 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
7738 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
7740 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
7747 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
7749 20 FUNCO52p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
7750 !CCC FUNCG5A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
7754 !C *** END OF FUNCTION FUNCO5 *******************************************
7759 !C=======================================================================
7761 !C *** ISORROPIA CODE II
7762 !C *** SUBROUTINE CALCO4
7765 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7766 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
7767 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7768 !C 3. SOLIDS POSSIBLE : NA2SO4, K2SO4, MGSO4, CASO4
7769 !C 4. Completely dissolved: NH4NO3, NH4CL, (NH4)2SO4
7770 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7771 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7772 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7774 !C=======================================================================
7776 SUBROUTINE CALCO42p1
7777 INCLUDE 'module_isrpia_inc.F'
7779 DOUBLE PRECISION LAMDA
7780 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7781 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7782 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7785 !C *** SETUP PARAMETERS ************************************************
7788 CHI9 = MIN (W(6), W(2)) ! CCASO4
7789 SO4FR = MAX (W(2)-CHI9, ZERO)
7790 CAFR = MAX (W(6)-CHI9, ZERO)
7791 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
7792 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
7793 SO4FR = MAX (SO4FR - CHI7, ZERO)
7794 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
7795 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
7796 SO4FR = MAX (SO4FR - CHI1, ZERO)
7797 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
7798 FRMG = MAX(W(8) - CHI8, ZERO)
7799 SO4FR = MAX(SO4FR - CHI8, ZERO)
7803 CHI2 = MAX (SO4FR, ZERO)
7804 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
7811 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
7813 WATER = CHI2/M0(4) + CHI1/M0(2) + CHI7/M0(17) + CHI8/M0(21)
7814 WATER = MAX (WATER , TINY)
7816 !C *** INITIAL VALUES FOR BISECTION ************************************
7820 IF (CHI6.LE.TINY) GOTO 50
7821 !CCC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
7822 !CCC IF (WATER .LE. TINY) GOTO 50 ! No water
7824 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
7826 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
7830 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
7835 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
7837 IF (ABS(Y2) .GT. EPS) Y2 = FUNCO42p1 (PSI6LO)
7840 !C *** PERFORM BISECTION ***********************************************
7845 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
7852 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
7854 CALL PUSHERR2p1 (0002, 'CALCO42p1') ! WARNING ERROR: NO CONVERGENCE
7856 !C *** CONVERGED ; RETURN **********************************************
7861 !C *** FINAL CALCULATIONS **********************************************
7865 !C *** Na2SO4 DISSOLUTION
7867 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
7868 CALL POLY32p1 (PSI2+PSI7+PSI8, ZERO, -A1/4.D0, PSI1, ISLV)
7870 PSI1 = MIN (PSI1, CHI1)
7877 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
7878 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
7879 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
7881 !C *** HSO4 equilibrium
7884 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
7885 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
7886 MOLAL(1) = MOLAL(1) - DELTA ! H+ AFFECT
7887 MOLAL(5) = MOLAL(5) - DELTA ! SO4 AFFECT
7888 MOLAL(6) = DELTA ! HSO4 AFFECT
7893 !C *** END OF SUBROUTINE CALCO4 ******************************************
7898 !C=======================================================================
7900 !C *** ISORROPIA CODE
7901 !C *** SUBROUTINE FUNCO4
7902 !C *** CASE O4 ; SUBCASE 1
7904 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
7905 !C 1. SULFATE POOR (SULRAT > 2.0) ; SODIUM POOR (SODRAT < 2.0)
7906 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
7907 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4
7909 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
7910 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
7911 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
7913 !C=======================================================================
7915 DOUBLE PRECISION FUNCTION FUNCO42p1 (X)
7916 INCLUDE 'module_isrpia_inc.F'
7918 DOUBLE PRECISION LAMDA
7919 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
7920 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
7921 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
7924 !C *** SETUP PARAMETERS ************************************************
7931 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
7935 A1 = XK5 *(WATER/GAMA(2))**3.0
7936 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
7937 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
7938 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
7939 A7 = XK17 *(WATER/GAMA(17))**3.0
7940 !C A8 = XK23 *(WATER/GAMA(21))**2.0
7942 !C CALCULATE DISSOCIATION QUANTITIES
7944 IF (CHI5.GE.TINY) THEN
7945 PSI5 = PSI6*CHI5/(A6/A5*(CHI6-PSI6) + PSI6)
7946 PSI5 = MIN (PSI5,CHI5)
7951 !CCC IF(CHI4.GT.TINY) THEN
7952 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
7953 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
7954 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
7955 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
7956 PSI4 =0.5d0*(-BB - SQRT(DD))
7957 PSI4 = MAX (MIN (PSI4,CHI4), ZERO)
7962 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI7
7963 CALL POLY32p1 (PSI2+PSI8, ZERO, -A7/4.D0, PSI7, ISLV)
7965 PSI7 = MAX (MIN (PSI7, CHI7), ZERO)
7973 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7975 MOLAL (2) = ZERO ! NAI
7976 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
7977 MOLAL (4) = PSI6 ! CLI
7978 MOLAL (5) = PSI2+PSI7+PSI8 ! SO4I
7979 MOLAL (6) = ZERO ! HSO4
7980 MOLAL (7) = PSI5 ! NO3I
7981 MOLAL (8) = ZERO ! CAI
7982 MOLAL (9) = 2.0D0*PSI7 ! KI
7983 MOLAL (10)= PSI8 ! MGI
7986 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
7989 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
7990 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
7991 -MOLAL(9)-2.D0*MOLAL(10)
7992 CALL CALCPH2p1 (SMIN, HI, OHI)
7995 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
7997 GNH3 = MAX(CHI4 - PSI4, TINY)
7998 GHNO3 = MAX(CHI5 - PSI5, TINY)
7999 GHCL = MAX(CHI6 - PSI6, TINY)
8004 CK2SO4 = MAX(CHI7 - PSI7, TINY)
8008 CALL CALCMR2p1 ! Water content
8010 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8012 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8019 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
8021 20 FUNCO42p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
8022 !CCC FUNCO4 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
8026 !C *** END OF FUNCTION FUNCO4 *******************************************
8030 !C=======================================================================
8032 !C *** ISORROPIA CODE II
8033 !C *** SUBROUTINE CALCO3
8036 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8037 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
8038 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
8039 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
8041 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8042 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8043 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8045 !C=======================================================================
8047 SUBROUTINE CALCO32p1
8048 INCLUDE 'module_isrpia_inc.F'
8049 EXTERNAL CALCO1A2p1, CALCO42p1
8051 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
8053 IF (W(4).GT.TINY .AND. W(5).GT.TINY) THEN ! NO3,CL EXIST, WATER POSSIBLE
8054 SCASE = 'O3 ; SUBCASE 1'
8056 SCASE = 'O3 ; SUBCASE 1'
8057 ELSE ! NO3, CL NON EXISTANT
8058 SCASE = 'O1 ; SUBCASE 1'
8060 SCASE = 'O1 ; SUBCASE 1'
8063 IF (WATER.LE.TINY) THEN
8064 IF (RH.LT.DRMO3) THEN ! ONLY SOLIDS
8070 SCASE = 'O3 ; SUBCASE 2'
8073 SCASE = 'O3 ; SUBCASE 3' ! MDRH REGION (NA2SO4, NH42S4, K2SO4, MGSO4, CASO4)
8074 CALL CALCMDRH22p1 (RH, DRMO3, DRNH42S4, CALCO1A2p1, CALCO42p1)
8075 SCASE = 'O3 ; SUBCASE 3'
8081 !C *** END OF SUBROUTINE CALCO3 ******************************************
8085 !C=======================================================================
8087 !C *** ISORROPIA CODE II
8088 !C *** SUBROUTINE CALCO3A
8089 !C *** CASE O3 ; SUBCASE 1
8091 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8092 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
8093 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8094 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, K2SO4, MGSO4, CASO4
8095 !C 4. Completely dissolved: NH4NO3, NH4CL
8097 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8098 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8099 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8101 !C=======================================================================
8103 SUBROUTINE CALCO3A2p1
8104 INCLUDE 'module_isrpia_inc.F'
8106 DOUBLE PRECISION LAMDA
8107 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8108 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
8109 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
8112 !C *** SETUP PARAMETERS ************************************************
8115 CHI9 = MIN (W(6), W(2)) ! CCASO4
8116 SO4FR = MAX (W(2)-CHI9, ZERO)
8117 CAFR = MAX (W(6)-CHI9, ZERO)
8118 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
8119 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
8120 SO4FR = MAX (SO4FR - CHI7, ZERO)
8121 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
8122 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
8123 SO4FR = MAX (SO4FR - CHI1, ZERO)
8124 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
8125 FRMG = MAX(W(8) - CHI8, ZERO)
8126 SO4FR = MAX(SO4FR - CHI8, ZERO)
8130 CHI2 = MAX (SO4FR, ZERO)
8131 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
8139 !C *** INITIAL VALUES FOR BISECTION ************************************
8142 Y1 = FUNCO3A2p1 (X1)
8143 IF (CHI6.LE.TINY) GOTO 50
8144 !CCC IF (ABS(Y1).LE.EPS .OR. CHI7.LE.TINY) GOTO 50
8145 !CCC IF (WATER .LE. TINY) GOTO 50 ! No water
8147 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
8149 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
8152 Y2 = FUNCO3A2p1 (X2)
8153 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
8158 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
8160 IF (ABS(Y2) .GT. EPS) Y2 = FUNCO3A2p1 (PSI6LO)
8163 !C *** PERFORM BISECTION ***********************************************
8167 Y3 = FUNCO3A2p1 (X3)
8168 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
8175 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
8177 CALL PUSHERR2p1 (0002, 'CALCO3A2p1') ! WARNING ERROR: NO CONVERGENCE
8179 !C *** CONVERGED ; RETURN **********************************************
8182 Y3 = FUNCO3A2p1 (X3)
8184 !C *** FINAL CALCULATIONS *************************************************
8188 !C *** Na2SO4 DISSOLUTION
8190 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
8191 CALL POLY32p1 (PSI2+PSI7+PSI8, ZERO, -A1/4.D0, PSI1, ISLV)
8193 PSI1 = MIN (max (PSI1, zero), CHI1)
8200 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
8201 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
8202 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
8204 !C *** HSO4 equilibrium
8206 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
8207 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
8208 MOLAL(1) = MOLAL(1) - DELTA ! H+ AFFECT
8209 MOLAL(5) = MOLAL(5) - DELTA ! SO4 AFFECT
8210 MOLAL(6) = DELTA ! HSO4 AFFECT
8215 !C *** END OF SUBROUTINE CALCO3A ******************************************
8219 !C=======================================================================
8221 !C *** ISORROPIA CODE II
8222 !C *** SUBROUTINE FUNCO3A
8223 !C *** CASE O3; SUBCASE 1
8225 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8226 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
8227 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8228 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NA2SO4, K2SO4, MgSO4, CaSO4
8229 !C 4. Completely dissolved: NH4NO3, NH4CL
8231 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8232 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8233 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8235 !C=======================================================================
8237 DOUBLE PRECISION FUNCTION FUNCO3A2p1 (X)
8238 INCLUDE 'module_isrpia_inc.F'
8240 DOUBLE PRECISION LAMDA
8241 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8242 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
8243 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
8246 !C *** SETUP PARAMETERS ************************************************
8256 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8260 A1 = XK5 *(WATER/GAMA(2))**3.0D0
8261 A2 = XK7 *(WATER/GAMA(4))**3.0D0
8262 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0D0
8263 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0D0
8264 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0D0
8265 A7 = XK17 *(WATER/GAMA(17))**3.0D0
8266 !C A8 = XK23 *(WATER/GAMA(21))**2.0D0
8269 !C CALCULATE DISSOCIATION QUANTITIES
8271 DENO = MAX(CHI6-PSI6-PSI3, ZERO)
8272 PSI5 = PSI6*CHI5/(A6/A5*DENO + PSI6)
8273 PSI5 = MIN(MAX(PSI5,ZERO),CHI5)
8275 !CCC IF(CHI4.GT.TINY) THEN ! PSI4
8276 IF(W(2).GT.TINY) THEN ! Accounts for NH3 evaporation
8277 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
8278 CC = CHI4*(PSI5+PSI6) - 2.d0*PSI2/A4
8279 DD = MAX(BB*BB-4.d0*CC,ZERO) ! Patch proposed by Uma Shankar, 19/11/01
8280 PSI4 =0.5d0*(-BB - SQRT(DD))
8284 PSI4 = MIN (MAX (PSI4,ZERO), CHI4)
8286 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI7
8287 CALL POLY32p1 (PSI2+PSI8, ZERO, -A7/4.D0, PSI7, ISLV)
8289 PSI7 = MAX (MIN (PSI7, CHI7), ZERO)
8297 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
8298 CALL POLY32p1 (PSI7+PSI8+PSI4, PSI4*(PSI7+PSI8)+ &
8299 PSI4*PSI4/4.D0, (PSI4*PSI4*(PSI7+PSI8)-A2) &
8301 IF (ISLV.EQ.0) PSI2 = MIN (MAX(PSI20,ZERO), CHI2)
8303 !C PSI2 = 0.5D0*(2.0D0*SQRT(A2/A7)*PSI7 - PSI4)
8304 !C PSI2 = MIN (MAX(PSI2, ZERO), CHI2)
8307 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8309 MOLAL (2) = ZERO ! NaI
8310 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
8311 MOLAL (4) = PSI6 ! CLI
8312 MOLAL (5) = PSI2+PSI7+PSI8 ! SO4I
8313 MOLAL (6) = ZERO ! HSO4
8314 MOLAL (7) = PSI5 ! NO3I
8315 MOLAL (8) = ZERO ! CAI
8316 MOLAL (9) = 2.0D0*PSI7 ! KI
8317 MOLAL (10)= PSI8 ! MGI
8319 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
8320 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
8321 -MOLAL(9)-2.D0*MOLAL(10)
8322 CALL CALCPH2p1 (SMIN, HI, OHI)
8325 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8327 GNH3 = MAX(CHI4 - PSI4, TINY)
8328 GHNO3 = MAX(CHI5 - PSI5, TINY)
8329 GHCL = MAX(CHI6 - PSI6, TINY)
8331 !C CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
8332 CNH42S4 = MAX(CHI2 - PSI2, ZERO)
8335 CK2SO4 = MAX(CHI7 - PSI7, ZERO)
8339 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES **********************
8343 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8345 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8352 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
8354 20 FUNCO3A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
8359 !C *** END OF FUNCTION FUNCO3A *******************************************
8364 !C=======================================================================
8366 !C *** ISORROPIA CODE II
8367 !C *** SUBROUTINE CALCO2
8370 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8371 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
8372 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
8373 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
8375 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8376 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8377 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8379 !C=======================================================================
8381 SUBROUTINE CALCO22p1
8382 INCLUDE 'module_isrpia_inc.F'
8383 EXTERNAL CALCO1A2p1, CALCO3A2p1, CALCO42p1
8385 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
8387 IF (W(4).GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
8388 SCASE = 'O2 ; SUBCASE 1'
8390 SCASE = 'O2 ; SUBCASE 1'
8391 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
8392 SCASE = 'O1 ; SUBCASE 1'
8394 SCASE = 'O1 ; SUBCASE 1'
8397 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
8399 IF (WATER.LE.TINY) THEN
8400 IF (RH.LT.DRMO2) THEN ! ONLY SOLIDS
8406 SCASE = 'O2 ; SUBCASE 2'
8408 IF (W(5).GT. TINY) THEN
8409 SCASE = 'O2 ; SUBCASE 3' ! MDRH (NH4CL, NA2SO4, NH42S4, K2SO4, MGSO4, CASO4)
8410 CALL CALCMDRH22p1 (RH, DRMO2, DRNH4CL, CALCO1A2p1, CALCO3A2p1)
8411 SCASE = 'O2 ; SUBCASE 3'
8413 IF (WATER.LE.TINY .AND. RH.GE.DRMO3) THEN
8414 SCASE = 'O2 ; SUBCASE 4' ! MDRH (NA2SO4, NH42S4, K2SO4, MGSO4, CASO4)
8415 CALL CALCMDRH22p1 (RH, DRMO3, DRNH42S4, CALCO1A2p1, CALCO42p1)
8416 SCASE = 'O2 ; SUBCASE 4'
8423 SCASE = 'O2 ; SUBCASE 2'
8430 !C *** END OF SUBROUTINE CALCO2 ******************************************
8434 !C=======================================================================
8436 !C *** ISORROPIA CODE II
8437 !C *** SUBROUTINE CALCO2A
8438 !C *** CASE O2 ; SUBCASE 1
8440 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8441 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
8442 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8443 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4, K2SO4, MgSO4, CaSO4
8444 !C 4. Completely dissolved: NH4NO3
8446 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8447 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8448 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8450 !C=======================================================================
8452 SUBROUTINE CALCO2A2p1
8453 INCLUDE 'module_isrpia_inc.F'
8455 DOUBLE PRECISION LAMDA
8456 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8457 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
8458 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
8461 !C *** SETUP PARAMETERS *************************************************
8464 CHI9 = MIN (W(6), W(2)) ! CCASO4
8465 SO4FR = MAX (W(2)-CHI9, ZERO)
8466 CAFR = MAX (W(6)-CHI9, ZERO)
8467 CHI7 = MIN (0.5D0*W(7), SO4FR) ! CK2SO4
8468 FRK = MAX (W(7) - 2.D0*CHI7, ZERO)
8469 SO4FR = MAX (SO4FR - CHI7, ZERO)
8470 CHI1 = MIN (0.5D0*W(1), SO4FR) ! NA2SO4
8471 NAFR = MAX (W(1) - 2.D0*CHI1, ZERO)
8472 SO4FR = MAX (SO4FR - CHI1, ZERO)
8473 CHI8 = MIN (W(8), SO4FR) ! CMGSO4
8474 FRMG = MAX(W(8) - CHI8, ZERO)
8475 SO4FR = MAX(SO4FR - CHI8, ZERO)
8479 CHI2 = MAX (SO4FR, ZERO)
8480 CHI4 = MAX (W(3)-2.D0*CHI2, ZERO)
8488 !C *** INITIAL VALUES FOR BISECTION *************************************
8491 Y1 = FUNCO2A2p1 (X1)
8492 IF (CHI6.LE.TINY) GOTO 50
8493 !CCC IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
8494 !CCC IF (WATER .LE. TINY) GOTO 50 ! No water
8496 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO ***********************
8498 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
8501 Y2 = FUNCO2A2p1 (X2)
8502 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
8507 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
8509 IF (ABS(Y2) .GT. EPS) WATER = TINY
8512 !C *** PERFORM BISECTION ************************************************
8516 Y3 = FUNCO2A2p1 (X3)
8517 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
8524 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
8526 CALL PUSHERR2p1 (0002, 'CALCO2A') ! WARNING ERROR: NO CONVERGENCE
8528 !C *** CONVERGED ; RETURN ***********************************************
8531 IF (X3.LE.TINY2) THEN ! PRACTICALLY NO NITRATES, SO DRY SOLUTION
8534 Y3 = FUNCO2A2p1 (X3)
8537 !C *** FINAL CALCULATIONS *************************************************
8541 !C *** Na2SO4 DISSOLUTION
8543 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI1
8544 CALL POLY32p1 (PSI2+PSI7+PSI8, ZERO, -A1/4.D0, PSI1, ISLV)
8546 PSI1 = MIN (PSI1, CHI1)
8553 MOLAL(2) = 2.0D0*PSI1 ! Na+ EFFECT
8554 MOLAL(5) = MOLAL(5) + PSI1 ! SO4 EFFECT
8555 CNA2SO4 = MAX(CHI1 - PSI1, ZERO) ! NA2SO4(s) depletion
8557 !C *** HSO4 equilibrium
8559 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
8560 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
8561 MOLAL(1) = MOLAL(1) - DELTA ! H+ AFFECT
8562 MOLAL(5) = MOLAL(5) - DELTA ! SO4 AFFECT
8563 MOLAL(6) = DELTA ! HSO4 AFFECT
8568 !C *** END OF SUBROUTINE CALCO2A ******************************************
8572 !C=======================================================================
8574 !C *** ISORROPIA CODE II
8575 !C *** SUBROUTINE FUNCO2A
8576 !C *** CASE O2; SUBCASE 1
8578 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8579 !C 1. (Rsulfate > 2.0 ; R(Cr+Na) < 2.0)
8580 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8581 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4CL, NA2SO4, K2SO4, MgSO4, CaSO4
8582 !C 4. Completely dissolved: NH4NO3
8583 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8584 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8585 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8587 !C=======================================================================
8589 DOUBLE PRECISION FUNCTION FUNCO2A2p1 (X)
8590 INCLUDE 'module_isrpia_inc.F'
8592 DOUBLE PRECISION LAMDA
8593 COMMON /CASEO2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8594 CHI9, LAMDA, PSI1, PSI2, PSI3, PSI4, PSI5, &
8595 PSI6, PSI7, PSI8, PSI9, A1, A2, A3, A4, &
8598 !C *** SETUP PARAMETERS ************************************************
8607 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
8611 A1 = XK5 *(WATER/GAMA(2))**3.0D0
8612 A2 = XK7 *(WATER/GAMA(4))**3.0D0
8613 A3 = XK6 /(R*TEMP*R*TEMP)
8614 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0D0
8615 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0D0
8616 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0D0
8618 A7 = XK17 *(WATER/GAMA(17))**3.0D0
8619 !C A8 = XK23 *(WATER/GAMA(21))**2.0D0
8621 DENO = MAX(CHI6-PSI6-PSI3, ZERO)
8622 PSI5 = PSI6*CHI5/(A6/A5*DENO + PSI6)
8623 PSI5 = MIN(PSI5,CHI5)
8625 PSI4 = MIN(PSI5+PSI6,CHI4)
8628 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! PSI7
8629 CALL POLY32p1 (PSI2+PSI8, ZERO, -A7/4.D0, PSI7, ISLV)
8631 PSI7 = MAX (MIN (PSI7, CHI7), ZERO)
8639 IF (CHI2.GT.TINY .AND. WATER.GT.TINY) THEN
8640 CALL POLY32p1 (PSI7+PSI8+PSI4, PSI4*(PSI7+PSI8)+ &
8641 PSI4*PSI4/4.D0, (PSI4*PSI4*(PSI7+PSI8)-A2) &
8643 IF (ISLV.EQ.0) PSI2 = MIN (MAX(PSI20,ZERO), CHI2)
8645 !C PSI2 = 0.5D0*(2.0D0*SQRT(A2/A7)*PSI7 - PSI4)
8646 !C PSI2 = MIN (PSI2, CHI2)
8649 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
8651 MOLAL (2) = ZERO ! NaI
8652 MOLAL (3) = 2.0D0*PSI2 + PSI4 ! NH4I
8653 MOLAL (4) = PSI6 ! CLI
8654 MOLAL (5) = PSI2+PSI7+PSI8 ! SO4I
8655 MOLAL (6) = ZERO ! HSO4
8656 MOLAL (7) = PSI5 ! NO3I
8657 MOLAL (8) = ZERO ! CAI
8658 MOLAL (9) = 2.0D0*PSI7 ! KI
8659 MOLAL (10)= PSI8 ! MGI
8661 !CCC MOLAL (1) = MAX(CHI5 - PSI5, TINY)*A5/PSI5 ! HI
8662 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
8663 -MOLAL(9)-2.D0*MOLAL(10)
8664 CALL CALCPH2p1 (SMIN, HI, OHI)
8667 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8669 GNH3 = MAX(CHI4 - PSI4, TINY)
8670 GHNO3 = MAX(CHI5 - PSI5, TINY)
8671 GHCL = MAX(CHI6 - PSI6, TINY)
8673 !C CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
8674 CNH42S4 = MAX(CHI2 - PSI2, ZERO)
8676 CK2SO4 = MAX(CHI7 - PSI7, ZERO)
8681 !C *** NH4Cl(s) calculations
8683 A3 = XK6 /(R*TEMP*R*TEMP)
8684 IF (GNH3*GHCL.GT.A3) THEN
8685 DELT = MIN(GNH3, GHCL)
8688 DD = BB*BB - 4.D0*CC
8689 PSI31 = 0.5D0*(-BB + SQRT(DD))
8690 PSI32 = 0.5D0*(-BB - SQRT(DD))
8691 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
8693 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
8701 PSI3 = MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6)
8703 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
8705 GNH3 = MAX(GNH3 - PSI3, TINY)
8706 GHCL = MAX(GHCL - PSI3, TINY)
8709 !C *** CALCULATE MOLALR ARRAY, WATER AND ACTIVITIES *********************
8713 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
8715 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
8722 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP **************************
8725 !C20 IF (CHI4.LE.TINY) THEN
8726 !C FUNCO2A = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
8728 20 FUNCO2A2p1 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
8733 !C *** END OF FUNCTION FUNCO2A ****************************************
8737 !C=======================================================================
8739 !C *** ISORROPIA CODE II
8740 !C *** SUBROUTINE CALCO1
8743 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8744 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
8745 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
8746 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
8748 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
8749 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
8750 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCO1A)
8752 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
8753 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8754 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
8756 !C=======================================================================
8758 SUBROUTINE CALCO12p1
8759 INCLUDE 'module_isrpia_inc.F'
8760 EXTERNAL CALCO1A2p1, CALCO2A2p1
8762 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
8764 IF (RH.LT.DRMO1) THEN
8765 SCASE = 'O1 ; SUBCASE 1'
8766 CALL CALCO1A2p1 ! SOLID PHASE ONLY POSSIBLE
8767 SCASE = 'O1 ; SUBCASE 1'
8769 SCASE = 'O1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
8770 CALL CALCMDRH22p1 (RH, DRMO1, DRNH4NO3, CALCO1A2p1, CALCO2A2p1)
8771 SCASE = 'O1 ; SUBCASE 2'
8776 !C *** END OF SUBROUTINE CALCO1 ******************************************
8779 !C=======================================================================
8781 !C *** ISORROPIA CODE II
8782 !C *** SUBROUTINE CALCO1A
8785 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8786 !C 1. SULFATE POOR (SO4RAT > 2.0), Cr+NA poor (CRNARAT < 2)
8787 !C 2. SOLID AEROSOL ONLY
8788 !C 3. SOLIDS POSSIBLE : (NH4)2SO4, NH4NO3, NH4Cl, NA2SO4, K2SO4, MGSO4, CASO4
8790 !C SOLID (NH4)2SO4 IS CALCULATED FROM THE SULFATES, WHILE NH4NO3
8791 !C IS CALCULATED FROM NH3-HNO3 EQUILIBRIUM. 'ZE' IS THE AMOUNT OF
8792 !C NH4NO3 THAT VOLATIZES WHEN ALL POSSILBE NH4NO3 IS INITIALLY IN
8795 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8796 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8797 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8799 !C=======================================================================
8801 SUBROUTINE CALCO1A2p1
8802 INCLUDE 'module_isrpia_inc.F'
8803 DOUBLE PRECISION LAMDA, LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2
8805 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
8807 CCASO4 = MIN (W(6), W(2)) ! CCASO4
8808 SO4FR = MAX(W(2) - CCASO4, ZERO)
8809 CAFR = MAX(W(6) - CCASO4, ZERO)
8810 CK2SO4 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
8811 FRK = MAX(W(7) - 2.D0*CK2SO4, ZERO)
8812 SO4FR = MAX(SO4FR - CK2SO4, ZERO)
8813 CNA2SO4 = MIN (0.5D0*W(1), SO4FR) ! CNA2SO4
8814 FRNA = MAX(W(1) - 2.D0*CNA2SO4, ZERO)
8815 SO4FR = MAX(SO4FR - CNA2SO4, ZERO)
8816 CMGSO4 = MIN (W(8), SO4FR) ! CMGSO4
8817 FRMG = MAX(W(8) - CMGSO4, ZERO)
8818 SO4FR = MAX(SO4FR - CMGSO4, ZERO)
8820 CNH42S4 = MAX (SO4FR , ZERO) ! CNH42S4
8822 !C *** CALCULATE VOLATILE SPECIES **************************************
8824 ALF = W(3) - 2.0D0*CNH42S4
8828 RTSQ = R*TEMP*R*TEMP
8833 THETA1 = GAM - BET*(A2/A1)
8836 !C QUADRATIC EQUATION SOLUTION
8838 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
8839 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
8840 DD = BB*BB - 4.0D0*CC
8841 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
8843 !C TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
8846 KAPA1 = 0.5D0*(-BB+SQDD)
8847 KAPA2 = 0.5D0*(-BB-SQDD)
8848 LAMDA1 = THETA1 + THETA2*KAPA1
8849 LAMDA2 = THETA1 + THETA2*KAPA2
8851 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
8852 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
8853 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
8860 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
8861 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
8862 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
8869 !C SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
8873 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
8874 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
8876 !C NH4CL EQUILIBRIUM
8878 IF (DD1.GE.ZERO) THEN
8880 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
8881 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
8883 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
8885 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
8892 !C NH4NO3 EQUILIBRIUM
8894 IF (DD2.GE.ZERO) THEN
8896 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
8897 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
8899 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
8901 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
8908 !C IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
8910 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
8911 IF (BET .LT. LAMDA/THETA1) THEN
8918 !C *** CALCULATE COMPOSITION OF VOLATILE SPECIES ************************
8924 GNH3 = MAX(ALF - KAPA - LAMDA, ZERO)
8925 GHNO3 = MAX(GAM - LAMDA, ZERO)
8926 GHCL = MAX(BET - KAPA, ZERO)
8930 !C *** END OF SUBROUTINE CALCO1A *****************************************
8934 !C=======================================================================
8936 !C *** ISORROPIA CODE II
8937 !C *** SUBROUTINE CALCM8
8940 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
8941 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
8942 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
8943 !C 3. SOLIDS POSSIBLE : CaSO4
8944 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4, NA2SO4, K2SO4
8946 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
8947 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
8948 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
8950 !C=======================================================================
8952 SUBROUTINE CALCM82p1
8953 INCLUDE 'module_isrpia_inc.F'
8955 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
8956 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
8957 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
8958 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
8959 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
8960 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
8962 !C *** SETUP PARAMETERS ************************************************
8965 CHI11 = MIN (W(6), W(2)) ! CCASO4
8966 SO4FR = MAX(W(2)-CHI11, ZERO)
8967 CAFR = MAX(W(6)-CHI11, ZERO)
8968 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
8969 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
8970 SO4FR = MAX(SO4FR-CHI9, ZERO)
8971 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
8972 FRMG = MAX(W(8)-CHI10, ZERO)
8973 SO4FR = MAX(SO4FR-CHI10, ZERO)
8974 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
8975 CHI2 = ZERO ! CNH42S4
8976 CHI3 = ZERO ! CNH4CL
8977 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
8978 CHI8 = MIN (FRNA, W(4)) ! CNANO3
8979 CHI4 = W(3) ! NH3(g)
8980 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
8981 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
8982 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
8985 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
8987 !C *** INITIAL VALUES FOR BISECTION ************************************
8991 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
8993 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
8995 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
8999 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9004 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
9006 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM82p1 (PSI6LO)
9009 !C *** PERFORM BISECTION ***********************************************
9014 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9021 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9023 CALL PUSHERR2p1 (0002, 'CALCM8') ! WARNING ERROR: NO CONVERGENCE
9025 !C *** CONVERGED ; RETURN **********************************************
9030 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
9033 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
9034 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
9035 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
9036 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
9037 MOLAL(6) = DELTA ! HSO4 EFFECT
9042 !C *** END OF SUBROUTINE CALCM8 ******************************************
9049 !C=======================================================================
9051 !C *** ISORROPIA CODE II
9052 !C *** SUBROUTINE FUNCM8
9055 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9056 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9057 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9058 !C 3. SOLIDS POSSIBLE : CaSO4
9059 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4, NA2SO4, K2SO4
9061 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9062 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9064 !C=======================================================================
9066 DOUBLE PRECISION FUNCTION FUNCM82p1 (X)
9067 INCLUDE 'module_isrpia_inc.F'
9069 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9070 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9071 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9072 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9073 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9074 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9076 !C *** SETUP PARAMETERS ************************************************
9090 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9094 !C A1 = XK5 *(WATER/GAMA(2))**3.0
9095 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
9096 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
9097 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
9098 !C A7 = XK8 *(WATER/GAMA(1))**2.0
9099 !C A8 = XK9 *(WATER/GAMA(3))**2.0
9100 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9102 !C CALCULATE DISSOCIATION QUANTITIES
9104 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
9105 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
9106 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
9108 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
9109 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
9110 CC = CHI4*(PSI5+PSI6)
9111 DD = MAX(BB*BB-4.d0*CC,ZERO)
9112 PSI4 =0.5d0*(-BB - SQRT(DD))
9113 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
9118 !C *** CALCULATE SPECIATION ********************************************
9120 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
9121 MOLAL (3) = PSI4 ! NH4I
9122 MOLAL (4) = PSI6 + PSI7 ! CLI
9123 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
9124 MOLAL (6) = ZERO ! HSO4I
9125 MOLAL (7) = PSI5 + PSI8 ! NO3I
9126 MOLAL (8) = PSI11 ! CAI
9127 MOLAL (9) = 2.D0*PSI9 ! KI
9128 MOLAL (10)= PSI10 ! MGI
9130 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
9131 - MOLAL(9) - 2.D0*MOLAL(10)
9132 CALL CALCPH2p1 (SMIN, HI, OHI)
9135 GNH3 = MAX(CHI4 - PSI4, TINY)
9136 GHNO3 = MAX(CHI5 - PSI5, TINY)
9137 GHCL = MAX(CHI6 - PSI6, TINY)
9148 CALL CALCMR2p1 ! Water content
9150 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9152 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9159 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
9161 !C20 FUNCM8 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
9162 20 FUNCM82p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
9166 !C *** END OF FUNCTION FUNCM8 *******************************************
9171 !C=======================================================================
9173 !C *** ISORROPIA CODE II
9174 !C *** SUBROUTINE CALCM7
9177 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9178 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9179 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9180 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4
9181 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4, NA2SO4
9183 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9184 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9186 !C=======================================================================
9188 SUBROUTINE CALCM72p1
9189 INCLUDE 'module_isrpia_inc.F'
9191 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9192 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9193 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9194 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9195 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9196 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9198 !C *** SETUP PARAMETERS ************************************************
9201 CHI11 = MIN (W(6), W(2)) ! CCASO4
9202 SO4FR = MAX(W(2)-CHI11, ZERO)
9203 CAFR = MAX(W(6)-CHI11, ZERO)
9204 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
9205 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
9206 SO4FR = MAX(SO4FR-CHI9, ZERO)
9207 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
9208 FRMG = MAX(W(8)-CHI10, ZERO)
9209 SO4FR = MAX(SO4FR-CHI10, ZERO)
9210 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
9211 CHI2 = ZERO ! CNH42S4
9212 CHI3 = ZERO ! CNH4CL
9213 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
9214 CHI8 = MIN (FRNA, W(4)) ! CNANO3
9215 CHI4 = W(3) ! NH3(g)
9216 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
9217 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
9218 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
9221 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
9223 !C *** INITIAL VALUES FOR BISECTION ************************************
9227 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
9229 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
9231 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
9235 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9240 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
9242 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM72p1 (PSI6LO)
9245 !C *** PERFORM BISECTION ***********************************************
9250 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9257 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9259 CALL PUSHERR2p1 (0002, 'CALCM7') ! WARNING ERROR: NO CONVERGENCE
9261 !C *** CONVERGED ; RETURN **********************************************
9266 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
9269 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
9270 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
9271 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
9272 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
9273 MOLAL(6) = DELTA ! HSO4 EFFECT
9278 !C *** END OF SUBROUTINE CALCM7 ******************************************
9283 !C=======================================================================
9285 !C *** ISORROPIA CODE II
9286 !C *** SUBROUTINE FUNCM7
9289 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9290 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9291 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9292 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4
9293 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4, NA2SO4
9295 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9296 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9298 !C=======================================================================
9300 DOUBLE PRECISION FUNCTION FUNCM72p1 (X)
9301 INCLUDE 'module_isrpia_inc.F'
9303 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9304 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9305 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9306 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9307 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9308 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9310 !C *** SETUP PARAMETERS ************************************************
9324 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9328 !C A1 = XK5 *(WATER/GAMA(2))**3.0
9329 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
9330 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
9331 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
9332 A9 = XK17 *(WATER/GAMA(17))**3.0
9333 !C A7 = XK8 *(WATER/GAMA(1))**2.0
9334 !C A8 = XK9 *(WATER/GAMA(3))**2.0
9335 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9337 !C CALCULATE DISSOCIATION QUANTITIES
9339 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
9340 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
9341 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
9343 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
9344 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
9345 CC = CHI4*(PSI5+PSI6)
9346 DD = MAX(BB*BB-4.d0*CC,ZERO)
9347 PSI4 =0.5d0*(-BB - SQRT(DD))
9348 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
9353 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
9354 CALL POLY32p1 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
9356 PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
9362 !C *** CALCULATE SPECIATION ********************************************
9364 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
9365 MOLAL (3) = PSI4 ! NH4I
9366 MOLAL (4) = PSI6 + PSI7 ! CLI
9367 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
9368 MOLAL (6) = ZERO ! HSO4I
9369 MOLAL (7) = PSI5 + PSI8 ! NO3I
9370 MOLAL (8) = PSI11 ! CAI
9371 MOLAL (9) = 2.D0*PSI9 ! KI
9372 MOLAL (10)= PSI10 ! MGI
9374 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
9375 - MOLAL(9) - 2.D0*MOLAL(10)
9376 CALL CALCPH2p1 (SMIN, HI, OHI)
9379 GNH3 = MAX(CHI4 - PSI4, TINY)
9380 GHNO3 = MAX(CHI5 - PSI5, TINY)
9381 GHCL = MAX(CHI6 - PSI6, TINY)
9388 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
9392 CALL CALCMR2p1 ! Water content
9394 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9396 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9403 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
9405 !C20 FUNCM7 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
9406 20 FUNCM72p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
9410 !C *** END OF FUNCTION FUNCM7 *******************************************
9413 !C=======================================================================
9415 !C *** ISORROPIA CODE II
9416 !C *** SUBROUTINE CALCM6
9419 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9420 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9421 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9422 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4
9423 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4
9425 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9426 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9428 !C=======================================================================
9430 SUBROUTINE CALCM62p1
9431 INCLUDE 'module_isrpia_inc.F'
9433 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9434 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9435 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9436 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9437 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9438 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9440 !C *** SETUP PARAMETERS ************************************************
9443 CHI11 = MIN (W(6), W(2)) ! CCASO4
9444 SO4FR = MAX(W(2)-CHI11, ZERO)
9445 CAFR = MAX(W(6)-CHI11, ZERO)
9446 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
9447 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
9448 SO4FR = MAX(SO4FR-CHI9, ZERO)
9449 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
9450 FRMG = MAX(W(8)-CHI10, ZERO)
9451 SO4FR = MAX(SO4FR-CHI10, ZERO)
9452 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
9453 CHI2 = ZERO ! CNH42S4
9454 CHI3 = ZERO ! CNH4CL
9455 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
9456 CHI8 = MIN (FRNA, W(4)) ! CNANO3
9457 CHI4 = W(3) ! NH3(g)
9458 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
9459 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
9460 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
9463 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
9465 !C *** INITIAL VALUES FOR BISECTION ************************************
9469 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
9471 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
9473 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
9477 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9482 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
9484 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM62p1 (PSI6LO)
9487 !C *** PERFORM BISECTION ***********************************************
9492 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9499 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9501 CALL PUSHERR2p1 (0002, 'CALCM6') ! WARNING ERROR: NO CONVERGENCE
9503 !C *** CONVERGED ; RETURN **********************************************
9508 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
9511 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
9512 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
9513 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
9514 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
9515 MOLAL(6) = DELTA ! HSO4 EFFECT
9520 !C *** END OF SUBROUTINE CALCM6 ******************************************
9524 !C=======================================================================
9526 !C *** ISORROPIA CODE II
9527 !C *** SUBROUTINE FUNCM6
9530 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9531 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9532 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9533 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4
9534 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL, MgSO4
9536 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9537 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9539 !C=======================================================================
9541 DOUBLE PRECISION FUNCTION FUNCM62p1 (X)
9542 INCLUDE 'module_isrpia_inc.F'
9544 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9545 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9546 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9547 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9548 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9549 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9551 !C *** SETUP PARAMETERS ************************************************
9565 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9569 A1 = XK5 *(WATER/GAMA(2))**3.0
9570 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
9571 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
9572 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
9573 A9 = XK17 *(WATER/GAMA(17))**3.0
9574 !C A7 = XK8 *(WATER/GAMA(1))**2.0
9575 !C A8 = XK9 *(WATER/GAMA(3))**2.0
9576 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9578 !C CALCULATE DISSOCIATION QUANTITIES
9580 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
9581 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
9582 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
9584 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
9585 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
9586 CC = CHI4*(PSI5+PSI6)
9587 DD = MAX(BB*BB-4.d0*CC,ZERO)
9588 PSI4 =0.5d0*(-BB - SQRT(DD))
9589 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
9594 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN !NA2SO4
9596 AA = (0.5D0*RIZ*(PSI7+PSI8)+PSI10+(1.D0+RIZ)*(PSI7+PSI8)) &
9598 BB = ((PSI7+PSI8)*(0.5D0*RIZ*(PSI7+PSI8)+PSI10)+0.25D0* &
9599 (PSI7+PSI8)**2.0*(1.D0+RIZ))/(1.D0+RIZ)
9600 CC = (0.25D0*(PSI7+PSI8)**2.0*(0.5D0*RIZ*(PSI7+PSI8)+PSI10) &
9601 -A1/4.D0)/(1.D0+RIZ)
9602 !C AA = PSI7+PSI8+PSI9+PSI10
9603 !C BB = (PSI7+PSI8)*(PSI9+PSI10)+0.25D0*(PSI7+PSI8)**2.
9604 !C CC = ((PSI7+PSI8)**2.*(PSI9+PSI10)-A1)/4.0D0
9606 CALL POLY32p1 (AA,BB,CC,PSI1,ISLV)
9608 PSI1 = MIN (PSI1,CHI1)
9614 !C IF (CHI9.GE.TINY .AND. WATER.GT.TINY) THEN
9615 !C PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
9616 !C PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
9621 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
9622 CALL POLY32p1 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
9624 PSI9 = MIN (PSI9,CHI9)
9630 !C *** CALCULATE SPECIATION ********************************************
9632 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
9633 MOLAL (3) = PSI4 ! NH4I
9634 MOLAL (4) = PSI6 + PSI7 ! CLI
9635 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
9636 MOLAL (6) = ZERO ! HSO4I
9637 MOLAL (7) = PSI5 + PSI8 ! NO3I
9638 MOLAL (8) = PSI11 ! CAI
9639 MOLAL (9) = 2.D0*PSI9 ! KI
9640 MOLAL (10)= PSI10 ! MGI
9642 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
9643 - MOLAL(9) - 2.D0*MOLAL(10)
9644 CALL CALCPH2p1 (SMIN, HI, OHI)
9647 GNH3 = MAX(CHI4 - PSI4, TINY)
9648 GHNO3 = MAX(CHI5 - PSI5, TINY)
9649 GHCL = MAX(CHI6 - PSI6, TINY)
9655 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
9656 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
9660 CALL CALCMR2p1 ! Water content
9662 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9664 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9671 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
9673 !C20 FUNCM6 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
9674 20 FUNCM62p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
9678 !C *** END OF FUNCTION FUNCM6 *******************************************
9682 !C=======================================================================
9684 !C *** ISORROPIA CODE II
9685 !C *** SUBROUTINE CALCM5
9688 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9689 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9690 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9691 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4
9692 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL
9694 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9695 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9697 !C=======================================================================
9699 SUBROUTINE CALCM52p1
9700 INCLUDE 'module_isrpia_inc.F'
9702 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9703 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9704 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9705 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9706 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9707 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9709 !C *** SETUP PARAMETERS ************************************************
9712 CHI11 = MIN (W(6), W(2)) ! CCASO4
9713 SO4FR = MAX(W(2)-CHI11, ZERO)
9714 CAFR = MAX(W(6)-CHI11, ZERO)
9715 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
9716 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
9717 SO4FR = MAX(SO4FR-CHI9, ZERO)
9718 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
9719 FRMG = MAX(W(8)-CHI10, ZERO)
9720 SO4FR = MAX(SO4FR-CHI10, ZERO)
9721 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
9722 CHI2 = ZERO ! CNH42S4
9723 CHI3 = ZERO ! CNH4CL
9724 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
9725 CHI8 = MIN (FRNA, W(4)) ! CNANO3
9726 CHI4 = W(3) ! NH3(g)
9727 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
9728 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
9729 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
9732 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
9734 !C *** INITIAL VALUES FOR BISECTION ************************************
9738 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
9740 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
9742 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
9746 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
9751 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
9753 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM52p1 (PSI6LO)
9756 !C *** PERFORM BISECTION ***********************************************
9761 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
9768 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
9770 CALL PUSHERR2p1 (0002, 'CALCM5') ! WARNING ERROR: NO CONVERGENCE
9772 !C *** CONVERGED ; RETURN **********************************************
9777 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
9780 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
9781 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
9782 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
9783 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
9784 MOLAL(6) = DELTA ! HSO4 EFFECT
9789 !C *** END OF SUBROUTINE CALCM5 ******************************************
9793 !C=======================================================================
9795 !C *** ISORROPIA CODE II
9796 !C *** SUBROUTINE FUNCM5
9799 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9800 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9801 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9802 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4
9803 !C 4. Completely dissolved: NH4NO3, NH4CL, NANO3, NACL
9805 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9806 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9808 !C=======================================================================
9810 DOUBLE PRECISION FUNCTION FUNCM52p1 (X)
9811 INCLUDE 'module_isrpia_inc.F'
9813 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9814 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9815 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9816 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9817 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6,&
9818 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9820 !C *** SETUP PARAMETERS ************************************************
9834 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
9838 A1 = XK5 *(WATER/GAMA(2))**3.0
9839 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
9840 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
9841 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
9842 A9 = XK17 *(WATER/GAMA(17))**3.0
9843 !C A7 = XK8 *(WATER/GAMA(1))**2.0
9844 !C A8 = XK9 *(WATER/GAMA(3))**2.0
9845 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
9847 !C CALCULATE DISSOCIATION QUANTITIES
9849 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
9850 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
9851 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
9853 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
9854 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
9855 CC = CHI4*(PSI5+PSI6)
9856 DD = MAX(BB*BB-4.d0*CC,ZERO)
9857 PSI4 =0.5d0*(-BB - SQRT(DD))
9858 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
9863 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN !NA2SO4
9865 AA = (0.5D0*RIZ*(PSI7+PSI8)+PSI10+(1.D0+RIZ)*(PSI7+PSI8)) &
9867 BB = ((PSI7+PSI8)*(0.5D0*RIZ*(PSI7+PSI8)+PSI10)+0.25D0* &
9868 (PSI7+PSI8)**2.0*(1.D0+RIZ))/(1.D0+RIZ)
9869 CC = (0.25D0*(PSI7+PSI8)**2.0*(0.5D0*RIZ*(PSI7+PSI8)+PSI10) &
9870 -A1/4.D0)/(1.D0+RIZ)
9871 !C AA = PSI7+PSI8+PSI9+PSI10
9872 !C BB = (PSI7+PSI8)*(PSI9+PSI10)+0.25D0*(PSI7+PSI8)**2.
9873 !C CC = ((PSI7+PSI8)**2.*(PSI9+PSI10)-A1)/4.0D0
9875 CALL POLY32p1 (AA,BB,CC,PSI1,ISLV)
9877 PSI1 = MIN (PSI1,CHI1)
9883 IF (CHI9.GE.TINY .AND. WATER.GT.TINY) THEN
9884 PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
9885 PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
9890 !C IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
9891 !C CALL POLY3 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
9892 !C IF (ISLV.EQ.0) THEN
9893 !C PSI9 = MIN (PSI9,CHI9)
9899 !C *** CALCULATE SPECIATION ********************************************
9901 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
9902 MOLAL (3) = PSI4 ! NH4I
9903 MOLAL (4) = PSI6 + PSI7 ! CLI
9904 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
9905 MOLAL (6) = ZERO ! HSO4I
9906 MOLAL (7) = PSI5 + PSI8 ! NO3I
9907 MOLAL (8) = PSI11 ! CAI
9908 MOLAL (9) = 2.D0*PSI9 ! KI
9909 MOLAL (10)= PSI10 ! MGI
9911 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
9912 - MOLAL(9) - 2.D0*MOLAL(10)
9913 CALL CALCPH2p1 (SMIN, HI, OHI)
9916 GNH3 = MAX(CHI4 - PSI4, TINY)
9917 GHNO3 = MAX(CHI5 - PSI5, TINY)
9918 GHCL = MAX(CHI6 - PSI6, TINY)
9924 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
9925 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
9929 CALL CALCMR2p1 ! Water content
9931 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
9933 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
9940 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
9942 !C20 FUNCM5 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
9943 20 FUNCM52p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
9947 !C *** END OF FUNCTION FUNCM5 *******************************************
9951 !C=======================================================================
9953 !C *** ISORROPIA CODE II
9954 !C *** SUBROUTINE CALCM4
9957 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
9958 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
9959 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
9960 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL
9961 !C 4. Completely dissolved: NH4NO3, NANO3, NACL
9963 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
9964 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
9966 !C=======================================================================
9968 SUBROUTINE CALCM42p1
9969 INCLUDE 'module_isrpia_inc.F'
9971 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
9972 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
9973 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
9974 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
9975 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
9976 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
9978 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
9980 IF (W(4).LE.TINY .AND. W(5).LE.TINY) THEN
9981 SCASE = 'M4 ; SUBCASE 1'
9983 SCASE = 'M4 ; SUBCASE 1'
9987 !C *** SETUP PARAMETERS ************************************************
9990 CHI11 = MIN (W(6), W(2)) ! CCASO4
9991 SO4FR = MAX(W(2)-CHI11, ZERO)
9992 CAFR = MAX(W(6)-CHI11, ZERO)
9993 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
9994 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
9995 SO4FR = MAX(SO4FR-CHI9, ZERO)
9996 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
9997 FRMG = MAX(W(8)-CHI10, ZERO)
9998 SO4FR = MAX(SO4FR-CHI10, ZERO)
9999 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
10000 CHI2 = ZERO ! CNH42S4
10001 CHI3 = ZERO ! CNH4CL
10002 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
10003 CHI8 = MIN (FRNA, W(4)) ! CNANO3
10004 CHI4 = W(3) ! NH3(g)
10005 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
10006 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
10007 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
10010 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
10012 !C *** INITIAL VALUES FOR BISECTION ************************************
10015 Y1 = FUNCM42p1 (X1)
10016 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
10018 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10020 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
10023 Y2 = FUNCM42p1 (X2)
10024 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10029 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
10031 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM42p1 (PSI6LO)
10034 !C *** PERFORM BISECTION ***********************************************
10038 Y3 = FUNCM42p1 (X3)
10039 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10046 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
10048 CALL PUSHERR2p1 (0002, 'CALCM4') ! WARNING ERROR: NO CONVERGENCE
10050 !C *** CONVERGED ; RETURN **********************************************
10052 40 X3 = 0.5*(X1+X2)
10053 Y3 = FUNCM42p1 (X3)
10055 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10058 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
10059 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10060 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10061 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10062 MOLAL(6) = DELTA ! HSO4 EFFECT
10067 !C *** END OF SUBROUTINE CALCM4 ******************************************
10071 !C=======================================================================
10073 !C *** ISORROPIA CODE II
10074 !C *** SUBROUTINE FUNCM4
10077 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10078 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10079 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10080 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL
10081 !C 4. Completely dissolved: NH4NO3, NANO3, NACL
10083 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
10084 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10086 !C=======================================================================
10088 DOUBLE PRECISION FUNCTION FUNCM42p1 (X)
10089 INCLUDE 'module_isrpia_inc.F'
10091 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10092 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10093 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10094 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10095 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10096 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10098 !C *** SETUP PARAMETERS ************************************************
10112 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10116 A1 = XK5 *(WATER/GAMA(2))**3.0
10117 A3 = XK6 /(R*TEMP*R*TEMP)
10118 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10119 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
10120 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
10121 A9 = XK17 *(WATER/GAMA(17))**3.0
10122 !C A7 = XK8 *(WATER/GAMA(1))**2.0
10123 !C A8 = XK9 *(WATER/GAMA(3))**2.0
10124 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
10126 !C CALCULATE DISSOCIATION QUANTITIES
10128 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
10129 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
10130 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
10132 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
10133 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
10134 CC = CHI4*(PSI5+PSI6)
10135 DD = MAX(BB*BB-4.d0*CC,ZERO)
10136 PSI4 =0.5d0*(-BB - SQRT(DD))
10137 PSI4 = MIN(MAX(PSI4,TINY),CHI4)
10142 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN !NA2SO4
10144 AA = (0.5D0*RIZ*(PSI7+PSI8)+PSI10+(1.D0+RIZ)*(PSI7+PSI8)) &
10146 BB = ((PSI7+PSI8)*(0.5D0*RIZ*(PSI7+PSI8)+PSI10)+0.25D0* &
10147 (PSI7+PSI8)**2.0*(1.D0+RIZ))/(1.D0+RIZ)
10148 CC = (0.25D0*(PSI7+PSI8)**2.0*(0.5D0*RIZ*(PSI7+PSI8)+PSI10) &
10149 -A1/4.D0)/(1.D0+RIZ)
10150 !C AA = PSI7+PSI8+PSI9+PSI10
10151 !C BB = (PSI7+PSI8)*(PSI9+PSI10)+0.25D0*(PSI7+PSI8)**2.
10152 !C CC = ((PSI7+PSI8)**2.*(PSI9+PSI10)-A1)/4.0D0
10154 CALL POLY32p1 (AA,BB,CC,PSI1,ISLV)
10155 IF (ISLV.EQ.0) THEN
10156 PSI1 = MIN (PSI1,CHI1)
10162 IF (CHI9.GE.TINY .AND. WATER.GT.TINY) THEN
10163 PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
10164 PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
10169 !C IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
10170 !C CALL POLY3 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
10171 !C IF (ISLV.EQ.0) THEN
10172 !C PSI9 = MIN (PSI9,CHI9)
10178 !C *** CALCULATE SPECIATION ********************************************
10180 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
10181 MOLAL (3) = PSI4 ! NH4I
10182 MOLAL (4) = PSI6 + PSI7 ! CLI
10183 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
10184 MOLAL (6) = ZERO ! HSO4I
10185 MOLAL (7) = PSI5 + PSI8 ! NO3I
10186 MOLAL (8) = PSI11 ! CAI
10187 MOLAL (9) = 2.D0*PSI9 ! KI
10188 MOLAL (10)= PSI10 ! MGI
10190 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
10191 - MOLAL(9) - 2.D0*MOLAL(10)
10192 CALL CALCPH2p1 (SMIN, HI, OHI)
10195 GNH3 = MAX(CHI4 - PSI4, TINY)
10196 GHNO3 = MAX(CHI5 - PSI5, TINY)
10197 GHCL = MAX(CHI6 - PSI6, TINY)
10203 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
10204 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
10208 !C *** NH4Cl(s) calculations
10210 A3 = XK6 /(R*TEMP*R*TEMP)
10211 IF (GNH3*GHCL.GT.A3) THEN
10212 DELT = MIN(GNH3, GHCL)
10215 DD = BB*BB - 4.D0*CC
10216 PSI31 = 0.5D0*(-BB + SQRT(DD))
10217 PSI32 = 0.5D0*(-BB - SQRT(DD))
10218 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
10220 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
10228 PSI3 = MAX (MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6), ZERO)
10230 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10232 GNH3 = MAX(GNH3 - PSI3, TINY)
10233 GHCL = MAX(GHCL - PSI3, TINY)
10236 CALL CALCMR2p1 ! Water content
10238 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10240 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10247 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
10249 !C20 FUNCM4 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
10250 20 FUNCM42p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
10254 !C *** END OF FUNCTION FUNCM4 *******************************************
10258 !C=======================================================================
10260 !C *** ISORROPIA CODE II
10261 !C *** SUBROUTINE CALCM3
10264 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10265 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10266 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10267 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL
10268 !C 4. Completely dissolved: NH4NO3, NANO3
10270 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
10271 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10273 !C=======================================================================
10275 SUBROUTINE CALCM32p1
10276 INCLUDE 'module_isrpia_inc.F'
10278 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10279 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10280 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10281 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10282 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10283 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10285 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
10287 IF (W(4).LE.TINY) THEN ! NO3 NOT EXIST, WATER NOT POSSIBLE
10288 SCASE = 'M3 ; SUBCASE 1'
10290 SCASE = 'M3 ; SUBCASE 1'
10294 !C *** SETUP PARAMETERS ************************************************
10297 CHI11 = MIN (W(6), W(2)) ! CCASO4
10298 SO4FR = MAX(W(2)-CHI11, ZERO)
10299 CAFR = MAX(W(6)-CHI11, ZERO)
10300 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
10301 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
10302 SO4FR = MAX(SO4FR-CHI9, ZERO)
10303 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
10304 FRMG = MAX(W(8)-CHI10, ZERO)
10305 SO4FR = MAX(SO4FR-CHI10, ZERO)
10306 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
10307 CHI2 = ZERO ! CNH42S4
10308 CHI3 = ZERO ! CNH4CL
10309 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
10310 CHI8 = MIN (FRNA, W(4)) ! CNANO3
10311 CHI4 = W(3) ! NH3(g)
10312 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
10313 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
10314 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
10317 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
10319 !C *** INITIAL VALUES FOR BISECTION ************************************
10322 Y1 = FUNCM32p1 (X1)
10323 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
10325 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10327 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
10330 Y2 = FUNCM32p1 (X2)
10331 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10336 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
10338 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM32p1 (PSI6LO)
10341 !C *** PERFORM BISECTION ***********************************************
10345 Y3 = FUNCM32p1 (X3)
10346 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10353 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
10355 CALL PUSHERR2p1 (0002, 'CALCM3') ! WARNING ERROR: NO CONVERGENCE
10357 !C *** CONVERGED ; RETURN **********************************************
10359 40 X3 = 0.5*(X1+X2)
10360 Y3 = FUNCM32p1 (X3)
10362 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10365 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
10366 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10367 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10368 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10369 MOLAL(6) = DELTA ! HSO4 EFFECT
10374 !C *** END OF SUBROUTINE CALCM3 ******************************************
10378 !C=======================================================================
10380 !C *** ISORROPIA CODE II
10381 !C *** SUBROUTINE FUNCM3
10384 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10385 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10386 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10387 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL
10388 !C 4. Completely dissolved: NH4NO3, NANO3
10390 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
10391 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10393 !C=======================================================================
10395 DOUBLE PRECISION FUNCTION FUNCM32p1 (X)
10396 INCLUDE 'module_isrpia_inc.F'
10398 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10399 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10400 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10401 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10402 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10403 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10405 !C *** SETUP PARAMETERS ************************************************
10419 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10423 A1 = XK5 *(WATER/GAMA(2))**3.0
10424 A3 = XK6 /(R*TEMP*R*TEMP)
10425 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10426 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
10427 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
10428 A7 = XK8 *(WATER/GAMA(1))**2.0
10429 A9 = XK17 *(WATER/GAMA(17))**3.0
10430 A10 = XK23 *(WATER/GAMA(21))**2.0
10431 !C A8 = XK9 *(WATER/GAMA(3))**2.0
10432 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
10434 !C CALCULATE DISSOCIATION QUANTITIES
10436 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
10437 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
10438 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
10440 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
10441 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
10442 CC = CHI4*(PSI5+PSI6)
10443 DD = MAX(BB*BB-4.d0*CC,ZERO)
10444 PSI4 =0.5d0*(-BB - SQRT(DD))
10445 PSI4 = MIN(MAX(PSI4,TINY),CHI4)
10450 !C IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
10451 !C VITA = 2.D0*PSI1+PSI8+PSI6 ! AN DE DOULEPSEI KALA VGALE PSI1 APO DW
10452 !C GKAMA= PSI6*(2.D0*PSI1+PSI8)-A7
10453 !C DIAK = MAX(VITA**2.0 - 4.0D0*GKAMA,ZERO)
10454 !C PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
10455 !C PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
10458 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
10459 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
10460 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
10461 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
10465 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN !NA2SO4
10467 AA = (0.5D0*RIZ*(PSI7+PSI8)+PSI10+(1.D0+RIZ)*(PSI7+PSI8)) &
10469 BB = ((PSI7+PSI8)*(0.5D0*RIZ*(PSI7+PSI8)+PSI10)+0.25D0* &
10470 (PSI7+PSI8)**2.0*(1.D0+RIZ))/(1.D0+RIZ)
10471 CC = (0.25D0*(PSI7+PSI8)**2.0*(0.5D0*RIZ*(PSI7+PSI8)+PSI10) &
10472 -A1/4.D0)/(1.D0+RIZ)
10473 !C AA = PSI7+PSI8+PSI9+PSI10
10474 !C BB = (PSI7+PSI8)*(PSI9+PSI10)+0.25D0*(PSI7+PSI8)**2.
10475 !C CC = ((PSI7+PSI8)**2.*(PSI9+PSI10)-A1)/4.0D0
10477 CALL POLY32p1 (AA,BB,CC,PSI1,ISLV)
10478 IF (ISLV.EQ.0) THEN
10479 PSI1 = MIN (PSI1,CHI1)
10485 IF (CHI9.GE.TINY) THEN
10486 PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
10487 PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
10492 !C IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
10493 !C CALL POLY3 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
10494 !C IF (ISLV.EQ.0) THEN
10495 !C PSI9 = MIN (PSI9,CHI9)
10501 !C *** CALCULATE SPECIATION ********************************************
10503 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
10504 MOLAL (3) = PSI4 ! NH4I
10505 MOLAL (4) = PSI6 + PSI7 ! CLI
10506 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
10507 MOLAL (6) = ZERO ! HSO4I
10508 MOLAL (7) = PSI5 + PSI8 ! NO3I
10509 MOLAL (8) = PSI11 ! CAI
10510 MOLAL (9) = 2.D0*PSI9 ! KI
10511 MOLAL (10)= PSI10 ! MGI
10513 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
10514 - MOLAL(9) - 2.D0*MOLAL(10)
10515 CALL CALCPH2p1 (SMIN, HI, OHI)
10518 GNH3 = MAX(CHI4 - PSI4, TINY)
10519 GHNO3 = MAX(CHI5 - PSI5, TINY)
10520 GHCL = MAX(CHI6 - PSI6, TINY)
10524 CNACL = MAX(CHI7 - PSI7, ZERO)
10526 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
10527 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
10531 !C *** NH4Cl(s) calculations
10533 A3 = XK6 /(R*TEMP*R*TEMP)
10534 IF (GNH3*GHCL.GT.A3) THEN
10535 DELT = MIN(GNH3, GHCL)
10538 DD = BB*BB - 4.D0*CC
10539 PSI31 = 0.5D0*(-BB + SQRT(DD))
10540 PSI32 = 0.5D0*(-BB - SQRT(DD))
10541 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
10543 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
10551 PSI3 = MAX (MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6), ZERO)
10553 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10555 GNH3 = MAX(GNH3 - PSI3, TINY)
10556 GHCL = MAX(GHCL - PSI3, TINY)
10559 CALL CALCMR2p1 ! Water content
10561 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10563 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10570 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
10572 !C20 FUNCM3 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
10573 20 FUNCM32p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
10577 !!C *** END OF FUNCTION FUNCM3 *******************************************
10582 !C=======================================================================
10584 !C *** ISORROPIA CODE II
10585 !C *** SUBROUTINE CALCM2
10588 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10589 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10590 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
10591 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3
10593 !C THERE ARE THREE REGIMES IN THIS CASE:
10594 !C 1. NH4NO3(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCH2A)
10595 !C 2. NH4NO3(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
10596 !C 3. NH4NO3(s) NOT POSSIBLE, AND RH >= MDRH. (MDRH REGION)
10598 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES M1A, M2B
10599 !C RESPECTIVELY (BECAUSE MDRH POINTS COINCIDE).
10601 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10602 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10603 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10605 !C=======================================================================
10607 SUBROUTINE CALCM22p1
10608 INCLUDE 'module_isrpia_inc.F'
10609 EXTERNAL CALCM1A2p1, CALCM32p1
10611 !C *** REGIME DEPENDS ON THE EXISTANCE OF NITRATES ***********************
10615 IF (CNH4NO3.GT.TINY) THEN ! NO3 EXISTS, WATER POSSIBLE
10616 SCASE = 'M2 ; SUBCASE 1'
10618 SCASE = 'M2 ; SUBCASE 1'
10619 ELSE ! NO3 NON EXISTANT, WATER NOT POSSIBLE
10620 SCASE = 'M2 ; SUBCASE 1'
10622 SCASE = 'M2 ; SUBCASE 1'
10625 IF (WATER.LE.TINY .AND. RH.LT.DRMM2) THEN ! DRY AEROSOL
10626 SCASE = 'M2 ; SUBCASE 2'
10628 ELSEIF (WATER.LE.TINY .AND. RH.GE.DRMM2) THEN ! MDRH OF M2
10629 SCASE = 'M2 ; SUBCASE 3'
10630 CALL CALCMDRH22p1 (RH, DRMM2, DRNANO3, CALCM1A2p1, CALCM32p1)
10631 SCASE = 'M2 ; SUBCASE 3'
10636 !C *** END OF SUBROUTINE CALCM2 ******************************************
10640 !C=======================================================================
10642 !C *** ISORROPIA CODE II
10643 !C *** SUBROUTINE CALCM2A
10646 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10647 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10648 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10649 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3
10650 !C 4. Completely dissolved: NH4NO3
10652 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
10653 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10655 !C=======================================================================
10657 SUBROUTINE CALCM2A2p1
10658 INCLUDE 'module_isrpia_inc.F'
10660 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10661 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10662 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10663 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10664 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10665 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10667 !C *** SETUP PARAMETERS ************************************************
10670 CHI11 = MIN (W(6), W(2)) ! CCASO4
10671 SO4FR = MAX(W(2)-CHI11, ZERO)
10672 CAFR = MAX(W(6)-CHI11, ZERO)
10673 CHI9 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
10674 FRK = MAX(W(7)-2.D0*CHI9, ZERO)
10675 SO4FR = MAX(SO4FR-CHI9, ZERO)
10676 CHI10 = MIN (W(8), SO4FR) ! CMGSO4
10677 FRMG = MAX(W(8)-CHI10, ZERO)
10678 SO4FR = MAX(SO4FR-CHI10, ZERO)
10679 CHI1 = MAX (SO4FR,ZERO) ! CNA2SO4
10680 CHI2 = ZERO ! CNH42S4
10681 CHI3 = ZERO ! CNH4CL
10682 FRNA = MAX (W(1)-2.D0*CHI1, ZERO)
10683 CHI8 = MIN (FRNA, W(4)) ! CNANO3
10684 CHI4 = W(3) ! NH3(g)
10685 CHI5 = MAX (W(4)-CHI8, ZERO) ! HNO3(g)
10686 CHI7 = MIN (MAX(FRNA-CHI8, ZERO), W(5)) ! CNACL
10687 CHI6 = MAX (W(5)-CHI7, ZERO) ! HCL(g)
10690 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
10692 !C *** INITIAL VALUES FOR BISECTION ************************************
10695 Y1 = FUNCM2A2p1 (X1)
10696 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
10698 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
10700 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
10703 Y2 = FUNCM2A2p1 (X2)
10704 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
10709 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
10711 IF (ABS(Y2) .GT. EPS) Y2 = FUNCM2A2p1 (PSI6LO)
10714 !C *** PERFORM BISECTION ***********************************************
10718 Y3 = FUNCM2A2p1 (X3)
10719 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
10726 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
10728 CALL PUSHERR2p1 (0002, 'CALCM2A') ! WARNING ERROR: NO CONVERGENCE
10730 !C *** CONVERGED ; RETURN **********************************************
10732 40 X3 = 0.5*(X1+X2)
10733 Y3 = FUNCM2A2p1 (X3)
10735 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
10738 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
10739 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
10740 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
10741 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
10742 MOLAL(6) = DELTA ! HSO4 EFFECT
10747 !C *** END OF SUBROUTINE CALCM2A ******************************************
10751 !C=======================================================================
10753 !C *** ISORROPIA CODE II
10754 !C *** SUBROUTINE FUNCM2A
10757 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10758 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10759 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
10760 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3
10761 !C 4. Completely dissolved: NH4NO3
10763 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
10764 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10766 !C=======================================================================
10768 DOUBLE PRECISION FUNCTION FUNCM2A2p1 (X)
10769 INCLUDE 'module_isrpia_inc.F'
10771 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
10772 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
10773 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
10774 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
10775 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
10776 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
10778 !C *** SETUP PARAMETERS ************************************************
10792 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
10796 A1 = XK5 *(WATER/GAMA(2))**3.0
10797 A3 = XK6 /(R*TEMP*R*TEMP)
10798 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
10799 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
10800 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
10801 A7 = XK8 *(WATER/GAMA(1))**2.0
10802 A8 = XK9 *(WATER/GAMA(3))**2.0
10803 A9 = XK17 *(WATER/GAMA(17))**3.0
10804 A64 = (XK3*XK2/XKW)*(GAMA(10)/GAMA(5)/GAMA(11))**2.0
10805 A64 = A64*(R*TEMP*WATER)**2.0
10806 !C A11 = XK1*WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
10808 !C CALCULATE DISSOCIATION QUANTITIES
10810 PSI5 = CHI5*(PSI6+PSI7) - A6/A5*PSI8*(CHI6-PSI6-PSI3)
10811 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7)
10812 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
10814 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
10815 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
10816 CC = CHI4*(PSI5+PSI6)
10817 DD = MAX(BB*BB-4.d0*CC,ZERO)
10818 PSI4 =0.5d0*(-BB - SQRT(DD))
10819 PSI4 = MIN(MAX(PSI4,TINY),CHI4)
10824 !C IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
10825 !C VITA = 2.D0*PSI1+PSI8+PSI6
10826 !C GKAMA= PSI6*(2.D0*PSI1+PSI8)-A7
10827 !C DIAK = MAX(VITA**2.0 - 4.0D0*GKAMA,ZERO)
10828 !C PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
10829 !C PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
10832 !C IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
10833 !C BIT = 2.D0*PSI1+PSI7+PSI5
10834 !C GKAM = PSI5*(2.D0*PSI1+PSI8)-A8
10835 !C DIA = BIT**2.0 - 4.0D0*GKAM
10836 !C PSI8 = 0.5D0*( -BIT + SQRT(DIA) )
10837 !C PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
10840 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
10841 DIAK = (PSI8-PSI6)**2.D0 + 4.D0*A7
10842 PSI7 = 0.5D0*( -(PSI8+PSI6) + SQRT(DIAK) )
10843 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
10846 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
10847 DIAK = (PSI7-PSI5)**2.D0 + 4.D0*A8
10848 PSI8 = 0.5D0*( -(PSI7+PSI5) + SQRT(DIAK) )
10849 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
10852 IF (CHI1.GT.TINY .AND. WATER.GT.TINY) THEN !NA2SO4
10854 AA = (0.5D0*RIZ*(PSI7+PSI8)+PSI10+(1.D0+RIZ)*(PSI7+PSI8)) &
10856 BB = ((PSI7+PSI8)*(0.5D0*RIZ*(PSI7+PSI8)+PSI10)+0.25D0* &
10857 (PSI7+PSI8)**2.0*(1.D0+RIZ))/(1.D0+RIZ)
10858 CC = (0.25D0*(PSI7+PSI8)**2.0*(0.5D0*RIZ*(PSI7+PSI8)+PSI10) &
10859 -A1/4.D0)/(1.D0+RIZ)
10861 !C AA = PSI7+PSI8+PSI9+PSI10
10862 !C BB = (PSI7+PSI8)*(PSI9+PSI10)+0.25D0*(PSI7+PSI8)**2.
10863 !C CC = ((PSI7+PSI8)**2.*(PSI9+PSI10)-A1)/4.0D0
10865 CALL POLY32p1 (AA,BB,CC,PSI1,ISLV)
10866 IF (ISLV.EQ.0) THEN
10867 PSI1 = MIN (PSI1,CHI1)
10873 IF (CHI9.GE.TINY .AND. WATER.GT.TINY) THEN
10874 !C PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
10875 PSI9 = 0.5D0*SQRT(A9/A1)*(2.0D0*PSI1+PSI7+PSI8)
10876 PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
10881 !C IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
10882 !C CALL POLY3 (PSI1+PSI10,ZERO,-A9/4.D0, PSI9, ISLV)
10883 !C IF (ISLV.EQ.0) THEN
10884 !C PSI9 = MAX (MIN (PSI9,CHI9), ZERO)
10890 !C *** CALCULATE SPECIATION ********************************************
10892 MOLAL (2) = PSI8 + PSI7 + 2.D0*PSI1 ! NAI
10893 MOLAL (3) = PSI4 ! NH4I
10894 MOLAL (4) = PSI6 + PSI7 ! CLI
10895 MOLAL (5) = PSI2 + PSI1 + PSI9 + PSI10 ! SO4I
10896 MOLAL (6) = ZERO ! HSO4I
10897 MOLAL (7) = PSI5 + PSI8 ! NO3I
10898 MOLAL (8) = PSI11 ! CAI
10899 MOLAL (9) = 2.D0*PSI9 ! KI
10900 MOLAL (10)= PSI10 ! MGI
10902 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
10903 - MOLAL(9) - 2.D0*MOLAL(10)
10904 CALL CALCPH2p1 (SMIN, HI, OHI)
10907 GNH3 = MAX(CHI4 - PSI4, TINY)
10908 GHNO3 = MAX(CHI5 - PSI5, TINY)
10909 GHCL = MAX(CHI6 - PSI6, TINY)
10913 CNACL = MAX(CHI7 - PSI7, ZERO)
10914 CNANO3 = MAX(CHI8 - PSI8, ZERO)
10915 CNA2SO4 = MAX(CHI1 - PSI1, ZERO)
10916 CK2SO4 = MAX(CHI9 - PSI9, ZERO)
10920 !C *** NH4Cl(s) calculations
10922 A3 = XK6 /(R*TEMP*R*TEMP)
10923 IF (GNH3*GHCL.GT.A3) THEN
10924 DELT = MIN(GNH3, GHCL)
10927 DD = BB*BB - 4.D0*CC
10928 PSI31 = 0.5D0*(-BB + SQRT(DD))
10929 PSI32 = 0.5D0*(-BB - SQRT(DD))
10930 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
10932 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
10940 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6), ZERO)
10942 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
10944 GNH3 = MAX(GNH3 - PSI3, TINY)
10945 GHCL = MAX(GHCL - PSI3, TINY)
10948 CALL CALCMR2p1 ! Water content
10950 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
10952 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
10959 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
10961 !C20 FUNCM2A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A64 - ONE
10962 20 FUNCM2A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
10966 !C *** END OF FUNCTION FUNCM2A *******************************************
10970 !C=======================================================================
10972 !C *** ISORROPIA CODE II
10973 !C *** SUBROUTINE CALCM1
10976 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
10977 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
10978 !C 2. SOLID AEROSOL ONLY
10979 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3, NH4NO3
10981 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
10982 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
10983 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCH1A)
10985 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
10986 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
10987 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
10989 !C=======================================================================
10991 SUBROUTINE CALCM12p1
10992 INCLUDE 'module_isrpia_inc.F'
10993 EXTERNAL CALCM1A2p1, CALCM2A2p1
10995 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
10997 IF (RH.LT.DRMM1) THEN
10998 SCASE = 'M1 ; SUBCASE 1'
10999 CALL CALCM1A2p1 ! SOLID PHASE ONLY POSSIBLE
11000 SCASE = 'M1 ; SUBCASE 1'
11002 SCASE = 'M1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
11003 CALL CALCMDRH22p1 (RH, DRMM1, DRNH4NO3, CALCM1A2p1, CALCM2A2p1)
11004 SCASE = 'M1 ; SUBCASE 2'
11009 !C *** END OF SUBROUTINE CALCM1 ******************************************
11013 !C=======================================================================
11015 !C *** ISORROPIA CODE II
11016 !C *** SUBROUTINE CALCM1A
11019 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11020 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr < 2)
11021 !C 2. SOLID AEROSOL ONLY
11022 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, NA2SO4, MGSO4, NH4CL, NACL, NANO3, NH4NO3
11024 !C *** COPYRIGHT 1996-2000, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11025 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
11027 !C=======================================================================
11029 SUBROUTINE CALCM1A2p1
11030 INCLUDE 'module_isrpia_inc.F'
11031 DOUBLE PRECISION LAMDA, LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2, NAFR, &
11034 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
11036 CCASO4 = MIN (W(6), W(2)) ! CCASO4
11037 SO4FR = MAX(W(2) - CCASO4, ZERO)
11038 CAFR = MAX(W(6) - CCASO4, ZERO)
11039 CK2SO4 = MIN (0.5D0*W(7), SO4FR) ! CK2S04
11040 FRK = MAX(W(7) - 2.D0*CK2SO4, ZERO)
11041 SO4FR = MAX(SO4FR - CK2SO4, ZERO)
11042 CMGSO4 = MIN (W(8), SO4FR) ! CMGSO4
11043 FRMG = MAX(W(8) - CMGSO4, ZERO)
11044 SO4FR = MAX(SO4FR - CMGSO4, ZERO)
11045 CNA2SO4 = MAX (SO4FR,ZERO) ! CNA2SO4
11046 NAFR = MAX (W(1)-2.D0*CNA2SO4, ZERO)
11047 CNANO3 = MIN (NAFR, W(4)) ! CNANO3
11048 NO3FR = MAX (W(4)-CNANO3, ZERO)
11049 CNACL = MIN (MAX(NAFR-CNANO3, ZERO), W(5)) ! CNACL
11050 CLFR = MAX (W(5)-CNACL, ZERO)
11052 !C *** CALCULATE VOLATILE SPECIES **************************************
11054 ALF = W(3) ! FREE NH3
11055 BET = CLFR ! FREE CL
11056 GAM = NO3FR ! FREE NO3
11058 RTSQ = R*TEMP*R*TEMP
11062 THETA1 = GAM - BET*(A2/A1)
11065 !C QUADRATIC EQUATION SOLUTION
11067 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
11068 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
11069 DD = BB*BB - 4.0D0*CC
11070 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
11072 !C TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
11075 KAPA1 = 0.5D0*(-BB+SQDD)
11076 KAPA2 = 0.5D0*(-BB-SQDD)
11077 LAMDA1 = THETA1 + THETA2*KAPA1
11078 LAMDA2 = THETA1 + THETA2*KAPA2
11080 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
11081 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
11082 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
11089 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
11090 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
11091 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
11098 !C SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
11102 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
11103 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
11105 !C NH4CL EQUILIBRIUM
11107 IF (DD1.GE.ZERO) THEN
11109 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
11110 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
11112 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
11114 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
11121 !C NH4NO3 EQUILIBRIUM
11123 IF (DD2.GE.ZERO) THEN
11125 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
11126 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
11128 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
11130 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
11137 !C IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
11139 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
11140 IF (BET .LT. LAMDA/THETA1) THEN
11147 !C *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
11153 GNH3 = ALF - KAPA - LAMDA
11154 GHNO3 = GAM - LAMDA
11159 !C *** END OF SUBROUTINE CALCM1A *****************************************
11163 !C=======================================================================
11165 !C *** ISORROPIA CODE II
11166 !C *** SUBROUTINE CALCP13
11169 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11170 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11171 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11172 !C 3. SOLIDS POSSIBLE : CaSO4
11173 !C 4. Completely dissolved: CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
11174 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11176 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11177 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11178 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11180 !C=======================================================================
11182 SUBROUTINE CALCP132p1
11183 INCLUDE 'module_isrpia_inc.F'
11185 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11186 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11187 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11188 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11189 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11190 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11192 !C *** SETUP PARAMETERS ************************************************
11195 CHI11 = MIN (W(2), W(6)) ! CCASO4
11196 FRCA = MAX (W(6) - CHI11, ZERO)
11197 FRSO4 = MAX (W(2) - CHI11, ZERO)
11198 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
11199 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
11200 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
11201 CHI10 = FRSO4 ! CMGSO4
11202 FRMG = MAX (W(8) - CHI10, ZERO)
11203 CHI7 = MIN (W(1), W(5)) ! CNACL
11204 FRNA = MAX (W(1) - CHI7, ZERO)
11205 FRCL = MAX (W(5) - CHI7, ZERO)
11206 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
11207 FRCA = MAX (FRCA - CHI12, ZERO)
11208 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
11209 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
11210 FRCA = MAX (FRCA - CHI17, ZERO)
11211 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
11212 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
11213 FRMG = MAX (FRMG - CHI15, ZERO)
11214 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
11215 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
11216 FRMG = MAX (FRMG - CHI16, ZERO)
11217 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
11218 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
11219 FRNA = MAX (FRNA - CHI8, ZERO)
11220 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
11221 CHI14 = MIN (FRK, FRCL) ! CKCL
11222 FRK = MAX (FRK - CHI14, ZERO)
11223 FRCL = MAX (FRCL - CHI14, ZERO)
11224 CHI13 = MIN (FRK, FRNO3) ! CKNO3
11225 FRK = MAX (FRK - CHI13, ZERO)
11226 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
11228 CHI5 = FRNO3 ! HNO3(g)
11229 CHI6 = FRCL ! HCL(g)
11230 CHI4 = W(3) ! NH3(g)
11232 CHI3 = ZERO ! CNH4CL
11237 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
11239 !C *** INITIAL VALUES FOR BISECTION ************************************
11242 Y1 = FUNCP132p1 (X1)
11243 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
11245 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11247 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11250 Y2 = FUNCP132p1 (X2)
11251 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11256 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11258 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP132p1 (PSI6LO)
11261 !C *** PERFORM BISECTION ***********************************************
11265 Y3 = FUNCP132p1 (X3)
11266 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11273 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11275 CALL PUSHERR2p1 (0002, 'CALCP13') ! WARNING ERROR: NO CONVERGENCE
11277 !C *** CONVERGED ; RETURN **********************************************
11279 40 X3 = 0.5*(X1+X2)
11280 Y3 = FUNCP132p1 (X3)
11282 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
11285 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11286 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11287 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
11288 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
11289 MOLAL(6) = DELTA ! HSO4 EFFECT
11294 !C *** END OF SUBROUTINE CALCP13 ******************************************
11299 !C=======================================================================
11301 !C *** ISORROPIA CODE II
11302 !C *** SUBROUTINE FUNCP13
11305 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11306 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11307 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11308 !C 3. SOLIDS POSSIBLE : CaSO4
11309 !C 4. Completely dissolved: CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
11310 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11312 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11313 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11314 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11316 !C=======================================================================
11318 DOUBLE PRECISION FUNCTION FUNCP132p1 (X)
11319 INCLUDE 'module_isrpia_inc.F'
11321 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11322 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11323 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11324 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11325 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11326 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11328 !C *** SETUP PARAMETERS ************************************************
11349 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11353 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11354 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11355 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11357 !C CALCULATE DISSOCIATION QUANTITIES
11359 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
11360 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6)
11361 PSI5 = PSI5/(A6/A5*(CHI6-PSI6) + PSI6 + PSI7 + PSI14 + &
11362 2.D0*PSI16 + 2.D0*PSI17)
11363 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
11365 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
11366 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
11367 CC = CHI4*(PSI5+PSI6)
11368 DD = MAX(BB*BB-4.d0*CC,ZERO)
11369 PSI4 =0.5d0*(-BB - SQRT(DD))
11370 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
11375 !C *** CALCULATE SPECIATION *********************************************
11377 MOLAL (2) = PSI8 + PSI7 ! NAI
11378 MOLAL (3) = PSI4 ! NH4I
11379 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
11380 MOLAL (5) = PSI9 + PSI10 ! SO4I
11381 MOLAL (6) = ZERO ! HSO4I
11382 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
11383 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
11384 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
11385 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
11387 !C *** CALCULATE H+ *****************************************************
11389 !C REST = 2.D0*W(2) + W(4) + W(5)
11393 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
11395 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
11397 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
11398 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
11400 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
11402 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
11403 !C DELT1 = 0.5*(-ALFA1 + DIAK)
11404 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
11406 !C DELT2 = MIN ( DELT2, DELT1)
11407 !C MOLAL(1) = DELT1 + DELT2 ! H+
11410 !C *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
11412 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
11413 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
11414 CALL CALCPH2p1 (SMIN, HI, OHI)
11418 GNH3 = MAX(CHI4 - PSI4, TINY)
11419 GHNO3 = MAX(CHI5 - PSI5, TINY)
11420 GHCL = MAX(CHI6 - PSI6, TINY)
11436 CALL CALCMR2p1 ! Water content
11438 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11440 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11447 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
11449 !C20 FUNCP13 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
11450 20 FUNCP132p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
11454 !C *** END OF FUNCTION FUNCP13 *******************************************
11457 !C=======================================================================
11459 !C *** ISORROPIA CODE II
11460 !C *** SUBROUTINE CALCP12
11463 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11464 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11465 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11466 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4
11467 !C 4. Completely dissolved: CA(NO3)2, CACL2, KNO3, KCL, MGSO4,
11468 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11470 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11471 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11472 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11474 !C=======================================================================
11476 SUBROUTINE CALCP122p1
11477 INCLUDE 'module_isrpia_inc.F'
11479 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11480 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11481 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11482 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11483 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11484 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11486 !C *** SETUP PARAMETERS ************************************************
11489 CHI11 = MIN (W(2), W(6)) ! CCASO4
11490 FRCA = MAX (W(6) - CHI11, ZERO)
11491 FRSO4 = MAX (W(2) - CHI11, ZERO)
11492 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
11493 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
11494 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
11495 CHI10 = FRSO4 ! CMGSO4
11496 FRMG = MAX (W(8) - CHI10, ZERO)
11497 CHI7 = MIN (W(1), W(5)) ! CNACL
11498 FRNA = MAX (W(1) - CHI7, ZERO)
11499 FRCL = MAX (W(5) - CHI7, ZERO)
11500 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
11501 FRCA = MAX (FRCA - CHI12, ZERO)
11502 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
11503 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
11504 FRCA = MAX (FRCA - CHI17, ZERO)
11505 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
11506 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
11507 FRMG = MAX (FRMG - CHI15, ZERO)
11508 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
11509 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
11510 FRMG = MAX (FRMG - CHI16, ZERO)
11511 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
11512 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
11513 FRNA = MAX (FRNA - CHI8, ZERO)
11514 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
11515 CHI14 = MIN (FRK, FRCL) ! CKCL
11516 FRK = MAX (FRK - CHI14, ZERO)
11517 FRCL = MAX (FRCL - CHI14, ZERO)
11518 CHI13 = MIN (FRK, FRNO3) ! CKNO3
11519 FRK = MAX (FRK - CHI13, ZERO)
11520 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
11522 CHI5 = FRNO3 ! HNO3(g)
11523 CHI6 = FRCL ! HCL(g)
11524 CHI4 = W(3) ! NH3(g)
11526 CHI3 = ZERO ! CNH4CL
11531 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
11533 !C *** INITIAL VALUES FOR BISECTION ************************************
11536 Y1 = FUNCP122p1 (X1)
11537 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
11539 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11541 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11544 Y2 = FUNCP122p1 (X2)
11545 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11550 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11552 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP122p1 (PSI6LO)
11555 !C *** PERFORM BISECTION ***********************************************
11559 Y3 = FUNCP122p1 (X3)
11560 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11567 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11569 CALL PUSHERR2p1 (0002, 'CALCP12') ! WARNING ERROR: NO CONVERGENCE
11571 !C *** CONVERGED ; RETURN **********************************************
11573 40 X3 = 0.5*(X1+X2)
11574 Y3 = FUNCP122p1 (X3)
11576 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
11579 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11580 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11581 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
11582 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
11583 MOLAL(6) = DELTA ! HSO4 EFFECT
11588 !C *** END OF SUBROUTINE CALCP12 ******************************************
11593 !C=======================================================================
11595 !C *** ISORROPIA CODE II
11596 !C *** SUBROUTINE FUNCP12
11599 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11600 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11601 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11602 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4
11603 !C 4. Completely dissolved: CA(NO3)2, CACL2, KNO3, KCL, MGSO4,
11604 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11606 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11607 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11608 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11610 !C=======================================================================
11612 DOUBLE PRECISION FUNCTION FUNCP122p1 (X)
11613 INCLUDE 'module_isrpia_inc.F'
11615 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11616 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11617 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11618 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11619 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11620 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11622 !C *** SETUP PARAMETERS ************************************************
11643 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11647 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11648 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11649 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11650 A9 = XK17 *(WATER/GAMA(17))**3.0
11652 !C CALCULATE DISSOCIATION QUANTITIES
11654 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
11655 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
11656 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
11657 2.D0*PSI16 + 2.D0*PSI17)
11658 PSI5 = MIN(MAX(PSI5, TINY),CHI5)
11660 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
11661 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
11662 CC = CHI4*(PSI5+PSI6)
11663 DD = MAX(BB*BB-4.d0*CC,ZERO)
11664 PSI4 =0.5d0*(-BB - SQRT(DD))
11665 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
11670 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
11671 BBP = PSI10+PSI13+PSI14
11672 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
11673 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
11674 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
11675 IF (ISLV.EQ.0) THEN
11676 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
11683 !C *** CALCULATE SPECIATION ********************************************
11685 MOLAL (2) = PSI8 + PSI7 ! NAI
11686 MOLAL (3) = PSI4 ! NH4I
11687 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
11688 MOLAL (5) = PSI9 + PSI10 ! SO4I
11689 MOLAL (6) = ZERO ! HSO4I
11690 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
11691 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
11692 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
11693 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
11695 !C *** CALCULATE H+ *****************************************************
11697 !C REST = 2.D0*W(2) + W(4) + W(5)
11701 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
11703 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
11705 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
11706 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
11708 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
11710 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
11711 !C DELT1 = 0.5*(-ALFA1 + DIAK)
11712 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
11714 !C DELT2 = MIN ( DELT2, DELT1)
11715 !C MOLAL(1) = DELT1 + DELT2 ! H+
11718 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
11720 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
11721 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
11722 CALL CALCPH2p1 (SMIN, HI, OHI)
11726 GNH3 = MAX(CHI4 - PSI4, TINY)
11727 GHNO3 = MAX(CHI5 - PSI5, TINY)
11728 GHCL = MAX(CHI6 - PSI6, TINY)
11734 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
11744 CALL CALCMR2p1 ! Water content
11746 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
11748 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
11755 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
11757 !!C20 FUNCP12 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
11758 20 FUNCP122p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
11762 !!C *** END OF FUNCTION FUNCP12 *******************************************
11766 !C=======================================================================
11768 !C *** ISORROPIA CODE II
11769 !C *** SUBROUTINE CALCP11
11772 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11773 !!C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11774 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11775 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3
11776 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL, MGSO4,
11777 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11779 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11780 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11781 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11783 !C=======================================================================
11785 SUBROUTINE CALCP112p1
11786 INCLUDE 'module_isrpia_inc.F'
11788 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11789 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11790 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11791 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11792 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11793 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11795 !C *** SETUP PARAMETERS ************************************************
11798 CHI11 = MIN (W(2), W(6)) ! CCASO4
11799 FRCA = MAX (W(6) - CHI11, ZERO)
11800 FRSO4 = MAX (W(2) - CHI11, ZERO)
11801 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
11802 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
11803 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
11804 CHI10 = FRSO4 ! CMGSO4
11805 FRMG = MAX (W(8) - CHI10, ZERO)
11806 CHI7 = MIN (W(1), W(5)) ! CNACL
11807 FRNA = MAX (W(1) - CHI7, ZERO)
11808 FRCL = MAX (W(5) - CHI7, ZERO)
11809 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
11810 FRCA = MAX (FRCA - CHI12, ZERO)
11811 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
11812 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
11813 FRCA = MAX (FRCA - CHI17, ZERO)
11814 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
11815 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
11816 FRMG = MAX (FRMG - CHI15, ZERO)
11817 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
11818 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
11819 FRMG = MAX (FRMG - CHI16, ZERO)
11820 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
11821 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
11822 FRNA = MAX (FRNA - CHI8, ZERO)
11823 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
11824 CHI14 = MIN (FRK, FRCL) ! CKCL
11825 FRK = MAX (FRK - CHI14, ZERO)
11826 FRCL = MAX (FRCL - CHI14, ZERO)
11827 CHI13 = MIN (FRK, FRNO3) ! CKNO3
11828 FRK = MAX (FRK - CHI13, ZERO)
11829 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
11831 CHI5 = FRNO3 ! HNO3(g)
11832 CHI6 = FRCL ! HCL(g)
11833 CHI4 = W(3) ! NH3(g)
11835 CHI3 = ZERO ! CNH4CL
11840 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
11842 !C *** INITIAL VALUES FOR BISECTION ************************************
11845 Y1 = FUNCP112p1 (X1)
11846 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
11848 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
11850 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
11853 Y2 = FUNCP112p1 (X2)
11854 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
11859 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
11861 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP112p1 (PSI6LO)
11864 !C *** PERFORM BISECTION ***********************************************
11868 Y3 = FUNCP112p1 (X3)
11869 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
11876 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
11878 CALL PUSHERR2p1 (0002, 'CALCP11') ! WARNING ERROR: NO CONVERGENCE
11880 !C *** CONVERGED ; RETURN **********************************************
11882 40 X3 = 0.5*(X1+X2)
11883 Y3 = FUNCP112p1 (X3)
11885 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
11888 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
11889 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
11890 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
11891 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
11892 MOLAL(6) = DELTA ! HSO4 EFFECT
11897 !C *** END OF SUBROUTINE CALCP11 ******************************************
11902 !C=======================================================================
11904 !C *** ISORROPIA CODE II
11905 !C *** SUBROUTINE FUNCP11
11908 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
11909 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
11910 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
11911 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3
11912 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL, MGSO4,
11913 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
11915 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
11916 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
11917 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
11919 !C=======================================================================
11921 DOUBLE PRECISION FUNCTION FUNCP112p1 (X)
11922 INCLUDE 'module_isrpia_inc.F'
11924 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
11925 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
11926 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
11927 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
11928 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
11929 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
11931 !C *** SETUP PARAMETERS ************************************************
11951 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
11955 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
11956 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
11957 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
11958 A9 = XK17 *(WATER/GAMA(17))**3.0
11959 A13 = XK19 *(WATER/GAMA(19))**2.0
11961 !C CALCULATE DISSOCIATION QUANTITIES
11963 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
11964 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
11965 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
11966 2.D0*PSI16 + 2.D0*PSI17)
11967 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
11969 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
11970 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
11971 CC = CHI4*(PSI5+PSI6)
11972 DD = MAX(BB*BB-4.d0*CC,ZERO)
11973 PSI4 =0.5d0*(-BB - SQRT(DD))
11974 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
11979 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
11980 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
11981 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
11982 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
11983 PSI13 =0.5d0*(-VHTA + SQRT(DELTA))
11984 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
11987 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
11988 BBP = PSI10+PSI13+PSI14
11989 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
11990 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
11991 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
11992 IF (ISLV.EQ.0) THEN
11993 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
12000 !C *** CALCULATE SPECIATION ********************************************
12002 MOLAL (2) = PSI8 + PSI7 ! NAI
12003 MOLAL (3) = PSI4 ! NH4I
12004 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
12005 MOLAL (5) = PSI9 + PSI10 ! SO4I
12006 MOLAL (6) = ZERO ! HSO4I
12007 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
12008 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
12009 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
12010 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
12012 !C *** CALCULATE H+ *****************************************************
12014 !C REST = 2.D0*W(2) + W(4) + W(5)
12018 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
12020 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
12022 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
12023 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
12025 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
12027 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
12028 !C DELT1 = 0.5*(-ALFA1 + DIAK)
12029 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
12031 !C DELT2 = MIN ( DELT2, DELT1)
12032 !C MOLAL(1) = DELT1 + DELT2 ! H+
12035 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
12037 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
12038 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
12039 CALL CALCPH2p1 (SMIN, HI, OHI)
12043 GNH3 = MAX(CHI4 - PSI4, TINY)
12044 GHNO3 = MAX(CHI5 - PSI5, TINY)
12045 GHCL = MAX(CHI6 - PSI6, TINY)
12051 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
12055 CKNO3 = MAX (CHI13 - PSI13, ZERO)
12061 CALL CALCMR2p1 ! Water content
12063 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12065 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12072 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12074 !C20 FUNCP11 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12075 20 FUNCP112p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
12079 !C *** END OF FUNCTION FUNCP11 *******************************************
12083 !C=======================================================================
12085 !C *** ISORROPIA CODE II
12086 !C *** SUBROUTINE CALCP10
12089 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12090 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12091 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12092 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4
12093 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL,
12094 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
12096 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12097 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12098 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12100 !C=======================================================================
12102 SUBROUTINE CALCP102p1
12103 INCLUDE 'module_isrpia_inc.F'
12105 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12106 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12107 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12108 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12109 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12110 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12112 !C *** SETUP PARAMETERS ************************************************
12115 CHI11 = MIN (W(2), W(6)) ! CCASO4
12116 FRCA = MAX (W(6) - CHI11, ZERO)
12117 FRSO4 = MAX (W(2) - CHI11, ZERO)
12118 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
12119 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
12120 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
12121 CHI10 = FRSO4 ! CMGSO4
12122 FRMG = MAX (W(8) - CHI10, ZERO)
12123 CHI7 = MIN (W(1), W(5)) ! CNACL
12124 FRNA = MAX (W(1) - CHI7, ZERO)
12125 FRCL = MAX (W(5) - CHI7, ZERO)
12126 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
12127 FRCA = MAX (FRCA - CHI12, ZERO)
12128 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
12129 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
12130 FRCA = MAX (FRCA - CHI17, ZERO)
12131 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
12132 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
12133 FRMG = MAX (FRMG - CHI15, ZERO)
12134 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
12135 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
12136 FRMG = MAX (FRMG - CHI16, ZERO)
12137 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
12138 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
12139 FRNA = MAX (FRNA - CHI8, ZERO)
12140 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
12141 CHI14 = MIN (FRK, FRCL) ! CKCL
12142 FRK = MAX (FRK - CHI14, ZERO)
12143 FRCL = MAX (FRCL - CHI14, ZERO)
12144 CHI13 = MIN (FRK, FRNO3) ! CKNO3
12145 FRK = MAX (FRK - CHI13, ZERO)
12146 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
12148 CHI5 = FRNO3 ! HNO3(g)
12149 CHI6 = FRCL ! HCL(g)
12150 CHI4 = W(3) ! NH3(g)
12152 CHI3 = ZERO ! CNH4CL
12157 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12159 !C *** INITIAL VALUES FOR BISECTION ************************************
12162 Y1 = FUNCP102p1 (X1)
12163 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12165 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12167 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12170 Y2 = FUNCP102p1 (X2)
12171 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12176 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12178 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP102p1 (PSI6LO)
12181 !C *** PERFORM BISECTION ***********************************************
12185 Y3 = FUNCP102p1 (X3)
12186 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12193 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12195 CALL PUSHERR2p1 (0002, 'CALCP10') ! WARNING ERROR: NO CONVERGENCE
12197 !C *** CONVERGED ; RETURN **********************************************
12199 40 X3 = 0.5*(X1+X2)
12200 Y3 = FUNCP102p1 (X3)
12202 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12205 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12206 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12207 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12208 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12209 MOLAL(6) = DELTA ! HSO4 EFFECT
12214 !C *** END OF SUBROUTINE CALCP10 ******************************************
12219 !C=======================================================================
12221 !C *** ISORROPIA CODE II
12222 !C *** SUBROUTINE FUNCP10
12225 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12226 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12227 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12228 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4
12229 !C 4. Completely dissolved: CA(NO3)2, CACL2, KCL,
12230 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
12232 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12233 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12234 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12236 !C=======================================================================
12238 DOUBLE PRECISION FUNCTION FUNCP102p1 (X)
12239 INCLUDE 'module_isrpia_inc.F'
12241 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12242 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12243 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12244 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12245 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12246 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12248 !C *** SETUP PARAMETERS ************************************************
12268 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12272 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12273 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12274 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12275 A9 = XK17 *(WATER/GAMA(17))**3.0
12276 A13 = XK19 *(WATER/GAMA(19))**2.0
12278 !C CALCULATE DISSOCIATION QUANTITIES
12280 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
12281 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
12282 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
12283 2.D0*PSI16 + 2.D0*PSI17)
12284 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
12286 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12287 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12288 CC = CHI4*(PSI5+PSI6)
12289 DD = MAX(BB*BB-4.d0*CC,ZERO)
12290 PSI4 =0.5d0*(-BB - SQRT(DD))
12291 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
12296 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
12297 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
12298 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
12299 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
12300 PSI13 =0.5d0*(-VHTA + SQRT(DELTA))
12301 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
12304 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
12305 BBP = PSI10+PSI13+PSI14
12306 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
12307 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
12308 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
12309 IF (ISLV.EQ.0) THEN
12310 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
12317 !C *** CALCULATE SPECIATION ********************************************
12319 MOLAL (2) = PSI8 + PSI7 ! NAI
12320 MOLAL (3) = PSI4 ! NH4I
12321 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
12322 MOLAL (5) = PSI9 + PSI10 ! SO4I
12323 MOLAL (6) = ZERO ! HSO4I
12324 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
12325 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
12326 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
12327 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
12329 !C *** CALCULATE H+ *****************************************************
12331 !C REST = 2.D0*W(2) + W(4) + W(5)
12335 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
12337 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
12339 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
12340 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
12342 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
12344 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
12345 !C DELT1 = 0.5*(-ALFA1 + DIAK)
12346 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
12348 !C DELT2 = MIN ( DELT2, DELT1)
12349 !C MOLAL(1) = DELT1 + DELT2 ! H+
12352 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
12354 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
12355 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
12356 CALL CALCPH2p1 (SMIN, HI, OHI)
12360 GNH3 = MAX(CHI4 - PSI4, TINY)
12361 GHNO3 = MAX(CHI5 - PSI5, TINY)
12362 GHCL = MAX(CHI6 - PSI6, TINY)
12368 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
12372 CKNO3 = MAX (CHI13 - PSI13, ZERO)
12378 CALL CALCMR2p1 ! Water content
12380 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12382 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12389 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12391 !C20 FUNCP10 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12392 20 FUNCP102p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
12396 !C *** END OF FUNCTION FUNCP10 *******************************************
12400 !C=======================================================================
12402 !C *** ISORROPIA CODE II
12403 !C *** SUBROUTINE CALCP9
12406 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12407 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12408 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12409 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL
12410 !C 4. Completely dissolved: CA(NO3)2, CACL2,
12411 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
12413 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12414 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12415 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12417 !C=======================================================================
12419 SUBROUTINE CALCP92p1
12420 INCLUDE 'module_isrpia_inc.F'
12422 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12423 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12424 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12425 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12426 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12427 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12429 !C *** SETUP PARAMETERS ************************************************
12432 CHI11 = MIN (W(2), W(6)) ! CCASO4
12433 FRCA = MAX (W(6) - CHI11, ZERO)
12434 FRSO4 = MAX (W(2) - CHI11, ZERO)
12435 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
12436 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
12437 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
12438 CHI10 = FRSO4 ! CMGSO4
12439 FRMG = MAX (W(8) - CHI10, ZERO)
12440 CHI7 = MIN (W(1), W(5)) ! CNACL
12441 FRNA = MAX (W(1) - CHI7, ZERO)
12442 FRCL = MAX (W(5) - CHI7, ZERO)
12443 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
12444 FRCA = MAX (FRCA - CHI12, ZERO)
12445 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
12446 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
12447 FRCA = MAX (FRCA - CHI17, ZERO)
12448 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
12449 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
12450 FRMG = MAX (FRMG - CHI15, ZERO)
12451 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
12452 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
12453 FRMG = MAX (FRMG - CHI16, ZERO)
12454 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
12455 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
12456 FRNA = MAX (FRNA - CHI8, ZERO)
12457 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
12458 CHI14 = MIN (FRK, FRCL) ! CKCL
12459 FRK = MAX (FRK - CHI14, ZERO)
12460 FRCL = MAX (FRCL - CHI14, ZERO)
12461 CHI13 = MIN (FRK, FRNO3) ! CKNO3
12462 FRK = MAX (FRK - CHI13, ZERO)
12463 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
12465 CHI5 = FRNO3 ! HNO3(g)
12466 CHI6 = FRCL ! HCL(g)
12467 CHI4 = W(3) ! NH3(g)
12469 CHI3 = ZERO ! CNH4CL
12474 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12476 !C *** INITIAL VALUES FOR BISECTION ************************************
12479 Y1 = FUNCP92p1 (X1)
12480 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12482 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12484 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12487 Y2 = FUNCP92p1 (X2)
12488 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12493 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12495 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP92p1 (PSI6LO)
12498 !C *** PERFORM BISECTION ***********************************************
12502 Y3 = FUNCP92p1 (X3)
12503 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12510 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12512 CALL PUSHERR2p1 (0002, 'CALCP9') ! WARNING ERROR: NO CONVERGENCE
12514 !C *** CONVERGED ; RETURN **********************************************
12516 40 X3 = 0.5*(X1+X2)
12517 Y3 = FUNCP92p1 (X3)
12519 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12522 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12523 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12524 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12525 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12526 MOLAL(6) = DELTA ! HSO4 EFFECT
12531 !C *** END OF SUBROUTINE CALCP9 ******************************************
12536 !C=======================================================================
12538 !C *** ISORROPIA CODE II
12539 !C *** SUBROUTINE FUNCP9
12542 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12543 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12544 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12545 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL
12546 !C 4. Completely dissolved: CA(NO3)2, CACL2,
12547 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
12549 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12550 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12551 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12553 !C=======================================================================
12555 DOUBLE PRECISION FUNCTION FUNCP92p1 (X)
12556 INCLUDE 'module_isrpia_inc.F'
12558 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12559 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12560 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12561 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12562 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12563 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12565 !C *** SETUP PARAMETERS ************************************************
12585 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12589 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12590 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12591 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12592 A9 = XK17 *(WATER/GAMA(17))**3.0
12593 A13 = XK19 *(WATER/GAMA(19))**2.0
12594 A14 = XK20 *(WATER/GAMA(20))**2.0
12596 !C CALCULATE DISSOCIATION QUANTITIES
12598 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
12599 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
12600 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
12601 2.D0*PSI16 + 2.D0*PSI17)
12602 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
12604 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12605 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12606 CC = CHI4*(PSI5+PSI6)
12607 DD = MAX(BB*BB-4.d0*CC,ZERO)
12608 PSI4 =0.5d0*(-BB - SQRT(DD))
12609 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
12614 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
12615 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
12616 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
12617 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
12618 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
12619 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
12622 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
12623 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
12624 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
12625 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
12628 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
12629 BBP = PSI10+PSI13+PSI14
12630 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
12631 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
12632 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
12633 IF (ISLV.EQ.0) THEN
12634 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
12641 !C *** CALCULATE SPECIATION ********************************************
12643 MOLAL (2) = PSI8 + PSI7 ! NAI
12644 MOLAL (3) = PSI4 ! NH4I
12645 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
12646 MOLAL (5) = PSI9 + PSI10 ! SO4I
12647 MOLAL (6) = ZERO ! HSO4I
12648 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
12649 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
12650 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
12651 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
12653 !C *** CALCULATE H+ *****************************************************
12655 !C REST = 2.D0*W(2) + W(4) + W(5)
12659 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
12661 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
12663 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
12664 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
12666 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
12668 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
12669 !C DELT1 = 0.5*(-ALFA1 + DIAK)
12670 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
12672 !C DELT2 = MIN ( DELT2, DELT1)
12673 !C MOLAL(1) = DELT1 + DELT2 ! H+
12676 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
12678 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
12679 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
12680 CALL CALCPH2p1 (SMIN, HI, OHI)
12684 GNH3 = MAX(CHI4 - PSI4, TINY)
12685 GHNO3 = MAX(CHI5 - PSI5, TINY)
12686 GHCL = MAX(CHI6 - PSI6, TINY)
12692 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
12696 CKNO3 = MAX (CHI13 - PSI13, ZERO)
12697 CKCL = MAX (CHI14 - PSI14, ZERO)
12702 CALL CALCMR2p1 ! Water content
12704 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
12706 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
12713 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
12715 !C20 FUNCP9 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
12716 20 FUNCP92p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
12720 !C *** END OF FUNCTION FUNCP9 *******************************************
12723 !C=======================================================================
12725 !C *** ISORROPIA CODE II
12726 !C *** SUBROUTINE CALCP8
12729 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12730 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12731 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12732 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL
12733 !C 4. Completely dissolved: CA(NO3)2, CACL2,
12734 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3
12736 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12737 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12738 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12740 !C=======================================================================
12742 SUBROUTINE CALCP82p1
12743 INCLUDE 'module_isrpia_inc.F'
12745 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12746 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12747 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12748 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12749 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12750 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12752 !C *** SETUP PARAMETERS ************************************************
12755 CHI11 = MIN (W(2), W(6)) ! CCASO4
12756 FRCA = MAX (W(6) - CHI11, ZERO)
12757 FRSO4 = MAX (W(2) - CHI11, ZERO)
12758 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
12759 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
12760 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
12761 CHI10 = FRSO4 ! CMGSO4
12762 FRMG = MAX (W(8) - CHI10, ZERO)
12763 CHI7 = MIN (W(1), W(5)) ! CNACL
12764 FRNA = MAX (W(1) - CHI7, ZERO)
12765 FRCL = MAX (W(5) - CHI7, ZERO)
12766 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
12767 FRCA = MAX (FRCA - CHI12, ZERO)
12768 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
12769 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
12770 FRCA = MAX (FRCA - CHI17, ZERO)
12771 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
12772 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
12773 FRMG = MAX (FRMG - CHI15, ZERO)
12774 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
12775 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
12776 FRMG = MAX (FRMG - CHI16, ZERO)
12777 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
12778 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
12779 FRNA = MAX (FRNA - CHI8, ZERO)
12780 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
12781 CHI14 = MIN (FRK, FRCL) ! CKCL
12782 FRK = MAX (FRK - CHI14, ZERO)
12783 FRCL = MAX (FRCL - CHI14, ZERO)
12784 CHI13 = MIN (FRK, FRNO3) ! CKNO3
12785 FRK = MAX (FRK - CHI13, ZERO)
12786 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
12788 CHI5 = FRNO3 ! HNO3(g)
12789 CHI6 = FRCL ! HCL(g)
12790 CHI4 = W(3) ! NH3(g)
12792 CHI3 = ZERO ! CNH4CL
12797 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
12799 !C *** INITIAL VALUES FOR BISECTION ************************************
12802 Y1 = FUNCP82p1 (X1)
12803 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
12805 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
12807 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
12810 Y2 = FUNCP82p1 (X2)
12811 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
12816 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
12818 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP82p1 (PSI6LO)
12821 !C *** PERFORM BISECTION ***********************************************
12825 Y3 = FUNCP82p1 (X3)
12826 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
12833 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
12835 CALL PUSHERR2p1 (0002, 'CALCP8') ! WARNING ERROR: NO CONVERGENCE
12837 !C *** CONVERGED ; RETURN **********************************************
12839 40 X3 = 0.5*(X1+X2)
12840 Y3 = FUNCP82p1 (X3)
12842 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
12845 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
12846 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
12847 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
12848 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
12849 MOLAL(6) = DELTA ! HSO4 EFFECT
12854 !C *** END OF SUBROUTINE CALCP8 ******************************************
12859 !C=======================================================================
12861 !C *** ISORROPIA CODE II
12862 !C *** SUBROUTINE FUNCP8
12865 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
12866 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
12867 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
12868 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL
12869 !C 4. Completely dissolved: CA(NO3)2, CACL2,
12870 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3
12872 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
12873 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
12874 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
12876 !C=======================================================================
12878 DOUBLE PRECISION FUNCTION FUNCP82p1 (X)
12879 INCLUDE 'module_isrpia_inc.F'
12881 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
12882 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
12883 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
12884 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
12885 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
12886 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
12888 !C *** SETUP PARAMETERS ************************************************
12908 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
12912 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
12913 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
12914 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
12915 A9 = XK17 *(WATER/GAMA(17))**3.0
12916 A13 = XK19 *(WATER/GAMA(19))**2.0
12917 A14 = XK20 *(WATER/GAMA(20))**2.0
12919 !C CALCULATE DISSOCIATION QUANTITIES
12921 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
12922 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
12923 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
12924 2.D0*PSI16 + 2.D0*PSI17)
12925 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
12927 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
12928 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
12929 CC = CHI4*(PSI5+PSI6)
12930 DD = MAX(BB*BB-4.d0*CC,ZERO)
12931 PSI4 =0.5d0*(-BB - SQRT(DD))
12932 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
12937 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
12938 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
12939 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
12940 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
12941 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
12942 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
12945 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
12946 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
12947 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
12948 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
12951 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
12952 BBP = PSI10+PSI13+PSI14
12953 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
12954 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
12955 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
12956 IF (ISLV.EQ.0) THEN
12957 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
12964 !C *** CALCULATE SPECIATION ********************************************
12966 MOLAL (2) = PSI8 + PSI7 ! NAI
12967 MOLAL (3) = PSI4 ! NH4I
12968 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
12969 MOLAL (5) = PSI9 + PSI10 ! SO4I
12970 MOLAL (6) = ZERO ! HSO4I
12971 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
12972 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
12973 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
12974 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
12976 !C *** CALCULATE H+ *****************************************************
12978 !C REST = 2.D0*W(2) + W(4) + W(5)
12982 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
12984 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
12986 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
12987 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
12989 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
12991 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
12992 !C DELT1 = 0.5*(-ALFA1 + DIAK)
12993 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
12995 !C DELT2 = MIN ( DELT2, DELT1)
12996 !C MOLAL(1) = DELT1 + DELT2 ! H+
12999 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
13001 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
13002 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
13003 CALL CALCPH2p1 (SMIN, HI, OHI)
13007 GNH3 = MAX(CHI4 - PSI4, TINY)
13008 GHNO3 = MAX(CHI5 - PSI5, TINY)
13009 GHCL = MAX(CHI6 - PSI6, TINY)
13015 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
13019 CKNO3 = MAX (CHI13 - PSI13, ZERO)
13020 CKCL = MAX (CHI14 - PSI14, ZERO)
13025 !C *** NH4Cl(s) calculations
13027 A3 = XK6 /(R*TEMP*R*TEMP)
13028 IF (GNH3*GHCL.GT.A3) THEN
13029 DELT = MIN(GNH3, GHCL)
13032 DD = BB*BB - 4.D0*CC
13033 PSI31 = 0.5D0*(-BB + SQRT(DD))
13034 PSI32 = 0.5D0*(-BB - SQRT(DD))
13035 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
13037 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
13045 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
13047 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
13049 GNH3 = MAX(GNH3 - PSI3, TINY)
13050 GHCL = MAX(GHCL - PSI3, TINY)
13053 CALL CALCMR2p1 ! Water content
13055 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13057 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13064 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
13066 !C20 FUNCP8 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
13067 20 FUNCP82p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
13071 !C *** END OF FUNCTION FUNCP8 *******************************************
13074 !C=======================================================================
13076 !C *** ISORROPIA CODE II
13077 !C *** SUBROUTINE CALCP7
13080 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13081 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13082 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
13083 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL
13084 !C 4. Completely dissolved: CA(NO3)2, CACL2,
13085 !C MG(NO3)2, MGCL2, NANO3, NH4NO3
13087 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
13088 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13089 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
13091 !C=======================================================================
13093 SUBROUTINE CALCP72p1
13094 INCLUDE 'module_isrpia_inc.F'
13096 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
13097 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
13098 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
13099 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
13100 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
13101 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
13103 !C *** SETUP PARAMETERS ************************************************
13106 CHI11 = MIN (W(2), W(6)) ! CCASO4
13107 FRCA = MAX (W(6) - CHI11, ZERO)
13108 FRSO4 = MAX (W(2) - CHI11, ZERO)
13109 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
13110 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
13111 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
13112 CHI10 = FRSO4 ! CMGSO4
13113 FRMG = MAX (W(8) - CHI10, ZERO)
13114 CHI7 = MIN (W(1), W(5)) ! CNACL
13115 FRNA = MAX (W(1) - CHI7, ZERO)
13116 FRCL = MAX (W(5) - CHI7, ZERO)
13117 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
13118 FRCA = MAX (FRCA - CHI12, ZERO)
13119 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
13120 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
13121 FRCA = MAX (FRCA - CHI17, ZERO)
13122 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
13123 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
13124 FRMG = MAX (FRMG - CHI15, ZERO)
13125 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
13126 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
13127 FRMG = MAX (FRMG - CHI16, ZERO)
13128 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
13129 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
13130 FRNA = MAX (FRNA - CHI8, ZERO)
13131 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
13132 CHI14 = MIN (FRK, FRCL) ! CKCL
13133 FRK = MAX (FRK - CHI14, ZERO)
13134 FRCL = MAX (FRCL - CHI14, ZERO)
13135 CHI13 = MIN (FRK, FRNO3) ! CKNO3
13136 FRK = MAX (FRK - CHI13, ZERO)
13137 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
13139 CHI5 = FRNO3 ! HNO3(g)
13140 CHI6 = FRCL ! HCL(g)
13141 CHI4 = W(3) ! NH3(g)
13143 CHI3 = ZERO ! CNH4CL
13148 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
13150 !C *** INITIAL VALUES FOR BISECTION ************************************
13153 Y1 = FUNCP72p1 (X1)
13154 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
13156 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13158 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
13161 Y2 = FUNCP72p1 (X2)
13162 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13167 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
13169 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP72p1 (PSI6LO)
13172 !C *** PERFORM BISECTION ***********************************************
13176 Y3 = FUNCP72p1 (X3)
13177 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13184 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13186 CALL PUSHERR2p1 (0002, 'CALCP7') ! WARNING ERROR: NO CONVERGENCE
13188 !C *** CONVERGED ; RETURN **********************************************
13190 40 X3 = 0.5*(X1+X2)
13191 Y3 = FUNCP72p1 (X3)
13193 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
13196 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
13197 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
13198 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
13199 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
13200 MOLAL(6) = DELTA ! HSO4 EFFECT
13205 !C *** END OF SUBROUTINE CALCP7 ******************************************
13210 !C=======================================================================
13212 !C *** ISORROPIA CODE II
13213 !C *** SUBROUTINE FUNCP7
13216 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13217 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13218 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
13219 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL
13220 !C 4. Completely dissolved: CA(NO3)2, CACL2,
13221 !C MG(NO3)2, MGCL2, NANO3, NH4NO3
13223 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
13224 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13225 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
13227 !C=======================================================================
13229 DOUBLE PRECISION FUNCTION FUNCP72p1 (X)
13230 INCLUDE 'module_isrpia_inc.F'
13232 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
13233 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
13234 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
13235 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
13236 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
13237 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
13239 !C *** SETUP PARAMETERS ************************************************
13259 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13263 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
13264 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
13265 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
13266 A9 = XK17 *(WATER/GAMA(17))**3.0
13267 A13 = XK19 *(WATER/GAMA(19))**2.0
13268 A14 = XK20 *(WATER/GAMA(20))**2.0
13269 A7 = XK8 *(WATER/GAMA(1))**2.0
13271 !C CALCULATE DISSOCIATION QUANTITIES
13273 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
13274 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
13275 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
13276 2.D0*PSI16 + 2.D0*PSI17)
13277 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
13279 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
13280 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
13281 CC = CHI4*(PSI5+PSI6)
13282 DD = MAX(BB*BB-4.d0*CC,ZERO)
13283 PSI4 =0.5d0*(-BB - SQRT(DD))
13284 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
13289 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
13290 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
13291 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
13292 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
13293 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
13294 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
13297 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
13298 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
13299 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
13300 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
13303 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
13304 BBP = PSI10+PSI13+PSI14
13305 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
13306 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
13307 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
13308 IF (ISLV.EQ.0) THEN
13309 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
13315 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
13316 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
13317 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
13318 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
13319 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
13320 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
13324 !C *** CALCULATE SPECIATION ********************************************
13326 MOLAL (2) = PSI8 + PSI7 ! NAI
13327 MOLAL (3) = PSI4 ! NH4I
13328 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
13329 MOLAL (5) = PSI9 + PSI10 ! SO4I
13330 MOLAL (6) = ZERO ! HSO4I
13331 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
13332 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
13333 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
13334 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
13336 !C *** CALCULATE H+ *****************************************************
13338 !C REST = 2.D0*W(2) + W(4) + W(5)
13342 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
13344 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
13346 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
13347 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
13349 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
13351 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
13352 !C DELT1 = 0.5*(-ALFA1 + DIAK)
13353 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
13355 !C DELT2 = MIN ( DELT2, DELT1)
13356 !C MOLAL(1) = DELT1 + DELT2 ! H+
13359 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
13361 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
13362 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
13363 CALL CALCPH2p1 (SMIN, HI, OHI)
13367 GNH3 = MAX(CHI4 - PSI4, TINY)
13368 GHNO3 = MAX(CHI5 - PSI5, TINY)
13369 GHCL = MAX(CHI6 - PSI6, TINY)
13373 CNACL = MAX (CHI7 - PSI7, ZERO)
13375 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
13379 CKNO3 = MAX (CHI13 - PSI13, ZERO)
13380 CKCL = MAX (CHI14 - PSI14, ZERO)
13385 !C *** NH4Cl(s) calculations
13387 A3 = XK6 /(R*TEMP*R*TEMP)
13388 IF (GNH3*GHCL.GT.A3) THEN
13389 DELT = MIN(GNH3, GHCL)
13392 DD = BB*BB - 4.D0*CC
13393 PSI31 = 0.5D0*(-BB + SQRT(DD))
13394 PSI32 = 0.5D0*(-BB - SQRT(DD))
13395 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
13397 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
13405 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
13407 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
13409 GNH3 = MAX(GNH3 - PSI3, TINY)
13410 GHCL = MAX(GHCL - PSI3, TINY)
13413 CALL CALCMR2p1 ! Water content
13415 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13417 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13424 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
13426 !C20 FUNCP7 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
13427 20 FUNCP72p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
13431 !C *** END OF FUNCTION FUNCP7 *******************************************
13434 !C=======================================================================
13436 !C *** ISORROPIA CODE II
13437 !C *** SUBROUTINE CALCP6
13440 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13441 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13442 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
13443 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3
13444 !C 4. Completely dissolved: CA(NO3)2, CACL2,
13445 !C MG(NO3)2, MGCL2, NH4NO3
13447 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
13448 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13449 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
13451 !C=======================================================================
13453 SUBROUTINE CALCP62p1
13454 INCLUDE 'module_isrpia_inc.F'
13456 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
13457 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
13458 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
13459 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
13460 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
13461 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
13463 !C *** SETUP PARAMETERS ************************************************
13466 CHI11 = MIN (W(2), W(6)) ! CCASO4
13467 FRCA = MAX (W(6) - CHI11, ZERO)
13468 FRSO4 = MAX (W(2) - CHI11, ZERO)
13469 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
13470 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
13471 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
13472 CHI10 = FRSO4 ! CMGSO4
13473 FRMG = MAX (W(8) - CHI10, ZERO)
13474 CHI7 = MIN (W(1), W(5)) ! CNACL
13475 FRNA = MAX (W(1) - CHI7, ZERO)
13476 FRCL = MAX (W(5) - CHI7, ZERO)
13477 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
13478 FRCA = MAX (FRCA - CHI12, ZERO)
13479 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
13480 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
13481 FRCA = MAX (FRCA - CHI17, ZERO)
13482 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
13483 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
13484 FRMG = MAX (FRMG - CHI15, ZERO)
13485 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
13486 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
13487 FRMG = MAX (FRMG - CHI16, ZERO)
13488 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
13489 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
13490 FRNA = MAX (FRNA - CHI8, ZERO)
13491 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
13492 CHI14 = MIN (FRK, FRCL) ! CKCL
13493 FRK = MAX (FRK - CHI14, ZERO)
13494 FRCL = MAX (FRCL - CHI14, ZERO)
13495 CHI13 = MIN (FRK, FRNO3) ! CKNO3
13496 FRK = MAX (FRK - CHI13, ZERO)
13497 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
13499 CHI5 = FRNO3 ! HNO3(g)
13500 CHI6 = FRCL ! HCL(g)
13501 CHI4 = W(3) ! NH3(g)
13503 CHI3 = ZERO ! CNH4CL
13508 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
13510 !C *** INITIAL VALUES FOR BISECTION ************************************
13513 Y1 = FUNCP62p1 (X1)
13514 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
13516 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13518 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
13521 Y2 = FUNCP62p1 (X2)
13522 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13527 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
13529 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP62p1 (PSI6LO)
13532 !C *** PERFORM BISECTION ***********************************************
13536 Y3 = FUNCP62p1 (X3)
13537 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13544 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13546 CALL PUSHERR2p1 (0002, 'CALCP6') ! WARNING ERROR: NO CONVERGENCE
13548 !C *** CONVERGED ; RETURN **********************************************
13550 40 X3 = 0.5*(X1+X2)
13551 Y3 = FUNCP62p1 (X3)
13553 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
13556 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
13557 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
13558 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
13559 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
13560 MOLAL(6) = DELTA ! HSO4 EFFECT
13565 !C *** END OF SUBROUTINE CALCP6 ******************************************
13570 !C=======================================================================
13572 !C *** ISORROPIA CODE II
13573 !C *** SUBROUTINE FUNCP6
13576 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13577 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13578 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
13579 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3
13580 !C 4. Completely dissolved: CA(NO3)2, CACL2,
13581 !C MG(NO3)2, MGCL2, NH4NO3
13583 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
13584 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13585 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
13587 !C=======================================================================
13589 DOUBLE PRECISION FUNCTION FUNCP62p1 (X)
13590 INCLUDE 'module_isrpia_inc.F'
13592 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
13593 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
13594 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
13595 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
13596 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
13597 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
13599 !C *** SETUP PARAMETERS ************************************************
13619 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
13623 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
13624 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
13625 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
13626 A9 = XK17 *(WATER/GAMA(17))**3.0
13627 A13 = XK19 *(WATER/GAMA(19))**2.0
13628 A14 = XK20 *(WATER/GAMA(20))**2.0
13629 A7 = XK8 *(WATER/GAMA(1))**2.0
13630 A8 = XK9 *(WATER/GAMA(3))**2.0
13632 !C CALCULATE DISSOCIATION QUANTITIES
13634 PSI5 = CHI5*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) - &
13635 A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
13636 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
13637 2.D0*PSI16 + 2.D0*PSI17)
13638 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
13640 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
13641 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
13642 CC = CHI4*(PSI5+PSI6)
13643 DD = MAX(BB*BB-4.d0*CC,ZERO)
13644 PSI4 =0.5d0*(-BB - SQRT(DD))
13645 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
13650 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
13651 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
13652 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
13653 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
13654 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
13655 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
13658 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
13659 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
13660 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
13661 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
13664 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
13665 BBP = PSI10+PSI13+PSI14
13666 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
13667 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
13668 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
13669 IF (ISLV.EQ.0) THEN
13670 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
13676 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
13677 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
13678 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
13679 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
13680 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
13681 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
13684 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
13685 !C VIT = PSI5+PSI13+PSI7+2.D0*PSI12+2.D0*PSI15
13686 !C GKAM = PSI7*(2.D0*PSI12+PSI5+PSI13+2.D0*PSI15)-A8
13687 !C DIA = MAX(VIT*VIT - 4.0D0*GKAM,ZERO)
13688 !C PSI8 = 0.5D0*( -VIT + SQRT(DIA) )
13689 PSI8 = A8/A7*(PSI6+PSI7+PSI14+2.D0*PSI16+2.D0*PSI17)- &
13690 PSI5-2.D0*PSI12-PSI13-2.D0*PSI15
13691 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
13695 !C *** CALCULATE SPECIATION ********************************************
13697 MOLAL (2) = PSI8 + PSI7 ! NAI
13698 MOLAL (3) = PSI4 ! NH4I
13699 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
13700 MOLAL (5) = PSI9 + PSI10 ! SO4I
13701 MOLAL (6) = ZERO ! HSO4I
13702 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
13703 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
13704 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
13705 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
13707 !C *** CALCULATE H+ *****************************************************
13709 !C REST = 2.D0*W(2) + W(4) + W(5)
13713 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
13715 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
13717 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
13718 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
13720 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
13722 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
13723 !C DELT1 = 0.5*(-ALFA1 + DIAK)
13724 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
13726 !C DELT2 = MIN ( DELT2, DELT1)
13727 !C MOLAL(1) = DELT1 + DELT2 ! H+
13730 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
13732 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
13733 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
13734 CALL CALCPH2p1 (SMIN, HI, OHI)
13738 GNH3 = MAX(CHI4 - PSI4, TINY)
13739 GHNO3 = MAX(CHI5 - PSI5, TINY)
13740 GHCL = MAX(CHI6 - PSI6, TINY)
13744 CNACL = MAX (CHI7 - PSI7, ZERO)
13745 CNANO3 = MAX (CHI8 - PSI8, ZERO)
13746 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
13750 CKNO3 = MAX (CHI13 - PSI13, ZERO)
13751 CKCL = MAX (CHI14 - PSI14, ZERO)
13756 !C *** NH4Cl(s) calculations
13758 A3 = XK6 /(R*TEMP*R*TEMP)
13759 IF (GNH3*GHCL.GT.A3) THEN
13760 DELT = MIN(GNH3, GHCL)
13763 DD = BB*BB - 4.D0*CC
13764 PSI31 = 0.5D0*(-BB + SQRT(DD))
13765 PSI32 = 0.5D0*(-BB - SQRT(DD))
13766 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
13768 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
13776 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
13778 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
13780 GNH3 = MAX(GNH3 - PSI3, TINY)
13781 GHCL = MAX(GHCL - PSI3, TINY)
13784 CALL CALCMR2p1 ! Water content
13786 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
13788 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
13795 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
13797 !C20 FUNCP6 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
13798 20 FUNCP62p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
13802 !C *** END OF FUNCTION FUNCP6 *******************************************
13806 !C=======================================================================
13808 !C *** ISORROPIA CODE II
13809 !C *** SUBROUTINE CALCP5
13812 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13813 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13814 !C 2. SOLID AEROSOL ONLY
13815 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, KCL, MGSO4,
13816 !C NANO3, NACL, NH4NO3, NH4CL
13818 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
13819 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13820 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
13822 !C=======================================================================
13824 SUBROUTINE CALCP52p1
13825 INCLUDE 'module_isrpia_inc.F'
13826 EXTERNAL CALCP1A2p1, CALCP62p1
13828 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
13830 IF (W(4).GT.TINY) THEN ! NO3 EXIST, WATER POSSIBLE
13831 SCASE = 'P5 ; SUBCASE 1'
13833 SCASE = 'P5 ; SUBCASE 1'
13834 ELSE ! NO3, CL NON EXISTANT
13835 SCASE = 'P1 ; SUBCASE 1'
13837 SCASE = 'P1 ; SUBCASE 1'
13840 IF (WATER.LE.TINY) THEN
13841 IF (RH.LT.DRMP5) THEN ! ONLY SOLIDS
13847 SCASE = 'P5 ; SUBCASE 2'
13850 SCASE = 'P5 ; SUBCASE 3' ! MDRH REGION (CaSO4, K2SO4, KNO3, KCL, MGSO4,
13851 !C NANO3, NACL, NH4NO3, NH4CL)
13852 CALL CALCMDRH22p1 (RH, DRMP5, DRNH4NO3, CALCP1A2p1, CALCP62p1)
13853 SCASE = 'P5 ; SUBCASE 3'
13859 !C *** END OF SUBROUTINE CALCP5 ******************************************
13863 !C=======================================================================
13865 !C *** ISORROPIA CODE II
13866 !C *** SUBROUTINE CALCP5A
13869 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
13870 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
13871 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
13872 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3, NH4NO3
13873 !C 4. Completely dissolved: CA(NO3)2, CACL2,
13876 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
13877 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
13878 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
13880 !C=======================================================================
13882 SUBROUTINE CALCP5A2p1
13883 INCLUDE 'module_isrpia_inc.F'
13885 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
13886 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
13887 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
13888 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
13889 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
13890 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
13892 !C *** SETUP PARAMETERS ************************************************
13895 CHI11 = MIN (W(2), W(6)) ! CCASO4
13896 FRCA = MAX (W(6) - CHI11, ZERO)
13897 FRSO4 = MAX (W(2) - CHI11, ZERO)
13898 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
13899 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
13900 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
13901 CHI10 = FRSO4 ! CMGSO4
13902 FRMG = MAX (W(8) - CHI10, ZERO)
13903 CHI7 = MIN (W(1), W(5)) ! CNACL
13904 FRNA = MAX (W(1) - CHI7, ZERO)
13905 FRCL = MAX (W(5) - CHI7, ZERO)
13906 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
13907 FRCA = MAX (FRCA - CHI12, ZERO)
13908 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
13909 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
13910 FRCA = MAX (FRCA - CHI17, ZERO)
13911 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
13912 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
13913 FRMG = MAX (FRMG - CHI15, ZERO)
13914 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
13915 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
13916 FRMG = MAX (FRMG - CHI16, ZERO)
13917 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
13918 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
13919 FRNA = MAX (FRNA - CHI8, ZERO)
13920 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
13921 CHI14 = MIN (FRK, FRCL) ! CKCL
13922 FRK = MAX (FRK - CHI14, ZERO)
13923 FRCL = MAX (FRCL - CHI14, ZERO)
13924 CHI13 = MIN (FRK, FRNO3) ! CKNO3
13925 FRK = MAX (FRK - CHI13, ZERO)
13926 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
13928 CHI5 = FRNO3 ! HNO3(g)
13929 CHI6 = FRCL ! HCL(g)
13930 CHI4 = W(3) ! NH3(g)
13932 CHI3 = ZERO ! CNH4CL
13937 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
13939 !C *** INITIAL VALUES FOR BISECTION ************************************
13942 Y1 = FUNCP52p1 (X1)
13943 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
13945 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
13947 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
13950 Y2 = FUNCP52p1 (X2)
13951 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
13956 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
13958 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP52p1 (PSI6LO)
13961 !C *** PERFORM BISECTION ***********************************************
13965 Y3 = FUNCP52p1 (X3)
13966 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
13973 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
13975 CALL PUSHERR2p1 (0002, 'CALCP5') ! WARNING ERROR: NO CONVERGENCE
13977 !C *** CONVERGED ; RETURN **********************************************
13979 40 X3 = 0.5*(X1+X2)
13980 Y3 = FUNCP52p1 (X3)
13982 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
13985 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
13986 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
13987 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
13988 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
13989 MOLAL(6) = DELTA ! HSO4 EFFECT
13994 !C *** END OF SUBROUTINE CALCP5A ******************************************
13999 !C=======================================================================
14001 !C *** ISORROPIA CODE II
14002 !C *** SUBROUTINE FUNCP5
14005 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14006 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14007 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
14008 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3, NH4NO3
14009 !C 4. Completely dissolved: CA(NO3)2, CACL2,
14012 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
14013 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14014 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
14016 !C=======================================================================
14018 DOUBLE PRECISION FUNCTION FUNCP52p1 (X)
14019 INCLUDE 'module_isrpia_inc.F'
14021 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
14022 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
14023 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
14024 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
14025 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
14026 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
14028 !C *** SETUP PARAMETERS ************************************************
14048 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14052 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
14053 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
14054 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
14055 A9 = XK17 *(WATER/GAMA(17))**3.0
14056 A13 = XK19 *(WATER/GAMA(19))**2.0
14057 A14 = XK20 *(WATER/GAMA(20))**2.0
14058 A7 = XK8 *(WATER/GAMA(1))**2.0
14059 A8 = XK9 *(WATER/GAMA(3))**2.0
14061 !C CALCULATE DISSOCIATION QUANTITIES
14063 PSI5 = (CHI5-PSI2)*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) &
14064 - A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
14065 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
14066 2.D0*PSI16 + 2.D0*PSI17)
14067 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
14069 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
14070 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
14071 CC = CHI4*(PSI5+PSI6)
14072 DD = MAX(BB*BB-4.d0*CC,ZERO)
14073 PSI4 =0.5d0*(-BB - SQRT(DD))
14074 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
14079 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
14080 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
14081 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
14082 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
14083 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
14084 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
14087 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
14088 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
14089 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
14090 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
14093 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
14094 BBP = PSI10+PSI13+PSI14
14095 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
14096 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
14097 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
14098 IF (ISLV.EQ.0) THEN
14099 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
14105 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
14106 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
14107 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
14108 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
14109 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
14110 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
14113 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
14114 !C VIT = PSI5+PSI13+PSI7+2.D0*PSI12+2.D0*PSI15
14115 !C GKAM = PSI7*(2.D0*PSI12+PSI5+PSI13+2.D0*PSI15)-A8
14116 !C DIA = MAX(VIT*VIT - 4.0D0*GKAM,ZERO)
14117 !C PSI8 = 0.5D0*( -VIT + SQRT(DIA) )
14118 PSI8 = A8/A7*(PSI6+PSI7+PSI14+2.D0*PSI16+2.D0*PSI17)- &
14119 PSI5-2.D0*PSI12-PSI13-2.D0*PSI15
14120 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
14124 !C *** CALCULATE SPECIATION ********************************************
14126 MOLAL (2) = PSI8 + PSI7 ! NAI
14127 MOLAL (3) = PSI4 ! NH4I
14128 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
14129 MOLAL (5) = PSI9 + PSI10 ! SO4I
14130 MOLAL (6) = ZERO ! HSO4I
14131 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
14132 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
14133 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
14134 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
14136 !CC *** CALCULATE H+ *****************************************************
14138 !C REST = 2.D0*W(2) + W(4) + W(5)
14142 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
14144 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
14146 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
14147 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
14149 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
14151 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
14152 !C DELT1 = 0.5*(-ALFA1 + DIAK)
14153 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
14155 !C DELT2 = MIN ( DELT2, DELT1)
14156 !C MOLAL(1) = DELT1 + DELT2 ! H+
14159 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
14161 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
14162 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
14163 CALL CALCPH2p1 (SMIN, HI, OHI)
14167 GNH3 = MAX(CHI4 - PSI4, TINY)
14168 GHNO3 = MAX(CHI5 - PSI5, TINY)
14169 GHCL = MAX(CHI6 - PSI6, TINY)
14173 CNACL = MAX (CHI7 - PSI7, ZERO)
14174 CNANO3 = MAX (CHI8 - PSI8, ZERO)
14175 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
14179 CKNO3 = MAX (CHI13 - PSI13, ZERO)
14180 CKCL = MAX (CHI14 - PSI14, ZERO)
14185 !C *** NH4Cl(s) calculations
14187 A3 = XK6 /(R*TEMP*R*TEMP)
14188 IF (GNH3*GHCL.GT.A3) THEN
14189 DELT = MIN(GNH3, GHCL)
14192 DD = BB*BB - 4.D0*CC
14193 PSI31 = 0.5D0*(-BB + SQRT(DD))
14194 PSI32 = 0.5D0*(-BB - SQRT(DD))
14195 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
14197 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
14205 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
14207 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
14209 GNH3 = MAX(GNH3 - PSI3, TINY)
14210 GHCL = MAX(GHCL - PSI3, TINY)
14213 !C *** NH4NO3(s) calculations
14215 A2 = XK10 /(R*TEMP*R*TEMP)
14216 IF (GNH3*GHNO3.GT.A2) THEN
14217 DELT = MIN(GNH3, GHNO3)
14220 DD = BB*BB - 4.D0*CC
14221 PSI21 = 0.5D0*(-BB + SQRT(DD))
14222 PSI22 = 0.5D0*(-BB - SQRT(DD))
14223 IF (DELT-PSI21.GT.ZERO .AND. PSI21.GT.ZERO) THEN
14225 ELSEIF (DELT-PSI22.GT.ZERO .AND. PSI22.GT.ZERO) THEN
14233 PSI2 = MAX(MIN(MIN(PSI2,CHI4-PSI4-PSI3),CHI5-PSI5), ZERO)
14235 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
14237 GNH3 = MAX(GNH3 - PSI2, TINY)
14238 GHCL = MAX(GHNO3 - PSI2, TINY)
14241 CALL CALCMR2p1 ! Water content
14243 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14245 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14252 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
14254 !C20 FUNCP5 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
14255 20 FUNCP52p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
14259 !C *** END OF FUNCTION FUNCP5 *******************************************
14263 !C=======================================================================
14265 !C *** ISORROPIA CODE II
14266 !C *** SUBROUTINE CALCP4
14269 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14270 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14271 !C 2. SOLID AEROSOL ONLY
14272 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, KCL, MGSO4,
14273 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
14275 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14276 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14277 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
14279 !C=======================================================================
14281 SUBROUTINE CALCP42p1
14282 INCLUDE 'module_isrpia_inc.F'
14283 EXTERNAL CALCP1A2p1, CALCP5A2p1
14285 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
14287 IF (W(4).GT.TINY) THEN ! NO3 EXIST, WATER POSSIBLE
14288 SCASE = 'P4 ; SUBCASE 1'
14290 SCASE = 'P4 ; SUBCASE 1'
14291 ELSE ! NO3, CL NON EXISTANT
14292 SCASE = 'P1 ; SUBCASE 1'
14294 SCASE = 'P1 ; SUBCASE 1'
14297 IF (WATER.LE.TINY) THEN
14298 IF (RH.LT.DRMP4) THEN ! ONLY SOLIDS
14304 SCASE = 'P4 ; SUBCASE 2'
14307 SCASE = 'P4 ; SUBCASE 3' ! MDRH REGION (CaSO4, K2SO4, KNO3, KCL, MGSO4,
14308 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
14309 CALL CALCMDRH22p1 (RH, DRMP4, DRMGNO32, CALCP1A2p1, CALCP5A2p1)
14310 SCASE = 'P4 ; SUBCASE 3'
14316 !C *** END OF SUBROUTINE CALCP4 ******************************************
14320 !C=======================================================================
14322 !C *** ISORROPIA CODE II
14323 !C *** SUBROUTINE CALCP4A
14326 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14327 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14328 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
14329 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3, NH4NO3, MG(NO3)2
14330 !C 4. Completely dissolved: CA(NO3)2, CACL2, MGCL2
14332 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
14333 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14334 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
14336 !C=======================================================================
14338 SUBROUTINE CALCP4A2p1
14339 INCLUDE 'module_isrpia_inc.F'
14341 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
14342 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
14343 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
14344 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
14345 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
14346 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
14348 !C *** SETUP PARAMETERS ************************************************
14351 CHI11 = MIN (W(2), W(6)) ! CCASO4
14352 FRCA = MAX (W(6) - CHI11, ZERO)
14353 FRSO4 = MAX (W(2) - CHI11, ZERO)
14354 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
14355 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
14356 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
14357 CHI10 = FRSO4 ! CMGSO4
14358 FRMG = MAX (W(8) - CHI10, ZERO)
14359 CHI7 = MIN (W(1), W(5)) ! CNACL
14360 FRNA = MAX (W(1) - CHI7, ZERO)
14361 FRCL = MAX (W(5) - CHI7, ZERO)
14362 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
14363 FRCA = MAX (FRCA - CHI12, ZERO)
14364 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
14365 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
14366 FRCA = MAX (FRCA - CHI17, ZERO)
14367 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
14368 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
14369 FRMG = MAX (FRMG - CHI15, ZERO)
14370 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
14371 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
14372 FRMG = MAX (FRMG - CHI16, ZERO)
14373 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
14374 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
14375 FRNA = MAX (FRNA - CHI8, ZERO)
14376 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
14377 CHI14 = MIN (FRK, FRCL) ! CKCL
14378 FRK = MAX (FRK - CHI14, ZERO)
14379 FRCL = MAX (FRCL - CHI14, ZERO)
14380 CHI13 = MIN (FRK, FRNO3) ! CKNO3
14381 FRK = MAX (FRK - CHI13, ZERO)
14382 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
14384 CHI5 = FRNO3 ! HNO3(g)
14385 CHI6 = FRCL ! HCL(g)
14386 CHI4 = W(3) ! NH3(g)
14388 CHI3 = ZERO ! CNH4CL
14393 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
14395 !C *** INITIAL VALUES FOR BISECTION ************************************
14398 Y1 = FUNCP42p1 (X1)
14399 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
14401 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14403 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
14406 Y2 = FUNCP42p1 (X2)
14407 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14412 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
14414 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP42p1 (PSI6LO)
14417 !C *** PERFORM BISECTION ***********************************************
14421 Y3 = FUNCP42p1 (X3)
14422 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14429 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14431 CALL PUSHERR2p1 (0002, 'CALCP4') ! WARNING ERROR: NO CONVERGENCE
14433 !C *** CONVERGED ; RETURN **********************************************
14435 40 X3 = 0.5*(X1+X2)
14436 Y3 = FUNCP42p1 (X3)
14438 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
14441 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
14442 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
14443 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
14444 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
14445 MOLAL(6) = DELTA ! HSO4 EFFECT
14450 !C *** END OF SUBROUTINE CALCP4A ******************************************
14455 !C=======================================================================
14457 !C *** ISORROPIA CODE II
14458 !C *** SUBROUTINE FUNCP4
14461 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14462 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14463 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
14464 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL, NANO3, NH4NO3, MG(NO3)2
14465 !C 4. Completely dissolved: CA(NO3)2, CACL2, MGCL2
14467 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
14468 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14469 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
14471 !C=======================================================================
14473 DOUBLE PRECISION FUNCTION FUNCP42p1 (X)
14474 INCLUDE 'module_isrpia_inc.F'
14476 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
14477 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
14478 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
14479 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
14480 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
14481 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
14483 !C *** SETUP PARAMETERS ************************************************
14503 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14507 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
14508 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
14509 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
14510 A9 = XK17 *(WATER/GAMA(17))**3.0
14511 A13 = XK19 *(WATER/GAMA(19))**2.0
14512 A14 = XK20 *(WATER/GAMA(20))**2.0
14513 A7 = XK8 *(WATER/GAMA(1))**2.0
14514 A8 = XK9 *(WATER/GAMA(3))**2.0
14516 !C CALCULATE DISSOCIATION QUANTITIES
14518 PSI5 = (CHI5-PSI2)*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) &
14519 - A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
14520 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
14521 2.D0*PSI16 + 2.D0*PSI17)
14522 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
14524 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
14525 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
14526 CC = CHI4*(PSI5+PSI6)
14527 DD = MAX(BB*BB-4.d0*CC,ZERO)
14528 PSI4 =0.5d0*(-BB - SQRT(DD))
14529 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
14534 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
14535 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
14536 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
14537 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
14538 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
14539 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
14542 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
14543 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
14544 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
14545 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
14548 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
14549 BBP = PSI10+PSI13+PSI14
14550 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
14551 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
14552 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
14553 IF (ISLV.EQ.0) THEN
14554 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
14560 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
14561 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
14562 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
14563 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
14564 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
14565 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
14568 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
14569 !C VIT = PSI5+PSI13+PSI7+2.D0*PSI12+2.D0*PSI15
14570 !C GKAM = PSI7*(2.D0*PSI12+PSI5+PSI13+2.D0*PSI15)-A8
14571 !C DIA = MAX(VIT*VIT - 4.0D0*GKAM,ZERO)
14572 !C PSI8 = 0.5D0*( -VIT + SQRT(DIA) )
14573 PSI8 = A8/A7*(PSI6+PSI7+PSI14+2.D0*PSI16+2.D0*PSI17)- &
14574 PSI5-2.D0*PSI12-PSI13-2.D0*PSI15
14575 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
14579 !C *** CALCULATE SPECIATION ********************************************
14581 MOLAL (2) = PSI8 + PSI7 ! NAI
14582 MOLAL (3) = PSI4 ! NH4I
14583 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
14584 MOLAL (5) = PSI9 + PSI10 ! SO4I
14585 MOLAL (6) = ZERO ! HSO4I
14586 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
14587 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
14588 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
14589 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
14591 !C *** CALCULATE H+ *****************************************************
14593 !C REST = 2.D0*W(2) + W(4) + W(5)
14597 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
14599 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
14601 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
14602 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
14604 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
14606 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
14607 !C DELT1 = 0.5*(-ALFA1 + DIAK)
14608 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
14610 !C DELT2 = MIN ( DELT2, DELT1)
14611 !C MOLAL(1) = DELT1 + DELT2 ! H+
14614 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
14616 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
14617 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
14618 CALL CALCPH2p1 (SMIN, HI, OHI)
14622 GNH3 = MAX(CHI4 - PSI4, TINY)
14623 GHNO3 = MAX(CHI5 - PSI5, TINY)
14624 GHCL = MAX(CHI6 - PSI6, TINY)
14628 CNACL = MAX (CHI7 - PSI7, ZERO)
14629 CNANO3 = MAX (CHI8 - PSI8, ZERO)
14630 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
14634 CKNO3 = MAX (CHI13 - PSI13, ZERO)
14635 CKCL = MAX (CHI14 - PSI14, ZERO)
14640 !C *** NH4Cl(s) calculations
14642 A3 = XK6 /(R*TEMP*R*TEMP)
14643 IF (GNH3*GHCL.GT.A3) THEN
14644 DELT = MIN(GNH3, GHCL)
14647 DD = BB*BB - 4.D0*CC
14648 PSI31 = 0.5D0*(-BB + SQRT(DD))
14649 PSI32 = 0.5D0*(-BB - SQRT(DD))
14650 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
14652 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
14660 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
14662 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
14664 GNH3 = MAX(GNH3 - PSI3, TINY)
14665 GHCL = MAX(GHCL - PSI3, TINY)
14668 !C *** NH4NO3(s) calculations
14670 A2 = XK10 /(R*TEMP*R*TEMP)
14671 IF (GNH3*GHNO3.GT.A2) THEN
14672 DELT = MIN(GNH3, GHNO3)
14675 DD = BB*BB - 4.D0*CC
14676 PSI21 = 0.5D0*(-BB + SQRT(DD))
14677 PSI22 = 0.5D0*(-BB - SQRT(DD))
14678 IF (DELT-PSI21.GT.ZERO .AND. PSI21.GT.ZERO) THEN
14680 ELSEIF (DELT-PSI22.GT.ZERO .AND. PSI22.GT.ZERO) THEN
14688 PSI2 = MAX(MIN(MIN(PSI2,CHI4-PSI4-PSI3),CHI5-PSI5), ZERO)
14690 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
14692 GNH3 = MAX(GNH3 - PSI2, TINY)
14693 GHCL = MAX(GHNO3 - PSI2, TINY)
14696 CALL CALCMR2p1 ! Water content
14698 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
14700 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
14707 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
14709 !C20 FUNCP4 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
14710 20 FUNCP42p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
14714 !C *** END OF FUNCTION FUNCP4 *******************************************
14718 !C=======================================================================
14720 !C *** ISORROPIA CODE II
14721 !C *** SUBROUTINE CALCP3
14724 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14725 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14726 !C 2. SOLID AEROSOL ONLY
14727 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
14728 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
14730 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
14731 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14732 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
14734 !C=======================================================================
14736 SUBROUTINE CALCP32p1
14737 INCLUDE 'module_isrpia_inc.F'
14738 EXTERNAL CALCP1A2p1, CALCP4A2p1
14740 !C *** REGIME DEPENDS ON THE EXISTANCE OF WATER AND OF THE RH ************
14742 IF (W(4).GT.TINY .AND. W(5).GT.TINY) THEN ! NO3,CL EXIST, WATER POSSIBLE
14743 SCASE = 'P3 ; SUBCASE 1'
14745 SCASE = 'P3 ; SUBCASE 1'
14746 ELSE ! NO3, CL NON EXISTANT
14747 SCASE = 'P1 ; SUBCASE 1'
14749 SCASE = 'P1 ; SUBCASE 1'
14752 IF (WATER.LE.TINY) THEN
14753 IF (RH.LT.DRMP3) THEN ! ONLY SOLIDS
14759 SCASE = 'P3 ; SUBCASE 2'
14762 SCASE = 'P3 ; SUBCASE 3' ! MDRH REGION (CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
14763 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
14764 CALL CALCMDRH22p1 (RH, DRMP3, DRCANO32, CALCP1A2p1, CALCP4A2p1)
14765 SCASE = 'P3 ; SUBCASE 3'
14771 !C *** END OF SUBROUTINE CALCP3 ******************************************
14775 !C=======================================================================
14777 !C *** ISORROPIA CODE II
14778 !C *** SUBROUTINE CALCP3A
14781 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14782 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14783 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
14784 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
14785 !C NANO3, NH4NO3, MG(NO3)2, CA(NO3)2
14786 !C 4. Completely dissolved: CACL2, MGCL2
14788 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
14789 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14790 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
14792 !C=======================================================================
14794 SUBROUTINE CALCP3A2p1
14795 INCLUDE 'module_isrpia_inc.F'
14797 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
14798 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
14799 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
14800 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
14801 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
14802 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
14804 !C *** SETUP PARAMETERS ************************************************
14807 CHI11 = MIN (W(2), W(6)) ! CCASO4
14808 FRCA = MAX (W(6) - CHI11, ZERO)
14809 FRSO4 = MAX (W(2) - CHI11, ZERO)
14810 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
14811 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
14812 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
14813 CHI10 = FRSO4 ! CMGSO4
14814 FRMG = MAX (W(8) - CHI10, ZERO)
14815 CHI7 = MIN (W(1), W(5)) ! CNACL
14816 FRNA = MAX (W(1) - CHI7, ZERO)
14817 FRCL = MAX (W(5) - CHI7, ZERO)
14818 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
14819 FRCA = MAX (FRCA - CHI12, ZERO)
14820 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
14821 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
14822 FRCA = MAX (FRCA - CHI17, ZERO)
14823 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
14824 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
14825 FRMG = MAX (FRMG - CHI15, ZERO)
14826 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
14827 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
14828 FRMG = MAX (FRMG - CHI16, ZERO)
14829 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
14830 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
14831 FRNA = MAX (FRNA - CHI8, ZERO)
14832 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
14833 CHI14 = MIN (FRK, FRCL) ! CKCL
14834 FRK = MAX (FRK - CHI14, ZERO)
14835 FRCL = MAX (FRCL - CHI14, ZERO)
14836 CHI13 = MIN (FRK, FRNO3) ! CKNO3
14837 FRK = MAX (FRK - CHI13, ZERO)
14838 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
14840 CHI5 = FRNO3 ! HNO3(g)
14841 CHI6 = FRCL ! HCL(g)
14842 CHI4 = W(3) ! NH3(g)
14844 CHI3 = ZERO ! CNH4CL
14849 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
14851 !C *** INITIAL VALUES FOR BISECTION ************************************
14854 Y1 = FUNCP32p1 (X1)
14855 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
14857 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
14859 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
14862 Y2 = FUNCP32p1 (X2)
14863 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
14868 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
14870 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP32p1 (PSI6LO)
14873 !C *** PERFORM BISECTION ***********************************************
14877 Y3 = FUNCP32p1 (X3)
14878 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
14885 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
14887 CALL PUSHERR2p1 (0002, 'CALCP3') ! WARNING ERROR: NO CONVERGENCE
14889 !C *** CONVERGED ; RETURN **********************************************
14891 40 X3 = 0.5*(X1+X2)
14892 Y3 = FUNCP32p1 (X3)
14894 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
14897 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
14898 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
14899 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
14900 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
14901 MOLAL(6) = DELTA ! HSO4 EFFECT
14906 !C *** END OF SUBROUTINE CALCP3A ******************************************
14911 !C=======================================================================
14913 !C *** ISORROPIA CODE II
14914 !C *** SUBROUTINE FUNCP3
14917 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
14918 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
14919 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
14920 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
14921 !C NANO3, NH4NO3, MG(NO3)2, CA(NO3)2
14922 !C 4. Completely dissolved: CACL2, MGCL2
14924 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
14925 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
14926 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
14928 !C=======================================================================
14930 DOUBLE PRECISION FUNCTION FUNCP32p1 (X)
14931 INCLUDE 'module_isrpia_inc.F'
14933 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
14934 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
14935 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
14936 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
14937 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
14938 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
14940 !C *** SETUP PARAMETERS ************************************************
14960 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
14964 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
14965 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
14966 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
14967 A9 = XK17 *(WATER/GAMA(17))**3.0
14968 A13 = XK19 *(WATER/GAMA(19))**2.0
14969 A14 = XK20 *(WATER/GAMA(20))**2.0
14970 A7 = XK8 *(WATER/GAMA(1))**2.0
14971 A8 = XK9 *(WATER/GAMA(3))**2.0
14973 !C CALCULATE DISSOCIATION QUANTITIES
14975 PSI5 = (CHI5-PSI2)*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) &
14976 - A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
14977 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
14978 2.D0*PSI16 + 2.D0*PSI17)
14979 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
14981 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
14982 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
14983 CC = CHI4*(PSI5+PSI6)
14984 DD = MAX(BB*BB-4.d0*CC,ZERO)
14985 PSI4 =0.5d0*(-BB - SQRT(DD))
14986 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
14991 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
14992 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
14993 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
14994 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
14995 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
14996 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
14999 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
15000 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
15001 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
15002 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
15005 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
15006 BBP = PSI10+PSI13+PSI14
15007 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
15008 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
15009 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
15010 IF (ISLV.EQ.0) THEN
15011 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
15017 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
15018 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
15019 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
15020 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
15021 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
15022 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
15025 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
15026 !C VIT = PSI5+PSI13+PSI7+2.D0*PSI12+2.D0*PSI15
15027 !C GKAM = PSI7*(2.D0*PSI12+PSI5+PSI13+2.D0*PSI15)-A8
15028 !C DIA = MAX(VIT*VIT - 4.0D0*GKAM,ZERO)
15029 !C PSI8 = 0.5D0*( -VIT + SQRT(DIA) )
15030 PSI8 = A8/A7*(PSI6+PSI7+PSI14+2.D0*PSI16+2.D0*PSI17)- &
15031 PSI5-2.D0*PSI12-PSI13-2.D0*PSI15
15032 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
15036 !C *** CALCULATE SPECIATION ********************************************
15038 MOLAL (2) = PSI8 + PSI7 ! NAI
15039 MOLAL (3) = PSI4 ! NH4I
15040 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
15041 MOLAL (5) = PSI9 + PSI10 ! SO4I
15042 MOLAL (6) = ZERO ! HSO4I
15043 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
15044 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
15045 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
15046 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
15048 !C *** CALCULATE H+ *****************************************************
15050 !C REST = 2.D0*W(2) + W(4) + W(5)
15054 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
15056 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
15058 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
15059 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
15061 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
15063 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
15064 !C DELT1 = 0.5*(-ALFA1 + DIAK)
15065 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
15067 !C DELT2 = MIN ( DELT2, DELT1)
15068 !C MOLAL(1) = DELT1 + DELT2 ! H+
15071 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
15073 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
15074 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
15075 CALL CALCPH2p1 (SMIN, HI, OHI)
15079 GNH3 = MAX(CHI4 - PSI4, TINY)
15080 GHNO3 = MAX(CHI5 - PSI5, TINY)
15081 GHCL = MAX(CHI6 - PSI6, TINY)
15085 CNACL = MAX (CHI7 - PSI7, ZERO)
15086 CNANO3 = MAX (CHI8 - PSI8, ZERO)
15087 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
15091 CKNO3 = MAX (CHI13 - PSI13, ZERO)
15092 CKCL = MAX (CHI14 - PSI14, ZERO)
15097 !C *** NH4Cl(s) calculations
15099 A3 = XK6 /(R*TEMP*R*TEMP)
15100 IF (GNH3*GHCL.GT.A3) THEN
15101 DELT = MIN(GNH3, GHCL)
15104 DD = BB*BB - 4.D0*CC
15105 PSI31 = 0.5D0*(-BB + SQRT(DD))
15106 PSI32 = 0.5D0*(-BB - SQRT(DD))
15107 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
15109 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
15117 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6), ZERO)
15119 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
15121 GNH3 = MAX(GNH3 - PSI3, TINY)
15122 GHCL = MAX(GHCL - PSI3, TINY)
15125 !C *** NH4NO3(s) calculations
15127 A2 = XK10 /(R*TEMP*R*TEMP)
15128 IF (GNH3*GHNO3.GT.A2) THEN
15129 DELT = MIN(GNH3, GHNO3)
15132 DD = BB*BB - 4.D0*CC
15133 PSI21 = 0.5D0*(-BB + SQRT(DD))
15134 PSI22 = 0.5D0*(-BB - SQRT(DD))
15135 IF (DELT-PSI21.GT.ZERO .AND. PSI21.GT.ZERO) THEN
15137 ELSEIF (DELT-PSI22.GT.ZERO .AND. PSI22.GT.ZERO) THEN
15145 PSI2 = MAX(MIN(MIN(PSI2,CHI4-PSI4-PSI3),CHI5-PSI5),ZERO)
15147 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
15149 GNH3 = MAX(GNH3 - PSI2, TINY)
15150 GHCL = MAX(GHNO3 - PSI2, TINY)
15153 CALL CALCMR2p1 ! Water content
15155 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
15157 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
15164 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
15166 !C20 FUNCP3 = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
15167 20 FUNCP32p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
15171 !C *** END OF FUNCTION FUNCP3 *******************************************
15175 !C=======================================================================
15177 !C *** ISORROPIA CODE II
15178 !C *** SUBROUTINE CALCP2
15181 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15182 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
15183 !C 2. SOLID AEROSOL ONLY
15184 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
15185 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
15187 !C THERE ARE THREE REGIMES IN THIS CASE:
15188 !C 1. CACL2(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCL2A)
15189 !C 2. CACL2(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
15190 !C 3. CACL2(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
15192 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES P1A, P2B
15194 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
15195 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15196 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
15198 !C=======================================================================
15201 SUBROUTINE CALCP22p1
15202 INCLUDE 'module_isrpia_inc.F'
15203 EXTERNAL CALCP1A2p1, CALCP3A2p1, CALCP4A2p1, CALCP5A2p1, CALCP62p1
15205 !C *** FIND DRY COMPOSITION **********************************************
15209 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
15211 IF (CCACL2.GT.TINY) THEN
15212 SCASE = 'P2 ; SUBCASE 1'
15214 SCASE = 'P2 ; SUBCASE 1'
15217 IF (WATER.LE.TINY) THEN
15218 IF (RH.LT.DRMP2) THEN ! ONLY SOLIDS
15224 SCASE = 'P2 ; SUBCASE 2'
15226 IF (CMGCL2.GT. TINY) THEN
15227 SCASE = 'P2 ; SUBCASE 3' ! MDRH (CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4, MGCL2,
15228 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
15229 CALL CALCMDRH22p1 (RH, DRMP2, DRMGCL2, CALCP1A2p1, CALCP3A2p1)
15230 SCASE = 'P2 ; SUBCASE 3'
15232 IF (WATER.LE.TINY .AND. RH.GE.DRMP3 .AND. RH.LT.DRMP4) THEN
15233 SCASE = 'P2 ; SUBCASE 4' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4, CANO32,
15234 !C MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL)
15235 CALL CALCMDRH22p1 (RH, DRMP3, DRCANO32, CALCP1A2p1, CALCP4A2p1)
15236 SCASE = 'P2 ; SUBCASE 4'
15238 IF (WATER.LE.TINY .AND. RH.GE.DRMP4 .AND. RH.LT.DRMP5) THEN
15239 SCASE = 'P2 ; SUBCASE 5' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4,
15240 !C MGNO32, NANO3, NACL, NH4NO3, NH4CL)
15241 CALL CALCMDRH22p1 (RH, DRMP4, DRMGNO32, CALCP1A2p1, CALCP5A2p1)
15242 SCASE = 'P2 ; SUBCASE 5'
15244 IF (WATER.LE.TINY .AND. RH.GE.DRMP5) THEN
15245 SCASE = 'P2 ; SUBCASE 6' ! MDRH (CaSO4, K2SO4, KNO3, KCL, MGSO4,
15246 !C NANO3, NACL, NH4NO3, NH4CL)
15247 CALL CALCMDRH22p1 (RH, DRMP5, DRNH4NO3, CALCP1A2p1, CALCP62p1)
15248 SCASE = 'P2 ; SUBCASE 6'
15255 SCASE = 'P2 ; SUBCASE 2'
15262 !C *** END OF SUBROUTINE CALCP2 ******************************************
15266 !C=======================================================================
15268 !C *** ISORROPIA CODE II
15269 !C *** SUBROUTINE CALCP2A
15272 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15273 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
15274 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
15275 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
15276 !C NANO3, NH4NO3, MG(NO3)2, CA(NO3)2
15277 !C 4. Completely dissolved: CACL2
15279 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
15280 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15281 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
15283 !C=======================================================================
15285 SUBROUTINE CALCP2A2p1
15286 INCLUDE 'module_isrpia_inc.F'
15288 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
15289 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
15290 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
15291 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
15292 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
15293 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
15295 !C *** SETUP PARAMETERS ************************************************
15298 CHI11 = MIN (W(2), W(6)) ! CCASO4
15299 FRCA = MAX (W(6) - CHI11, ZERO)
15300 FRSO4 = MAX (W(2) - CHI11, ZERO)
15301 CHI9 = MIN (FRSO4, 0.5D0*W(7)) ! CK2SO4
15302 FRK = MAX (W(7) - 2.D0*CHI9, ZERO)
15303 FRSO4 = MAX (FRSO4 - CHI9, ZERO)
15304 CHI10 = FRSO4 ! CMGSO4
15305 FRMG = MAX (W(8) - CHI10, ZERO)
15306 CHI7 = MIN (W(1), W(5)) ! CNACL
15307 FRNA = MAX (W(1) - CHI7, ZERO)
15308 FRCL = MAX (W(5) - CHI7, ZERO)
15309 CHI12 = MIN (FRCA, 0.5D0*W(4)) ! CCANO32
15310 FRCA = MAX (FRCA - CHI12, ZERO)
15311 FRNO3 = MAX (W(4) - 2.D0*CHI12, ZERO)
15312 CHI17 = MIN (FRCA, 0.5D0*FRCL) ! CCACL2
15313 FRCA = MAX (FRCA - CHI17, ZERO)
15314 FRCL = MAX (FRCL - 2.D0*CHI17, ZERO)
15315 CHI15 = MIN (FRMG, 0.5D0*FRNO3) ! CMGNO32
15316 FRMG = MAX (FRMG - CHI15, ZERO)
15317 FRNO3 = MAX (FRNO3 - 2.D0*CHI15, ZERO)
15318 CHI16 = MIN (FRMG, 0.5D0*FRCL) ! CMGCL2
15319 FRMG = MAX (FRMG - CHI16, ZERO)
15320 FRCL = MAX (FRCL - 2.D0*CHI16, ZERO)
15321 CHI8 = MIN (FRNA, FRNO3) ! CNANO3
15322 FRNA = MAX (FRNA - CHI8, ZERO)
15323 FRNO3 = MAX (FRNO3 - CHI8, ZERO)
15324 CHI14 = MIN (FRK, FRCL) ! CKCL
15325 FRK = MAX (FRK - CHI14, ZERO)
15326 FRCL = MAX (FRCL - CHI14, ZERO)
15327 CHI13 = MIN (FRK, FRNO3) ! CKNO3
15328 FRK = MAX (FRK - CHI13, ZERO)
15329 FRNO3 = MAX (FRNO3 - CHI13, ZERO)
15331 CHI5 = FRNO3 ! HNO3(g)
15332 CHI6 = FRCL ! HCL(g)
15333 CHI4 = W(3) ! NH3(g)
15335 CHI3 = ZERO ! CNH4CL
15340 PSI6HI = CHI6-TINY ! MIN(CHI6-TINY, CHI4)
15342 !C *** INITIAL VALUES FOR BISECTION ************************************
15345 Y1 = FUNCP2A2p1 (X1)
15346 IF (ABS(Y1).LE.EPS .OR. CHI6.LE.TINY) GOTO 50
15348 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
15350 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
15353 Y2 = FUNCP2A2p1 (X2)
15354 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
15359 !C *** NO SUBDIVISION WITH SOLUTION; IF ABS(Y2)<EPS SOLUTION IS ASSUMED
15361 IF (ABS(Y2) .GT. EPS) Y2 = FUNCP2A2p1(PSI6LO)
15364 !C *** PERFORM BISECTION ***********************************************
15368 Y3 = FUNCP2A2p1 (X3)
15369 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
15376 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
15378 CALL PUSHERR2p1 (0002, 'CALCP2A') ! WARNING ERROR: NO CONVERGENCE
15380 !C *** CONVERGED ; RETURN **********************************************
15382 40 X3 = 0.5*(X1+X2)
15383 Y3 = FUNCP2A2p1 (X3)
15385 !C *** CALCULATE HSO4 SPECIATION AND RETURN *******************************
15388 IF (MOLAL(1).GT.TINY .AND. MOLAL(5).GT.TINY) THEN
15389 CALL CALCHS42p1 (MOLAL(1), MOLAL(5), ZERO, DELTA)
15390 MOLAL(1) = MOLAL(1) - DELTA ! H+ EFFECT
15391 MOLAL(5) = MOLAL(5) - DELTA ! SO4 EFFECT
15392 MOLAL(6) = DELTA ! HSO4 EFFECT
15397 !C *** END OF SUBROUTINE CALCP2A ******************************************
15402 !C=======================================================================
15404 !C *** ISORROPIA CODE II
15405 !C *** SUBROUTINE FUNCP2A
15408 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15409 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
15410 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
15411 !C 3. SOLIDS POSSIBLE : CaSO4, K2SO4, KNO3, MGSO4, KCL, NH4CL, NACL,
15412 !C NANO3, NH4NO3, MG(NO3)2, CA(NO3)2, MGCL2
15413 !C 4. Completely dissolved: CACL2
15415 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
15416 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15417 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
15419 !C=======================================================================
15421 DOUBLE PRECISION FUNCTION FUNCP2A2p1 (X)
15422 INCLUDE 'module_isrpia_inc.F'
15424 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
15425 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
15426 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
15427 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
15428 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
15429 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
15431 !C *** SETUP PARAMETERS ************************************************
15451 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
15455 A4 = (XK2/XKW)*R*TEMP*(GAMA(10)/GAMA(5))**2.0
15456 A5 = XK4 *R*TEMP*(WATER/GAMA(10))**2.0
15457 A6 = XK3 *R*TEMP*(WATER/GAMA(11))**2.0
15458 A9 = XK17 *(WATER/GAMA(17))**3.0
15459 A13 = XK19 *(WATER/GAMA(19))**2.0
15460 A14 = XK20 *(WATER/GAMA(20))**2.0
15461 A7 = XK8 *(WATER/GAMA(1))**2.0
15462 A8 = XK9 *(WATER/GAMA(3))**2.0
15464 !C CALCULATE DISSOCIATION QUANTITIES
15466 PSI5 = (CHI5-PSI2)*(PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17) &
15467 - A6/A5*(PSI8+2.D0*PSI12+PSI13+2.D0*PSI15)*(CHI6-PSI6-PSI3)
15468 PSI5 = PSI5/(A6/A5*(CHI6-PSI6-PSI3) + PSI6 + PSI7 + PSI14 + &
15469 2.D0*PSI16 + 2.D0*PSI17)
15470 PSI5 = MIN (MAX (PSI5, TINY) , CHI5)
15472 IF (W(3).GT.TINY .AND. WATER.GT.TINY) THEN ! First try 3rd order soln
15473 BB =-(CHI4 + PSI6 + PSI5 + 1.d0/A4)
15474 CC = CHI4*(PSI5+PSI6)
15475 DD = MAX(BB*BB-4.d0*CC,ZERO)
15476 PSI4 =0.5d0*(-BB - SQRT(DD))
15477 PSI4 = MIN(MAX(PSI4,ZERO),CHI4)
15482 IF (CHI13.GT.TINY .AND. WATER.GT.TINY) THEN !KNO3
15483 VHTA = PSI5+PSI8+2.D0*PSI12+2.D0*PSI15+PSI14+2.D0*PSI9
15484 GKAMA = (PSI5+PSI8+2.D0*PSI12+2.D0*PSI15)*(2.D0*PSI9+PSI14)-A13
15485 DELTA = MAX(VHTA*VHTA-4.d0*GKAMA,ZERO)
15486 PSI13 = 0.5d0*(-VHTA + SQRT(DELTA))
15487 PSI13 = MIN(MAX(PSI13,ZERO),CHI13)
15490 IF (CHI14.GT.TINY .AND. WATER.GT.TINY) THEN !KCL
15491 PSI14 = A14/A13*(PSI5+PSI8+2.D0*PSI12+PSI13+2.D0*PSI15) - &
15492 PSI6-PSI7-2.D0*PSI16-2.D0*PSI17
15493 PSI14 = MIN (MAX (PSI14, ZERO), CHI14)
15496 IF (CHI9.GT.TINY .AND. WATER.GT.TINY) THEN !K2SO4
15497 BBP = PSI10+PSI13+PSI14
15498 CCP = (PSI13+PSI14)*(0.25D0*(PSI13+PSI14)+PSI10)
15499 DDP = 0.25D0*(PSI13+PSI14)**2.0*PSI10-A9/4.D0
15500 CALL POLY32p1 (BBP, CCP, DDP, PSI9, ISLV)
15501 IF (ISLV.EQ.0) THEN
15502 PSI9 = MIN (MAX(PSI9,ZERO) , CHI9)
15508 IF (CHI7.GT.TINY .AND. WATER.GT.TINY) THEN ! NACL DISSOLUTION
15509 VITA = PSI6+PSI14+PSI8+2.D0*PSI16+2.D0*PSI17
15510 GKAMA= PSI8*(2.D0*PSI16+PSI6+PSI14+2.D0*PSI17)-A7
15511 DIAK = MAX(VITA*VITA - 4.0D0*GKAMA,ZERO)
15512 PSI7 = 0.5D0*( -VITA + SQRT(DIAK) )
15513 PSI7 = MAX(MIN(PSI7, CHI7), ZERO)
15516 IF (CHI8.GT.TINY .AND. WATER.GT.TINY) THEN ! NANO3 DISSOLUTION
15517 !C VIT = PSI5+PSI13+PSI7+2.D0*PSI12+2.D0*PSI15
15518 !C GKAM = PSI7*(2.D0*PSI12+PSI5+PSI13+2.D0*PSI15)-A8
15519 !C DIA = MAX(VIT*VIT - 4.0D0*GKAM,ZERO)
15520 !C PSI8 = 0.5D0*( -VIT + SQRT(DIA) )
15521 PSI8 = A8/A7*(PSI6+PSI7+PSI14+2.D0*PSI16+2.D0*PSI17)- &
15522 PSI5-2.D0*PSI12-PSI13-2.D0*PSI15
15523 PSI8 = MAX(MIN(PSI8, CHI8), ZERO)
15527 !C *** CALCULATE SPECIATION ********************************************
15529 MOLAL (2) = PSI8 + PSI7 ! NAI
15530 MOLAL (3) = PSI4 ! NH4I
15531 MOLAL (4) = PSI6 + PSI7 + PSI14 + 2.D0*PSI16 + 2.D0*PSI17 ! CLI
15532 MOLAL (5) = PSI9 + PSI10 ! SO4I
15533 MOLAL (6) = ZERO ! HSO4I
15534 MOLAL (7) = PSI5 + PSI8 + 2.D0*PSI12 + PSI13 + 2.D0*PSI15 ! NO3I
15535 MOLAL (8) = PSI11 + PSI12 + PSI17 ! CAI
15536 MOLAL (9) = 2.D0*PSI9 + PSI13 + PSI14 ! KI
15537 MOLAL (10)= PSI10 + PSI15 + PSI16 ! MGI
15539 !C *** CALCULATE H+ *****************************************************
15541 !C REST = 2.D0*W(2) + W(4) + W(5)
15545 !C IF (W(1)+W(6)+W(7)+W(8).GT.REST) THEN
15547 !CC *** CALCULATE EQUILIBRIUM CONSTANTS **********************************
15549 !C ALFA1 = XK26*RH*(WATER/1.0) ! CO2(aq) + H2O
15550 !C ALFA2 = XK27*(WATER/1.0) ! HCO3-
15552 !C X = W(1)+W(6)+W(7)+W(8) - REST ! EXCESS OF CRUSTALS EQUALS CO2(aq)
15554 !C DIAK = SQRT( (ALFA1)**2.0 + 4.0D0*ALFA1*X)
15555 !C DELT1 = 0.5*(-ALFA1 + DIAK)
15556 !C DELT1 = MIN ( MAX (DELT1, ZERO), X)
15558 !C DELT2 = MIN ( DELT2, DELT1)
15559 !C MOLAL(1) = DELT1 + DELT2 ! H+
15562 !CC *** NO EXCESS OF CRUSTALS CALCULATE H+ *******************************
15564 SMIN = 2.d0*MOLAL(5)+MOLAL(7)+MOLAL(4)-MOLAL(2)-MOLAL(3) &
15565 - MOLAL(9) - 2.D0*MOLAL(10) - 2.D0*MOLAL(8)
15566 CALL CALCPH2p1 (SMIN, HI, OHI)
15570 GNH3 = MAX(CHI4 - PSI4, TINY)
15571 GHNO3 = MAX(CHI5 - PSI5, TINY)
15572 GHCL = MAX(CHI6 - PSI6, TINY)
15576 CNACL = MAX (CHI7 - PSI7, ZERO)
15577 CNANO3 = MAX (CHI8 - PSI8, ZERO)
15578 CK2SO4 = MAX (CHI9 - PSI9, ZERO)
15582 CKNO3 = MAX (CHI13 - PSI13, ZERO)
15583 CKCL = MAX (CHI14 - PSI14, ZERO)
15588 !C *** NH4Cl(s) calculations
15590 A3 = XK6 /(R*TEMP*R*TEMP)
15591 IF (GNH3*GHCL.GT.A3) THEN
15592 DELT = MIN(GNH3, GHCL)
15595 DD = BB*BB - 4.D0*CC
15596 PSI31 = 0.5D0*(-BB + SQRT(DD))
15597 PSI32 = 0.5D0*(-BB - SQRT(DD))
15598 IF (DELT-PSI31.GT.ZERO .AND. PSI31.GT.ZERO) THEN
15600 ELSEIF (DELT-PSI32.GT.ZERO .AND. PSI32.GT.ZERO) THEN
15608 PSI3 = MAX(MIN(MIN(PSI3,CHI4-PSI4),CHI6-PSI6),ZERO)
15610 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
15612 GNH3 = MAX(GNH3 - PSI3, TINY)
15613 GHCL = MAX(GHCL - PSI3, TINY)
15616 !C *** NH4NO3(s) calculations
15618 A2 = XK10 /(R*TEMP*R*TEMP)
15619 IF (GNH3*GHNO3.GT.A2) THEN
15620 DELT = MIN(GNH3, GHNO3)
15623 DD = BB*BB - 4.D0*CC
15624 PSI21 = 0.5D0*(-BB + SQRT(DD))
15625 PSI22 = 0.5D0*(-BB - SQRT(DD))
15626 IF (DELT-PSI21.GT.ZERO .AND. PSI21.GT.ZERO) THEN
15628 ELSEIF (DELT-PSI22.GT.ZERO .AND. PSI22.GT.ZERO) THEN
15636 PSI2 = MAX(MIN(MIN(PSI2,CHI4-PSI4-PSI3),CHI5-PSI5),ZERO)
15638 !C *** CALCULATE GAS / SOLID SPECIES (LIQUID IN MOLAL ALREADY) *********
15640 GNH3 = MAX (GNH3 - PSI2, TINY)
15641 GHCL = MAX (GHNO3 - PSI2, TINY)
15644 CALL CALCMR2p1 ! Water content
15646 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
15648 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
15655 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
15657 !C20 FUNCP2A = MOLAL(3)*MOLAL(4)/GHCL/GNH3/A6/A4 - ONE
15658 20 FUNCP2A2p1 = MOLAL(1)*MOLAL(4)/GHCL/A6 - ONE
15662 !C *** END OF FUNCTION FUNCP2A *******************************************
15667 !C=======================================================================
15669 !C *** ISORROPIA CODE II
15670 !C *** SUBROUTINE CALCP1
15673 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15674 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
15675 !C 2. SOLID AEROSOL ONLY
15676 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
15677 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
15679 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
15680 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
15681 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCP1A)
15683 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
15684 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15685 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
15687 !C=======================================================================
15689 SUBROUTINE CALCP12p1
15690 INCLUDE 'module_isrpia_inc.F'
15691 EXTERNAL CALCP1A2p1, CALCP2A2p1
15693 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
15695 IF (RH.LT.DRMP1) THEN
15696 SCASE = 'P1 ; SUBCASE 1'
15697 CALL CALCP1A2p1 ! SOLID PHASE ONLY POSSIBLE
15698 SCASE = 'P1 ; SUBCASE 1'
15700 SCASE = 'P1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
15701 CALL CALCMDRH22p1 (RH, DRMP1, DRCACL2, CALCP1A2p1, CALCP2A2p1)
15702 SCASE = 'P1 ; SUBCASE 2'
15708 !C *** END OF SUBROUTINE CALCP1 ******************************************
15712 !C=======================================================================
15714 !C *** ISORROPIA CODE II
15715 !C *** SUBROUTINE CALCP1A
15718 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15719 !C 1. SULFATE POOR (SULRAT > 2.0) ; Rcr+Na >= 2.0 ; Rcr > 2)
15720 !C 2. SOLID AEROSOL ONLY
15721 !C 3. SOLIDS POSSIBLE : CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
15722 !C MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
15724 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
15725 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15726 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
15728 !C=======================================================================
15730 SUBROUTINE CALCP1A2p1
15731 INCLUDE 'module_isrpia_inc.F'
15732 DOUBLE PRECISION LAMDA, LAMDA1, LAMDA2, KAPA, KAPA1, KAPA2, NAFR, &
15735 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
15737 CCASO4 = MIN (W(2), W(6)) !SOLID CASO4
15738 CAFR = MAX (W(6) - CCASO4, ZERO)
15739 SO4FR = MAX (W(2) - CCASO4, ZERO)
15740 CK2SO4 = MIN (SO4FR, 0.5D0*W(7)) !SOLID K2SO4
15741 FRK = MAX (W(7) - 2.D0*CK2SO4, ZERO)
15742 SO4FR = MAX (SO4FR - CK2SO4, ZERO)
15743 CMGSO4 = SO4FR !SOLID MGSO4
15744 FRMG = MAX (W(8) - CMGSO4, ZERO)
15745 CNACL = MIN (W(1), W(5)) !SOLID NACL
15746 NAFR = MAX (W(1) - CNACL, ZERO)
15747 CLFR = MAX (W(5) - CNACL, ZERO)
15748 CCANO32 = MIN (CAFR, 0.5D0*W(4)) !SOLID CA(NO3)2
15749 CAFR = MAX (CAFR - CCANO32, ZERO)
15750 NO3FR = MAX (W(4) - 2.D0*CCANO32, ZERO)
15751 CCACL2 = MIN (CAFR, 0.5D0*CLFR) !SOLID CACL2
15752 CAFR = MAX (CAFR - CCACL2, ZERO)
15753 CLFR = MAX (CLFR - 2.D0*CCACL2, ZERO)
15754 CMGNO32 = MIN (FRMG, 0.5D0*NO3FR) !SOLID MG(NO3)2
15755 FRMG = MAX (FRMG - CMGNO32, ZERO)
15756 NO3FR = MAX (NO3FR - 2.D0*CMGNO32, ZERO)
15757 CMGCL2 = MIN (FRMG, 0.5D0*CLFR) !SOLID MGCL2
15758 FRMG = MAX (FRMG - CMGCL2, ZERO)
15759 CLFR = MAX (CLFR - 2.D0*CMGCL2, ZERO)
15760 CNANO3 = MIN (NAFR, NO3FR) !SOLID NANO3
15761 NAFR = MAX (NAFR - CNANO3, ZERO)
15762 NO3FR = MAX (NO3FR - CNANO3, ZERO)
15763 CKCL = MIN (FRK, CLFR) !SOLID KCL
15764 FRK = MAX (FRK - CKCL, ZERO)
15765 CLFR = MAX (CLFR - CKCL, ZERO)
15766 CKNO3 = MIN (FRK, NO3FR) !SOLID KNO3
15767 FRK = MAX (FRK - CKNO3, ZERO)
15768 NO3FR = MAX (NO3FR - CKNO3, ZERO)
15770 !C *** CALCULATE VOLATILE SPECIES **************************************
15772 ALF = W(3) ! FREE NH3
15773 BET = CLFR ! FREE CL
15774 GAM = NO3FR ! FREE NO3
15776 RTSQ = R*TEMP*R*TEMP
15780 THETA1 = GAM - BET*(A2/A1)
15783 !C QUADRATIC EQUATION SOLUTION
15785 BB = (THETA1-ALF-BET*(ONE+THETA2))/(ONE+THETA2)
15786 CC = (ALF*BET-A1-BET*THETA1)/(ONE+THETA2)
15787 DD = BB*BB - 4.0D0*CC
15788 IF (DD.LT.ZERO) GOTO 100 ! Solve each reaction seperately
15790 !C TWO ROOTS FOR KAPA, CHECK AND SEE IF ANY VALID
15793 KAPA1 = 0.5D0*(-BB+SQDD)
15794 KAPA2 = 0.5D0*(-BB-SQDD)
15795 LAMDA1 = THETA1 + THETA2*KAPA1
15796 LAMDA2 = THETA1 + THETA2*KAPA2
15798 IF (KAPA1.GE.ZERO .AND. LAMDA1.GE.ZERO) THEN
15799 IF (ALF-KAPA1-LAMDA1.GE.ZERO .AND. &
15800 BET-KAPA1.GE.ZERO .AND. GAM-LAMDA1.GE.ZERO) THEN
15807 IF (KAPA2.GE.ZERO .AND. LAMDA2.GE.ZERO) THEN
15808 IF (ALF-KAPA2-LAMDA2.GE.ZERO .AND. &
15809 BET-KAPA2.GE.ZERO .AND. GAM-LAMDA2.GE.ZERO) THEN
15816 !C SEPERATE SOLUTION OF NH4CL & NH4NO3 EQUILIBRIA
15820 DD1 = (ALF+BET)*(ALF+BET) - 4.0D0*(ALF*BET-A1)
15821 DD2 = (ALF+GAM)*(ALF+GAM) - 4.0D0*(ALF*GAM-A2)
15823 !C NH4CL EQUILIBRIUM
15825 IF (DD1.GE.ZERO) THEN
15827 KAPA1 = 0.5D0*(ALF+BET + SQDD1)
15828 KAPA2 = 0.5D0*(ALF+BET - SQDD1)
15830 IF (KAPA1.GE.ZERO .AND. KAPA1.LE.MIN(ALF,BET)) THEN
15832 ELSE IF (KAPA2.GE.ZERO .AND. KAPA2.LE.MIN(ALF,BET)) THEN
15839 !C NH4NO3 EQUILIBRIUM
15841 IF (DD2.GE.ZERO) THEN
15843 LAMDA1= 0.5D0*(ALF+GAM + SQDD2)
15844 LAMDA2= 0.5D0*(ALF+GAM - SQDD2)
15846 IF (LAMDA1.GE.ZERO .AND. LAMDA1.LE.MIN(ALF,GAM)) THEN
15848 ELSE IF (LAMDA2.GE.ZERO .AND. LAMDA2.LE.MIN(ALF,GAM)) THEN
15855 !C IF BOTH KAPA, LAMDA ARE > 0, THEN APPLY EXISTANCE CRITERION
15857 IF (KAPA.GT.ZERO .AND. LAMDA.GT.ZERO) THEN
15858 IF (BET .LT. LAMDA/THETA1) THEN
15865 !C *** CALCULATE COMPOSITION OF VOLATILE SPECIES ***********************
15871 GNH3 = ALF - KAPA - LAMDA
15872 GHNO3 = GAM - LAMDA
15877 !C *** END OF SUBROUTINE CALCP1A *****************************************
15881 !C======================================================================
15883 !C *** ISORROPIA CODE
15884 !C *** SUBROUTINE CALCL9
15887 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15888 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
15889 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
15890 !C 3. SOLIDS POSSIBLE : CASO4
15891 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4, MGSO4, NA2SO4, K2SO4
15893 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
15894 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
15895 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
15897 !C=======================================================================
15899 SUBROUTINE CALCL92p1
15900 INCLUDE 'module_isrpia_inc.F'
15901 DOUBLE PRECISION LAMDA
15902 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
15903 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
15904 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
15905 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
15906 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
15907 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
15909 !C *** FIND DRY COMPOSITION **********************************************
15913 !C *** SETUP PARAMETERS ************************************************
15915 CHI1 = CNH4HS4 ! Save from CALCL1 run
15924 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
15933 CALAOU = .TRUE. ! Outer loop activity calculation flag
15937 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
15941 A9 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.
15943 !C CALCULATE DISSOCIATION QUANTITIES
15945 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
15946 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
15947 DD = MAX(BB*BB - 4.D0*CC, ZERO)
15948 LAMDA= 0.5D0*(-BB + SQRT(DD))
15949 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
15951 !C *** CALCULATE SPECIATION ********************************************
15953 MOLAL(1) = LAMDA ! HI
15954 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
15955 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
15956 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
15957 MOLAL(6) = PSI2 + PSI3 + PSI1 + PSI8 - LAMDA ! HSO4I
15958 MOLAL(9) = PSI8 + 2.0D0*PSI6 ! KI
15959 MOLAL(10)= PSI7 ! MGI
15970 CALL CALCMR2p1 ! Water content
15973 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
15975 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
15984 !C *** END OF SUBROUTINE CALCL9 *****************************************
15987 !C=======================================================================
15989 !C *** ISORROPIA CODE
15990 !C *** SUBROUTINE CALCL8
15993 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
15994 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
15995 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
15996 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4
15997 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4, MGSO4, NA2SO4
15999 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16000 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16001 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16003 !C=======================================================================
16005 SUBROUTINE CALCL82p1
16006 INCLUDE 'module_isrpia_inc.F'
16007 DOUBLE PRECISION LAMDA
16008 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16009 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16010 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16011 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16012 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16013 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16015 !C *** FIND DRY COMPOSITION **********************************************
16019 !C *** SETUP PARAMETERS ************************************************
16021 CHI1 = CNH4HS4 ! Save from CALCL1 run
16030 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
16039 CALAOU = .TRUE. ! Outer loop activity calculation flag
16040 PSI6LO = ZERO ! Low limit
16041 PSI6HI = CHI6 ! High limit
16043 !C *** INITIAL VALUES FOR BISECTION ************************************
16045 IF (CHI6.LE.TINY) THEN
16046 Y1 = FUNCL82p1 (ZERO)
16051 Y1 = FUNCL82p1 (X1)
16052 YHI= Y1 ! Save Y-value at HI position
16054 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH K2SO4 *********
16056 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
16058 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
16060 DX = (PSI6HI-PSI6LO)/FLOAT(NDIV)
16063 Y2 = FUNCL82p1 (X2)
16064 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
16069 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH K2SO4
16071 YLO= Y1 ! Save Y-value at Hi position
16072 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
16073 Y3 = FUNCL82p1 (ZERO)
16075 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
16078 CALL PUSHERR2p1 (0001, 'CALCL8') ! WARNING ERROR: NO SOLUTION
16081 !C *** PERFORM BISECTION ***********************************************
16085 Y3 = FUNCL82p1 (X3)
16086 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
16093 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
16095 CALL PUSHERR2p1 (0002, 'CALCL8') ! WARNING ERROR: NO CONVERGENCE
16097 !C *** CONVERGED ; RETURN **********************************************
16099 40 X3 = 0.5*(X1+X2)
16100 Y3 = FUNCL82p1 (X3)
16104 !C *** END OF SUBROUTINE CALCL8 *****************************************
16108 !C=======================================================================
16110 !C *** ISORROPIA CODE II
16111 !C *** FUNCTION FUNCL8
16114 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16115 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
16116 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16117 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4
16118 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4, MGSO4, NA2SO4
16120 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
16121 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16122 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16123 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16125 !C=======================================================================
16127 DOUBLE PRECISION FUNCTION FUNCL82p1 (P6)
16128 INCLUDE 'module_isrpia_inc.F'
16129 DOUBLE PRECISION LAMDA
16130 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16131 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16132 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16133 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16134 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16135 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16137 !C *** SETUP PARAMETERS ************************************************
16141 !C *** SETUP PARAMETERS ************************************************
16146 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
16150 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
16152 !C CALCULATE DISSOCIATION QUANTITIES
16154 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
16155 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
16156 DD = BB*BB - 4.D0*CC
16157 LAMDA= 0.5D0*(-BB + SQRT(DD))
16158 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
16160 !C *** CALCULATE SPECIATION ********************************************
16162 MOLAL(1) = LAMDA ! HI
16163 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
16164 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
16165 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
16166 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
16167 MOLAL(9) = PSI8 + 2.0*PSI6 ! KI
16168 MOLAL(10)= PSI7 ! MGI
16175 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
16178 CALL CALCMR2p1 ! Water content
16180 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
16182 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
16189 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
16191 20 A6 = XK17*(WATER/GAMA(17))**3.0
16192 FUNCL82p1 = MOLAL(9)*MOLAL(9)*MOLAL(5)/A6 - ONE
16195 !C *** END OF FUNCTION FUNCL8 ****************************************
16199 !C=======================================================================
16201 !C *** ISORROPIA CODE II
16202 !C *** SUBROUTINE CALCL7
16205 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16206 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
16207 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16208 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
16209 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4, MGSO4
16211 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16212 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16213 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16215 !C=======================================================================
16217 SUBROUTINE CALCL72p1
16218 INCLUDE 'module_isrpia_inc.F'
16219 DOUBLE PRECISION LAMDA
16220 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16221 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16222 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16223 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16224 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16225 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16227 !C *** FIND DRY COMPOSITION **********************************************
16231 !C *** SETUP PARAMETERS ************************************************
16233 CHI1 = CNH4HS4 ! Save from CALCL1 run
16242 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
16251 CALAOU = .TRUE. ! Outer loop activity calculation flag
16252 PSI4LO = ZERO ! Low limit
16253 PSI4HI = CHI4 ! High limit
16255 !C *** INITIAL VALUES FOR BISECTION ************************************
16257 IF (CHI4.LE.TINY) THEN
16258 Y1 = FUNCL72p1 (ZERO)
16263 Y1 = FUNCL72p1 (X1)
16264 YHI= Y1 ! Save Y-value at HI position
16266 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH K2SO4 *********
16268 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
16270 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
16272 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
16275 Y2 = FUNCL72p1 (X2)
16276 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
16281 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH K2SO4
16283 YLO= Y1 ! Save Y-value at Hi position
16284 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
16285 Y3 = FUNCL72p1 (ZERO)
16287 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
16290 CALL PUSHERR2p1 (0001, 'CALCL7') ! WARNING ERROR: NO SOLUTION
16293 !C *** PERFORM BISECTION ***********************************************
16297 Y3 = FUNCL72p1 (X3)
16298 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
16305 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
16307 CALL PUSHERR2p1 (0002, 'CALCL7') ! WARNING ERROR: NO CONVERGENCE
16309 !C *** CONVERGED ; RETURN **********************************************
16311 40 X3 = 0.5*(X1+X2)
16312 Y3 = FUNCL72p1 (X3)
16316 !C *** END OF SUBROUTINE CALCL7 *****************************************
16320 !C=======================================================================
16322 !C *** ISORROPIA CODE II
16323 !C *** FUNCTION FUNCL7
16326 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16327 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
16328 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16329 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, NA2SO4
16330 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4, MGSO4
16332 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
16333 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16334 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16335 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16337 !C=======================================================================
16339 DOUBLE PRECISION FUNCTION FUNCL72p1 (P4)
16340 INCLUDE 'module_isrpia_inc.F'
16341 DOUBLE PRECISION LAMDA
16342 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16343 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16344 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16345 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16346 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16347 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16349 !C *** SETUP PARAMETERS ************************************************
16353 !C *** SETUP PARAMETERS ************************************************
16358 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
16362 A4 = XK5 *(WATER/GAMA(2))**3.0
16363 A6 = XK17*(WATER/GAMA(17))**3.0
16364 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
16366 !C CALCULATE DISSOCIATION QUANTITIES
16368 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
16369 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
16371 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
16372 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
16373 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
16374 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
16375 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
16376 IF (ISLV.EQ.0) THEN
16377 PSI6 = MIN (PSI6, CHI6)
16383 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
16384 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
16385 DD = BB*BB - 4.D0*CC
16386 LAMDA= 0.5D0*(-BB + SQRT(DD))
16387 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
16390 !C *** CALCULATE SPECIATION ********************************************
16392 MOLAL(1) = LAMDA ! HI
16393 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
16394 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
16395 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
16396 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
16397 MOLAL(9) = PSI8 + 2.0*PSI6 ! KI
16398 MOLAL(10)= PSI7 ! MGI
16402 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
16405 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
16408 CALL CALCMR2p1 ! Water content
16410 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
16412 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
16419 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
16421 20 A4 = XK5 *(WATER/GAMA(2))**3.0
16422 FUNCL72p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
16425 !C *** END OF FUNCTION FUNCL7 ****************************************
16430 !C=======================================================================
16432 !C *** ISORROPIA CODE II
16433 !C *** SUBROUTINE CALCL6
16436 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16437 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
16438 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16439 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, NA2SO4
16440 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4, KHSO4
16442 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16443 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16444 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16446 !C=======================================================================
16448 SUBROUTINE CALCL62p1
16449 INCLUDE 'module_isrpia_inc.F'
16450 DOUBLE PRECISION LAMDA
16451 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16452 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16453 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16454 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16455 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16456 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16458 !C *** FIND DRY COMPOSITION **********************************************
16462 !C *** SETUP PARAMETERS ************************************************
16464 CHI1 = CNH4HS4 ! Save from CALCL1 run
16473 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
16482 CALAOU = .TRUE. ! Outer loop activity calculation flag
16483 PSI4LO = ZERO ! Low limit
16484 PSI4HI = CHI4 ! High limit
16486 !C *** INITIAL VALUES FOR BISECTION ************************************
16488 IF (CHI4.LE.TINY) THEN
16489 Y1 = FUNCL62p1 (ZERO)
16494 Y1 = FUNCL62p1 (X1)
16495 YHI= Y1 ! Save Y-value at HI position
16497 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH K2SO4 *********
16499 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
16501 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
16503 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
16506 Y2 = FUNCL62p1 (X2)
16507 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
16512 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH K2SO4
16514 YLO= Y1 ! Save Y-value at Hi position
16515 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
16516 Y3 = FUNCL62p1 (ZERO)
16518 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
16521 CALL PUSHERR2p1 (0001, 'CALCL6') ! WARNING ERROR: NO SOLUTION
16525 !C *** PERFORM BISECTION ***********************************************
16529 Y3 = FUNCL62p1 (X3)
16530 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
16537 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
16539 CALL PUSHERR2p1 (0002, 'CALCL6') ! WARNING ERROR: NO CONVERGENCE
16541 !C *** CONVERGED ; RETURN **********************************************
16543 40 X3 = 0.5*(X1+X2)
16544 Y3 = FUNCL62p1 (X3)
16548 !C *** END OF SUBROUTINE CALCL6 *****************************************
16552 !C=======================================================================
16554 !C *** ISORROPIA CODE II
16555 !C *** FUNCTION FUNCL6
16558 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16559 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
16560 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16561 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, NA2SO4
16563 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
16564 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16565 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16566 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16568 !C=======================================================================
16570 DOUBLE PRECISION FUNCTION FUNCL62p1 (P4)
16571 INCLUDE 'module_isrpia_inc.F'
16572 DOUBLE PRECISION LAMDA
16573 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16574 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16575 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16576 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16577 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16578 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16580 !C *** SETUP PARAMETERS ************************************************
16584 !C *** SETUP PARAMETERS ************************************************
16589 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
16593 A4 = XK5*(WATER/GAMA(2))**3.0
16594 A6 = XK17*(WATER/GAMA(17))**3.0
16595 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
16597 !C CALCULATE DISSOCIATION QUANTITIES
16599 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
16600 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
16602 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
16603 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
16604 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
16605 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
16606 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
16607 IF (ISLV.EQ.0) THEN
16608 PSI6 = MIN (PSI6, CHI6)
16616 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
16617 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
16618 DD = BB*BB - 4.D0*CC
16619 LAMDA= 0.5D0*(-BB + SQRT(DD))
16620 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
16622 !C *** CALCULATE SPECIATION ********************************************
16624 MOLAL(1) = LAMDA ! HI
16625 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
16626 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
16627 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
16628 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
16629 MOLAL(9) = PSI8 + 2.0*PSI6 ! KI
16630 MOLAL(10)= PSI7 ! MGI
16634 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
16637 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
16640 CALL CALCMR2p1 ! Water content
16642 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
16644 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
16651 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
16653 20 A4 = XK5 *(WATER/GAMA(2))**3.0
16654 FUNCL62p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
16657 !C *** END OF FUNCTION FUNCL6 ****************************************
16661 !C=======================================================================
16663 !C *** ISORROPIA CODE II
16664 !C *** SUBROUTINE CALCL5
16667 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16668 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
16669 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16670 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NA2SO4
16671 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4
16673 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16674 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16675 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16677 !C=======================================================================
16679 SUBROUTINE CALCL52p1
16680 INCLUDE 'module_isrpia_inc.F'
16681 DOUBLE PRECISION LAMDA
16682 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16683 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16684 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16685 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16686 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16687 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16689 !C *** FIND DRY COMPOSITION **********************************************
16693 !C *** SETUP PARAMETERS ************************************************
16695 CHI1 = CNH4HS4 ! Save from CALCL1 run
16704 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
16713 CALAOU = .TRUE. ! Outer loop activity calculation flag
16714 PSI4LO = ZERO ! Low limit
16715 PSI4HI = CHI4 ! High limit
16718 !C *** INITIAL VALUES FOR BISECTION ************************************
16720 IF (CHI4.LE.TINY) THEN
16721 Y1 = FUNCL52p1 (ZERO)
16726 Y1 = FUNCL52p1 (X1)
16727 YHI= Y1 ! Save Y-value at HI position
16729 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *********
16731 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
16733 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
16736 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
16738 X2 = MAX(X1-DX, PSI4LO)
16739 Y2 = FUNCL52p1 (X2)
16740 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
16745 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4
16747 YLO= Y1 ! Save Y-value at Hi position
16748 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
16749 Y3 = FUNCL52p1 (ZERO)
16751 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
16754 CALL PUSHERR2p1 (0001, 'CALCL5') ! WARNING ERROR: NO SOLUTION
16758 !C *** PERFORM BISECTION ***********************************************
16762 Y3 = FUNCL52p1 (X3)
16763 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
16770 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
16772 CALL PUSHERR2p1 (0002, 'CALCL5') ! WARNING ERROR: NO CONVERGENCE
16774 !C *** CONVERGED ; RETURN **********************************************
16776 40 X3 = 0.5*(X1+X2)
16777 Y3 = FUNCL52p1 (X3)
16781 !C *** END OF SUBROUTINE CALCL5 *****************************************
16785 !C=======================================================================
16787 !C *** ISORROPIA CODE II
16788 !C *** FUNCTION FUNCL5
16791 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16792 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
16793 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16794 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NA2SO4
16795 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC, (NH4)2SO4
16797 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
16798 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16799 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16800 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16802 !C=======================================================================
16804 DOUBLE PRECISION FUNCTION FUNCL52p1 (P4)
16805 INCLUDE 'module_isrpia_inc.F'
16806 DOUBLE PRECISION LAMDA
16807 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16808 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16809 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16810 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16811 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16812 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16814 !C *** SETUP PARAMETERS ************************************************
16818 !C *** SETUP PARAMETERS ************************************************
16823 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
16827 A4 = XK5*(WATER/GAMA(2))**3.0
16828 A6 = XK17*(WATER/GAMA(17))**3.0
16829 A8 = XK18*(WATER/GAMA(18))**2.0
16830 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
16832 !C CALCULATE DISSOCIATION QUANTITIES
16834 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
16835 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
16837 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
16838 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
16839 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
16840 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
16841 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
16842 IF (ISLV.EQ.0) THEN
16843 PSI6 = MIN (PSI6, CHI6)
16851 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
16852 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
16853 DD = MAX(BB*BB - 4.D0*CC, ZERO)
16854 LAMDA= 0.5D0*(-BB + SQRT(DD))
16855 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
16857 BITA = PSI3 + PSI2 + PSI1 + 2.D0*PSI6 - LAMDA
16858 CAMA = 2.D0*PSI6*(PSI3 + PSI2 + PSI1 - LAMDA) - A8
16859 DELT = MAX(BITA*BITA - 4.D0*CAMA, ZERO)
16860 PSI8 = 0.5D0*(-BITA + SQRT(DELT))
16861 PSI8 = MIN(MAX (PSI8, ZERO), CHI8)
16863 !C *** CALCULATE SPECIATION ********************************************
16865 MOLAL(1) = LAMDA ! HI
16866 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
16867 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
16868 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
16869 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
16870 MOLAL(9) = PSI8 + 2.0D0*PSI6 ! KI
16871 MOLAL(10)= PSI7 ! MGI
16875 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
16878 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
16880 CKHSO4 = MAX(CHI8 - PSI8, ZERO)
16882 CALL CALCMR2p1 ! Water content
16884 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
16887 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
16894 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
16896 20 A4 = XK5 *(WATER/GAMA(2))**3.0
16897 FUNCL52p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
16901 !C *** END OF FUNCTION FUNCL5 ****************************************
16905 !C=======================================================================
16907 !C *** ISORROPIA CODE II
16908 !C *** SUBROUTINE CALCL4
16911 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
16912 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
16913 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
16914 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, (NH4)2SO4, NA2SO4
16915 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC
16917 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
16918 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
16919 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
16921 !C=======================================================================
16923 SUBROUTINE CALCL42p1
16924 INCLUDE 'module_isrpia_inc.F'
16925 DOUBLE PRECISION LAMDA
16926 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
16927 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
16928 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
16929 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
16930 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
16931 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
16933 !C *** FIND DRY COMPOSITION **********************************************
16937 !C *** SETUP PARAMETERS ************************************************
16939 CHI1 = CNH4HS4 ! Save from CALCL1 run
16948 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
16957 CALAOU = .TRUE. ! Outer loop activity calculation flag
16958 PSI4LO = ZERO ! Low limit
16959 PSI4HI = CHI4 ! High limit
16961 IF (CHI4.LE.TINY) THEN
16962 Y1 = FUNCL42p1 (ZERO)
16966 !C *** INITIAL VALUES FOR BISECTION ************************************
16969 Y1 = FUNCL42p1 (X1)
16970 YHI= Y1 ! Save Y-value at HI position
16972 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *********
16974 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
16976 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
16978 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
16981 Y2 = FUNCL42p1 (X2)
16982 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
16987 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4 **
16989 YLO= Y1 ! Save Y-value at Hi position
16990 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
16991 Y3 = FUNCL42p1 (ZERO)
16993 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
16996 CALL PUSHERR2p1 (0001, 'CALCL4') ! WARNING ERROR: NO SOLUTION
17000 !C *** PERFORM BISECTION ***********************************************
17004 Y3 = FUNCL42p1 (X3)
17005 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
17012 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
17014 CALL PUSHERR2p1 (0002, 'CALCL4') ! WARNING ERROR: NO CONVERGENCE
17016 !C *** CONVERGED ; RETURN **********************************************
17018 40 X3 = 0.5*(X1+X2)
17019 Y3 = FUNCL42p1 (X3)
17023 !C *** END OF SUBROUTINE CALCL4 *****************************************
17027 !C=======================================================================
17029 !C *** ISORROPIA CODE II
17030 !C *** FUNCTION FUNCL4
17033 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17034 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
17035 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17036 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, (NH4)2SO4, NA2SO4
17037 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4, LC
17039 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
17040 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17041 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17042 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17044 !C=======================================================================
17046 DOUBLE PRECISION FUNCTION FUNCL42p1 (P4)
17047 INCLUDE 'module_isrpia_inc.F'
17048 DOUBLE PRECISION LAMDA
17049 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17050 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17051 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17052 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17053 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17054 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17056 !C *** SETUP PARAMETERS ************************************************
17060 !C *** SETUP PARAMETERS ************************************************
17065 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
17069 A4 = XK5*(WATER/GAMA(2))**3.0
17070 A5 = XK7*(WATER/GAMA(4))**3.0
17071 A6 = XK17*(WATER/GAMA(17))**3.0
17072 A8 = XK18*(WATER/GAMA(18))**2.0
17073 A9 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
17075 !C CALCULATE DISSOCIATION QUANTITIES
17077 PSI5 = (PSI3 + 2.D0*PSI4 - SQRT(A4/A5)*(3.D0*PSI2 + PSI1)) &! psi5
17079 PSI5 = MAX (MIN (PSI5, CHI5), ZERO)
17083 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
17084 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
17085 DD = MAX(BB*BB - 4.D0*CC, ZERO)
17086 LAMDA= 0.5D0*(-BB + SQRT(DD))
17087 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
17089 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
17090 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
17092 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
17093 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
17094 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
17095 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
17096 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
17097 IF (ISLV.EQ.0) THEN
17098 PSI6 = MIN (PSI6, CHI6)
17104 BITA = PSI3 + PSI2 + PSI1 + 2.D0*PSI6 - LAMDA
17105 CAMA = 2.D0*PSI6*(PSI3 + PSI2 + PSI1 - LAMDA) - A8
17106 DELT = MAX(BITA*BITA - 4.D0*CAMA, ZERO)
17107 PSI8 = 0.5D0*(-BITA + SQRT(DELT))
17108 PSI8 = MIN(MAX (PSI8, ZERO), CHI8)
17110 !C *** CALCULATE SPECIATION ********************************************
17112 MOLAL(1) = LAMDA ! HI
17113 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
17114 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
17115 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
17116 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
17117 MOLAL(9) = PSI8 + 2.0D0*PSI6 ! KI
17118 MOLAL(10)= PSI7 ! MGI
17122 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
17123 CNH42S4 = MAX(CHI5 - PSI5, ZERO)
17125 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
17127 CKHSO4 = MAX(CHI8 - PSI8, ZERO)
17128 CALL CALCMR2p1 ! Water content
17130 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
17132 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
17139 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
17141 20 A4 = XK5 *(WATER/GAMA(2))**3.0
17142 FUNCL42p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
17145 !C *** END OF FUNCTION FUNCL4 ****************************************
17148 !C=======================================================================
17150 !C *** ISORROPIA CODE II
17151 !C *** SUBROUTINE CALCL3
17154 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17155 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17156 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17157 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17159 !C THERE ARE THREE REGIMES IN THIS CASE:
17160 !C 1.(NA,NH4)HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCI3A)
17161 !C 2.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
17162 !C 3.(NA,NH4)HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
17164 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES I1A, I2B
17167 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
17168 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17169 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
17171 !C=======================================================================
17173 SUBROUTINE CALCL32p1
17174 INCLUDE 'module_isrpia_inc.F'
17175 EXTERNAL CALCL1A2p1, CALCL42p1
17177 !C *** FIND DRY COMPOSITION *********************************************
17181 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH *********************
17183 IF (CNH4HS4.GT.TINY .OR. CNAHSO4.GT.TINY) THEN
17184 SCASE = 'L3 ; SUBCASE 1'
17185 CALL CALCL3A2p1 ! FULL SOLUTION
17186 SCASE = 'L3 ; SUBCASE 1'
17189 IF (WATER.LE.TINY) THEN
17190 IF (RH.LT.DRML3) THEN ! SOLID SOLUTION
17196 SCASE = 'L3 ; SUBCASE 2'
17198 ELSEIF (RH.GE.DRML3) THEN ! MDRH OF L3
17199 SCASE = 'L3 ; SUBCASE 3'
17200 CALL CALCMDRH22p1 (RH, DRML3, DRLC, CALCL1A2p1, CALCL42p1)
17201 SCASE = 'L3 ; SUBCASE 3'
17207 !C *** END OF SUBROUTINE CALCL3 *****************************************
17211 !C=======================================================================
17213 !C *** ISORROPIA CODE II
17214 !C *** SUBROUTINE CALCL3A
17215 !C *** CASE L3 ; SUBCASE 1
17217 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17218 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17219 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17220 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, (NH4)2SO4, NA2SO4, LC
17221 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4
17223 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17224 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17225 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17227 !C=======================================================================
17229 SUBROUTINE CALCL3A2p1
17230 INCLUDE 'module_isrpia_inc.F'
17231 DOUBLE PRECISION LAMDA
17232 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17233 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17234 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17235 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17236 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17237 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17239 !C *** FIND DRY COMPOSITION **********************************************
17243 !C *** SETUP PARAMETERS ************************************************
17245 CHI1 = CNH4HS4 ! Save from CALCL1 run
17254 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
17263 CALAOU = .TRUE. ! Outer loop activity calculation flag
17264 PSI2LO = ZERO ! Low limit
17265 PSI2HI = CHI2 ! High limit
17267 !C *** INITIAL VALUES FOR BISECTION ************************************
17270 Y1 = FUNCL3A2p1 (X1)
17271 YHI= Y1 ! Save Y-value at HI position
17273 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
17275 IF (YHI.LT.EPS) GOTO 50
17277 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
17279 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
17281 X2 = MAX(X1-DX, PSI2LO)
17282 Y2 = FUNCL3A2p1 (X2)
17283 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
17288 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
17290 IF (Y2.GT.EPS) Y2 = FUNCL3A2p1 (ZERO)
17293 !C *** PERFORM BISECTION ***********************************************
17297 Y3 = FUNCL3A2p1 (X3)
17298 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
17305 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
17307 CALL PUSHERR2p1 (0002, 'CALCL3A') ! WARNING ERROR: NO CONVERGENCE
17309 !C *** CONVERGED ; RETURN **********************************************
17311 40 X3 = 0.5*(X1+X2)
17312 Y3 = FUNCL3A2p1 (X3)
17316 !C *** END OF SUBROUTINE CALCL3A *****************************************
17320 !C=======================================================================
17322 !C *** ISORROPIA CODE II
17323 !C *** SUBROUTINE FUNCL3A
17324 !C *** CASE L3 ; SUBCASE 1
17326 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17327 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17328 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17329 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, (NH4)2SO4, NA2SO4, LC
17330 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4
17332 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17333 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17334 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17336 !C=======================================================================
17338 DOUBLE PRECISION FUNCTION FUNCL3A2p1 (P2)
17339 INCLUDE 'module_isrpia_inc.F'
17340 DOUBLE PRECISION LAMDA
17341 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17342 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17343 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17344 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17345 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17346 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17348 !C *** SETUP PARAMETERS ************************************************
17351 PSI2 = P2 ! Save PSI2 in COMMON BLOCK
17352 PSI4LO = ZERO ! Low limit for PSI4
17353 PSI4HI = CHI4 ! High limit for PSI4
17355 !C *** IF NH3 =0, CALL FUNCL3B FOR Y4=0 ********************************
17357 IF (CHI4.LE.TINY) THEN
17358 FUNCL3A2p1 = FUNCL3B2p1 (ZERO)
17362 !C *** INITIAL VALUES FOR BISECTION ************************************
17365 Y1 = FUNCL3B2p1 (X1)
17366 IF (ABS(Y1).LE.EPS) GOTO 50
17367 YHI= Y1 ! Save Y-value at HI position
17369 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *********
17371 IF (YHI.LT.ZERO) GOTO 50
17373 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
17375 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
17377 X2 = MAX(X1-DX, PSI4LO)
17378 Y2 = FUNCL3B2p1 (X2)
17379 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
17384 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4
17386 IF (Y2.GT.EPS) Y2 = FUNCL3B2p1 (PSI4LO)
17389 !C *** PERFORM BISECTION ***********************************************
17393 Y3 = FUNCL3B2p1 (X3)
17394 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
17401 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
17403 CALL PUSHERR2p1 (0004, 'FUNCL3A2p1') ! WARNING ERROR: NO CONVERGENCE
17405 !C *** INNER LOOP CONVERGED **********************************************
17407 40 X3 = 0.5*(X1+X2)
17408 Y3 = FUNCL3B2p1 (X3)
17410 !C *** CALCULATE FUNCTION VALUE FOR INTERNAL LOOP ***************************
17412 50 A2 = XK13*(WATER/GAMA(13))**5.0
17413 FUNCL3A2p1 = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.0/A2 - ONE
17416 !C *** END OF FUNCTION FUNCL3A *******************************************
17420 !C=======================================================================
17422 !C *** ISORROPIA CODE II
17423 !C *** FUNCTION FUNCL3B
17424 !C *** CASE L3 ; SUBCASE 2
17426 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17427 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SULRAT < 2.0)
17428 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17429 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, (NH4)2SO4, NA2SO4, LC
17430 !C 4. COMPLETELY DISSOLVED: NH4HSO4, NAHSO4
17432 !C SOLUTION IS SAVED IN COMMON BLOCK /CASE/
17433 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17434 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17435 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17437 !C=======================================================================
17439 DOUBLE PRECISION FUNCTION FUNCL3B2p1 (P4)
17440 INCLUDE 'module_isrpia_inc.F'
17441 DOUBLE PRECISION LAMDA
17442 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17443 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17444 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17445 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17446 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17447 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17449 !C *** SETUP PARAMETERS ************************************************
17456 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
17460 A4 = XK5*(WATER/GAMA(2))**3.0
17461 A5 = XK7*(WATER/GAMA(4))**3.0
17462 A6 = XK17*(WATER/GAMA(17))**3.0
17463 A8 = XK18*(WATER/GAMA(18))**2.0
17464 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
17466 !C CALCULATE DISSOCIATION QUANTITIES
17468 PSI5 = (PSI3 + 2.D0*PSI4 - SQRT(A4/A5)*(3.D0*PSI2 + PSI1)) & ! psi5
17470 PSI5 = MAX (MIN (PSI5, CHI5), ZERO)
17474 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
17475 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
17476 DD = MAX(BB*BB - 4.D0*CC, ZERO)
17477 LAMDA= 0.5D0*(-BB + SQRT(DD))
17478 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
17480 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
17481 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
17483 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
17484 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
17485 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
17486 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
17487 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
17488 IF (ISLV.EQ.0) THEN
17489 PSI6 = MIN (PSI6, CHI6)
17495 BITA = PSI3 + PSI2 + PSI1 + 2.D0*PSI6 - LAMDA
17496 CAMA = 2.D0*PSI6*(PSI3 + PSI2 + PSI1 - LAMDA) - A8
17497 DELT = MAX(BITA*BITA - 4.D0*CAMA, ZERO)
17498 PSI8 = 0.5D0*(-BITA + SQRT(DELT))
17499 PSI8 = MIN(MAX (PSI8, ZERO), CHI8)
17501 !C *** CALCULATE SPECIATION ********************************************
17503 MOLAL(1) = LAMDA ! HI
17504 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
17505 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
17506 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
17507 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
17508 MOLAL(9) = PSI8 + 2.0D0*PSI6 ! KI
17509 MOLAL(10)= PSI7 ! MGI
17511 CLC = MAX(CHI2 - PSI2, ZERO)
17513 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
17514 CNH42S4 = MAX(CHI5 - PSI5, ZERO)
17516 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
17517 CMGSO4 = MAX(CHI7 - PSI7, ZERO)
17518 CKHSO4 = MAX(CHI8 - PSI8, ZERO)
17519 CALL CALCMR2p1 ! Water content
17521 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
17523 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
17530 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
17532 20 A4 = XK5 *(WATER/GAMA(2))**3.0
17533 FUNCL3B2p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
17536 !C *** END OF FUNCTION FUNCL3B ****************************************
17540 !C=======================================================================
17542 !C *** ISORROPIA CODE II
17543 !C *** SUBROUTINE CALCL2
17546 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17547 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17548 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17549 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17551 !C THERE ARE THREE REGIMES IN THIS CASE:
17552 !C 1. NH4HSO4(s) POSSIBLE. LIQUID & SOLID AEROSOL (SUBROUTINE CALCL2A)
17553 !C 2. NH4HSO4(s) NOT POSSIBLE, AND RH < MDRH. SOLID AEROSOL ONLY
17554 !C 3. NH4HSO4(s) NOT POSSIBLE, AND RH >= MDRH. SOLID & LIQUID AEROSOL
17556 !C REGIMES 2. AND 3. ARE CONSIDERED TO BE THE SAME AS CASES L1A, L2B
17559 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
17560 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17561 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
17563 !C=======================================================================
17565 SUBROUTINE CALCL22p1
17566 INCLUDE 'module_isrpia_inc.F'
17567 EXTERNAL CALCL1A2p1, CALCL3A2p1
17569 !C *** FIND DRY COMPOSITION **********************************************
17573 !C *** REGIME DEPENDS UPON THE POSSIBLE SOLIDS & RH **********************
17575 IF (CNH4HS4.GT.TINY) THEN
17576 SCASE = 'L2 ; SUBCASE 1'
17578 SCASE = 'L2 ; SUBCASE 1'
17581 IF (WATER.LE.TINY) THEN
17582 IF (RH.LT.DRML2) THEN ! SOLID SOLUTION ONLY
17588 SCASE = 'L2 ; SUBCASE 2'
17590 ELSEIF (RH.GE.DRML2) THEN ! MDRH OF L2
17591 SCASE = 'L2 ; SUBCASE 3'
17592 CALL CALCMDRH22p1 (RH, DRML2, DRNAHSO4, CALCL1A2p1, CALCL3A2p1)
17593 SCASE = 'L2 ; SUBCASE 3'
17599 !C *** END OF SUBROUTINE CALCL2 ******************************************
17603 !C=======================================================================
17605 !C *** ISORROPIA CODE II
17606 !C *** SUBROUTINE CALCL2A
17607 !C *** CASE L2 ; SUBCASE 1
17609 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17610 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17611 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17612 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17613 !C 4. COMPLETELY DISSOLVED: NH4HSO4
17615 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17616 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17617 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17619 !C=======================================================================
17621 SUBROUTINE CALCL2A2p1
17622 INCLUDE 'module_isrpia_inc.F'
17623 DOUBLE PRECISION LAMDA
17624 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17625 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17626 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17627 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17628 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17629 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17631 !C *** SETUP PARAMETERS ************************************************
17633 CHI1 = CNH4HS4 ! Save from CALCL1 run
17643 PSI1 = CNH4HS4 ! ASSIGN INITIAL PSI's
17652 CALAOU = .TRUE. ! Outer loop activity calculation flag
17653 PSI2LO = ZERO ! Low limit
17654 PSI2HI = CHI2 ! High limit
17656 !C *** INITIAL VALUES FOR BISECTION ************************************
17659 Y1 = FUNCL2A2p1 (X1)
17660 YHI= Y1 ! Save Y-value at HI position
17662 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH NA2SO4 *********
17664 IF (YHI.LT.EPS) GOTO 50
17666 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
17668 DX = (PSI2HI-PSI2LO)/FLOAT(NDIV)
17670 X2 = MAX(X1-DX, PSI2LO)
17671 Y2 = FUNCL2A2p1 (X2)
17672 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
17677 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH NA2SO4
17679 IF (Y2.GT.EPS) Y2 = FUNCL2A2p1 (ZERO)
17682 !C *** PERFORM BISECTION ***********************************************
17686 Y3 = FUNCL2A2p1 (X3)
17687 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
17694 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
17696 CALL PUSHERR2p1 (0002, 'CALCL2A') ! WARNING ERROR: NO CONVERGENCE
17698 !C *** CONVERGED ; RETURN **********************************************
17700 40 X3 = 0.5*(X1+X2)
17701 Y3 = FUNCL2A2p1 (X3)
17705 !C *** END OF SUBROUTINE CALCL2A *****************************************
17709 !C=======================================================================
17711 !C *** ISORROPIA CODE II
17712 !C *** SUBROUTINE FUNCL2A
17713 !C *** CASE L2 ; SUBCASE 1
17715 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17716 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17717 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17718 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17719 !C 4. COMPLETELY DISSOLVED: NH4HSO4
17721 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17722 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17723 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17725 !C=======================================================================
17727 DOUBLE PRECISION FUNCTION FUNCL2A2p1 (P2)
17728 INCLUDE 'module_isrpia_inc.F'
17729 DOUBLE PRECISION LAMDA
17730 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17731 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17732 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17733 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17734 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17735 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17737 !C *** SETUP PARAMETERS ************************************************
17740 PSI2 = P2 ! Save PSI3 in COMMON BLOCK
17741 PSI4LO = ZERO ! Low limit for PSI4
17742 PSI4HI = CHI4 ! High limit for PSI4
17744 !C *** IF NH3 =0, CALL FUNCL3B FOR Y4=0 ********************************
17747 IF (CHI4.LE.TINY) THEN
17748 FUNCL2A2p1 = FUNCL2B2p1 (ZERO)
17752 !C *** INITIAL VALUES FOR BISECTION ************************************
17756 Y1 = FUNCL2B2p1 (X1)
17758 IF (ABS(Y1).LE.EPS) GOTO 50
17759 YHI= Y1 ! Save Y-value at HI position
17761 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH LC *********
17763 IF (YHI.LT.ZERO) GOTO 50
17765 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
17767 DX = (PSI4HI-PSI4LO)/FLOAT(NDIV)
17769 X2 = MAX(X1-DX, PSI4LO)
17770 Y2 = FUNCL2B2p1 (X2)
17771 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
17776 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH LC
17778 IF (Y2.GT.EPS) Y2 = FUNCL2B2p1 (PSI4LO)
17781 !C *** PERFORM BISECTION ***********************************************
17785 Y3 = FUNCL2B2p1 (X3)
17786 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
17793 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
17795 CALL PUSHERR2p1 (0004, 'FUNCL2A2p1') ! WARNING ERROR: NO CONVERGENCE
17797 !C *** INNER LOOP CONVERGED **********************************************
17799 40 X3 = 0.5*(X1+X2)
17800 Y3 = FUNCL2B2p1 (X3)
17802 !C *** CALCULATE FUNCTION VALUE FOR OUTER LOOP ***************************
17804 50 A2 = XK13*(WATER/GAMA(13))**5.0
17805 FUNCL2A2p1 = MOLAL(5)*MOLAL(6)*MOLAL(3)**3.0/A2 - ONE
17808 !C *** END OF FUNCTION FUNCL2A *******************************************
17812 !C=======================================================================
17814 !C *** ISORROPIA CODE II
17815 !C *** SUBROUTINE FUNCL2B
17816 !C *** CASE L2 ; SUBCASE 2
17818 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17819 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17820 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17821 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17822 !C 4. COMPLETELY DISSOLVED: NH4HSO4
17824 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
17825 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17826 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
17828 !C=======================================================================
17830 DOUBLE PRECISION FUNCTION FUNCL2B2p1 (P4)
17831 INCLUDE 'module_isrpia_inc.F'
17832 DOUBLE PRECISION LAMDA
17833 COMMON /SOLUT2p1/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
17834 CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
17835 CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
17836 PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
17837 PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
17838 A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
17840 !C *** SETUP PARAMETERS ************************************************
17842 PSI4 = P4 ! Save PSI4 in COMMON BLOCK
17844 !C *** SETUP PARAMETERS ************************************************
17854 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
17858 A3 = XK11*(WATER/GAMA(12))**2.0
17859 A4 = XK5*(WATER/GAMA(2))**3.0
17860 A5 = XK7*(WATER/GAMA(4))**3.0
17861 A6 = XK17*(WATER/GAMA(17))**3.0
17862 A8 = XK18*(WATER/GAMA(18))**2.0
17863 A9 = XK1*(WATER)*(GAMA(8)**2.0)/(GAMA(7)**3.0)
17865 !C CALCULATE DISSOCIATION QUANTITIES
17867 PSI5 = (PSI3 + 2.D0*PSI4 - SQRT(A4/A5)*(3.D0*PSI2 + PSI1)) &! psi5
17869 PSI5 = MAX (MIN (PSI5, CHI5), ZERO)
17871 IF (CHI3.GT.TINY .AND. WATER.GT.TINY) THEN
17872 AA = 2.D0*PSI4 + PSI2 + PSI1 + PSI8 - LAMDA
17873 BB = 2.D0*PSI4*(PSI2 + PSI1 + PSI8 - LAMDA) - A3
17875 CALL POLY32p1 (AA, BB, CC, PSI3, ISLV)
17876 IF (ISLV.EQ.0) THEN
17877 PSI3 = MIN (PSI3, CHI3)
17885 BB = PSI7 + PSI6 + PSI5 + PSI4 + PSI2 + A9 ! LAMDA
17886 CC = -A9*(PSI8 + PSI1 + PSI2 + PSI3)
17887 DD = MAX(BB*BB - 4.D0*CC, ZERO)
17888 LAMDA= 0.5D0*(-BB + SQRT(DD))
17889 LAMDA= MIN(MAX (LAMDA, TINY), PSI8+PSI3+PSI2+PSI1)
17891 !C PSI6 = 0.5*(SQRT(A6/A4)*(2.D0*PSI4+PSI3)-PSI8) ! PSI6
17892 !C PSI6 = MIN (MAX (PSI6, ZERO), CHI6)
17894 IF (CHI6.GT.TINY .AND. WATER.GT.TINY) THEN
17895 AA = PSI5+PSI4+PSI2+PSI7+PSI8+LAMDA
17896 BB = PSI8*(PSI5+PSI4+PSI2+PSI7+0.25D0*PSI8+LAMDA)
17897 CC = 0.25D0*(PSI8*PSI8*(PSI5+PSI4+PSI2+PSI7+LAMDA)-A6)
17898 CALL POLY32p1 (AA, BB, CC, PSI6, ISLV)
17899 IF (ISLV.EQ.0) THEN
17900 PSI6 = MIN (PSI6, CHI6)
17906 BITA = PSI3 + PSI2 + PSI1 + 2.D0*PSI6 - LAMDA ! PSI8
17907 CAMA = 2.D0*PSI6*(PSI3 + PSI2 + PSI1 - LAMDA) - A8
17908 DELT = MAX(BITA*BITA - 4.D0*CAMA, ZERO)
17909 PSI8 = 0.5D0*(-BITA + SQRT(DELT))
17910 PSI8 = MIN(MAX (PSI8, ZERO), CHI8)
17912 !C *** CALCULATE SPECIATION ********************************************
17914 MOLAL(1) = LAMDA ! HI
17915 MOLAL(2) = 2.D0*PSI4 + PSI3 ! NAI
17916 MOLAL(3) = 3.D0*PSI2 + 2.D0*PSI5 + PSI1 ! NH4I
17917 MOLAL(5) = PSI2 + PSI4 + PSI5 + PSI6 + PSI7 + LAMDA ! SO4I
17918 MOLAL(6) = MAX(PSI2 + PSI3 + PSI1 + PSI8 - LAMDA, TINY) ! HSO4I
17919 MOLAL(9) = PSI8 + 2.0D0*PSI6 ! KI
17920 MOLAL(10)= PSI7 ! MGI
17922 CLC = MAX(CHI2 - PSI2, ZERO)
17923 CNAHSO4 = MAX(CHI3 - PSI3, ZERO)
17924 CNA2SO4 = MAX(CHI4 - PSI4, ZERO)
17925 CNH42S4 = MAX(CHI5 - PSI5, ZERO)
17927 CK2SO4 = MAX(CHI6 - PSI6, ZERO)
17928 CMGSO4 = MAX(CHI7 - PSI7, ZERO)
17929 CKHSO4 = MAX(CHI8 - PSI8, ZERO)
17930 CALL CALCMR2p1 ! Water content
17932 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
17934 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
17941 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
17943 20 A4 = XK5 *(WATER/GAMA(2))**3.0
17944 FUNCL2B2p1 = MOLAL(5)*MOLAL(2)*MOLAL(2)/A4 - ONE
17947 !C *** END OF FUNCTION FUNCL2B ****************************************
17951 !C=======================================================================
17953 !C *** ISORROPIA CODE II
17954 !C *** SUBROUTINE CALCL1
17957 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
17958 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
17959 !C 2. SOLID & LIQUID AEROSOL POSSIBLE
17960 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
17962 !C THERE ARE TWO POSSIBLE REGIMES HERE, DEPENDING ON RELATIVE HUMIDITY:
17963 !C 1. WHEN RH >= MDRH ; LIQUID PHASE POSSIBLE (MDRH REGION)
17964 !C 2. WHEN RH < MDRH ; ONLY SOLID PHASE POSSIBLE (SUBROUTINE CALCI1A)
17966 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
17967 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
17968 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
17970 !C=======================================================================
17972 SUBROUTINE CALCL12p1
17973 INCLUDE 'module_isrpia_inc.F'
17974 EXTERNAL CALCL1A2p1, CALCL2A2p1
17976 !C *** REGIME DEPENDS UPON THE AMBIENT RELATIVE HUMIDITY *****************
17978 IF (RH.LT.DRML1) THEN
17979 SCASE = 'L1 ; SUBCASE 1'
17980 CALL CALCL1A2p1 ! SOLID PHASE ONLY POSSIBLE
17981 SCASE = 'L1 ; SUBCASE 1'
17983 SCASE = 'L1 ; SUBCASE 2' ! LIQUID & SOLID PHASE POSSIBLE
17984 CALL CALCMDRH22p1 (RH, DRML1, DRNH4HS4, CALCL1A2p1, CALCL2A2p1)
17985 SCASE = 'L1 ; SUBCASE 2'
17988 !C *** AMMONIA IN GAS PHASE **********************************************
17994 !C *** END OF SUBROUTINE CALCL1 ******************************************
17998 !C=======================================================================
18000 !C *** ISORROPIA CODE II
18001 !C *** SUBROUTINE CALCL1A
18004 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18005 !C 1. SULFATE RICH, NO FREE ACID (1.0 <= SO4RAT < 2.0)
18006 !C 2. SOLID AEROSOL ONLY
18007 !C 3. SOLIDS POSSIBLE : K2SO4, CASO4, MGSO4, KHSO4, NH4HSO4, NAHSO4, (NH4)2SO4, NA2SO4, LC
18009 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18010 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18011 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18013 !C=======================================================================
18015 SUBROUTINE CALCL1A2p1
18016 INCLUDE 'module_isrpia_inc.F'
18018 !C *** CALCULATE NON VOLATILE SOLIDS ***********************************
18020 CCASO4 = MIN (W(6), W(2)) ! CCASO4
18021 FRSO4 = MAX(W(2) - CCASO4, ZERO)
18022 CAFR = MAX(W(6) - CCASO4, ZERO)
18023 CK2SO4 = MIN (0.5D0*W(7), FRSO4) ! CK2SO4
18024 FRK = MAX(W(7) - 2.D0*CK2SO4, ZERO)
18025 FRSO4 = MAX(FRSO4 - CK2SO4, ZERO)
18026 CNA2SO4 = MIN (0.5D0*W(1), FRSO4) ! CNA2SO4
18027 FRNA = MAX(W(1) - 2.D0*CNA2SO4, ZERO)
18028 FRSO4 = MAX(FRSO4 - CNA2SO4, ZERO)
18029 CMGSO4 = MIN (W(8), FRSO4) ! CMGSO4
18030 FRMG = MAX(W(8) - CMGSO4, ZERO)
18031 FRSO4 = MAX(FRSO4 - CMGSO4, ZERO)
18038 CLC = MIN(W(3)/3.D0, FRSO4/2.D0)
18039 FRSO4 = MAX(FRSO4-2.D0*CLC, ZERO)
18040 FRNH4 = MAX(W(3)-3.D0*CLC, ZERO)
18042 IF (FRSO4.LE.TINY) THEN
18043 CLC = MAX(CLC - FRNH4, ZERO)
18044 CNH42S4 = 2.D0*FRNH4
18046 ELSEIF (FRNH4.LE.TINY) THEN
18047 CNH4HS4 = 3.D0*MIN(FRSO4, CLC)
18048 CLC = MAX(CLC-FRSO4, ZERO)
18049 !C IF (CK2SO4.GT.TINY) THEN
18050 !C FRSO4 = MAX(FRSO4-CNH4HS4/3.D0, ZERO)
18051 !C CKHSO4 = 2.D0*FRSO4
18052 !C CK2SO4 = MAX(CK2SO4-FRSO4, ZERO)
18054 !C IF (CNA2SO4.GT.TINY) THEN
18055 !C FRSO4 = MAX(FRSO4-CKHSO4/2.D0, ZERO)
18056 !C CNAHSO4 = 2.D0*FRSO4
18057 !C CNA2SO4 = MAX(CNA2SO4-FRSO4, ZERO)
18060 IF (CNA2SO4.GT.TINY) THEN
18061 FRSO4 = MAX(FRSO4-CNH4HS4/3.D0, ZERO)
18062 CNAHSO4 = 2.D0*FRSO4
18063 CNA2SO4 = MAX(CNA2SO4-FRSO4, ZERO)
18065 IF (CK2SO4.GT.TINY) THEN
18066 FRSO4 = MAX(FRSO4-CNH4HS4/3.D0, ZERO)
18067 CKHSO4 = 2.D0*FRSO4
18068 CK2SO4 = MAX(CK2SO4-FRSO4, ZERO)
18072 !C *** CALCULATE GAS SPECIES ********************************************
18080 !C *** END OF SUBROUTINE CALCL1A *****************************************
18085 !C=======================================================================
18087 !C *** ISORROPIA CODE II
18088 !C *** SUBROUTINE CALCK4
18091 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18092 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18093 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18094 !C 3. SOLIDS POSSIBLE : CASO4
18096 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18097 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18098 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18100 !C=======================================================================
18102 SUBROUTINE CALCK42p1
18103 INCLUDE 'module_isrpia_inc.F'
18105 DOUBLE PRECISION LAMDA, KAPA
18106 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18109 !C *** SETUP PARAMETERS ************************************************
18111 CALAOU =.TRUE. ! Outer loop activity calculation flag
18115 CHI1 = W(3) ! Total NH4 initially as NH4HSO4
18116 CHI2 = W(1) ! Total NA initially as NaHSO4
18117 CHI3 = W(7) ! Total K initially as KHSO4
18118 CHI4 = W(8) ! Total Mg initially as MgSO4
18120 LAMDA = MAX(W(2) - W(3) - W(1) - W(6) - W(7) - W(8), TINY) ! FREE H2SO4
18121 PSI1 = CHI1 ! ALL NH4HSO4 DELIQUESCED
18122 PSI2 = CHI2 ! ALL NaHSO4 DELIQUESCED
18123 PSI3 = CHI3 ! ALL KHSO4 DELIQUESCED
18124 PSI4 = CHI4 ! ALL MgSO4 DELIQUESCED
18126 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
18130 A4 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
18132 BB = A4+LAMDA+PSI4 ! KAPA
18133 CC =-A4*(LAMDA + PSI3 + PSI2 + PSI1) + LAMDA*PSI4
18134 DD = MAX(BB*BB-4.D0*CC, ZERO)
18135 KAPA = 0.5D0*(-BB+SQRT(DD))
18137 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
18139 MOLAL (1) = MAX(LAMDA + KAPA, TINY) ! HI
18140 MOLAL (2) = PSI2 ! NAI
18141 MOLAL (3) = PSI1 ! NH4I
18142 MOLAL (5) = MAX(KAPA + PSI4, ZERO) ! SO4I
18143 MOLAL (6) = MAX(LAMDA + PSI1 + PSI2 + PSI3 - KAPA, ZERO) ! HSO4I
18144 MOLAL (9) = PSI3 ! KI
18145 MOLAL (10)= PSI4 ! MGI
18153 CALL CALCMR2p1 ! Water content
18155 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
18157 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
18166 !C *** END OF SUBROUTINE CALCK4
18170 !C=======================================================================
18172 !C *** ISORROPIA CODE II
18173 !C *** SUBROUTINE CALCK3
18176 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18177 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18178 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18179 !C 3. SOLIDS POSSIBLE : KHSO4, CASO4
18181 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18182 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18183 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18185 !C=======================================================================
18187 SUBROUTINE CALCK32p1
18188 INCLUDE 'module_isrpia_inc.F'
18190 DOUBLE PRECISION LAMDA, KAPA
18191 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18194 !C *** SETUP PARAMETERS ************************************************
18196 CALAOU =.TRUE. ! Outer loop activity calculation flag
18197 CHI1 = W(3) ! Total NH4 initially as NH4HSO4
18198 CHI2 = W(1) ! Total NA initially as NaHSO4
18199 CHI3 = W(7) ! Total K initially as KHSO4
18200 CHI4 = W(8) ! Total Mg initially as MgSO4
18202 PSI3LO = TINY ! Low limit
18203 PSI3HI = CHI3 ! High limit
18205 !C *** INITIAL VALUES FOR BISECTION ************************************
18208 Y1 = FUNCK32p1 (X1)
18209 YHI= Y1 ! Save Y-value at HI position
18211 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH KHSO4 ****
18213 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
18215 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
18217 DX = (PSI3HI-PSI3LO)/FLOAT(NDIV)
18220 Y2 = FUNCK32p1 (X2)
18221 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
18226 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH KHSO4
18228 YLO= Y1 ! Save Y-value at Hi position
18229 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
18230 Y3 = FUNCK32p1 (ZERO)
18232 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
18235 CALL PUSHERR2p1 (0001, 'CALCK3') ! WARNING ERROR: NO SOLUTION
18239 !C *** PERFORM BISECTION ***********************************************
18243 Y3 = FUNCK32p1 (X3)
18244 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
18251 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
18253 CALL PUSHERR2p1 (0002, 'CALCK3') ! WARNING ERROR: NO CONVERGENCE
18255 !C *** CONVERGED ; RETURN **********************************************
18257 40 X3 = 0.5*(X1+X2)
18258 Y3 = FUNCK32p1 (X3)
18262 !C *** END OF SUBROUTINE CALCK3 ******************************************
18266 !C=======================================================================
18268 !C *** ISORROPIA CODE
18269 !C *** SUBROUTINE FUNCK3
18272 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18273 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18274 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18275 !C 3. SOLIDS POSSIBLE : KHSO4, CaSO4
18277 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18278 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18279 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18281 !C=======================================================================
18283 DOUBLE PRECISION FUNCTION FUNCK32p1 (P1)
18284 INCLUDE 'module_isrpia_inc.F'
18285 DOUBLE PRECISION LAMDA, KAPA
18286 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18289 !C *** SETUP PARAMETERS ************************************************
18294 LAMDA = MAX(W(2) - W(3) - W(1) - W(6) - W(7) - W(8), TINY) ! FREE H2SO4
18296 PSI1 = CHI1 ! ALL NH4HSO4 DELIQUESCED
18297 PSI2 = CHI2 ! ALL NaHSO4 DELIQUESCED
18298 PSI4 = CHI4 ! ALL MgSO4 DELIQUESCED
18301 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
18305 A3 = XK18 *(WATER/GAMA(18))**2.0
18306 A4 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
18309 BB = A4+LAMDA+PSI4 ! KAPA
18310 CC =-A4*(LAMDA + PSI3 + PSI2 + PSI1) + LAMDA*PSI4
18311 DD = MAX(BB*BB-4.D0*CC, ZERO)
18312 KAPA = 0.5D0*(-BB+SQRT(DD))
18314 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
18316 MOLAL (1) = MAX(LAMDA + KAPA, ZERO) ! HI
18317 MOLAL (2) = PSI2 ! NAI
18318 MOLAL (3) = PSI1 ! NH4I
18320 MOLAL (5) = MAX(KAPA + PSI4, ZERO) ! SO4I
18321 MOLAL (6) = MAX(LAMDA+PSI1+PSI2+PSI3-KAPA,ZERO) ! HSO4I
18324 MOLAL (9) = PSI3 ! KI
18333 CALL CALCMR2p1 ! Water content
18335 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
18337 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
18344 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
18346 20 FUNCK32p1 = MOLAL(9)*MOLAL(6)/A3 - ONE
18348 !C *** END OF FUNCTION FUNCK3 *******************************************
18352 !C=======================================================================
18354 !C *** ISORROPIA CODE II
18355 !C *** SUBROUTINE CALCK2
18358 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18359 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18360 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18361 !C 3. SOLIDS POSSIBLE : NAHSO4, KHSO4, CaSO4
18363 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18364 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18365 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18367 !C=======================================================================
18369 SUBROUTINE CALCK22p1
18370 INCLUDE 'module_isrpia_inc.F'
18372 DOUBLE PRECISION LAMDA, KAPA
18373 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18376 !C *** SETUP PARAMETERS ************************************************
18378 CALAOU =.TRUE. ! Outer loop activity calculation flag
18379 CHI1 = W(3) ! Total NH4 initially as NH4HSO4
18380 CHI2 = W(1) ! Total NA initially as NaHSO4
18381 CHI3 = W(7) ! Total K initially as KHSO4
18382 CHI4 = W(8) ! Total Mg initially as MgSO4
18384 PSI3LO = TINY ! Low limit
18385 PSI3HI = CHI3 ! High limit
18387 !C *** INITIAL VALUES FOR BISECTION ************************************
18390 Y1 = FUNCK22p1 (X1)
18391 YHI= Y1 ! Save Y-value at HI position
18393 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH KHSO4 ****
18395 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
18397 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
18399 DX = (PSI3HI-PSI3LO)/FLOAT(NDIV)
18402 Y2 = FUNCK22p1 (X2)
18403 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
18408 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH KHSO4
18410 YLO= Y1 ! Save Y-value at Hi position
18411 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
18412 Y3 = FUNCK22p1 (ZERO)
18414 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
18417 CALL PUSHERR2p1 (0001, 'CALCK2') ! WARNING ERROR: NO SOLUTION
18421 !C *** PERFORM BISECTION ***********************************************
18425 Y3 = FUNCK22p1 (X3)
18426 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
18433 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
18435 CALL PUSHERR2p1 (0002, 'CALCK2') ! WARNING ERROR: NO CONVERGENCE
18437 !C *** CONVERGED ; RETURN **********************************************
18439 40 X3 = 0.5*(X1+X2)
18440 Y3 = FUNCK22p1 (X3)
18444 !C *** END OF SUBROUTINE CALCK2 ******************************************
18448 !C=======================================================================
18450 !C *** ISORROPIA CODE II
18451 !C *** SUBROUTINE FUNCK2
18454 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18455 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18456 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18457 !C 3. SOLIDS POSSIBLE : NAHSO4, KHSO4, CaSO4
18459 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18460 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18461 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18463 !C=======================================================================
18465 DOUBLE PRECISION FUNCTION FUNCK22p1 (P1)
18466 INCLUDE 'module_isrpia_inc.F'
18467 DOUBLE PRECISION LAMDA, KAPA
18468 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18471 !C *** SETUP PARAMETERS ************************************************
18476 LAMDA = MAX(W(2) - W(3) - W(1) - W(6) - W(7) - W(8), TINY) ! FREE H2SO4
18478 PSI1 = CHI1 ! ALL NH4HSO4 DELIQUESCED
18479 PSI4 = CHI4 ! ALL MgSO4 DELIQUESCED
18481 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
18485 A2 = XK11 *(WATER/GAMA(12))**2.0
18486 A3 = XK18 *(WATER/GAMA(18))**2.0
18487 A4 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
18489 PSI2 = A2/A3*PSI3 ! PSI2
18490 PSI2 = MIN(MAX(PSI2, ZERO),CHI2)
18492 BB = A4+LAMDA+PSI4 ! KAPA
18493 CC =-A4*(LAMDA + PSI3 + PSI2 + PSI1) + LAMDA*PSI4
18494 DD = MAX(BB*BB-4.D0*CC, ZERO)
18495 KAPA = 0.5D0*(-BB+SQRT(DD))
18497 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
18499 MOLAL (1) = MAX(LAMDA + KAPA, ZERO) ! HI
18500 MOLAL (2) = PSI2 ! NAI
18501 MOLAL (3) = PSI1 ! NH4I
18503 MOLAL (5) = MAX(KAPA + PSI4, ZERO) ! SO4I
18504 MOLAL (6) = MAX(LAMDA+PSI1+PSI2+PSI3-KAPA,ZERO) ! HSO4I
18507 MOLAL (9) = PSI3 ! KI
18511 CNAHSO4 = CHI2-PSI2
18516 CALL CALCMR2p1 ! Water content
18518 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
18520 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
18527 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
18529 20 FUNCK22p1 = MOLAL(9)*MOLAL(6)/A3 - ONE
18531 !C *** END OF FUNCTION FUNCK2 *******************************************
18535 !C=======================================================================
18537 !C *** ISORROPIA CODE II
18538 !C *** SUBROUTINE CALCK1
18541 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18542 !C 1. SULFATE SUPER RICH, FREE ACID (SO4RAT < 1.0)
18543 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18544 !C 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4, KHSO4, CASO4
18546 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18547 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18548 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18550 !C=======================================================================
18552 SUBROUTINE CALCK12p1
18553 INCLUDE 'module_isrpia_inc.F'
18555 DOUBLE PRECISION LAMDA, KAPA
18556 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18559 !C *** SETUP PARAMETERS ************************************************
18562 CALAOU =.TRUE. ! Outer loop activity calculation flag
18563 CHI1 = W(3) ! Total NH4 initially as NH4HSO4
18564 CHI2 = W(1) ! Total NA initially as NaHSO4
18565 CHI3 = W(7) ! Total K initially as KHSO4
18566 CHI4 = W(8) ! Total Mg initially as MGSO4
18568 PSI3LO = TINY ! Low limit
18569 PSI3HI = CHI3 ! High limit
18571 !C *** INITIAL VALUES FOR BISECTION ************************************
18574 Y1 = FUNCK12p1 (X1)
18575 YHI= Y1 ! Save Y-value at HI position
18577 !C *** YHI < 0.0 THE SOLUTION IS ALWAYS UNDERSATURATED WITH KHSO4 ****
18579 IF (ABS(Y1).LE.EPS .OR. YHI.LT.ZERO) GOTO 50
18581 !C *** ROOT TRACKING ; FOR THE RANGE OF HI AND LO **********************
18583 DX = (PSI3HI-PSI3LO)/FLOAT(NDIV)
18586 Y2 = FUNCK12p1 (X2)
18587 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y2).LT.ZERO) GOTO 20 ! (Y1*Y2.LT.ZERO)
18592 !C *** { YLO, YHI } > 0.0 THE SOLUTION IS ALWAYS SUPERSATURATED WITH KHSO4
18594 YLO= Y1 ! Save Y-value at Hi position
18595 IF (YLO.GT.ZERO .AND. YHI.GT.ZERO) THEN
18596 Y3 = FUNCK12p1 (ZERO)
18598 ELSE IF (ABS(Y2) .LT. EPS) THEN ! X2 IS A SOLUTION
18601 CALL PUSHERR2p1 (0001, 'CALCK1') ! WARNING ERROR: NO SOLUTION
18605 !C *** PERFORM BISECTION ***********************************************
18609 Y3 = FUNCK12p1 (X3)
18610 IF (SIGN(1.d0,Y1)*SIGN(1.d0,Y3) .LE. ZERO) THEN ! (Y1*Y3 .LE. ZERO)
18617 IF (ABS(X2-X1) .LE. EPS*X1) GOTO 40
18619 CALL PUSHERR2p1 (0002, 'CALCK1') ! WARNING ERROR: NO CONVERGENCE
18621 !C *** CONVERGED ; RETURN **********************************************
18623 40 X3 = 0.5*(X1+X2)
18624 Y3 = FUNCK12p1 (X3)
18628 !C *** END OF SUBROUTINE CALCK1 ******************************************
18632 !C=======================================================================
18634 !C *** ISORROPIA CODE II
18635 !C *** SUBROUTINE FUNCK1
18638 !C THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
18639 !C 1. SULFATE super RICH, FREE ACID (SO4RAT < 1.0)
18640 !C 2. THERE IS BOTH A LIQUID & SOLID PHASE
18641 !C 3. SOLIDS POSSIBLE : NH4HSO4, NAHSO4, KHSO4, CASO4
18643 !C *** COPYRIGHT 1996-2006, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY
18644 !C *** GEORGIA INSTITUTE OF TECHNOLOGY
18645 !C *** WRITTEN BY CHRISTOS FOUNTOUKIS AND ATHANASIOS NENES
18647 !C=======================================================================
18649 DOUBLE PRECISION FUNCTION FUNCK12p1 (P1)
18650 INCLUDE 'module_isrpia_inc.F'
18651 DOUBLE PRECISION LAMDA, KAPA
18652 COMMON /CASEK2p1/ CHI1,CHI2,CHI3,CHI4,LAMDA,KAPA,PSI1,PSI2,PSI3, &
18655 !C *** SETUP PARAMETERS ************************************************
18660 LAMDA = MAX(W(2) - W(3) - W(1) - W(6) - W(7) - W(8), TINY) ! FREE H2SO4
18662 PSI4 = CHI4 ! ALL MgSO4 DELIQUESCED
18664 !C *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
18668 A1 = XK12 *(WATER/GAMA(09))**2.0
18669 A2 = XK11 *(WATER/GAMA(12))**2.0
18670 A3 = XK18 *(WATER/GAMA(18))**2.0
18671 A4 = XK1 *WATER/GAMA(7)*(GAMA(8)/GAMA(7))**2.0
18673 PSI1 = A1/A3*PSI3 ! PSI1
18674 PSI1 = MIN(MAX(PSI1, ZERO),CHI1)
18676 PSI2 = A2/A3*PSI3 ! PSI2
18677 PSI2 = MIN(MAX(PSI2, ZERO),CHI2)
18679 BB = A4+LAMDA+PSI4 ! KAPA
18680 CC =-A4*(LAMDA + PSI3 + PSI2 + PSI1) + LAMDA*PSI4
18681 DD = MAX(BB*BB-4.D0*CC, ZERO)
18682 KAPA = 0.5D0*(-BB+SQRT(DD))
18684 !C *** SAVE CONCENTRATIONS IN MOLAL ARRAY ******************************
18686 MOLAL (1) = MAX(LAMDA + KAPA, ZERO) ! HI
18687 MOLAL (2) = PSI2 ! NAI
18688 MOLAL (3) = PSI1 ! NH4I
18689 MOLAL (4) = ZERO ! CLI
18690 MOLAL (5) = MAX(KAPA + PSI4, ZERO) ! SO4I
18691 MOLAL (6) = MAX(LAMDA+PSI1+PSI2+PSI3-KAPA,ZERO) ! HSO4I
18692 MOLAL (7) = ZERO ! NO3I
18693 MOLAL (8) = ZERO ! CAI
18694 MOLAL (9) = PSI3 ! KI
18695 MOLAL (10)= PSI4 ! MGI
18697 CNH4HS4 = CHI1-PSI1
18698 CNAHSO4 = CHI2-PSI2
18703 CALL CALCMR2p1 ! Water content
18705 !C *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
18707 IF (FRST.AND.CALAOU .OR. .NOT.FRST.AND.CALAIN) THEN
18715 !C *** CALCULATE OBJECTIVE FUNCTION ************************************
18717 20 FUNCK12p1 = MOLAL(9)*MOLAL(6)/A3 - ONE
18719 !C *** END OF FUNCTION FUNCK1 ****************************************