forked from ESCOMP/CLUBB_CESM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_pdf.F90
2310 lines (2061 loc) · 95.5 KB
/
new_pdf.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
! $Id$
!===============================================================================
module new_pdf
! Description:
! The portion of CLUBB's multivariate, two-component PDF that is the
! trivariate, two-component normal PDF of vertical velocity (w), total water
! mixing ratio (rt), and liquid water potential temperature (thl).
! References:
! Griffin and Larson (2018)
!-------------------------------------------------------------------------
implicit none
public :: calc_mixture_fraction, & ! Procedure(s)
calc_setter_var_params, &
calc_responder_params, &
calc_limits_F_x_responder, &
calc_coef_wp4_implicit, &
calc_coef_wpxp2_implicit, &
calc_coefs_wp2xp_semiimpl, &
calc_coefs_wpxpyp_semiimpl
private :: sort_roots ! Procedure(s)
private
contains
!=============================================================================
!
! DESCRIPTION OF THE METHOD FOR THE VARIABLE THAT SETS THE MIXTURE FRACTION
! =========================================================================
!
! Many times, w has been used as the variable that sets the mixture fraction
! for the PDF. There are five PDF parameters that need to be calculated,
! which are mu_w_1 (the mean of w is the 1st PDF component), mu_w_2 (the mean
! of w in the 2nd PDF component), sigma_w_1 (the standard deviation of w in
! the 1st PDF component), sigma_w_2 (the standard deviation of w in the 2nd
! PDF component), and mixt_frac (the mixture fraction, which is the weight of
! the 1st PDF component). In order to solve for these five parameters, five
! equations are needed. These five equations are the equations for <w>,
! <w'^2>, and <w'^3> as found by integrating over the PDF. Additionally, two
! more equations, which involve tunable parameters F_w and zeta_w, and which
! are used to help control the spread of the PDF component means and the size
! of the PDF component standard deviations compared to each other,
! respectively, are used in this equation set. The five equations are:
!
! <w> = mixt_frac * mu_w_1 + ( 1 - mixt_frac ) * mu_w_2;
!
! <w'^2> = mixt_frac * ( ( mu_w_1 - <w> )^2 + sigma_w_1^2 )
! + ( 1 - mixt_frac ) * ( ( mu_w_2 - <w> )^2 + sigma_w_2^2 );
!
! <w'^3> = mixt_frac * ( mu_w_1 - <w> )
! * ( ( mu_w_1 - <w> )^2 + 3 * sigma_w_1^2 )
! + ( 1 - mixt_frac ) * ( mu_w_2 - <w> )
! * ( ( mu_w_2 - <w> )^2 + 3 * sigma_w_2^2 );
!
! mu_w_1 - <w> = sqrt(F_w) * ( sqrt( 1 - mixt_frac ) / sqrt( mixt_frac ) )
! * sqrt( <w'^2> );
!
! where 0 <= F_w <= 1; and
!
! 1 + zeta_w = ( mixt_frac * sigma_w_1^2 )
! / ( ( 1 - mixt_frac ) * sigma_w_2^2 );
!
! where zeta_w > -1.
!
! Following convention for w, mu_w_1 is defined to be greater than or equal to
! mu_w_2 (and is also greater than or equal to <w>, while mu_w_2 is less than
! or equal to <w>). This is relationship is found in the mu_w_1 - <w>
! equation above.
!
! The resulting equations for the five PDF parameters are:
!
! mixt_frac
! = ( 4 * F_w^3
! + 18 * F_w * ( zeta_w + 1 ) * ( 1 - F_w ) / ( zeta_w + 2 )
! + 6 * F_w^2 * ( 1 - F_w ) / ( zeta_w + 2 )
! + Skw^2
! - Skw * sqrt( 4 * F_w^3
! + 12 * F_w^2 * ( 1 - F_w )
! + 36 * F_w * ( zeta_w + 1 ) * ( 1 - F_w )^2
! / ( zeta_w + 2 )^2
! + Skw^2 ) )
! / ( 2 * F_w * ( F_w - 3 )^2 + 2 * Skw^2 );
!
! mu_w_1 = <w> + sqrt( F_w * ( ( 1 - mixt_frac ) / mixt_frac ) * <w'^2> );
!
! mu_w_2 = <w> - ( mixt_frac / ( 1 - mixt_frac ) ) * ( mu_w_1 - <w> );
!
! sigma_w_1
! = sqrt( ( ( zeta_w + 1 ) * ( 1 - F_w ) )
! / ( ( zeta_w + 2 ) * mixt_frac ) * <w'^2> ); and
!
! sigma_w_2
! = sqrt( ( mixt_frac * sigma_w_1^2 )
! / ( ( 1 - mixt_frac ) * ( 1 + zeta_w ) ) );
!
! where Skw is the skewness of w, and Skw = <w'^3> / <w'^2>^(3/2).
!
! This method works for all values of F_w (where 0 <= F_w <= 1) and zeta_w
! (where zeta_w > -1).
!
!
! Generalized equations for any variable, x, that sets the mixture fraction:
!
! A slight alteration is made to the above equations in order to have any
! variable, x, set the mixture fraction. The same five PDF parameters need to
! be calculated for the setting variable, which are mu_x_1 (the mean of x in
! the 1st PDF component), mu_x_2 (the mean of x in the 2nd PDF component),
! sigma_x_1 (the standard deviation of x in the 1st PDF component), sigma_x_2
! (the standard deviation of x in the 2nd PDF component), and mixt_frac (the
! mixture fraction). Again, five equations are needed, and they are the
! equations for <x>, <x'^2>, and <x'^3> as found by integrating over the PDF,
! as well as the equations that involve tunable parameters F_x and zeta_x.
! However, the equation for F_x is multiplied by a new variable,
! sgn( <w'x'> ), where <w'x'> is the covariance of w and x, and sgn( <w'x'> )
! is given by:
!
! sgn( <w'x'> ) = | 1, when <w'x'> >= 0;
! | -1, when <w'x'> < 0.
!
! The five equations are:
!
! <x> = mixt_frac * mu_x_1 + ( 1 - mixt_frac ) * mu_x_2;
!
! <x'^2> = mixt_frac * ( ( mu_x_1 - <x> )^2 + sigma_x_1^2 )
! + ( 1 - mixt_frac ) * ( ( mu_x_2 - <x> )^2 + sigma_x_2^2 );
!
! <x'^3> = mixt_frac * ( mu_x_1 - <x> )
! * ( ( mu_x_1 - <x> )^2 + 3 * sigma_x_1^2 )
! + ( 1 - mixt_frac ) * ( mu_x_2 - <x> )
! * ( ( mu_x_2 - <x> )^2 + 3 * sigma_x_2^2 );
!
! mu_x_1 - <x> = sqrt(F_x) * ( sqrt( 1 - mixt_frac ) / sqrt( mixt_frac ) )
! * sqrt( <x'^2> ) * sgn( <w'x'> );
!
! where 0 <= F_x <= 1; and
!
! 1 + zeta_x = ( mixt_frac * sigma_x_1^2 )
! / ( ( 1 - mixt_frac ) * sigma_x_2^2 );
!
! where zeta_x > -1.
!
! The only equations that are altered are the equation for mu_x_1 and the
! equation for mixt_frac, which now both contain a sgn( <w'x'> ). The mu_x_2
! equation is not altered, but the sign of mu_x_2 - <x> will be the opposite
! of the sign of mu_x_1 - <x>. The resulting equations for the five PDF
! parameters are:
!
! mixt_frac
! = ( 4 * F_x^3
! + 18 * F_x * ( zeta_x + 1 ) * ( 1 - F_x ) / ( zeta_x + 2 )
! + 6 * F_x^2 * ( 1 - F_x ) / ( zeta_x + 2 )
! + Skx^2
! - Skx * sgn( <w'x'> )
! * sqrt( 4 * F_x^3
! + 12 * F_x^2 * ( 1 - F_x )
! + 36 * F_x * ( zeta_x + 1 ) * ( 1 - F_x )^2
! / ( zeta_x + 2 )^2
! + Skx^2 ) )
! / ( 2 * F_x * ( F_x - 3 )^2 + 2 * Skx^2 );
!
! mu_x_1 = <x> + sqrt( F_x * ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2> )
! * sgn( <w'x'> );
!
! mu_x_2 = <x> - ( mixt_frac / ( 1 - mixt_frac ) ) * ( mu_x_1 - <x> );
!
! sigma_x_1
! = sqrt( ( ( zeta_x + 1 ) * ( 1 - F_x ) )
! / ( ( zeta_x + 2 ) * mixt_frac ) * <x'^2> ); and
!
! sigma_x_2
! = sqrt( ( mixt_frac * sigma_x_1^2 )
! / ( ( 1 - mixt_frac ) * ( 1 + zeta_x ) ) );
!
! where Skx is the skewness of x, and Skx = <x'^3> / <x'^2>^(3/2).
!
! This method works for all values of F_x (where 0 <= F_x <= 1) and zeta_x
! (where zeta_x > -1).
!
! When the generalized form is solved for w (x = w), sgn( <w'^2> ) = 1, and
! the equations are unaltered from the equations listed above for w.
!
!
! Special case:
!
! When Skx = 0 and F_x = 0, the equation for mixt_frac is undefined. The
! equation for mixture fraction in this scenario can be derived by using the
! above equation for mixture fraction and then setting Skx = 0. The resulting
! equation becomes:
!
! mixt_frac
! = ( 4 * F_x^3
! + 18 * F_x * ( zeta_x + 1 ) * ( 1 - F_x ) / ( zeta_x + 2 )
! + 6 * F_x^2 * ( 1 - F_x ) / ( zeta_x + 2 ) )
! / ( 2 * F_x * ( F_x - 3 )^2 ).
!
! All of the terms in the numerator and denominator contain a F_x, so this
! equation can be rewritten as:
!
! mixt_frac
! = ( 4 * F_x^2
! + 18 * ( zeta_x + 1 ) * ( 1 - F_x ) / ( zeta_x + 2 )
! + 6 * F_x * ( 1 - F_x ) / ( zeta_x + 2 ) )
! / ( 2 * ( F_x - 3 )^2 ).
!
! Now setting F_x = 0, the equation becomes:
!
! mixt_frac = ( 18 * ( zeta_x + 1 ) / ( zeta_x + 2 ) ) / 18;
!
! which can be rewritten as:
!
! mixt_frac = ( zeta_x + 1 ) / ( zeta_x + 2 ).
!
! When F_x = 0, Skx must have a value of 0 in order for the PDF to function
! correctly. When F_x = 0, mu_x_1 = mu_x_2. When the two PDF component means
! are equal to each other (and to the overall mean, <x>), the only value of
! Skx that can be represented is a value of 0. In the equation for mixture
! fraction, when F_x is set to 0, but | Skx | > 0, mixt_frac will either have
! a value of 0 or 1, depending on whether Skx is positive or negative,
! respectively.
!
! The value of F_x should be set as a function of Skx. The value F_x should
! go toward 0 as | Skx | (or Skx^2) goes toward 0. The value of F_x should
! go toward 1 as | Skx | (or Skx^2) goes to infinity.
!
!
! Tunable parameters:
!
! 1) F_x: This parameter controls the spread of the PDF component means. The
! range of this parameter is 0 <= F_x <= 1. When F_x = 0, the two
! PDF component means (mu_x_1 and mu_x_2) are equal to each other
! (and Skx must equal 0). All of the variance of x is accounted for
! by the PDF component standard deviations (sigma_x_1 and sigma_x_2).
! When F_x = 1, mu_x_1 and mu_x_2 are spread as far apart as they can
! be. Both PDF component standard deviations (sigma_x_1 and
! sigma_x_2) are equal to 0, and all of the variance of x is
! accounted for by the spread of the PDF component means.
!
! When sigma_x_1 = sigma_x_2 = 0, the equation for <x'^2> becomes:
!
! <x'^2> = mixt_frac * ( mu_x_1 - <x> )^2
! + ( 1 - mixt_frac ) * ( mu_x_2 - <x> )^2.
!
! Substituting the equation for <x> into the above equation for
! mu_x_2 - <x>, the above equation becomes:
!
! <x'^2> = ( mixt_frac / ( 1 - mixt_frac ) ) * ( mu_x_1 - <x> )^2;
!
! which can be rewritten as:
!
! ( mu_x_1 - <x> )^2 = ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2>.
!
! Taking the square root of the above equation:
!
! mu_x_1 - <x> = +/- ( sqrt( 1 - mixt_frac ) / sqrt(mixt_frac) )
! * sqrt( <x'^2> ).
!
! This equation can be compared to the equation for mu_x_1 - <x> in
! the set of 5 equations, which is:
!
! mu_x_1 - <x>
! = sqrt(F_x) * ( sqrt( 1 - mixt_frac ) / sqrt( mixt_frac ) )
! * sqrt( <x'^2> ) * sgn( <w'x'> ).
!
! The above equations give another example of the meaning of F_x.
! The value of sqrt(F_x) is ratio of mu_x_1 - <x> to its maximum
! value (or minimum value, depending on sgn( <w'x'> )), which is:
!
! sqrt( ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2> ) * sgn( <w'x'> ).
!
!
! 2) zeta_x: This parameter controls the size of the PDF component standard
! deviations compared to each other. The equation for zeta_x is:
!
! 1 + zeta_x = ( mixt_frac * sigma_x_1^2 )
! / ( ( 1 - mixt_frac ) * sigma_x_2^2 ).
!
! When zeta_x > 0, mixt_frac * sigma_x_1^2 increases at the
! expense of ( 1 - mixt_frac ) * sigma_x_2^2, which decreases in
! this variance-preserving equation set. When zeta_x = 0, then
! mixt_frac * sigma_x_1^2 = ( 1 - mixt_frac ) * sigma_x_2^2.
! When -1 < zeta_x < 0, ( 1 - mixt_frac ) * sigma_x_2^2 increases
! at the expense of mixt_frac * sigma_x_1^2, which decreases. As
! a result, greater values of zeta_x cause the 1st PDF component
! to become broader while the 2nd PDF component becomes narrower,
! and smaller values of zeta_x cause the 1st PDF component to
! become narrower while the 2nd PDF component becomes broader.
!
! Symmetry
!
! When zeta_x = 0, the PDF is always symmetric. In other words,
! the PDF at any positive value of Skx (for example, Skx = 2.5)
! will look like a mirror-image (reflection across the y-axis)
! of the PDF at a negative value of Skx of the same magnitude (in
! this example, Skx = -2.5). However, when zeta_x /= 0, the PDF
! loses this quality and is not symmetric.
!
! When symmetry is desired at values of zeta_x besides zeta_x = 0,
! the solution is to turn zeta_x into a function of Skx. A basic
! example of a zeta_x skewness equation that produces a symmetric
! PDF for values of zeta_x other than 0 is:
!
! zeta_x = | zeta_x_in, when Skx >= 0;
! | ( 1 / ( 1 + zeta_x_in ) ) - 1, when Skx < 0.
!
!
! Notes:
!
! When F_x = 0 (which can only happen when Skx = 0), mu_x_1 = mu_x_2, and
! mixt_frac = ( zeta_x + 1 ) / ( zeta_x + 2 ). When these equations are
! substituted into the equations for sigma_x_1 and sigma_x_2, the result is
! sigma_x_1 = sigma_x_2 = sqrt( <x'^2> ). This means that the distribution
! becomes a single Gaussian when F_x = 0 (and Skx = 0). This happens
! regardless of the value of zeta_x.
!
! The equations for the PDF component means and standard deviations can also
! be written as:
!
! mu_x_1 = <x> + sqrt( F_x * ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2> )
! * sgn( <w'x'> );
!
! mu_x_2 = <x> - sqrt( F_x * ( mixt_frac / ( 1 - mixt_frac ) ) * <x'^2> )
! * sgn( <w'x'> );
!
! sigma_x_1 = sqrt( coef_sigma_x_1_sqd * <x'^2> ); and
!
! sigma_x_2 = sqrt( coef_sigma_x_2_sqd * <x'^2> ); where
!
! coef_sigma_x_1_sqd = ( ( zeta_x + 1 ) * ( 1 - F_x ) )
! / ( ( zeta_x + 2 ) * mixt_frac ); and
!
! coef_sigma_x_2_sqd = ( 1 - F_x ) / ( ( zeta_x + 2 ) * ( 1 - mixt_frac ) ).
!
! The above equations can be substituted into an equation for a variable that
! has been derived by integrating over the PDF. Many variables like this are
! used in parts of the predictive equation set. These substitutions allow
! some terms to solved implicitly or semi-implicitly in the predictive
! equations.
!
!
! Brian Griffin; September 2017.
!
!=============================================================================
function calc_mixture_fraction( Skx, F_x, zeta_x, sgn_wpxp ) &
result( mixt_frac )
! Description:
! Calculates mixture fraction.
! References:
! Griffin and Larson (2018)
!-----------------------------------------------------------------------
use grid_class, only: &
gr ! Variable type(s)
use constants_clubb, only: &
thirty_six, & ! Constant(s)
eighteen, &
twelve, &
six, &
four, &
three, &
two, &
one, &
zero, &
fstderr
use clubb_precision, only: &
core_rknd ! Variable(s)
implicit none
! Input Variables
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
Skx, & ! Skewness of x [-]
F_x, & ! Parameter for the spread of the PDF component means of x [-]
zeta_x, & ! Parameter for the PDF component variances of x [-]
sgn_wpxp ! Sign of the covariance of w and x [-]
! Return Variable
real( kind = core_rknd ), dimension(gr%nz) :: &
mixt_frac ! Mixture fraction [-]
! Local Variable
! Flag that turns off when conditions aren't right for calculating mixt_frac
logical, dimension(gr%nz) :: &
l_calc_mixt_frac
! Initialize l_calc_mixt_frac
l_calc_mixt_frac = .true.
! Calculate mixture fraction, which is the weight of the 1st PDF component.
! The 2nd PDF component has a weight of 1 - mixt_frac.
where ( F_x > zero )
mixt_frac &
= ( four * F_x**3 &
+ eighteen * F_x &
* ( zeta_x + one ) * ( one - F_x ) / ( zeta_x + two ) &
+ six * F_x**2 * ( one - F_x ) / ( zeta_x + two ) &
+ Skx**2 &
- Skx * sgn_wpxp * sqrt( four * F_x**3 &
+ twelve * F_x**2 * ( one - F_x ) &
+ thirty_six * F_x &
* ( zeta_x + one ) * ( one - F_x )**2 &
/ ( zeta_x + two )**2 &
+ Skx**2 ) ) &
/ ( two * F_x * ( F_x - three )**2 + two * Skx**2 )
elsewhere ! F_x = 0
where ( abs( Skx ) > zero )
l_calc_mixt_frac = .false.
elsewhere ! Skx = 0
mixt_frac = ( zeta_x + one ) / ( zeta_x + two )
endwhere ! | Skx | > 0
endwhere ! F_x > 0
if ( any( .not. l_calc_mixt_frac ) ) then
write(fstderr,*) "Mixture fraction cannot be calculated."
write(fstderr,*) "The value of F_x must be greater than 0 when " &
// "| Skx | > 0."
stop
endif ! any( .not. l_valid_mixt_frac )
return
end function calc_mixture_fraction
!=============================================================================
subroutine calc_setter_var_params( xm, xp2, Skx, sgn_wpxp, & ! In
F_x, zeta_x, & ! In
mu_x_1, mu_x_2, sigma_x_1, & ! Out
sigma_x_2, mixt_frac, & ! Out
coef_sigma_x_1_sqd, & ! Out
coef_sigma_x_2_sqd ) ! Out
! Description:
! Calculates the PDF component means, the PDF component standard deviations,
! and the mixture fraction for the variable that sets the PDF.
! References:
! Griffin and Larson (2018)
!-----------------------------------------------------------------------
use grid_class, only: &
gr ! Variable type(s)
use constants_clubb, only: &
two, & ! Variable(s)
one
use clubb_precision, only: &
core_rknd ! Variable(s)
implicit none
! Input Variables
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
xm, & ! Mean of x (overall) [units vary]
xp2, & ! Variance of x (overall) [(units vary)^2]
Skx, & ! Skewness of x [-]
sgn_wpxp, & ! Sign of the covariance of w and x (overall) [-]
F_x, & ! Parameter for the spread of the PDF component means of x [-]
zeta_x ! Parameter for the PDF component variances of x [-]
! Output Variables
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
mu_x_1, & ! Mean of x (1st PDF component) [units vary]
mu_x_2, & ! Mean of x (2nd PDF component) [units vary]
sigma_x_1, & ! Standard deviation of x (1st PDF component) [units vary]
sigma_x_2, & ! Standard deviation of x (2nd PDF component) [units vary]
mixt_frac ! Mixture fraction [-]
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
coef_sigma_x_1_sqd, & ! sigma_x_1^2 = coef_sigma_x_1_sqd * <x'^2> [-]
coef_sigma_x_2_sqd ! sigma_x_2^2 = coef_sigma_x_2_sqd * <x'^2> [-]
! Calculate the mixture fraction.
mixt_frac = calc_mixture_fraction( Skx, F_x, zeta_x, sgn_wpxp )
! Calculate the mean of x in the 1st PDF component.
mu_x_1 = xm + sqrt( F_x * ( ( one - mixt_frac ) / mixt_frac ) * xp2 ) &
* sgn_wpxp
! Calculate the mean of x in the 2nd PDF component.
mu_x_2 = xm - ( mixt_frac / ( one - mixt_frac ) ) * ( mu_x_1 - xm )
! Calculate the standard deviation of x in the 1st PDF component.
! sigma_x_1 = sqrt( ( ( zeta_x + 1 ) * ( 1 - F_x ) )
! / ( ( zeta_x + 2 ) * mixt_frac ) * <x'^2> )
coef_sigma_x_1_sqd = ( ( zeta_x + one ) * ( one - F_x ) ) &
/ ( ( zeta_x + two ) * mixt_frac )
sigma_x_1 = sqrt( coef_sigma_x_1_sqd * xp2 )
! Calculate the standard deviation of x in the 2nd PDF component.
! sigma_x_2 = sqrt( ( mixt_frac * sigma_x_1^2 )
! / ( ( 1 - mixt_frac ) * ( 1 + zeta_x ) ) )
! = sqrt( ( 1 - F_x )
! / ( ( zeta_x + 2 ) * ( 1 - mixt_frac ) ) * <x'^2> )
coef_sigma_x_2_sqd = ( one - F_x ) &
/ ( ( zeta_x + two ) * ( one - mixt_frac ) )
sigma_x_2 = sqrt( coef_sigma_x_2_sqd * xp2 )
return
end subroutine calc_setter_var_params
!=============================================================================
!
! DESCRIPTION OF THE METHOD FOR EACH RESPONDING VARIABLE
! ======================================================
!
! In order to find equations for the four PDF parameters for each responding
! variable, which are mu_x_1, mu_x_2, sigma_x_1, and sigma_x_2 (where x stands
! for a responding variable here), four equations are needed. These four
! equations are the equations for <x>, <x'^2>, and <x'^3> as found by
! integrating over the PDF. Additionally, one more equation, which involves
! a tunable parameter F_x, and which is used to help control the spread of the
! PDF component means, is used in this equation set. The four equations are:
!
! <x> = mixt_frac * mu_x_1 + ( 1 - mixt_frac ) * mu_x_2;
!
! <x'^2> = mixt_frac * ( ( mu_x_1 - <x> )^2 + sigma_x_1^2 )
! + ( 1 - mixt_frac ) * ( ( mu_x_2 - <x> )^2 + sigma_x_2^2 );
!
! <x'^3> = mixt_frac * ( mu_x_1 - <x> )
! * ( ( mu_x_1 - <x> )^2 + 3 * sigma_x_1^2 )
! + ( 1 - mixt_frac ) * ( mu_x_2 - <x> )
! * ( ( mu_x_2 - <x> )^2 + 3 * sigma_x_2^2 ); and
!
! mu_x_1 - <x> = sqrt(F_x) * ( sqrt( 1 - mixt_frac ) / sqrt( mixt_frac ) )
! * sqrt( <x'^2> ) * sgn( <w'x'> );
!
! where 0 <= F_x <= 1, and where sgn( <w'x'> ) is given by:
!
! sgn( <w'x'> ) = | 1, when <w'x'> >= 0;
! | -1, when <w'x'> < 0.
!
! The resulting equations for the four PDF parameters are:
!
! mu_x_1 = <x> + sqrt( F_x * ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2> )
! * sgn( <w'x'> );
!
! mu_x_2 = <x> - ( mixt_frac / ( 1 - mixt_frac ) ) * ( mu_x_1 - <x> );
!
! sigma_x_1^2
! = ( ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! - ( 1 + mixt_frac ) * F_x^1.5 + 3 * mixt_frac * sqrt( F_x ) )
! / ( 3 * mixt_frac * sqrt( F_x ) ) )
! * <x'^2>; and
!
! sigma_x_2^2 = ( ( 1 - F_x ) / ( 1 - mixt_frac ) ) * <x'^2>
! - ( mixt_frac / ( 1 - mixt_frac ) ) * sigma_x_1^2;
!
! where Skx is the skewness of x, and Skx = <x'^3> / <x'^2>^(3/2).
!
!
! Special case:
!
! When Skx = 0 and F_x = 0, the equations for sigma_x_1^2 and sigma_x_2^2 are
! both undefined. The equations for sigma_x_1^2 and sigma_x_2^2 in this
! scenario can be derived by using the above equations for sigma_x_1^2 and
! sigma_x_2^2 and then setting Skx = 0. The resulting equation for
! sigma_x_1^2 becomes:
!
! sigma_x_1^2
! = ( ( - ( 1 + mixt_frac ) * F_x^1.5 + 3 * mixt_frac * sqrt( F_x ) )
! / ( 3 * mixt_frac * sqrt( F_x ) ) )
! * <x'^2>.
!
! All of the terms in the numerator and denominator contain a sqrt( F_x ),
! so this equation can be rewritten as:
!
! sigma_x_1^2
! = ( ( - ( 1 + mixt_frac ) * F_x + 3 * mixt_frac ) / ( 3 * mixt_frac ) )
! * <x'^2>.
!
! Now setting F_x = 0, the equation becomes:
!
! sigma_x_1^2 = ( ( 3 * mixt_frac ) / ( 3 * mixt_frac ) ) * <x'^2>;
!
! which can be rewritten as:
!
! sigma_x_1^2 = <x'^2>.
!
! Substituting the equation for sigma_x_1^2 into the equation for sigma_x_2^2,
! and also setting F_x = 0, the equation for sigma_x_2^2 becomes:
!
! sigma_x_2^2 = ( 1 / ( 1 - mixt_frac ) ) * <x'^2>
! - ( mixt_frac / ( 1 - mixt_frac ) ) * <x'^2>;
!
! which can be rewritten as:
!
! sigma_x_2^2
! = ( ( 1 / ( 1 - mixt_frac ) ) - ( mixt_frac / ( 1 - mixt_frac ) ) )
! * <x'^2>.
!
! This equation becomes:
!
! sigma_x_2^2 = ( ( 1 - mixt_frac ) / ( 1 - mixt_frac ) ) * <x'^2>;
!
! which can be rewritten as:
!
! sigma_x_2^2 = <x'^2>.
!
! When F_x = 0, Skx must have a value of 0 in order for the PDF to function
! correctly. When F_x = 0, mu_x_1 = mu_x_2. When the two PDF component means
! are equal to each other (and to the overall mean, <x>), the only value of
! Skx that can be represented is a value of 0. The equations that place
! limits on F_x for a responding variable (below) calculate the minimum
! allowable value of F_x to be greater than 0 when | Skx | > 0.
!
! The value of F_x should be set as a function of Skx. The value F_x should
! go toward 0 as | Skx | (or Skx^2) goes toward 0. The value of F_x should
! go toward 1 as | Skx | (or Skx^2) goes to infinity. However, the value of
! F_x must also be between the minimum and maximum allowable values of F_x for
! a responding variable (below).
!
!
! Tunable parameter:
!
! F_x: This parameter controls the spread of the PDF component means. The
! range of this parameter is 0 <= F_x <= 1. When F_x = 0, the two PDF
! component means (mu_x_1 and mu_x_2) are equal to each other (and Skx
! must equal 0). All of the variance of x is accounted for by the PDF
! component standard deviations (sigma_x_1 and sigma_x_2). When
! F_x = 1, mu_x_1 and mu_x_2 are spread as far apart as they can be.
! Both PDF component standard deviations (sigma_x_1 and sigma_x_2) are
! equal to 0, and all of the variance of x is accounted for by the
! spread of the PDF component means.
!
!
! Limits on F_x:
!
! Since the PDF parameters for this variable need to work with the mixture
! fraction that has been provided by the setting variable, the method does
! not work for all values of F_x and Skx. However, the limits of Skx and F_x
! can always be calculated. The limits are based on keeping the values of
! sigma_x_1 and sigma_x_2 greater than or equal to 0. The equation for
! keeping the value of sigma_x_1 greater than or equal to 0 is:
!
! - ( 1 + mixt_frac ) * sqrt( F_x )^3 + 3 * mixt_frac * sqrt( F_x )
! + sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> ) >= 0.
!
! The roots of sqrt( F_x ) can be solved by an equation of the form:
!
! A * sqrt( F_x )^3 + B * sqrt( F_x )^2 + C * sqrt( F_x ) + D = 0;
!
! where:
!
! A = - ( 1 + mixt_frac );
! B = 0;
! C = 3 * mixt_frac; and
! D = sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> ).
!
! The equation for keeping the value of sigma_x_2 greater than or equal to 0
! is:
!
! - ( 2 - mixt_frac ) * sqrt( F_x )^3 + 3 * ( 1 - mixt_frac ) * sqrt( F_x )
! - sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> ) >= 0.
!
! The roots of sqrt( F_x ) can be solved by an equation of the form:
!
! A * sqrt( F_x )^3 + B * sqrt( F_x )^2 + C * sqrt( F_x ) + D = 0;
!
! where:
!
! A = - ( 2 - mixt_frac );
! B = 0;
! C = 3 * ( 1 - mixt_frac ); and
! D = - sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> ).
!
! After careful analysis of the above equations, the following properties
! emerge:
!
! When Skx * sgn( <w'x'> ) >= 0,
! Skx^2 < 4 * ( 1 - mixt_frac )^2 / ( mixt_frac * ( 2 - mixt_frac ) )
! is required; and
! when Skx * sgn( <w'x'> ) < 0,
! Skx^2 < 4 * mixt_frac^2 / ( 1 - mixt_frac^2 ) is required.
!
! Whenever Skx^2 exceeds these limits, Skx must be limited (preserving its
! sign) in order to have any value of F_x that will work in the equation set.
!
! When Skx is found to be within the above limits (or after it has been
! limited to fall within its limits), the range of valid values of F_x can be
! found according to the following:
!
! When Skx * sgn( <w'x'> ) >= 0:
!
! When 4 * mixt_frac^2 / ( 1 - mixt_frac^2 ) < Skx^2
! < 4 * ( 1 - mixt_frac )^2 / ( mixt_frac * ( 2 - mixt_frac ) ):
!
! Minimum sqrt( F_x ): 2nd root (middle-valued root; also smallest
! positive) of the second equation (sigma_x_2
! based).
!
! Maximum sqrt( F_x ): Minimum of the largest root of the second
! equation (sigma_x_2 based) and the only* root
! of the first equation (sigma_x_1 based).
!
! When Skx^2 <= 4 * mixt_frac^2 / ( 1 - mixt_frac^2 ):
!
! Minimum sqrt( F_x ): 2nd root (middle-valued root; also smallest
! positive) of the second equation (sigma_x_2
! based).
!
! Maximum sqrt( F_x ): Minimum of the largest root of the second
! equation (sigma_x_2 based) and the largest
! root of the first equation (sigma_x_1 based).
!
! When Skx * sgn( <w'x'> ) < 0:
!
! When 4 * ( 1 - mixt_frac )^2 / ( mixt_frac * ( 2 - mixt_frac ) )
! < Skx^2 < 4 * mixt_frac^2 / ( 1 - mixt_frac^2 ):
!
! Minimum sqrt( F_x ): 2nd root (middle-valued root; also smallest
! positive) of the first equation (sigma_x_1
! based).
!
! Maximum sqrt( F_x ): Minimum of the largest root of the first
! equation (sigma_x_1 based) and the only* root
! of the second equation (sigma_x_2 based).
!
! When Skx^2
! <= 4 * ( 1 - mixt_frac )^2 / ( mixt_frac * ( 2 - mixt_frac ) ):
!
! Minimum sqrt( F_x ): 2nd root (middle-valued root; also smallest
! positive) of the first equation (sigma_x_1
! based).
!
! Maximum sqrt( F_x ): Minimum of the largest root of the first
! equation (sigma_x_1 based) and the largest
! root of the second equation (sigma_x_2
! based).
!
! Here, "only* root" means the the only root that isn't a complex root.
!
! The value of sqrt( F_x ) is also limited with a minimum of 0 and a maximum
! of 1. The minimum and maximum allowable values of F_x are found by taking
! the square of the minimum and maximum allowable values of sqrt( F_x ),
! respectively.
!
!
! Notes:
!
! When F_x = 0 (which can only happen when Skx = 0), mu_x_1 = mu_x_2, and
! sigma_x_1 = sigma_x_2 = sqrt( <x'^2> ). This means that the distribution
! becomes a single Gaussian when F_x = 0 (and Skx = 0).
!
! The equations for the PDF component means and standard deviations can also
! be written as:
!
! mu_x_1 = <x> + sqrt( F_x * ( ( 1 - mixt_frac ) / mixt_frac ) * <x'^2> )
! * sgn( <w'x'> );
!
! mu_x_2 = <x> - sqrt( F_x * ( mixt_frac / ( 1 - mixt_frac ) ) * <x'^2> )
! * sgn( <w'x'> );
!
! sigma_x_1 = sqrt( coef_sigma_x_1_sqd * <x'^2> ); and
!
! sigma_x_2 = sqrt( coef_sigma_x_2_sqd * <x'^2> ); where
!
! coef_sigma_x_1_sqd
! = ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! - ( 1 + mixt_frac ) * F_x^1.5 + 3 * mixt_frac * sqrt( F_x ) )
! / ( 3 * mixt_frac * sqrt( F_x ) )
! = sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! / ( 3 * mixt_frac * sqrt( F_x ) )
! - ( 1 + mixt_frac ) * F_x / ( 3 * mixt_frac )
! + 1; and
!
! coef_sigma_x_2_sqd
! = ( 1 - F_x ) / ( 1 - mixt_frac )
! - mixt_frac / ( 1 - mixt_frac )
! * ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! / ( 3 * mixt_frac * sqrt( F_x ) )
! - ( 1 + mixt_frac ) * F_x / ( 3 * mixt_frac )
! + 1 )
! = ( ( 1 - F_x ) - mixt_frac * coef_sigma_x_1_sqd ) / ( 1 - mixt_frac ).
!
! The above equations can be substituted into an equation for a variable that
! has been derived by integrating over the PDF. Many variables like this are
! used in parts of the predictive equation set. These substitutions allow
! some terms to solved implicitly or semi-implicitly in the predictive
! equations.
!
!
! Brian Griffin; September 2017.
!
!=============================================================================
subroutine calc_responder_params( xm, xp2, Skx, sgn_wpxp, & ! In
F_x, mixt_frac, & ! In
mu_x_1, mu_x_2, & ! Out
sigma_x_1_sqd, sigma_x_2_sqd, & ! Out
coef_sigma_x_1_sqd, & ! Out
coef_sigma_x_2_sqd ) ! Out
! Description:
! Calculates the PDF component means and the PDF component standard
! deviations for a responding variable (a variable that is not used to set
! the mixture fraction).
! References:
! Griffin and Larson (2018)
!-----------------------------------------------------------------------
use grid_class, only: &
gr ! Variable type(s)
use constants_clubb, only: &
three, & ! Variable(s)
one, &
zero
use clubb_precision, only: &
core_rknd ! Variable(s)
implicit none
! Input Variables
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
xm, & ! Mean of x (overall) [units vary]
xp2, & ! Variance of x (overall) [(units vary)^2]
Skx, & ! Skewness of x [-]
sgn_wpxp, & ! Sign of the covariance of w and x (overall) [-]
F_x, & ! Parameter for the spread of the PDF component means of x [-]
mixt_frac ! Mixture fraction [-]
! Output Variables
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
mu_x_1, & ! Mean of x (1st PDF component) [units vary]
mu_x_2, & ! Mean of x (2nd PDF component) [units vary]
sigma_x_1_sqd, & ! Variance of x (1st PDF component) [(units vary)^2]
sigma_x_2_sqd ! Variance of x (2nd PDF component) [(units vary)^2]
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
coef_sigma_x_1_sqd, & ! sigma_x_1^2 = coef_sigma_x_1_sqd * <x'^2> [-]
coef_sigma_x_2_sqd ! sigma_x_2^2 = coef_sigma_x_2_sqd * <x'^2> [-]
where ( F_x > zero )
! Calculate the mean of x in the 1st PDF component.
mu_x_1 = xm + sqrt( F_x * ( ( one - mixt_frac ) / mixt_frac ) * xp2 ) &
* sgn_wpxp
! Calculate the mean of x in the 2nd PDF component.
mu_x_2 = xm - ( mixt_frac / ( one - mixt_frac ) ) * ( mu_x_1 - xm )
! Calculate the variance of x in the 1st PDF component.
! sigma_x_1^2
! = ( ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! - ( 1 + mixt_frac ) * F_x^1.5 + 3 * mixt_frac * sqrt( F_x ) )
! / ( 3 * mixt_frac * sqrt( F_x ) ) ) * <x'^2>
! = ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! / ( 3 * mixt_frac * sqrt( F_x ) )
! - ( 1 + mixt_frac ) * F_x / ( 3 * mixt_frac )
! + 1 ) * <x'^2>
coef_sigma_x_1_sqd &
= sqrt( mixt_frac * ( one - mixt_frac ) ) * Skx * sgn_wpxp &
/ ( three * mixt_frac * sqrt( F_x ) ) &
- ( one + mixt_frac ) * F_x / ( three * mixt_frac ) &
+ one
sigma_x_1_sqd = coef_sigma_x_1_sqd * xp2
! Calculate the variance of x in the 2nd PDF component.
! sigma_x_2^2
! = ( ( 1 - F_x ) / ( 1 - mixt_frac )
! - mixt_frac / ( 1 - mixt_frac )
! * ( sqrt( mixt_frac * ( 1 - mixt_frac ) ) * Skx * sgn( <w'x'> )
! / ( 3 * mixt_frac * sqrt( F_x ) )
! - ( 1 + mixt_frac ) * F_x / ( 3 * mixt_frac )
! + 1 ) ) * <x'^2>
! = ( ( ( 1 - F_x ) - mixt_frac * coef_sigma_x_1_sqd )
! / ( 1 - mixt_frac ) ) * <x'^2>
coef_sigma_x_2_sqd &
= ( ( one - F_x ) - mixt_frac * coef_sigma_x_1_sqd ) &
/ ( one - mixt_frac )
sigma_x_2_sqd = coef_sigma_x_2_sqd * xp2
elsewhere ! F_x = 0
! When F_x has a value of 0, the PDF becomes a single Gaussian. This
! only works when Skx = 0. However, when Skx /= 0, the value of min_F_x
! is greater than 0, preventing a problem where F_x = 0 but | Skx | > 0.
mu_x_1 = xm
mu_x_2 = xm
sigma_x_1_sqd = xp2
sigma_x_2_sqd = xp2
coef_sigma_x_1_sqd = one
coef_sigma_x_2_sqd = one
endwhere ! F_x > 0
return
end subroutine calc_responder_params
!=============================================================================
subroutine calc_limits_F_x_responder( mixt_frac, Skx, sgn_wpxp, & ! In
max_Skx2_pos_Skx_sgn_wpxp, & ! In
max_Skx2_neg_Skx_sgn_wpxp, & ! In
min_F_x, max_F_x ) ! Out
! Description:
! Calculates the minimum and maximum allowable values for F_x for a
! responding variable.
! References:
!-----------------------------------------------------------------------
use grid_class, only: &
gr ! Variable type(s)
use constants_clubb, only: &
three, & ! Variable(s)
two, &
one, &
zero
use calc_roots, only: &
cubic_solve ! Procedure(s)
use clubb_precision, only: &
core_rknd ! Variable(s)
implicit none
! Input Variables
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
mixt_frac, & ! Mixture fraction [-]
Skx, & ! Skewness of x [-]
sgn_wpxp ! Sign of covariance of w and x [-]
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
max_Skx2_pos_Skx_sgn_wpxp, & ! Maximum Skx^2 when Skx*sgn(<w'x'>) >= 0 [-]
max_Skx2_neg_Skx_sgn_wpxp ! Maximum Skx^2 when Skx*sgn(<w'x'>) < 0 [-]
! Output Variables
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
min_F_x, & ! Minimum allowable value of F_x [-]
max_F_x ! Maximum allowable value of F_x [-]
! Local Variables
real( kind = core_rknd ), dimension(gr%nz) :: &
coef_A_1, & ! Coef. A in Ax^3 + Bx^2 + Cx + D = 0 (1st PDF comp. lim.) [-]
coef_B_1, & ! Coef. B in Ax^3 + Bx^2 + Cx + D = 0 (1st PDF comp. lim.) [-]
coef_C_1, & ! Coef. C in Ax^3 + Bx^2 + Cx + D = 0 (1st PDF comp. lim.) [-]
coef_D_1, & ! Coef. D in Ax^3 + Bx^2 + Cx + D = 0 (1st PDF comp. lim.) [-]
coef_A_2, & ! Coef. A in Ax^3 + Bx^2 + Cx + D = 0 (2nd PDF comp. lim.) [-]
coef_B_2, & ! Coef. B in Ax^3 + Bx^2 + Cx + D = 0 (2nd PDF comp. lim.) [-]
coef_C_2, & ! Coef. C in Ax^3 + Bx^2 + Cx + D = 0 (2nd PDF comp. lim.) [-]
coef_D_2 ! Coef. D in Ax^3 + Bx^2 + Cx + D = 0 (2nd PDF comp. lim.) [-]
complex( kind = core_rknd ), dimension(gr%nz,3) :: &
sqrt_F_x_roots_1, & ! Roots of sqrt(F_x) for the sigma_x_1 term [-]
sqrt_F_x_roots_2 ! Roots of sqrt(F_x) for the sigma_x_2 term [-]
real( kind = core_rknd ), dimension(gr%nz,3) :: &
sqrt_F_x_roots_1_sorted, & ! Sorted roots of sqrt(F_x): sigma_x_1 term [-]
sqrt_F_x_roots_2_sorted ! Sorted roots of sqrt(F_x): sigma_x_2 term [-]
real( kind = core_rknd ), dimension(gr%nz) :: &
min_sqrt_F_x, & ! Minimum allowable value of sqrt(F_x) [-]
max_sqrt_F_x ! Maximum allowable value of sqrt(F_x) [-]
! Set up the coefficients in the equation for the limit of sqrt(F_x) based
! on the 1st PDF component standard deviation (sigma_x_1) being greater than
! or equal to 0. This equation has the form:
! A * sqrt(F_x)^3 + B * sqrt(F_x)^2 + C * sqrt(F_x) + D = 0.
coef_A_1 = -( one + mixt_frac )
coef_B_1 = zero
coef_C_1 = three * mixt_frac
coef_D_1 = sqrt( mixt_frac * ( one - mixt_frac ) ) * Skx * sgn_wpxp
! Solve for the roots (values of sqrt(F_x)) that satisfy the above equation.
sqrt_F_x_roots_1 &