From 3de41dc93e10556f198c3ba3e815edc3d250a095 Mon Sep 17 00:00:00 2001 From: costachris Date: Fri, 1 Mar 2024 00:09:33 -0800 Subject: [PATCH] Use quadratures for computing ql/qi in env, remove shrink_mask, modify microphysics to handle sat/unsat cases with placeholder values --- post_processing/mse_tables.jl | 214 +++++++++++++++++----------------- src/EDMF_Environment.jl | 59 ++++++++-- src/Operators.jl | 30 ----- src/TurbulenceConvection.jl | 1 - src/update_aux.jl | 11 -- test/Project.toml | 2 +- 6 files changed, 159 insertions(+), 158 deletions(-) diff --git a/post_processing/mse_tables.jl b/post_processing/mse_tables.jl index 53a0c76c3..81733a3f4 100644 --- a/post_processing/mse_tables.jl +++ b/post_processing/mse_tables.jl @@ -5,35 +5,35 @@ all_best_mse = OrderedCollections.OrderedDict() # all_best_mse["ARM_SGP"] = OrderedCollections.OrderedDict() -all_best_mse["ARM_SGP"]["qt_mean"] = 0.3249438933135918 -all_best_mse["ARM_SGP"]["updraft_area"] = 332.89835313424055 -all_best_mse["ARM_SGP"]["updraft_w"] = 148.34173684573412 -all_best_mse["ARM_SGP"]["updraft_qt"] = 29.397883792071443 -all_best_mse["ARM_SGP"]["updraft_thetal"] = 172.00729836613058 +all_best_mse["ARM_SGP"]["qt_mean"] = 0.17168959445650236 +all_best_mse["ARM_SGP"]["updraft_area"] = 363.0010618219729 +all_best_mse["ARM_SGP"]["updraft_w"] = 134.14809648747197 +all_best_mse["ARM_SGP"]["updraft_qt"] = 25.187760133896287 +all_best_mse["ARM_SGP"]["updraft_thetal"] = 172.02551920979832 all_best_mse["ARM_SGP"]["u_mean"] = 1.3235797273549781e-5 -all_best_mse["ARM_SGP"]["tke_mean"] = 1072.5473851587003 -all_best_mse["ARM_SGP"]["temperature_mean"] = 0.00015761936156415393 -all_best_mse["ARM_SGP"]["ql_mean"] = 197.16973635335233 +all_best_mse["ARM_SGP"]["tke_mean"] = 464.45562461458604 +all_best_mse["ARM_SGP"]["temperature_mean"] = 6.13570439254086e-5 +all_best_mse["ARM_SGP"]["ql_mean"] = 182.18637802347223 all_best_mse["ARM_SGP"]["qi_mean"] = "NA" -all_best_mse["ARM_SGP"]["thetal_mean"] = 0.00014536162455561002 -all_best_mse["ARM_SGP"]["Hvar_mean"] = 456.3977384068547 -all_best_mse["ARM_SGP"]["QTvar_mean"] = 181.73753522273043 +all_best_mse["ARM_SGP"]["thetal_mean"] = 5.115010149554121e-5 +all_best_mse["ARM_SGP"]["Hvar_mean"] = 434.2170983867993 +all_best_mse["ARM_SGP"]["QTvar_mean"] = 140.1159242230395 # all_best_mse["Bomex"] = OrderedCollections.OrderedDict() -all_best_mse["Bomex"]["qt_mean"] = 0.0887701118776594 -all_best_mse["Bomex"]["updraft_area"] = 128.2420464243159 -all_best_mse["Bomex"]["updraft_w"] = 15.08569768953008 -all_best_mse["Bomex"]["updraft_qt"] = 6.880513891750003 -all_best_mse["Bomex"]["updraft_thetal"] = 69.78074426947806 -all_best_mse["Bomex"]["v_mean"] = 64.92475960362316 -all_best_mse["Bomex"]["u_mean"] = 0.2669779126692737 -all_best_mse["Bomex"]["tke_mean"] = 70.84079586591444 -all_best_mse["Bomex"]["temperature_mean"] = 3.226333000129311e-5 -all_best_mse["Bomex"]["ql_mean"] = 7.571403770673129 +all_best_mse["Bomex"]["qt_mean"] = 0.10325582681119501 +all_best_mse["Bomex"]["updraft_area"] = 134.90172436021814 +all_best_mse["Bomex"]["updraft_w"] = 16.04083342214573 +all_best_mse["Bomex"]["updraft_qt"] = 6.738755891899509 +all_best_mse["Bomex"]["updraft_thetal"] = 69.78236153812234 +all_best_mse["Bomex"]["v_mean"] = 53.12960020848831 +all_best_mse["Bomex"]["u_mean"] = 0.14960015065276774 +all_best_mse["Bomex"]["tke_mean"] = 184.3977214531033 +all_best_mse["Bomex"]["temperature_mean"] = 3.522737497830895e-5 +all_best_mse["Bomex"]["ql_mean"] = 57.47836747184314 all_best_mse["Bomex"]["qi_mean"] = "NA" -all_best_mse["Bomex"]["thetal_mean"] = 3.284382367855378e-5 -all_best_mse["Bomex"]["Hvar_mean"] = 5443.647560918222 -all_best_mse["Bomex"]["QTvar_mean"] = 1884.4437920358887 +all_best_mse["Bomex"]["thetal_mean"] = 3.627796057126377e-5 +all_best_mse["Bomex"]["Hvar_mean"] = 4944.898751546256 +all_best_mse["Bomex"]["QTvar_mean"] = 1727.3305536153262 # all_best_mse["DryBubble"] = OrderedCollections.OrderedDict() all_best_mse["DryBubble"]["updraft_area"] = 660.6653249242596 @@ -46,35 +46,35 @@ all_best_mse["DryBubble"]["thetal_mean"] = 1.935736560538072e-5 all_best_mse["DryBubble"]["Hvar_mean"] = 121.32454049526957 # all_best_mse["DYCOMS_RF01"] = OrderedCollections.OrderedDict() -all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.03220906548543714 -all_best_mse["DYCOMS_RF01"]["ql_mean"] = 36.04203164744301 -all_best_mse["DYCOMS_RF01"]["updraft_area"] = 29.995463778008077 -all_best_mse["DYCOMS_RF01"]["updraft_w"] = 6.404674911240405 -all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 1.887485183829736 -all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.18769972957411 -all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.010331251802356093 -all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.10491783393658967 -all_best_mse["DYCOMS_RF01"]["tke_mean"] = 16.65317835530956 -all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 9.762962342287577e-5 -all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 9.66612843550311e-5 -all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1280.6560925900878 -all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 515.4887127389062 +all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.048635264439905464 +all_best_mse["DYCOMS_RF01"]["ql_mean"] = 7.854438008681841 +all_best_mse["DYCOMS_RF01"]["updraft_area"] = 28.728979098219988 +all_best_mse["DYCOMS_RF01"]["updraft_w"] = 6.47276662790384 +all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 2.271863471973675 +all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.18866985505872 +all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.034528622097038414 +all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.14670139481493008 +all_best_mse["DYCOMS_RF01"]["tke_mean"] = 29.796818139826954 +all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 4.996763013166907e-5 +all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 4.905271661722055e-5 +all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1288.5902264803187 +all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 517.2719183546004 # all_best_mse["DYCOMS_RF02"] = OrderedCollections.OrderedDict() -all_best_mse["DYCOMS_RF02"]["qt_mean"] = 0.04122480240708501 -all_best_mse["DYCOMS_RF02"]["ql_mean"] = 4.8643831227025665 -all_best_mse["DYCOMS_RF02"]["qr_mean"] = 19.17182370592474 -all_best_mse["DYCOMS_RF02"]["updraft_area"] = 28.85674621136953 -all_best_mse["DYCOMS_RF02"]["updraft_w"] = 10.99415633575334 -all_best_mse["DYCOMS_RF02"]["updraft_qt"] = 4.5709278133611475 -all_best_mse["DYCOMS_RF02"]["updraft_thetal"] = 40.544891817103185 -all_best_mse["DYCOMS_RF02"]["v_mean"] = 43.322693639290016 -all_best_mse["DYCOMS_RF02"]["u_mean"] = 19.89122141264465 -all_best_mse["DYCOMS_RF02"]["tke_mean"] = 9.983666128080767 -all_best_mse["DYCOMS_RF02"]["temperature_mean"] = 2.5383994404251278e-5 -all_best_mse["DYCOMS_RF02"]["thetal_mean"] = 2.1245448930424953e-5 -all_best_mse["DYCOMS_RF02"]["Hvar_mean"] = 1145.670048203438 -all_best_mse["DYCOMS_RF02"]["QTvar_mean"] = 246.7727841170809 +all_best_mse["DYCOMS_RF02"]["qt_mean"] = 0.06998892398939573 +all_best_mse["DYCOMS_RF02"]["ql_mean"] = 5.322721127467429 +all_best_mse["DYCOMS_RF02"]["qr_mean"] = 3.4508306892381553 +all_best_mse["DYCOMS_RF02"]["updraft_area"] = 27.586838106440545 +all_best_mse["DYCOMS_RF02"]["updraft_w"] = 9.509239002565833 +all_best_mse["DYCOMS_RF02"]["updraft_qt"] = 5.1093457461478256 +all_best_mse["DYCOMS_RF02"]["updraft_thetal"] = 40.54876628271986 +all_best_mse["DYCOMS_RF02"]["v_mean"] = 42.647743055787814 +all_best_mse["DYCOMS_RF02"]["u_mean"] = 20.128179752470476 +all_best_mse["DYCOMS_RF02"]["tke_mean"] = 25.992652398218215 +all_best_mse["DYCOMS_RF02"]["temperature_mean"] = 2.5883851178571585e-5 +all_best_mse["DYCOMS_RF02"]["thetal_mean"] = 2.7840526137223346e-5 +all_best_mse["DYCOMS_RF02"]["Hvar_mean"] = 1459.888735308496 +all_best_mse["DYCOMS_RF02"]["QTvar_mean"] = 531.5579023392397 # all_best_mse["GABLS"] = OrderedCollections.OrderedDict() all_best_mse["GABLS"]["updraft_thetal"] = 1.8156574617731757e-5 @@ -86,19 +86,19 @@ all_best_mse["GABLS"]["thetal_mean"] = 1.809165422061695e-5 all_best_mse["GABLS"]["Hvar_mean"] = 28.599876754994327 # all_best_mse["life_cycle_Tan2018"] = OrderedCollections.OrderedDict() -all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 0.002211342148825581 -all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 2.4183620201647638 -all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 0.4538809157220784 -all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 2.316164226449786 -all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 0.037961829207293026 -all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 1.9751628754807552e-5 -all_best_mse["life_cycle_Tan2018"]["v_mean"] = 0.9463446698920103 -all_best_mse["life_cycle_Tan2018"]["u_mean"] = 0.0034489980116651966 -all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 0.5945501301750371 -all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 1.3849788863319248e-6 -all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 9.535745225413999e-7 -all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 25.319980025843748 -all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 15.95996141468029 +all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 0.007859312506979445 +all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 119.70607018155788 +all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 9.41803923666502 +all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 7.059456052793843 +all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 0.013312474625543186 +all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 2.853812002806019e-6 +all_best_mse["life_cycle_Tan2018"]["v_mean"] = 36.927239740993635 +all_best_mse["life_cycle_Tan2018"]["u_mean"] = 0.07259904426358213 +all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 67.23066987074446 +all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 2.57103639899307e-6 +all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 2.3954292840499067e-6 +all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 2132.3468030134272 +all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 775.7194182621 # all_best_mse["Nieuwstadt"] = OrderedCollections.OrderedDict() all_best_mse["Nieuwstadt"]["updraft_area"] = 137.4608101440273 @@ -111,59 +111,59 @@ all_best_mse["Nieuwstadt"]["thetal_mean"] = 1.2423059346873434e-5 all_best_mse["Nieuwstadt"]["Hvar_mean"] = 705.921960513593 # all_best_mse["Rico"] = OrderedCollections.OrderedDict() -all_best_mse["Rico"]["qt_mean"] = 0.9064659006363295 -all_best_mse["Rico"]["updraft_area"] = 482.70044158785436 -all_best_mse["Rico"]["updraft_w"] = 45.498053075429894 -all_best_mse["Rico"]["updraft_qt"] = 13.84662697663288 -all_best_mse["Rico"]["updraft_thetal"] = 133.8602392650707 -all_best_mse["Rico"]["v_mean"] = 0.7035186744515325 -all_best_mse["Rico"]["u_mean"] = 0.3758440657113606 -all_best_mse["Rico"]["tke_mean"] = 159.95901602166467 -all_best_mse["Rico"]["temperature_mean"] = 0.0005345213986532864 -all_best_mse["Rico"]["ql_mean"] = 75.91230888442624 +all_best_mse["Rico"]["qt_mean"] = 2.173431247056057 +all_best_mse["Rico"]["updraft_area"] = 489.2811697713321 +all_best_mse["Rico"]["updraft_w"] = 64.2815071444918 +all_best_mse["Rico"]["updraft_qt"] = 10.166822758460526 +all_best_mse["Rico"]["updraft_thetal"] = 133.74335006812095 +all_best_mse["Rico"]["v_mean"] = 0.6417179943339246 +all_best_mse["Rico"]["u_mean"] = 0.2503588143752357 +all_best_mse["Rico"]["tke_mean"] = 816.4958534496011 +all_best_mse["Rico"]["temperature_mean"] = 0.0009023978937165731 +all_best_mse["Rico"]["ql_mean"] = 209.34962958889204 all_best_mse["Rico"]["qi_mean"] = "NA" -all_best_mse["Rico"]["qr_mean"] = 769.6607013920155 -all_best_mse["Rico"]["thetal_mean"] = 0.0005080435716498096 -all_best_mse["Rico"]["Hvar_mean"] = 9607.676706202958 -all_best_mse["Rico"]["QTvar_mean"] = 2055.204727283282 +all_best_mse["Rico"]["qr_mean"] = 768.5189317641876 +all_best_mse["Rico"]["thetal_mean"] = 0.0008587603369080845 +all_best_mse["Rico"]["Hvar_mean"] = 10893.89797561844 +all_best_mse["Rico"]["QTvar_mean"] = 2218.3077219540223 # all_best_mse["Soares"] = OrderedCollections.OrderedDict() -all_best_mse["Soares"]["qt_mean"] = 0.06666153001244673 -all_best_mse["Soares"]["updraft_area"] = 99.04180912414058 -all_best_mse["Soares"]["updraft_w"] = 13.453086887212688 -all_best_mse["Soares"]["updraft_qt"] = 23.311355423799665 -all_best_mse["Soares"]["updraft_thetal"] = 65.72107918569473 -all_best_mse["Soares"]["u_mean"] = 93.4906586659487 -all_best_mse["Soares"]["tke_mean"] = 166.18252230444327 -all_best_mse["Soares"]["temperature_mean"] = 1.5824939272090217e-5 -all_best_mse["Soares"]["thetal_mean"] = 1.4456504017765566e-5 -all_best_mse["Soares"]["Hvar_mean"] = 678.6668112986791 +all_best_mse["Soares"]["qt_mean"] = 0.06368565992937084 +all_best_mse["Soares"]["updraft_area"] = 108.89902691946324 +all_best_mse["Soares"]["updraft_w"] = 19.205406688872255 +all_best_mse["Soares"]["updraft_qt"] = 23.08226809447033 +all_best_mse["Soares"]["updraft_thetal"] = 65.72238719211907 +all_best_mse["Soares"]["u_mean"] = 90.65934758139646 +all_best_mse["Soares"]["tke_mean"] = 68.17293889921241 +all_best_mse["Soares"]["temperature_mean"] = 1.825602416941279e-5 +all_best_mse["Soares"]["thetal_mean"] = 1.66146366377818e-5 +all_best_mse["Soares"]["Hvar_mean"] = 1087.6891885426305 # all_best_mse["TRMM_LBA"] = OrderedCollections.OrderedDict() -all_best_mse["TRMM_LBA"]["qt_mean"] = 2.216203816000645 -all_best_mse["TRMM_LBA"]["updraft_area"] = 1269.437981611964 -all_best_mse["TRMM_LBA"]["updraft_w"] = 9277.433537554722 -all_best_mse["TRMM_LBA"]["updraft_qt"] = 248.82895482149198 -all_best_mse["TRMM_LBA"]["updraft_thetal"] = 541.2488343862769 -all_best_mse["TRMM_LBA"]["v_mean"] = 70.91144192395473 -all_best_mse["TRMM_LBA"]["u_mean"] = 30.333920900654412 -all_best_mse["TRMM_LBA"]["tke_mean"] = 47464.486945110846 -all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0006430194595019945 -all_best_mse["TRMM_LBA"]["ql_mean"] = 249730.64943783078 +all_best_mse["TRMM_LBA"]["qt_mean"] = 2.6381580568938077 +all_best_mse["TRMM_LBA"]["updraft_area"] = 1152.8025046749667 +all_best_mse["TRMM_LBA"]["updraft_w"] = 8329.031007641812 +all_best_mse["TRMM_LBA"]["updraft_qt"] = 231.35337207321703 +all_best_mse["TRMM_LBA"]["updraft_thetal"] = 541.1758342563537 +all_best_mse["TRMM_LBA"]["v_mean"] = 71.0780026273951 +all_best_mse["TRMM_LBA"]["u_mean"] = 30.310761750219623 +all_best_mse["TRMM_LBA"]["tke_mean"] = 50339.07191828148 +all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0006240628005195082 +all_best_mse["TRMM_LBA"]["ql_mean"] = 1.3410828336081374e6 all_best_mse["TRMM_LBA"]["qi_mean"] = "NA" all_best_mse["TRMM_LBA"]["qr_mean"] = "NA" all_best_mse["TRMM_LBA"]["qs_mean"] = "NA" -all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.0005487576776037106 -all_best_mse["TRMM_LBA"]["Hvar_mean"] = 438431.4711619283 -all_best_mse["TRMM_LBA"]["QTvar_mean"] = 5888.54959735156 +all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.0005447641785973928 +all_best_mse["TRMM_LBA"]["Hvar_mean"] = 531736.2146476542 +all_best_mse["TRMM_LBA"]["QTvar_mean"] = 7048.1396123549275 # all_best_mse["LES_driven_SCM"] = OrderedCollections.OrderedDict() -all_best_mse["LES_driven_SCM"]["qt_mean"] = 0.1357375972513249 -all_best_mse["LES_driven_SCM"]["v_mean"] = 0.3411787550007831 -all_best_mse["LES_driven_SCM"]["u_mean"] = 0.08348065032117365 -all_best_mse["LES_driven_SCM"]["temperature_mean"] = 5.572368831205179e-5 -all_best_mse["LES_driven_SCM"]["ql_mean"] = 9575.977804414708 -all_best_mse["LES_driven_SCM"]["thetal_mean"] = 4.670858154531295e-5 +all_best_mse["LES_driven_SCM"]["qt_mean"] = 0.17160646636990368 +all_best_mse["LES_driven_SCM"]["v_mean"] = 0.38430123712006004 +all_best_mse["LES_driven_SCM"]["u_mean"] = 0.09272083322474388 +all_best_mse["LES_driven_SCM"]["temperature_mean"] = 5.789715013892643e-5 +all_best_mse["LES_driven_SCM"]["ql_mean"] = 25281.658375399376 +all_best_mse["LES_driven_SCM"]["thetal_mean"] = 6.0218382190883906e-5 # ################################# ################################# diff --git a/src/EDMF_Environment.jl b/src/EDMF_Environment.jl index 7a476ea50..e423fdcbd 100644 --- a/src/EDMF_Environment.jl +++ b/src/EDMF_Environment.jl @@ -53,11 +53,20 @@ function microphysics( aux_en_sat.T[k] = TD.air_temperature(thermo_params, ts) aux_en_sat.q_tot[k] = TD.total_specific_humidity(thermo_params, ts) aux_en_sat.q_vap[k] = TD.vapor_specific_humidity(thermo_params, ts) + aux_en.q_liq[k] = TD.liquid_specific_humidity(thermo_params, ts) + aux_en.q_ice[k] = TD.ice_specific_humidity(thermo_params, ts) else aux_en.cloud_fraction[k] = 0 aux_en_unsat.θ_dry[k] = TD.dry_pottemp(thermo_params, ts) aux_en_unsat.θ_virt[k] = TD.virtual_pottemp(thermo_params, ts) aux_en_unsat.q_tot[k] = TD.total_specific_humidity(thermo_params, ts) + aux_en_sat.T[k] = aux_en.T[k] + aux_en_sat.q_vap[k] = 0 + aux_en_sat.q_tot[k] = aux_en.q_tot[k] + aux_en_sat.θ_dry[k] = aux_en.θ_dry[k] + aux_en_sat.θ_liq_ice[k] = aux_en.θ_liq_ice[k] + aux_en.q_liq[k] = 0 + aux_en.q_ice[k] = 0 end # update_env_precip_tendencies @@ -214,6 +223,8 @@ function quad_loop(en_thermo::SGSQuadrature, precip_model, rain_formation_model, outer_src[idx] += inner_src[idx] * weights[m_q] * sqpi_inv end end + + outer_src_nt = (; SH_qt = outer_src[i_SH_qt], Sqt_H = outer_src[i_Sqt_H], @@ -299,8 +310,7 @@ function microphysics( ) outer_env, outer_src = quad_loop(en_thermo, precip_model, rain_formation_model, vars, param_set, Δt) - # update environmental variables - + # update environmental cloudy/dry variables for buoyancy in TKE # update_env_precip_tendencies qt_tendency = outer_src.Sqt θ_liq_ice_tendency = outer_src.SH @@ -313,8 +323,28 @@ function microphysics( tendencies_pr.q_rai[k] += qr_tendency * aux_en.area[k] tendencies_pr.q_sno[k] += qs_tendency * aux_en.area[k] - # update cloudy/dry variables for buoyancy in TKE - aux_en.cloud_fraction[k] = outer_env.cf + + if TD.has_condensate(outer_env.ql + outer_env.qi) + aux_en.cloud_fraction[k] = outer_env.cf + aux_en.q_liq[k] = outer_env.ql + aux_en.q_ice[k] = outer_env.qi + + else + aux_en.cloud_fraction[k] = 0.0 + aux_en.q_liq[k] = 0.0 + aux_en.q_ice[k] = 0.0 + + aux_en.qt_tendency_precip_formation[k] = 0.0 + aux_en.θ_liq_ice_tendency_precip_formation[k] = 0.0 + tendencies_pr.q_rai[k] = 0.0 + tendencies_pr.q_sno[k] = 0.0 + + aux_en.Hvar_rain_dt[k] = 0.0 + aux_en.QTvar_rain_dt[k] = 0.0 + aux_en.HQTcov_rain_dt[k] = 0.0 + + end + if aux_en.cloud_fraction[k] < 1 aux_en_unsat.q_tot[k] = outer_env.qt_unsat / (1 - aux_en.cloud_fraction[k]) T_unsat = outer_env.T_unsat / (1 - aux_en.cloud_fraction[k]) @@ -333,11 +363,12 @@ function microphysics( aux_en_sat.θ_dry[k] = TD.dry_pottemp(thermo_params, ts_sat) aux_en_sat.θ_liq_ice[k] = TD.liquid_ice_pottemp(thermo_params, ts_sat) else - aux_en_sat.T[k] = 0 + aux_en_sat.T[k] = aux_en.T[k] aux_en_sat.q_vap[k] = 0 - aux_en_sat.q_tot[k] = 0 - aux_en_sat.θ_dry[k] = 0 - aux_en_sat.θ_liq_ice[k] = 0 + aux_en_sat.q_tot[k] = aux_en.q_tot[k] + aux_en_sat.θ_dry[k] = aux_en.θ_dry[k] + aux_en_sat.θ_liq_ice[k] = aux_en.θ_liq_ice[k] + end # update var/covar rain sources @@ -346,6 +377,7 @@ function microphysics( aux_en.HQTcov_rain_dt[k] = outer_src.SH_qt - outer_src.SH * aux_en.q_tot[k] + outer_src.Sqt_H - outer_src.Sqt * aux_en.θ_liq_ice[k] + else # if variance and covariance are zero do the same as in SA_mean ts = ts_env[k] @@ -377,11 +409,22 @@ function microphysics( aux_en_sat.T[k] = TD.air_temperature(thermo_params, ts) aux_en_sat.q_tot[k] = TD.total_specific_humidity(thermo_params, ts) aux_en_sat.q_vap[k] = TD.vapor_specific_humidity(thermo_params, ts) + aux_en_unsat.θ_dry[k] = TD.dry_pottemp(thermo_params, ts) + aux_en_unsat.θ_virt[k] = TD.virtual_pottemp(thermo_params, ts) + aux_en_unsat.q_tot[k] = TD.total_specific_humidity(thermo_params, ts) + else aux_en.cloud_fraction[k] = 0 aux_en_unsat.θ_dry[k] = TD.dry_pottemp(thermo_params, ts) aux_en_unsat.θ_virt[k] = TD.virtual_pottemp(thermo_params, ts) aux_en_unsat.q_tot[k] = TD.total_specific_humidity(thermo_params, ts) + + aux_en_sat.T[k] = aux_en.T[k] + aux_en_sat.q_vap[k] = 0 + aux_en_sat.q_tot[k] = aux_en.q_tot[k] + aux_en_sat.θ_dry[k] = aux_en.θ_dry[k] + aux_en_sat.θ_liq_ice[k] = aux_en.θ_liq_ice[k] + end aux_en.Hvar_rain_dt[k] = 0 diff --git a/src/Operators.jl b/src/Operators.jl index 441299937..8b1378917 100644 --- a/src/Operators.jl +++ b/src/Operators.jl @@ -1,31 +1 @@ -##### -##### Masked operators -##### -""" - shrink_mask!(f, mask) - -Shrinks the subdomains of `f` where `mask == 1`. - -Example: - -```julia -using Test -f = Int[0, 0, 0, 1, 1, 1, 0, 0, 1, 1] -mask = Bool[0, 0, 0, 1, 1, 1, 0, 0, 1, 1] -@test shrink_mask!(f, mask) == Bool[0, 0, 0, 0, 1, 0, 0, 0, 0, 1] -``` -""" -function shrink_mask!(f::AbstractArray, mask::AbstractArray) - @inbounds for (i, m) in enumerate(mask) - if i == 1 || i == length(mask) - f[i] = m - elseif m == 1 && mask[i - 1] == 0 - f[i] = 0 - elseif m == 1 && mask[i + 1] == 0 - f[i] = 0 - else - f[i] = m - end - end -end diff --git a/src/TurbulenceConvection.jl b/src/TurbulenceConvection.jl index 00b5099c9..08a145a67 100644 --- a/src/TurbulenceConvection.jl +++ b/src/TurbulenceConvection.jl @@ -131,7 +131,6 @@ include("diagnostics.jl") include("Fields.jl") include("types.jl") include("name_aliases.jl") -include("Operators.jl") include("microphysics_coupling.jl") include("turbulence_functions.jl") diff --git a/src/update_aux.jl b/src/update_aux.jl index c96068b05..cc2a5c6b4 100644 --- a/src/update_aux.jl +++ b/src/update_aux.jl @@ -157,8 +157,6 @@ function update_aux!(edmf::EDMFModel, grid::Grid, state::State, surf::SurfaceBas aux_en.T[k] = TD.air_temperature(thermo_params, ts_en) aux_en.θ_virt[k] = TD.virtual_pottemp(thermo_params, ts_en) aux_en.θ_dry[k] = TD.dry_pottemp(thermo_params, ts_en) - aux_en.q_liq[k] = TD.liquid_specific_humidity(thermo_params, ts_en) - aux_en.q_ice[k] = TD.ice_specific_humidity(thermo_params, ts_en) rho = TD.air_density(thermo_params, ts_en) aux_en.buoy[k] = buoyancy_c(param_set, ρ_c[k], rho) aux_en.RH[k] = TD.relative_humidity(thermo_params, ts_en) @@ -377,20 +375,11 @@ function update_aux!(edmf::EDMFModel, grid::Grid, state::State, surf::SurfaceBas @. ∂θv∂z = ∇c(wvec(If0(θ_virt_en))) # Second order approximation: Use dry and cloudy environmental fields. - cf = aux_en.cloud_fraction - shm = copy(cf) - pshm = parent(shm) - shrink_mask!(pshm, vec(cf)) mix_len_params = mixing_length_params(edmf) - # Since NaN*0 ≠ 0, we need to conditionally replace - # our gradients by their default values. @. ∂qt∂z_sat = ∇c(wvec(If0(aux_en_sat.q_tot))) @. ∂θl∂z_sat = ∇c(wvec(If0(aux_en_sat.θ_liq_ice))) @. ∂θv∂z_unsat = ∇c(wvec(If0(aux_en_unsat.θ_virt))) - @. ∂qt∂z_sat = ifelse(shm == 0, ∂qt∂z, ∂qt∂z_sat) - @. ∂θl∂z_sat = ifelse(shm == 0, ∂θl∂z, ∂θl∂z_sat) - @. ∂θv∂z_unsat = ifelse(shm == 0, ∂θv∂z, ∂θv∂z_unsat) @inbounds for k in real_center_indices(grid) diff --git a/test/Project.toml b/test/Project.toml index 12171cd89..3cae73ada 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -53,8 +53,8 @@ ArgParse = "1.1" ArtifactWrappers = "0.2" AtmosphericProfilesLibrary = "0.1" CLIMAParameters = "0.7" -ClimaCore = "0.10" ClimaComms = "0.5.6" +ClimaCore = "0.10" CloudMicrophysics = "0.10, 0.11, 0.12" Dierckx = "0.5" Distributions = "0.25"