-
Notifications
You must be signed in to change notification settings - Fork 0
/
FUTURE_isorev.f90
11871 lines (9429 loc) · 356 KB
/
FUTURE_isorev.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE ISRP1R
! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
! AN AMMONIUM-SULFATE AEROSOL SYSTEM.
! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
! THE AMBIENT RELATIVE HUMIDITY.
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE ISRP1R (WI, RHI, TEMPI)
INCLUDE 'isrpia.inc'
DIMENSION WI(NCOMP)
! *** INITIALIZE COMMON BLOCK VARIABLES *********************************
CALL INIT1 (WI, RHI, TEMPI)
! *** CALCULATE SULFATE RATIO *******************************************
IF (RH >= DRNH42S4) THEN ! WET AEROSOL, NEED NH4 AT SRATIO=2.0
SULRATW = GETASR(WAER(2), RHI) ! AEROSOL SULFATE RATIO
ELSE
SULRATW = 2.0D0 ! DRY AEROSOL SULFATE RATIO
ENDIF
SULRAT = WAER(3)/WAER(2) ! SULFATE RATIO
! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
! *** SULFATE POOR
IF (SULRATW <= SULRAT) THEN
IF(METSTBL == 1) THEN
SCASE = 'S2'
CALL CALCS2 ! Only liquid (metastable)
ELSE
IF (RH < DRNH42S4) THEN
SCASE = 'S1'
CALL CALCS1 ! NH42SO4 ; case K1
ELSEIF (DRNH42S4 <= RH) THEN
SCASE = 'S2'
CALL CALCS2 ! Only liquid ; case K2
ENDIF
ENDIF
! *** SULFATE RICH (NO ACID)
ELSEIF (1.0 <= SULRAT .AND. SULRAT < SULRATW) THEN
W(2) = WAER(2)
W(3) = WAER(3)
IF(METSTBL == 1) THEN
SCASE = 'B4'
CALL CALCB4 ! Only liquid (metastable)
SCASE = 'B4'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'B1'
CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case B1
SCASE = 'B1'
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRLC) THEN
SCASE = 'B2'
CALL CALCB2 ! LC,NH42S4 ; case B2
SCASE = 'B2'
ELSEIF (DRLC <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'B3'
CALL CALCB3 ! NH42S4 ; case B3
SCASE = 'B3'
ELSEIF (DRNH42S4 <= RH) THEN
SCASE = 'B4'
CALL CALCB4 ! Only liquid ; case B4
SCASE = 'B4'
ENDIF
ENDIF
CALL CALCNH3P ! Compute NH3(g)
! *** SULFATE RICH (FREE ACID)
ELSEIF (SULRAT < 1.0) THEN
W(2) = WAER(2)
W(3) = WAER(3)
IF(METSTBL == 1) THEN
SCASE = 'C2'
CALL CALCC2 ! Only liquid (metastable)
SCASE = 'C2'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'C1'
CALL CALCC1 ! NH4HSO4 ; case C1
SCASE = 'C1'
ELSEIF (DRNH4HS4 <= RH) THEN
SCASE = 'C2'
CALL CALCC2 ! Only liquid ; case C2
SCASE = 'C2'
ENDIF
ENDIF
CALL CALCNH3P
ENDIF
RETURN
! *** END OF SUBROUTINE ISRP1R *****************************************
END SUBROUTINE ISRP1R
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE ISRP2R
! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
! AN AMMONIUM-SULFATE-NITRATE AEROSOL SYSTEM.
! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE RATIO AND BY
! THE AMBIENT RELATIVE HUMIDITY.
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE ISRP2R (WI, RHI, TEMPI)
INCLUDE 'isrpia.inc'
DIMENSION WI(NCOMP)
LOGICAL :: TRYLIQ
! *** INITIALIZE ALL VARIABLES IN COMMON BLOCK **************************
TRYLIQ = .TRUE. ! Assume liquid phase, sulfate poor limit
10 CALL INIT2 (WI, RHI, TEMPI)
! *** CALCULATE SULFATE RATIO *******************************************
IF (TRYLIQ .AND. RH >= DRNH4NO3) THEN ! *** WET AEROSOL
SULRATW = GETASR(WAER(2), RHI) ! LIMITING SULFATE RATIO
ELSE
SULRATW = 2.0D0 ! *** DRY AEROSOL
ENDIF
SULRAT = WAER(3)/WAER(2)
! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
! *** SULFATE POOR
IF (SULRATW <= SULRAT) THEN
IF(METSTBL == 1) THEN
SCASE = 'N3'
CALL CALCN3 ! Only liquid (metastable)
ELSE
IF (RH < DRNH4NO3) THEN
SCASE = 'N1'
CALL CALCN1 ! NH42SO4,NH4NO3 ; case N1
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'N2'
CALL CALCN2 ! NH42S4 ; case N2
ELSEIF (DRNH42S4 <= RH) THEN
SCASE = 'N3'
CALL CALCN3 ! Only liquid ; case N3
ENDIF
ENDIF
! *** SULFATE RICH (NO ACID)
! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
! AEROSOL EQUILIBRIUM.
ELSEIF (1.0 <= SULRAT .AND. SULRAT < SULRATW) THEN
W(2) = WAER(2)
W(3) = WAER(3)
W(4) = WAER(4)
IF(METSTBL == 1) THEN
SCASE = 'B4'
CALL CALCB4 ! Only liquid (metastable)
SCASE = 'B4'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'B1'
CALL CALCB1 ! NH4HSO4,LC,NH42SO4 ; case O1
SCASE = 'B1'
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRLC) THEN
SCASE = 'B2'
CALL CALCB2 ! LC,NH42S4 ; case O2
SCASE = 'B2'
ELSEIF (DRLC <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'B3'
CALL CALCB3 ! NH42S4 ; case O3
SCASE = 'B3'
ELSEIF (DRNH42S4 <= RH) THEN
SCASE = 'B4'
CALL CALCB4 ! Only liquid ; case O4
SCASE = 'B4'
ENDIF
ENDIF
! *** Add the NO3 to the solution now and calculate partitioning.
MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
CALL CALCNAP ! HNO3, NH3 dissolved
CALL CALCNH3P
! *** SULFATE RICH (FREE ACID)
! FOR SOLVING THIS CASE, NITRIC ACID AND AMMONIA IN THE GAS PHASE ARE
! ASSUMED A MINOR SPECIES, THAT DO NOT SIGNIFICANTLY AFFECT THE
! AEROSOL EQUILIBRIUM.
ELSEIF (SULRAT < 1.0) THEN
W(2) = WAER(2)
W(3) = WAER(3)
W(4) = WAER(4)
IF(METSTBL == 1) THEN
SCASE = 'C2'
CALL CALCC2 ! Only liquid (metastable)
SCASE = 'C2'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'C1'
CALL CALCC1 ! NH4HSO4 ; case P1
SCASE = 'C1'
ELSEIF (DRNH4HS4 <= RH) THEN
SCASE = 'C2'
CALL CALCC2 ! Only liquid ; case P2
SCASE = 'C2'
ENDIF
ENDIF
! *** Add the NO3 to the solution now and calculate partitioning.
MOLAL(7) = WAER(4) ! There is always water, so NO3(aer) is NO3-
MOLAL(1) = MOLAL(1) + WAER(4) ! Add H+ to balance out
CALL CALCNAP ! HNO3, NH3 dissolved
CALL CALCNH3P
ENDIF
! *** IF SULRATW < SULRAT < 2.0 and WATER = 0 => SULFATE RICH CASE.
IF (SULRATW <= SULRAT .AND. SULRAT < 2.0 &
.AND. WATER <= TINY) THEN
TRYLIQ = .FALSE.
GOTO 10
ENDIF
RETURN
! *** END OF SUBROUTINE ISRP2R *****************************************
END SUBROUTINE ISRP2R
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE ISRP3R
! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
! AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM AEROSOL SYSTEM.
! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
! RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE ISRP3R (WI, RHI, TEMPI)
INCLUDE 'isrpia.inc'
DIMENSION WI(NCOMP)
LOGICAL :: TRYLIQ
! C
! C *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
! C
!c WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
!c WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
! *** INITIALIZE ALL VARIABLES ******************************************
TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
10 CALL ISOINIT3 (WI, RHI, TEMPI) ! COMMON block variables
! C
! C *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
! C
!c REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
!c IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
!c WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
!c CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
!c ENDIF
! *** CALCULATE SULFATE & SODIUM RATIOS *********************************
IF (TRYLIQ .AND. RH >= DRNH4NO3) THEN ! ** WET AEROSOL
FRSO4 = WAER(2) - WAER(1)/2.0D0 ! SULFATE UNBOUND BY SODIUM
FRSO4 = MAX(FRSO4, TINY)
SRI = GETASR(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
SULRATW = (WAER(1)+FRSO4*SRI)/WAER(2) ! LIMITING SULFATE RATIO
SULRATW = MIN (SULRATW, 2.0D0)
ELSE
SULRATW = 2.0D0 ! ** DRY AEROSOL
ENDIF
SULRAT = (WAER(1)+WAER(3))/WAER(2)
SODRAT = WAER(1)/WAER(2)
! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
! *** SULFATE POOR ; SODIUM POOR
IF (SULRATW <= SULRAT .AND. SODRAT < 2.0) THEN
IF(METSTBL == 1) THEN
SCASE = 'Q5'
CALL CALCQ5 ! Only liquid (metastable)
SCASE = 'Q5'
ELSE
IF (RH < DRNH4NO3) THEN
SCASE = 'Q1'
CALL CALCQ1 ! NH42SO4,NH4NO3,NH4CL,NA2SO4
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNH4CL) THEN
SCASE = 'Q2'
CALL CALCQ2 ! NH42SO4,NH4CL,NA2SO4
ELSEIF (DRNH4CL <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'Q3'
CALL CALCQ3 ! NH42SO4,NA2SO4
ELSEIF (DRNH42S4 <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'Q4'
CALL CALCQ4 ! NA2SO4
SCASE = 'Q4'
ELSEIF (DRNA2SO4 <= RH) THEN
SCASE = 'Q5'
CALL CALCQ5 ! Only liquid
SCASE = 'Q5'
ENDIF
ENDIF
! *** SULFATE POOR ; SODIUM RICH
ELSE IF (SULRAT >= SULRATW .AND. SODRAT >= 2.0) THEN
IF(METSTBL == 1) THEN
SCASE = 'R6'
CALL CALCR6 ! Only liquid (metastable)
SCASE = 'R6'
ELSE
IF (RH < DRNH4NO3) THEN
SCASE = 'R1'
CALL CALCR1 ! NH4NO3,NH4CL,NA2SO4,NACL,NANO3
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNANO3) THEN
SCASE = 'R2'
CALL CALCR2 ! NH4CL,NA2SO4,NACL,NANO3
ELSEIF (DRNANO3 <= RH .AND. RH < DRNACL) THEN
SCASE = 'R3'
CALL CALCR3 ! NH4CL,NA2SO4,NACL
ELSEIF (DRNACL <= RH .AND. RH < DRNH4CL) THEN
SCASE = 'R4'
CALL CALCR4 ! NH4CL,NA2SO4
ELSEIF (DRNH4CL <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'R5'
CALL CALCR5 ! NA2SO4
SCASE = 'R5'
ELSEIF (DRNA2SO4 <= RH) THEN
SCASE = 'R6'
CALL CALCR6 ! NO SOLID
SCASE = 'R6'
ENDIF
ENDIF
! *** SULFATE RICH (NO ACID)
ELSEIF (1.0 <= SULRAT .AND. SULRAT < SULRATW) THEN
DO 100 I=1,NCOMP
W(I) = WAER(I)
100 END DO
IF(METSTBL == 1) THEN
SCASE = 'I6'
CALL CALCI6 ! Only liquid (metastable)
SCASE = 'I6'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'I1'
CALL CALCI1 ! NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
SCASE = 'I1'
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRNAHSO4) THEN
SCASE = 'I2'
CALL CALCI2 ! NA2SO4,(NH4)2SO4,NAHSO4,LC
SCASE = 'I2'
ELSEIF (DRNAHSO4 <= RH .AND. RH < DRLC) THEN
SCASE = 'I3'
CALL CALCI3 ! NA2SO4,(NH4)2SO4,LC
SCASE = 'I3'
ELSEIF (DRLC <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'I4'
CALL CALCI4 ! NA2SO4,(NH4)2SO4
SCASE = 'I4'
ELSEIF (DRNH42S4 <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'I5'
CALL CALCI5 ! NA2SO4
SCASE = 'I5'
ELSEIF (DRNA2SO4 <= RH) THEN
SCASE = 'I6'
CALL CALCI6 ! NO SOLIDS
SCASE = 'I6'
ENDIF
ENDIF
CALL CALCNHP ! HNO3, NH3, HCL in gas phase
CALL CALCNH3P
! *** SULFATE RICH (FREE ACID)
ELSEIF (SULRAT < 1.0) THEN
DO 200 I=1,NCOMP
W(I) = WAER(I)
200 END DO
IF(METSTBL == 1) THEN
SCASE = 'J3'
CALL CALCJ3 ! Only liquid (metastable)
SCASE = 'J3'
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'J1'
CALL CALCJ1 ! NH4HSO4,NAHSO4
SCASE = 'J1'
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRNAHSO4) THEN
SCASE = 'J2'
CALL CALCJ2 ! NAHSO4
SCASE = 'J2'
ELSEIF (DRNAHSO4 <= RH) THEN
SCASE = 'J3'
CALL CALCJ3
SCASE = 'J3'
ENDIF
ENDIF
CALL CALCNHP ! HNO3, NH3, HCL in gas phase
CALL CALCNH3P
ENDIF
! *** IF AFTER CALCULATIONS, SULRATW < SULRAT < 2.0
! and WATER = 0 => SULFATE RICH CASE.
IF (SULRATW <= SULRAT .AND. SULRAT < 2.0 &
.AND. WATER <= TINY) THEN
TRYLIQ = .FALSE.
GOTO 10
ENDIF
RETURN
! *** END OF SUBROUTINE ISRP3R *****************************************
END SUBROUTINE ISRP3R
!=======================================================================
! *** ISORROPIA CODE II
! *** SUBROUTINE ISRP4R
! *** THIS SUBROUTINE IS THE DRIVER ROUTINE FOR THE REVERSE PROBLEM OF
! AN AMMONIUM-SULFATE-NITRATE-CHLORIDE-SODIUM-CALCIUM-POTTASIUM-MAGNESIUM AEROSOL SYSTEM.
! THE COMPOSITION REGIME IS DETERMINED BY THE SULFATE & SODIUM
! RATIOS AND BY THE AMBIENT RELATIVE HUMIDITY.
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY CHRISTOS FOUNTOUKIS & ATHANASIOS NENES
!=======================================================================
SUBROUTINE ISRP4R (WI, RHI, TEMPI)
INCLUDE 'isrpia.inc'
DIMENSION WI(NCOMP)
LOGICAL :: TRYLIQ
! C
! C *** ADJUST FOR TOO LITTLE AMMONIUM AND CHLORIDE ***********************
! C
!c WI(3) = MAX (WI(3), 1.D-10) ! NH4+ : 1e-4 umoles/m3
!c WI(5) = MAX (WI(5), 1.D-10) ! Cl- : 1e-4 umoles/m3
! *** INITIALIZE ALL VARIABLES ******************************************
TRYLIQ = .TRUE. ! Use liquid phase sulfate poor limit
IPROB = 1 ! SOLVE REVERSE PROBLEM
! METSTBL = 1
10 CALL INIT4 (WI, RHI, TEMPI) ! COMMON block variables
! C
! C *** CHECK IF TOO MUCH SODIUM ; ADJUST AND ISSUE ERROR MESSAGE *********
! C
!c REST = 2.D0*WAER(2) + WAER(4) + WAER(5)
!c IF (WAER(1).GT.REST) THEN ! NA > 2*SO4+CL+NO3 ?
!c WAER(1) = (ONE-1D-6)*REST ! Adjust Na amount
!c CALL PUSHERR (0050, 'ISRP3R') ! Warning error: Na adjusted
!c ENDIF
! *** CALCULATE SULFATE, CRUSTAL & SODIUM RATIOS ***********************
IF (TRYLIQ) THEN ! ** WET AEROSOL
FRSO4 = WAER(2) - WAER(1)/2.0D0 &
- WAER(6) - WAER(7)/2.0D0 - WAER(8) ! SULFATE UNBOUND BY SODIUM,CALCIUM,POTTASIUM,MAGNESIUM
FRSO4 = MAX(FRSO4, TINY)
SRI = GETASR(FRSO4, RHI) ! SULFATE RATIO FOR NH4+
SULRATW = (WAER(1)+FRSO4*SRI+WAER(6) &
+WAER(7)+WAER(8))/WAER(2) ! LIMITING SULFATE RATIO
SULRATW = MIN (SULRATW, 2.0D0)
ELSE
SULRATW = 2.0D0 ! ** DRY AEROSOL
ENDIF
SO4RAT = (WAER(1)+WAER(3)+WAER(6)+WAER(7)+WAER(8))/WAER(2)
CRNARAT = (WAER(1)+WAER(6)+WAER(7)+WAER(8))/WAER(2)
CRRAT = (WAER(6)+WAER(7)+WAER(8))/WAER(2)
! *** FIND CALCULATION REGIME FROM (SULRAT,RH) **************************
! *** SULFATE POOR ; SODIUM+CRUSTALS POOR
IF (SULRATW <= SO4RAT .AND. CRNARAT < 2.0) THEN
IF(METSTBL == 1) THEN
SCASE = 'V7'
CALL CALCV7 ! Only liquid (metastable)
ELSE
IF (RH < DRNH4NO3) THEN
SCASE = 'V1'
CALL CALCV1 ! CaSO4, NH4NO3, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNH4CL) THEN
SCASE = 'V2'
CALL CALCV2 ! CaSO4, NH4CL, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
ELSEIF (DRNH4CL <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'V3'
CALL CALCV3 ! CaSO4, (NH4)2SO4, MGSO4, NA2SO4, K2SO4
ELSEIF (DRNH42S4 <= RH .AND. RH < DRMGSO4) THEN
SCASE = 'V4'
CALL CALCV4 ! CaSO4, MGSO4, NA2SO4, K2SO4
ELSEIF (DRMGSO4 <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'V5'
CALL CALCV5 ! CaSO4, NA2SO4, K2SO4
ELSEIF (DRNA2SO4 <= RH .AND. RH < DRK2SO4) THEN
SCASE = 'V6'
CALL CALCV6 ! CaSO4, K2SO4
ELSEIF (DRK2SO4 <= RH) THEN
SCASE = 'V7'
CALL CALCV7 ! CaSO4
ENDIF
ENDIF
! *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
ELSEIF (SO4RAT >= SULRATW .AND. CRNARAT >= 2.0) THEN
IF (CRRAT <= 2.0) THEN
IF(METSTBL == 1) THEN
SCASE = 'U8'
CALL CALCU8 ! Only liquid (metastable)
ELSE
IF (RH < DRNH4NO3) THEN
SCASE = 'U1'
CALL CALCU1 ! CaSO4, NH4NO3, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNANO3) THEN
SCASE = 'U2'
CALL CALCU2 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL, NANO3
ELSEIF (DRNANO3 <= RH .AND. RH < DRNACL) THEN
SCASE = 'U3'
CALL CALCU3 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4, NACL
ELSEIF (DRNACL <= RH .AND. RH < DRNH4Cl) THEN
SCASE = 'U4'
CALL CALCU4 ! CaSO4, NH4CL, MGSO4, NA2SO4, K2SO4
ELSEIF (DRNH4Cl <= RH .AND. RH < DRMGSO4) THEN
SCASE = 'U5'
CALL CALCU5 ! CaSO4, MGSO4, NA2SO4, K2SO4
ELSEIF (DRMGSO4 <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'U6'
CALL CALCU6 ! CaSO4, NA2SO4, K2SO4
ELSEIF (DRNA2SO4 <= RH .AND. RH < DRK2SO4) THEN
SCASE = 'U7'
CALL CALCU7 ! CaSO4, K2SO4
ELSEIF (DRK2SO4 <= RH) THEN
SCASE = 'U8'
CALL CALCU8 ! CaSO4
ENDIF
ENDIF
! *** SULFATE POOR: Rso4>2; (DUST + SODIUM) RICH: R(Cr+Na)>2; DUST POOR: Rcr<2.
ELSEIF (CRRAT > 2.0) THEN
IF(METSTBL == 1) THEN
SCASE = 'W13'
CALL CALCW13 ! Only liquid (metastable)
ELSE
IF (RH < DRCACL2) THEN
SCASE = 'W1'
CALL CALCW1 ! CaSO4, CA(NO3)2, CACL2, K2SO4, KNO3, KCL, MGSO4,
! ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
ELSEIF (DRCACL2 <= RH .AND. RH < DRMGCL2) THEN
SCASE = 'W2'
CALL CALCW2 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
! ! MG(NO3)2, MGCL2, NANO3, NACL, NH4NO3, NH4CL
ELSEIF (DRMGCL2 <= RH .AND. RH < DRCANO32) THEN
SCASE = 'W3'
CALL CALCW3 ! CaSO4, CA(NO3)2, K2SO4, KNO3, KCL, MGSO4,
! ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
ELSEIF (DRCANO32 <= RH .AND. RH < DRMGNO32) THEN
SCASE = 'W4'
CALL CALCW4 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
! ! MG(NO3)2, NANO3, NACL, NH4NO3, NH4CL
ELSEIF (DRMGNO32 <= RH .AND. RH < DRNH4NO3) THEN
SCASE = 'W5'
CALL CALCW5 ! CaSO4, K2SO4, KNO3, KCL, MGSO4,
! ! NANO3, NACL, NH4NO3, NH4CL
ELSEIF (DRNH4NO3 <= RH .AND. RH < DRNANO3) THEN
SCASE = 'W6'
CALL CALCW6 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NANO3, NACL, NH4CL
ELSEIF (DRNANO3 <= RH .AND. RH < DRNACL) THEN
SCASE = 'W7'
CALL CALCW7 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NACL, NH4CL
ELSEIF (DRNACL <= RH .AND. RH < DRNH4CL) THEN
SCASE = 'W8'
CALL CALCW8 ! CaSO4, K2SO4, KNO3, KCL, MGSO4, NH4CL
ELSEIF (DRNH4CL <= RH .AND. RH < DRKCL) THEN
SCASE = 'W9'
CALL CALCW9 ! CaSO4, K2SO4, KNO3, KCL, MGSO4
ELSEIF (DRKCL <= RH .AND. RH < DRMGSO4) THEN
SCASE = 'W10'
CALL CALCW10 ! CaSO4, K2SO4, KNO3, MGSO4
ELSEIF (DRMGSO4 <= RH .AND. RH < DRKNO3) THEN
SCASE = 'W11'
CALL CALCW11 ! CaSO4, K2SO4, KNO3
ELSEIF (DRKNO3 <= RH .AND. RH < DRK2SO4) THEN
SCASE = 'W12'
CALL CALCW12 ! CaSO4, K2SO4
ELSEIF (DRK2SO4 <= RH) THEN
SCASE = 'W13'
CALL CALCW13 ! CaSO4
ENDIF
ENDIF
! CALL CALCNH3
ENDIF
! *** SULFATE RICH (NO ACID): 1<Rso4<2;
ELSEIF (1.0 <= SO4RAT .AND. SO4RAT < SULRATW) THEN
DO 800 I=1,NCOMP
W(I) = WAER(I)
800 END DO
IF(METSTBL == 1) THEN
SCASE = 'L9'
CALL CALCL9 ! Only liquid (metastable)
ELSE
IF (RH < DRNH4HS4) THEN
SCASE = 'L1'
CALL CALCL1 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,NH4HSO4,LC
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRNAHSO4) THEN
SCASE = 'L2'
CALL CALCL2 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,NAHSO4,LC
ELSEIF (DRNAHSO4 <= RH .AND. RH < DRLC) THEN
SCASE = 'L3'
CALL CALCL3 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4,LC
ELSEIF (DRLC <= RH .AND. RH < DRNH42S4) THEN
SCASE = 'L4'
CALL CALCL4 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4,(NH4)2SO4
ELSEIF (DRNH42S4 <= RH .AND. RH < DRKHSO4) THEN
SCASE = 'L5'
CALL CALCL5 ! CASO4,K2SO4,MGSO4,KHSO4,NA2SO4
ELSEIF (DRKHSO4 <= RH .AND. RH < DRMGSO4) THEN
SCASE = 'L6'
CALL CALCL6 ! CASO4,K2SO4,MGSO4,NA2SO4
ELSEIF (DRMGSO4 <= RH .AND. RH < DRNA2SO4) THEN
SCASE = 'L7'
CALL CALCL7 ! CASO4,K2SO4,NA2SO4
ELSEIF (DRNA2SO4 <= RH .AND. RH < DRK2SO4) THEN
SCASE = 'L8'
CALL CALCL8 ! CASO4,K2SO4
ELSEIF (DRK2SO4 <= RH) THEN
SCASE = 'L9'
CALL CALCL9 ! CaSO4
ENDIF
ENDIF
CALL CALCNHP ! MINOR SPECIES: HNO3, HCl
CALL CALCNH3P ! NH3
! *** SULFATE SUPER RICH (FREE ACID): Rso4<1;
ELSEIF (SO4RAT < 1.0) THEN
DO 900 I=1,NCOMP
W(I) = WAER(I)
900 END DO
IF(METSTBL == 1) THEN
SCASE = 'K4'
CALL CALCK4 ! Only liquid (metastable)
ELSE
IF (RH < DRNH4HS4) THEN ! RH < 0.4
SCASE = 'K1'
CALL CALCK1 ! NH4HSO4,NAHSO4,KHSO4,CASO4
ELSEIF (DRNH4HS4 <= RH .AND. RH < DRNAHSO4) THEN
SCASE = 'K2'
CALL CALCK2 ! NAHSO4,KHSO4,CASO4
ELSEIF (DRNAHSO4 <= RH .AND. RH < DRKHSO4) THEN
SCASE = 'K3'
CALL CALCK3 ! KHSO4,CASO4 0.52 < RH < 0.86
ELSEIF (DRKHSO4 <= RH) THEN
SCASE = 'K4'
CALL CALCK4 ! CASO4
ENDIF
ENDIF
CALL CALCNHP ! MINOR SPECIES: HNO3, HCl
CALL CALCNH3P ! NH3
ENDIF
! *** IF AFTER CALCULATIONS, SULRATW < SO4RAT < 2.0
! and WATER = 0 => SULFATE RICH CASE.
IF (SULRATW <= SO4RAT .AND. SO4RAT < 2.0 &
.AND. WATER <= TINY) THEN
TRYLIQ = .FALSE.
GOTO 10
ENDIF
RETURN
! *** END OF SUBROUTINE ISRP4R *****************************************
END SUBROUTINE ISRP4R
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE CALCS2
! *** CASE S2
! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
! 1. SULFATE POOR (SULRAT > 2.0)
! 2. LIQUID AEROSOL PHASE ONLY POSSIBLE
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE CALCS2
INCLUDE 'isrpia.inc'
REAL :: NH4I, NH3GI, NH3AQ
! *** SETUP PARAMETERS ************************************************
CALAOU = .TRUE. ! Outer loop activity calculation flag
FRST = .TRUE.
CALAIN = .TRUE.
! *** CALCULATE WATER CONTENT *****************************************
MOLALR(4)= MIN(WAER(2), 0.5d0*WAER(3))
WATER = MOLALR(4)/M0(4) ! ZSR correlation
! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
DO 10 I=1,NSWEEP
!C A21 = XK21*WATER*R*TEMP
A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
AKW = XKW *RH*WATER*WATER
NH4I = WAER(3)
SO4I = WAER(2)
HSO4I= ZERO
CALL CALCPH (2.D0*SO4I - NH4I, HI, OHI) ! Get pH
NH3AQ = ZERO ! AMMONIA EQUILIBRIUM
IF (HI < OHI) THEN
CALL CALCAMAQ (NH4I, OHI, DEL)
NH4I = MAX (NH4I-DEL, ZERO)
OHI = MAX (OHI -DEL, TINY)
NH3AQ = DEL
HI = AKW/OHI
ENDIF
CALL CALCHS4 (HI, SO4I, ZERO, DEL) ! SULFATE EQUILIBRIUM
SO4I = SO4I - DEL
HI = HI - DEL
HSO4I = DEL
NH3GI = NH4I/HI/A2 ! NH3AQ/A21
! *** SPECIATION & WATER CONTENT ***************************************
MOLAL(1) = HI
MOLAL(3) = NH4I
MOLAL(5) = SO4I
MOLAL(6) = HSO4I
COH = OHI
GASAQ(1) = NH3AQ
GNH3 = NH3GI
! *** CALCULATE ACTIVITIES OR TERMINATE INTERNAL LOOP *****************
IF (FRST .AND. CALAOU .OR. .NOT. FRST .AND. CALAIN) THEN
CALL CALCACT
ELSE
GOTO 20
ENDIF
10 END DO
20 RETURN
! *** END OF SUBROUTINE CALCS2 ****************************************
END SUBROUTINE CALCS2
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE CALCS1
! *** CASE S1
! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
! 1. SULFATE POOR (SULRAT > 2.0)
! 2. SOLID AEROSOL ONLY
! 3. SOLIDS POSSIBLE : (NH4)2SO4
! A SIMPLE MATERIAL BALANCE IS PERFORMED, AND THE SOLID (NH4)2SO4
! IS CALCULATED FROM THE SULFATES. THE EXCESS AMMONIA REMAINS IN
! THE GAS PHASE.
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE CALCS1
INCLUDE 'isrpia.inc'
CNH42S4 = MIN(WAER(2),0.5d0*WAER(3)) ! For bad input problems
GNH3 = ZERO
W(2) = CNH42S4
W(3) = 2.D0*CNH42S4 + GNH3
RETURN
! *** END OF SUBROUTINE CALCS1 ******************************************
END SUBROUTINE CALCS1
!=======================================================================
! *** ISORROPIA CODE
! *** SUBROUTINE CALCN3
! *** CASE N3
! THE MAIN CHARACTERISTICS OF THIS REGIME ARE:
! 1. SULFATE POOR (SULRAT > 2.0)
! 2. THERE IS ONLY A LIQUID PHASE
! *** COPYRIGHT 1996-2008, UNIVERSITY OF MIAMI, CARNEGIE MELLON UNIVERSITY,
! *** GEORGIA INSTITUTE OF TECHNOLOGY
! *** WRITTEN BY ATHANASIOS NENES
!=======================================================================
SUBROUTINE CALCN3
INCLUDE 'isrpia.inc'
REAL :: NH4I, NO3I, NH3AQ, NO3AQ
COMMON /SOLUT/ CHI1, CHI2, CHI3, CHI4, CHI5, CHI6, CHI7, CHI8, &
CHI9, CHI10, CHI11, CHI12, CHI13, CHI14, CHI15, &
CHI16, CHI17, PSI1, PSI2, PSI3, PSI4, PSI5, PSI6, &
PSI7, PSI8, PSI9, PSI10, PSI11, PSI12, PSI13, &
PSI14, PSI15, PSI16, PSI17, A1, A2, A3, A4, A5, A6, &
A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
! *** SETUP PARAMETERS ************************************************
CALAOU = .TRUE. ! Outer loop activity calculation flag
FRST = .TRUE.
CALAIN = .TRUE.
! *** AEROSOL WATER CONTENT
MOLALR(4) = MIN(WAER(2),0.5d0*WAER(3)) ! (NH4)2SO4
AML5 = MAX(WAER(3)-2.D0*MOLALR(4),ZERO) ! "free" NH4
MOLALR(5) = MAX(MIN(AML5,WAER(4)), ZERO) ! NH4NO3=MIN("free",NO3)
WATER = MOLALR(4)/M0(4) + MOLALR(5)/M0(5)
WATER = MAX(WATER, TINY)
! *** SOLVE EQUATIONS ; WITH ITERATIONS FOR ACTIVITY COEF. ************
DO 10 I=1,NSWEEP
A2 = XK2 *R*TEMP/XKW/RH*(GAMA(8)/GAMA(9))**2.
!C A21 = XK21*WATER*R*TEMP
A3 = XK4*R*TEMP*(WATER/GAMA(10))**2.0
A4 = XK7*(WATER/GAMA(4))**3.0
AKW = XKW *RH*WATER*WATER
! ION CONCENTRATIONS
NH4I = WAER(3)
NO3I = WAER(4)
SO4I = WAER(2)
HSO4I = ZERO
CALL CALCPH (2.D0*SO4I + NO3I - NH4I, HI, OHI)