@@ -373,29 +373,81 @@ function thermo_state(
373
373
return get_ts (ρ, p, θ, e_int, q_tot, q_pt)
374
374
end
375
375
376
+ function ᶜthermo_state (
377
+ thermo_params;
378
+ ρ = nothing ,
379
+ p = nothing ,
380
+ θ = nothing ,
381
+ e_int = nothing ,
382
+ q_tot = nothing ,
383
+ q_pt = nothing ,
384
+ )
385
+
386
+ get_ts (ρ, :: Nothing , θ, :: Nothing , :: Nothing , :: Nothing ) =
387
+ TD. PhaseDry_ρθ (thermo_params, ρ, θ)
388
+ get_ts (ρ, :: Nothing , θ, :: Nothing , q_tot, :: Nothing ) =
389
+ TD. PhaseEquil_ρθq (thermo_params, ρ, θ, q_tot)
390
+ get_ts (ρ, :: Nothing , θ, :: Nothing , :: Nothing , q_pt) =
391
+ TD. PhaseNonEquil_ρθq (thermo_params, ρ, θ, q_pt)
392
+ get_ts (ρ, :: Nothing , :: Nothing , e_int, :: Nothing , :: Nothing ) =
393
+ TD. PhaseDry_ρe (thermo_params, ρ, e_int)
394
+ get_ts (ρ, :: Nothing , :: Nothing , e_int, q_tot, :: Nothing ) =
395
+ TD. PhaseEquil_ρeq (
396
+ thermo_params,
397
+ ρ,
398
+ e_int,
399
+ q_tot,
400
+ 3 ,
401
+ eltype (thermo_params)(0.003 ),
402
+ )
403
+ get_ts (ρ, :: Nothing , :: Nothing , e_int, :: Nothing , q_pt) =
404
+ TD. PhaseNonEquil (thermo_params, e_int, ρ, q_pt)
405
+ get_ts (:: Nothing , p, θ, :: Nothing , :: Nothing , :: Nothing ) =
406
+ TD. PhaseDry_pθ (thermo_params, p, θ)
407
+ get_ts (:: Nothing , p, θ, :: Nothing , q_tot, :: Nothing ) =
408
+ TD. PhaseEquil_pθq (thermo_params, p, θ, q_tot)
409
+ get_ts (:: Nothing , p, θ, :: Nothing , :: Nothing , q_pt) =
410
+ TD. PhaseNonEquil_pθq (thermo_params, p, θ, q_pt)
411
+ get_ts (:: Nothing , p, :: Nothing , e_int, :: Nothing , :: Nothing ) =
412
+ TD. PhaseDry_pe (thermo_params, p, e_int)
413
+ get_ts (:: Nothing , p, :: Nothing , e_int, q_tot, :: Nothing ) =
414
+ TD. PhaseEquil_peq (thermo_params, p, e_int, q_tot)
415
+ get_ts (:: Nothing , p, :: Nothing , e_int, :: Nothing , q_pt) =
416
+ TD. PhaseNonEquil_peq (thermo_params, p, e_int, q_pt)
417
+
418
+ return @. lazy (get_ts (ρ, p, θ, e_int, q_tot, q_pt))
419
+ end
420
+
376
421
function thermo_vars (moisture_model, microphysics_model, Y_c, K, Φ)
377
- e_tot = materialize ( @. lazy (specific (Y_c. ρe_tot, Y_c. ρ) ))
378
- energy_var = (; e_int = e_tot - K - Φ)
422
+ e_tot = @. lazy (specific (Y_c. ρe_tot, Y_c. ρ))
423
+ energy_var = (; e_int = @. lazy ( e_tot - K - Φ) )
379
424
380
425
moisture_var = if moisture_model isa DryModel
381
426
(;)
382
427
elseif moisture_model isa EquilMoistModel
383
- q_tot = materialize ( @. lazy (specific (Y_c. ρq_tot, Y_c. ρ) ))
428
+ q_tot = @. lazy (specific (Y_c. ρq_tot, Y_c. ρ))
384
429
(; q_tot)
385
430
elseif moisture_model isa NonEquilMoistModel
386
- q_tot = materialize ( @. lazy (specific (Y_c. ρq_tot, Y_c. ρ) ))
387
- q_liq = materialize ( @. lazy (specific (Y_c. ρq_liq, Y_c. ρ) ))
388
- q_ice = materialize ( @. lazy (specific (Y_c. ρq_ice, Y_c. ρ) ))
389
- q_rai = materialize ( @. lazy (specific (Y_c. ρq_rai, Y_c. ρ) ))
390
- q_sno = materialize ( @. lazy (specific (Y_c. ρq_sno, Y_c. ρ) ))
431
+ q_tot = @. lazy (specific (Y_c. ρq_tot, Y_c. ρ))
432
+ q_liq = @. lazy (specific (Y_c. ρq_liq, Y_c. ρ))
433
+ q_ice = @. lazy (specific (Y_c. ρq_ice, Y_c. ρ))
434
+ q_rai = @. lazy (specific (Y_c. ρq_rai, Y_c. ρ))
435
+ q_sno = @. lazy (specific (Y_c. ρq_sno, Y_c. ρ))
391
436
q_pt_args = (q_tot, q_liq + q_rai, q_ice + q_sno)
392
437
(; q_pt = TD. PhasePartition (q_pt_args... ))
393
438
end
394
439
return (; energy_var... , moisture_var... )
395
440
end
396
441
397
442
ts_gs (thermo_params, moisture_model, microphysics_model, ᶜY, K, Φ, ρ) =
398
- thermo_state (
443
+ ᶜthermo_state (
444
+ thermo_params;
445
+ thermo_vars (moisture_model, microphysics_model, ᶜY, K, Φ)... ,
446
+ ρ,
447
+ )
448
+
449
+ ᶜts_gs (thermo_params, moisture_model, microphysics_model, ᶜY, K, Φ, ρ) =
450
+ ᶜthermo_state (
399
451
thermo_params;
400
452
thermo_vars (moisture_model, microphysics_model, ᶜY, K, Φ)... ,
401
453
ρ,
@@ -467,7 +519,7 @@ NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
467
519
# @. ᶜK += Y.c.sgs⁰.ρatke / Y.c.ρ
468
520
# TODO : We should think more about these increments before we use them.
469
521
end
470
- @. ᶜts = ts_gs (thermo_args... , Y. c, ᶜK, ᶜΦ, Y. c. ρ)
522
+ ᶜts . = ᶜts_gs (thermo_args... , Y. c, ᶜK, ᶜΦ, Y. c. ρ)
471
523
@. ᶜp = TD. air_pressure (thermo_params, ᶜts)
472
524
473
525
if turbconv_model isa PrognosticEDMFX
0 commit comments