Skip to content

Commit

Permalink
Add masked operators, remove vanish sd grad
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Nov 13, 2021
1 parent 984b276 commit f79acc6
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 194 deletions.
2 changes: 1 addition & 1 deletion integration_tests/utils/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ face_aux_vars_edmf(FT, n_up) = (;
ρ_ae_KH = FT(0),
ρ_ae_K = FT(0),
ρ_ae_K∇ϕ = FT(0),
en = (; w = FT(0), sat = (; θ_liq_ice = FT(0), q_tot = FT(0)), unsat = (; θ_virt = FT(0))),
en = (; w = FT(0)),
up = ntuple(i -> face_aux_vars_up(FT), n_up),
massflux_h = FT(0),
massflux_qt = FT(0),
Expand Down
222 changes: 111 additions & 111 deletions integration_tests/utils/mse_tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,149 +5,149 @@
all_best_mse = OrderedCollections.OrderedDict()
#
all_best_mse["ARM_SGP"] = OrderedCollections.OrderedDict()
all_best_mse["ARM_SGP"]["qt_mean"] = 0.22260408607145526
all_best_mse["ARM_SGP"]["updraft_area"] = 335.3186790824817
all_best_mse["ARM_SGP"]["updraft_w"] = 142.01229468250628
all_best_mse["ARM_SGP"]["updraft_qt"] = 27.73127536471595
all_best_mse["ARM_SGP"]["updraft_thetal"] = 170.9811743126976
all_best_mse["ARM_SGP"]["qt_mean"] = 0.22286959111173252
all_best_mse["ARM_SGP"]["updraft_area"] = 335.3378419225924
all_best_mse["ARM_SGP"]["updraft_w"] = 141.84841956414584
all_best_mse["ARM_SGP"]["updraft_qt"] = 27.421852759548216
all_best_mse["ARM_SGP"]["updraft_thetal"] = 170.98083895236377
all_best_mse["ARM_SGP"]["u_mean"] = 1.3375737467153984e-5
all_best_mse["ARM_SGP"]["tke_mean"] = 1318.3361036369147
all_best_mse["ARM_SGP"]["temperature_mean"] = 0.00010914140178692959
all_best_mse["ARM_SGP"]["ql_mean"] = 174.89754948993047
all_best_mse["ARM_SGP"]["tke_mean"] = 1318.3154189170075
all_best_mse["ARM_SGP"]["temperature_mean"] = 0.00010925945966980263
all_best_mse["ARM_SGP"]["ql_mean"] = 174.380491712554
all_best_mse["ARM_SGP"]["qi_mean"] = "NA"
all_best_mse["ARM_SGP"]["thetal_mean"] = 0.00010058065940382863
all_best_mse["ARM_SGP"]["Hvar_mean"] = 10006.034571429314
all_best_mse["ARM_SGP"]["QTvar_mean"] = 6375.712096535838
all_best_mse["ARM_SGP"]["thetal_mean"] = 0.00010068350911718366
all_best_mse["ARM_SGP"]["Hvar_mean"] = 10272.960793535123
all_best_mse["ARM_SGP"]["QTvar_mean"] = 6518.918215318262
#
all_best_mse["Bomex"] = OrderedCollections.OrderedDict()
all_best_mse["Bomex"]["qt_mean"] = 0.11516917449744828
all_best_mse["Bomex"]["updraft_area"] = 129.4490200415662
all_best_mse["Bomex"]["updraft_w"] = 18.72095900025913
all_best_mse["Bomex"]["updraft_qt"] = 6.541537482460252
all_best_mse["Bomex"]["updraft_thetal"] = 69.46315590943559
all_best_mse["Bomex"]["v_mean"] = 66.93043387413974
all_best_mse["Bomex"]["u_mean"] = 0.32305284623455727
all_best_mse["Bomex"]["tke_mean"] = 74.3140355702218
all_best_mse["Bomex"]["temperature_mean"] = 4.591884954854846e-5
all_best_mse["Bomex"]["ql_mean"] = 9.279604539199164
all_best_mse["Bomex"]["qt_mean"] = 0.115170045283136
all_best_mse["Bomex"]["updraft_area"] = 129.45058117786624
all_best_mse["Bomex"]["updraft_w"] = 18.370154256735134
all_best_mse["Bomex"]["updraft_qt"] = 6.306330920610372
all_best_mse["Bomex"]["updraft_thetal"] = 69.45787769968938
all_best_mse["Bomex"]["v_mean"] = 66.9363180496193
all_best_mse["Bomex"]["u_mean"] = 0.3230987236309413
all_best_mse["Bomex"]["tke_mean"] = 74.29246691414228
all_best_mse["Bomex"]["temperature_mean"] = 4.591826060245829e-5
all_best_mse["Bomex"]["ql_mean"] = 8.909573333964328
all_best_mse["Bomex"]["qi_mean"] = "NA"
all_best_mse["Bomex"]["thetal_mean"] = 4.6675976163615926e-5
all_best_mse["Bomex"]["Hvar_mean"] = 3788.9644749083805
all_best_mse["Bomex"]["QTvar_mean"] = 1420.5895981298102
all_best_mse["Bomex"]["thetal_mean"] = 4.666238445127772e-5
all_best_mse["Bomex"]["Hvar_mean"] = 3822.8747397715383
all_best_mse["Bomex"]["QTvar_mean"] = 1433.09548125117
#
all_best_mse["DryBubble"] = OrderedCollections.OrderedDict()
all_best_mse["DryBubble"]["updraft_area"] = 0.0
all_best_mse["DryBubble"]["updraft_w"] = 0.0
all_best_mse["DryBubble"]["updraft_thetal"] = 0.0
all_best_mse["DryBubble"]["u_mean"] = 0.0
all_best_mse["DryBubble"]["tke_mean"] = 0.0
all_best_mse["DryBubble"]["tke_mean"] = 2.3501977062566578e-40
all_best_mse["DryBubble"]["temperature_mean"] = 0.0
all_best_mse["DryBubble"]["thetal_mean"] = 0.0
all_best_mse["DryBubble"]["Hvar_mean"] = 0.0
all_best_mse["DryBubble"]["Hvar_mean"] = 3.4874726372288367e-43
#
all_best_mse["DYCOMS_RF01"] = OrderedCollections.OrderedDict()
all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.022666124107562857
all_best_mse["DYCOMS_RF01"]["ql_mean"] = 10.29424580304818
all_best_mse["DYCOMS_RF01"]["updraft_area"] = 30.546869712149793
all_best_mse["DYCOMS_RF01"]["updraft_w"] = 4.13826148825719
all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 2.1512919048813117
all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.18689371056969
all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.0030072605135407506
all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.07908969038954133
all_best_mse["DYCOMS_RF01"]["tke_mean"] = 21.342247470474888
all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 8.099236820043368e-5
all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 8.159657479729185e-5
all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1243.0763870118528
all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 483.91315327538
all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.022666124109793833
all_best_mse["DYCOMS_RF01"]["ql_mean"] = 10.29424581361349
all_best_mse["DYCOMS_RF01"]["updraft_area"] = 30.54686971359306
all_best_mse["DYCOMS_RF01"]["updraft_w"] = 4.138261488244225
all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 2.1512919048289247
all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.18689371056938
all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.0030072605138559954
all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.07908969038701516
all_best_mse["DYCOMS_RF01"]["tke_mean"] = 21.342247465667818
all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 8.099236822693791e-5
all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 8.159657482364597e-5
all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1243.0763870159726
all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 483.91315327820047
#
all_best_mse["GABLS"] = OrderedCollections.OrderedDict()
all_best_mse["GABLS"]["updraft_thetal"] = 0.0
all_best_mse["GABLS"]["v_mean"] = 0.0
all_best_mse["GABLS"]["u_mean"] = 0.0
all_best_mse["GABLS"]["tke_mean"] = 0.0
all_best_mse["GABLS"]["temperature_mean"] = 0.0
all_best_mse["GABLS"]["thetal_mean"] = 0.0
all_best_mse["GABLS"]["Hvar_mean"] = 0.0
all_best_mse["GABLS"]["QTvar_mean"] = 0.0
all_best_mse["GABLS"]["qt_mean"] = 0.0
all_best_mse["GABLS"]["updraft_thetal"] = 4.5904248400012984e-32
all_best_mse["GABLS"]["v_mean"] = 2.9863510775758257e-26
all_best_mse["GABLS"]["u_mean"] = 3.5653565343617814e-28
all_best_mse["GABLS"]["tke_mean"] = 2.5532594247952552e-27
all_best_mse["GABLS"]["temperature_mean"] = 2.3209177991607466e-31
all_best_mse["GABLS"]["thetal_mean"] = 4.573449792507506e-32
all_best_mse["GABLS"]["Hvar_mean"] = 1.204603534644079e-25
all_best_mse["GABLS"]["QTvar_mean"] = 8.712740863504478e-27
all_best_mse["GABLS"]["qt_mean"] = 4.22896437880345e-27
#
all_best_mse["life_cycle_Tan2018"] = OrderedCollections.OrderedDict()
all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 0.0
all_best_mse["life_cycle_Tan2018"]["v_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["u_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 4.870949616027259e-12
all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 2.9408095702689907e-9
all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 4.5181722030838177e-11
all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 1.8706227853888109e-10
all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 8.921538771643461e-13
all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 5.269381089837162e-16
all_best_mse["life_cycle_Tan2018"]["v_mean"] = 1.526604656383764e-11
all_best_mse["life_cycle_Tan2018"]["u_mean"] = 5.741146289594956e-14
all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 1.7229389950750602e-11
all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 2.3695737488566606e-15
all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 2.3296538264903215e-15
all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 3.110057054481711e-5
all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 2.631979354952001e-5
#
all_best_mse["Nieuwstadt"] = OrderedCollections.OrderedDict()
all_best_mse["Nieuwstadt"]["updraft_area"] = 98.77517014009693
all_best_mse["Nieuwstadt"]["updraft_w"] = 12.495642974390554
all_best_mse["Nieuwstadt"]["updraft_area"] = 98.77517013992535
all_best_mse["Nieuwstadt"]["updraft_w"] = 12.495642974380058
all_best_mse["Nieuwstadt"]["updraft_thetal"] = 117.36697373364835
all_best_mse["Nieuwstadt"]["u_mean"] = 14.602386345210054
all_best_mse["Nieuwstadt"]["tke_mean"] = 313.2319990260036
all_best_mse["Nieuwstadt"]["temperature_mean"] = 9.723169961494773e-6
all_best_mse["Nieuwstadt"]["thetal_mean"] = 1.003536628584033e-5
all_best_mse["Nieuwstadt"]["Hvar_mean"] = 1277.7564627156673
all_best_mse["Nieuwstadt"]["u_mean"] = 14.602386345210023
all_best_mse["Nieuwstadt"]["tke_mean"] = 313.23199902597605
all_best_mse["Nieuwstadt"]["temperature_mean"] = 9.7231699614854e-6
all_best_mse["Nieuwstadt"]["thetal_mean"] = 1.0035366285832543e-5
all_best_mse["Nieuwstadt"]["Hvar_mean"] = 1277.7564627153547
#
all_best_mse["Rico"] = OrderedCollections.OrderedDict()
all_best_mse["Rico"]["qt_mean"] = 1.2348356677520063
all_best_mse["Rico"]["updraft_area"] = 477.46259802428483
all_best_mse["Rico"]["updraft_w"] = 108.123453851901
all_best_mse["Rico"]["updraft_qt"] = 12.128215447543258
all_best_mse["Rico"]["updraft_thetal"] = 133.3615630817877
all_best_mse["Rico"]["v_mean"] = 0.611195500426451
all_best_mse["Rico"]["u_mean"] = 0.6932437970565734
all_best_mse["Rico"]["tke_mean"] = 82.26809010566267
all_best_mse["Rico"]["temperature_mean"] = 0.0005721060978593456
all_best_mse["Rico"]["ql_mean"] = 63.57516679609136
all_best_mse["Rico"]["qt_mean"] = 1.2368324954575274
all_best_mse["Rico"]["updraft_area"] = 477.4540646477023
all_best_mse["Rico"]["updraft_w"] = 107.93534078910224
all_best_mse["Rico"]["updraft_qt"] = 12.106416673863404
all_best_mse["Rico"]["updraft_thetal"] = 133.36104664499535
all_best_mse["Rico"]["v_mean"] = 0.6116450245539317
all_best_mse["Rico"]["u_mean"] = 0.695169541619883
all_best_mse["Rico"]["tke_mean"] = 82.35898449028875
all_best_mse["Rico"]["temperature_mean"] = 0.0005727120565407745
all_best_mse["Rico"]["ql_mean"] = 63.507574798525205
all_best_mse["Rico"]["qi_mean"] = "NA"
all_best_mse["Rico"]["qr_mean"] = 760.7832680331468
all_best_mse["Rico"]["thetal_mean"] = 0.0005644774398077206
all_best_mse["Rico"]["Hvar_mean"] = 168760.41387534072
all_best_mse["Rico"]["QTvar_mean"] = 37889.64625145492
all_best_mse["Rico"]["qr_mean"] = 760.8475924163045
all_best_mse["Rico"]["thetal_mean"] = 0.0005650860400845547
all_best_mse["Rico"]["Hvar_mean"] = 173935.8383250262
all_best_mse["Rico"]["QTvar_mean"] = 39053.357708784606
#
all_best_mse["Soares"] = OrderedCollections.OrderedDict()
all_best_mse["Soares"]["qt_mean"] = 0.12605920198643053
all_best_mse["Soares"]["updraft_area"] = 98.11492529621005
all_best_mse["Soares"]["updraft_w"] = 11.391215812361056
all_best_mse["Soares"]["updraft_qt"] = 23.08519167889173
all_best_mse["Soares"]["updraft_thetal"] = 65.25330158630689
all_best_mse["Soares"]["u_mean"] = 96.34580613148802
all_best_mse["Soares"]["tke_mean"] = 241.30242939684976
all_best_mse["Soares"]["temperature_mean"] = 1.0979451729133836e-5
all_best_mse["Soares"]["thetal_mean"] = 1.040799929860969e-5
all_best_mse["Soares"]["Hvar_mean"] = 1124.1641081242815
all_best_mse["Soares"]["qt_mean"] = 0.12631256600224
all_best_mse["Soares"]["updraft_area"] = 96.19157396759499
all_best_mse["Soares"]["updraft_w"] = 11.391626503785842
all_best_mse["Soares"]["updraft_qt"] = 23.081037927314153
all_best_mse["Soares"]["updraft_thetal"] = 65.25330113168873
all_best_mse["Soares"]["u_mean"] = 96.34646256855906
all_best_mse["Soares"]["tke_mean"] = 241.36263695867387
all_best_mse["Soares"]["temperature_mean"] = 1.0985075298440972e-5
all_best_mse["Soares"]["thetal_mean"] = 1.0414382065295909e-5
all_best_mse["Soares"]["Hvar_mean"] = 1121.2519631022305
#
all_best_mse["TRMM_LBA"] = OrderedCollections.OrderedDict()
all_best_mse["TRMM_LBA"]["qt_mean"] = 3.9659428453652863
all_best_mse["TRMM_LBA"]["updraft_area"] = 7590.521944576046
all_best_mse["TRMM_LBA"]["updraft_w"] = 29147.73666793535
all_best_mse["TRMM_LBA"]["updraft_qt"] = 264.40322006294645
all_best_mse["TRMM_LBA"]["updraft_thetal"] = 1962.1800212491873
all_best_mse["TRMM_LBA"]["v_mean"] = 286.6313055852003
all_best_mse["TRMM_LBA"]["u_mean"] = 113.7950533341916
all_best_mse["TRMM_LBA"]["tke_mean"] = 25980.79441823836
all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0011280565198651163
all_best_mse["TRMM_LBA"]["ql_mean"] = 11329.91935493494
all_best_mse["TRMM_LBA"]["qt_mean"] = 3.9659428453653844
all_best_mse["TRMM_LBA"]["updraft_area"] = 7590.521944576031
all_best_mse["TRMM_LBA"]["updraft_w"] = 29147.7366679372
all_best_mse["TRMM_LBA"]["updraft_qt"] = 264.4032200629445
all_best_mse["TRMM_LBA"]["updraft_thetal"] = 1962.1800212491878
all_best_mse["TRMM_LBA"]["v_mean"] = 286.63130558520237
all_best_mse["TRMM_LBA"]["u_mean"] = 113.79505333419178
all_best_mse["TRMM_LBA"]["tke_mean"] = 25980.794418238478
all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0011280565198652176
all_best_mse["TRMM_LBA"]["ql_mean"] = 11329.919354934302
all_best_mse["TRMM_LBA"]["qi_mean"] = "NA"
all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.021118734698942345
all_best_mse["TRMM_LBA"]["Hvar_mean"] = 4347.874034179393
all_best_mse["TRMM_LBA"]["QTvar_mean"] = 2834.63299032306
all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.021118734698942185
all_best_mse["TRMM_LBA"]["Hvar_mean"] = 4347.874034178831
all_best_mse["TRMM_LBA"]["QTvar_mean"] = 2834.632990322874
#
all_best_mse["LES_driven_SCM"] = OrderedCollections.OrderedDict()
all_best_mse["LES_driven_SCM"]["qt_mean"] = 8.398966774944043
all_best_mse["LES_driven_SCM"]["v_mean"] = 3.2126761915549915
all_best_mse["LES_driven_SCM"]["u_mean"] = 1.1346893323826517
all_best_mse["LES_driven_SCM"]["temperature_mean"] = 0.003350514968624466
all_best_mse["LES_driven_SCM"]["ql_mean"] = 258.08240248588
all_best_mse["LES_driven_SCM"]["thetal_mean"] = 0.0036460773607307224
all_best_mse["LES_driven_SCM"]["qt_mean"] = 8.406564053715782
all_best_mse["LES_driven_SCM"]["v_mean"] = 3.2040337013230182
all_best_mse["LES_driven_SCM"]["u_mean"] = 1.1315506153907806
all_best_mse["LES_driven_SCM"]["temperature_mean"] = 0.0033521173395760517
all_best_mse["LES_driven_SCM"]["ql_mean"] = 250.69314421158143
all_best_mse["LES_driven_SCM"]["thetal_mean"] = 0.0036475573789737916
#
#################################
#################################
Expand Down
81 changes: 33 additions & 48 deletions src/Operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,54 +218,6 @@ function c∇(f::SA.SVector, grid::Grid, ::BottomBCTag, ::Extrapolate)
return (∇_staggered(f_dual⁺, grid) + ∇_staggered(f_dual⁻, grid)) / 2
end

# ∇(center data) for possibly vanishing subdomains.

"""
c∇_vanishing_subdomain
Used when the vertical gradient of a field must be computed over a conditional subdomain which may vanish
below or above the current cell. If the subdomains vanishes, a default user-defined gradient is returned.
Inputs:
- f_cut: Slice of field.
- sd_cut: Slice of subdomain volume fraction.
- default∇: Gradient used in vanishing subdomains.
"""
function c∇_vanishing_subdomain(
f_cut::SA.SVector,
sd_cut::SA.SVector,
default∇::FT,
grid::Grid,
k;
bottom = NoBCGivenError(),
top = NoBCGivenError(),
) where {FT <: Real}
if is_surface_center(grid, k)
return c∇(f_cut, grid, BottomBCTag(), bottom)
elseif is_toa_center(grid, k)
return c∇(f_cut, grid, TopBCTag(), top)
else
return c∇_vanishing_subdomain(f_cut, sd_cut, default∇, grid, InteriorTag())
end
end
function c∇_vanishing_subdomain(
f::SA.SVector,
sd::SA.SVector,
default∇::FT,
grid::Grid,
::InteriorTag,
) where {FT <: Real}
@assert length(f) == 3
@assert length(sd) == 3
if sd[1] * sd[3] FT(0)
return default∇
else
f_dual⁺ = SA.SVector(f[2], f[3])
f_dual⁻ = SA.SVector(f[1], f[2])
return (∇_staggered(f_dual⁺, grid) + ∇_staggered(f_dual⁻, grid)) / 2
end
end

#####
##### ∇(face data)
#####
Expand Down Expand Up @@ -492,3 +444,36 @@ function dual_centers(f, grid, k::CCO.PlusHalf, i_up::Int)
return SA.SVector(f[i_up, Cent(k.i - 1)], f[i_up, Cent(k.i)])
end
end


#####
##### Helpers for masked operators
#####

"""
shrink_mask(mask)
Shrinks the subdomains where `mask == 1`.
Example:
```julia
using Test
mask = Bool[0, 0, 0, 1, 1, 1, 0, 0, 1, 1]
shrunken_mask = Bool[0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
@test shrink_mask(mask) == shrunken_mask
```
"""
function shrink_mask(mask)
return map(enumerate(mask)) do (i, m)
if i == 1 || i == length(mask)
m
elseif m == 1 && mask[i - 1] == 0
m = 0
elseif m == 1 && mask[i + 1] == 0
m = 0
else
m
end
end
end
Loading

0 comments on commit f79acc6

Please sign in to comment.