@@ -331,11 +331,11 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
331
331
# norm_sqr(C123(ᶜuₕ) + C123(ᶜinterp(ᶠw))) / 2 =
332
332
# ACT12(ᶜuₕ) * ᶜuₕ / 2 + ACT3(ᶜinterp(ᶠw)) * ᶜinterp(ᶠw) / 2
333
333
# ∂(ᶜK)/∂(ᶠw) = ACT3(ᶜinterp(ᶠw)) * ᶜinterp_matrix()
334
- @. ∂ᶜK∂ᶠw = DiagonalMatrixRow (adjoint (CT3 (ᶜinterp (ᶠw)))) ⋅ ᶜinterp_matrix ()
334
+ @. ∂ᶜK∂ᶠw = DiagonalMatrixRow (adjoint (CT3 (ᶜinterp (ᶠw)))) * ᶜinterp_matrix ()
335
335
336
336
# ᶜρₜ = -ᶜdivᵥ(ᶠinterp(ᶜρ) * ᶠw)
337
337
# ∂(ᶜρₜ)/∂(ᶠw) = -ᶜdivᵥ_matrix() * ᶠinterp(ᶜρ) * ᶠg³³
338
- @. ∂ᶜρₜ∂ᶠ𝕄 = - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (ᶠinterp (ᶜρ) * g³³ (ᶠgⁱʲ))
338
+ @. ∂ᶜρₜ∂ᶠ𝕄 = - (ᶜdivᵥ_matrix ()) * DiagonalMatrixRow (ᶠinterp (ᶜρ) * g³³ (ᶠgⁱʲ))
339
339
340
340
if :ρθ in propertynames (Y. c)
341
341
ᶜρθ = Y. c. ρθ
@@ -349,14 +349,14 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
349
349
# ᶜρθₜ = -ᶜdivᵥ(ᶠinterp(ᶜρθ) * ᶠw)
350
350
# ∂(ᶜρθₜ)/∂(ᶠw) = -ᶜdivᵥ_matrix() * ᶠinterp(ᶜρθ) * ᶠg³³
351
351
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
352
- - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (ᶠinterp (ᶜρθ) * g³³ (ᶠgⁱʲ))
352
+ - (ᶜdivᵥ_matrix ()) * DiagonalMatrixRow (ᶠinterp (ᶜρθ) * g³³ (ᶠgⁱʲ))
353
353
else
354
354
# ᶜρθₜ = -ᶜdivᵥ(ᶠinterp(ᶜρ) * ᶠupwind_product(ᶠw, ᶜρθ / ᶜρ))
355
355
# ∂(ᶜρθₜ)/∂(ᶠw) =
356
356
# -ᶜdivᵥ_matrix() * ᶠinterp(ᶜρ) *
357
357
# ∂(ᶠupwind_product(ᶠw, ᶜρθ / ᶜρ))/∂(ᶠw)
358
358
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
359
- - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
359
+ - (ᶜdivᵥ_matrix ()) * DiagonalMatrixRow (
360
360
ᶠinterp (ᶜρ) *
361
361
vec_data (ᶠno_flux (ᶠupwind_product (ᶠw + εw, ᶜρθ / ᶜρ))) /
362
362
vec_data (CT3 (ᶠw + εw)) * g³³ (ᶠgⁱʲ),
@@ -381,10 +381,12 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
381
381
# ∂(ᶜp)/∂(ᶠw) = ∂(ᶜp)/∂(ᶜK) * ∂(ᶜK)/∂(ᶠw)
382
382
# ∂(ᶜp)/∂(ᶜK) = -ᶜρ * R_d / cv_d
383
383
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
384
- - (ᶜdivᵥ_matrix ()) ⋅ (
384
+ - (ᶜdivᵥ_matrix ()) * (
385
385
DiagonalMatrixRow (ᶠinterp (ᶜρe + ᶜp) * g³³ (ᶠgⁱʲ)) +
386
- DiagonalMatrixRow (CT3 (ᶠw)) ⋅ ᶠinterp_matrix () ⋅
387
- DiagonalMatrixRow (- (ᶜρ * R_d / cv_d)) ⋅ ∂ᶜK∂ᶠw
386
+ DiagonalMatrixRow (CT3 (ᶠw)) *
387
+ ᶠinterp_matrix () *
388
+ DiagonalMatrixRow (- (ᶜρ * R_d / cv_d)) *
389
+ ∂ᶜK∂ᶠw
388
390
)
389
391
else
390
392
# ᶜρeₜ =
@@ -397,15 +399,17 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
397
399
# ∂(ᶜp)/∂(ᶠw) = ∂(ᶜp)/∂(ᶜK) * ∂(ᶜK)/∂(ᶠw)
398
400
# ∂(ᶜp)/∂(ᶜK) = -ᶜρ * R_d / cv_d
399
401
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
400
- - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (ᶠinterp (ᶜρ)) ⋅ (
402
+ - (ᶜdivᵥ_matrix ()) *
403
+ DiagonalMatrixRow (ᶠinterp (ᶜρ)) *
404
+ (
401
405
DiagonalMatrixRow (
402
406
vec_data (
403
407
ᶠno_flux (
404
408
ᶠupwind_product (ᶠw + εw, (ᶜρe + ᶜp) / ᶜρ),
405
409
),
406
410
) / vec_data (CT3 (ᶠw + εw)) * g³³ (ᶠgⁱʲ),
407
411
) +
408
- ᶠno_flux_row (ᶠupwind_product_matrix (ᶠw)) ⋅
412
+ ᶠno_flux_row (ᶠupwind_product_matrix (ᶠw)) *
409
413
(- R_d / cv_d * ∂ᶜK∂ᶠw)
410
414
)
411
415
end
@@ -414,11 +418,11 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
414
418
# ∂ᶜ𝔼ₜ∂ᶠ𝕄 has 3 diagonals instead of 5
415
419
if isnothing (ᶠupwind_product)
416
420
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
417
- - (ᶜdivᵥ_matrix ()) ⋅
421
+ - (ᶜdivᵥ_matrix ()) *
418
422
DiagonalMatrixRow (ᶠinterp (ᶜρe + ᶜp) * g³³ (ᶠgⁱʲ))
419
423
else
420
424
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
421
- - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
425
+ - (ᶜdivᵥ_matrix ()) * DiagonalMatrixRow (
422
426
ᶠinterp (ᶜρ) * vec_data (
423
427
ᶠno_flux (ᶠupwind_product (ᶠw + εw, (ᶜρe + ᶜp) / ᶜρ)),
424
428
) / vec_data (CT3 (ᶠw + εw)) * g³³ (ᶠgⁱʲ),
@@ -443,9 +447,9 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
443
447
# -ᶜdivᵥ_matrix() * ᶠinterp(ᶜρe_int + ᶜp) * ᶠg³³ +
444
448
# ᶜinterp_matrix() * adjoint(ᶠgradᵥ(ᶜp)) * ᶠg³³
445
449
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
446
- - (ᶜdivᵥ_matrix ()) ⋅
450
+ - (ᶜdivᵥ_matrix ()) *
447
451
DiagonalMatrixRow (ᶠinterp (ᶜρe_int + ᶜp) * g³³ (ᶠgⁱʲ)) +
448
- ᶜinterp_matrix () ⋅
452
+ ᶜinterp_matrix () *
449
453
DiagonalMatrixRow (adjoint (ᶠgradᵥ (ᶜp)) * g³³ (ᶠgⁱʲ))
450
454
else
451
455
# ᶜρe_intₜ =
@@ -456,12 +460,12 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
456
460
# ∂(ᶠupwind_product(ᶠw, (ᶜρe_int + ᶜp) / ᶜρ))/∂(ᶠw) +
457
461
# ᶜinterp_matrix() * adjoint(ᶠgradᵥ(ᶜp)) * ᶠg³³
458
462
@. ∂ᶜ𝔼ₜ∂ᶠ𝕄 =
459
- - (ᶜdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
463
+ - (ᶜdivᵥ_matrix ()) * DiagonalMatrixRow (
460
464
ᶠinterp (ᶜρ) * vec_data (
461
465
ᶠno_flux (ᶠupwind_product (ᶠw + εw, (ᶜρe_int + ᶜp) / ᶜρ)),
462
466
) / vec_data (CT3 (ᶠw + εw)) * g³³ (ᶠgⁱʲ),
463
467
) +
464
- ᶜinterp_matrix () ⋅
468
+ ᶜinterp_matrix () *
465
469
DiagonalMatrixRow (adjoint (ᶠgradᵥ (ᶜp)) * g³³ (ᶠgⁱʲ))
466
470
end
467
471
end
@@ -480,7 +484,8 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
480
484
# ∂(ᶠgradᵥ(ᶜp))/∂(ᶜρθ) =
481
485
# ᶠgradᵥ_matrix() * γ * R_d * (ᶜρθ * R_d / p_0)^(γ - 1)
482
486
@. ∂ᶠ𝕄ₜ∂ᶜ𝔼 =
483
- - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅ ᶠgradᵥ_matrix () ⋅
487
+ - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) *
488
+ ᶠgradᵥ_matrix () *
484
489
DiagonalMatrixRow (γ * R_d * (ᶜρθ * R_d / p_0)^ (γ - 1 ))
485
490
486
491
if flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :exact
@@ -489,20 +494,20 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
489
494
# ∂(ᶠwₜ)/∂(ᶠinterp(ᶜρ)) = ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ)^2
490
495
# ∂(ᶠinterp(ᶜρ))/∂(ᶜρ) = ᶠinterp_matrix()
491
496
@. ∂ᶠ𝕄ₜ∂ᶜρ =
492
- DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) ⋅ ᶠinterp_matrix ()
497
+ DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) * ᶠinterp_matrix ()
493
498
elseif flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :hydrostatic_balance
494
499
# same as above, but we assume that ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) =
495
500
# -ᶠgradᵥ(ᶜΦ)
496
501
@. ∂ᶠ𝕄ₜ∂ᶜρ =
497
- - DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) ⋅ ᶠinterp_matrix ()
502
+ - DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) * ᶠinterp_matrix ()
498
503
end
499
504
elseif :ρe in propertynames (Y. c)
500
505
# ᶠwₜ = -ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) - ᶠgradᵥ(ᶜK + ᶜΦ)
501
506
# ∂(ᶠwₜ)/∂(ᶜρe) = ∂(ᶠwₜ)/∂(ᶠgradᵥ(ᶜp)) * ∂(ᶠgradᵥ(ᶜp))/∂(ᶜρe)
502
507
# ∂(ᶠwₜ)/∂(ᶠgradᵥ(ᶜp)) = -1 / ᶠinterp(ᶜρ)
503
508
# ∂(ᶠgradᵥ(ᶜp))/∂(ᶜρe) = ᶠgradᵥ_matrix() * R_d / cv_d
504
509
@. ∂ᶠ𝕄ₜ∂ᶜ𝔼 =
505
- - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅ (ᶠgradᵥ_matrix () * R_d / cv_d)
510
+ - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) * (ᶠgradᵥ_matrix () * R_d / cv_d)
506
511
507
512
if flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :exact
508
513
# ᶠwₜ = -ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) - ᶠgradᵥ(ᶜK + ᶜΦ)
@@ -515,24 +520,26 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
515
520
# ∂(ᶠwₜ)/∂(ᶠinterp(ᶜρ)) = ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ)^2
516
521
# ∂(ᶠinterp(ᶜρ))/∂(ᶜρ) = ᶠinterp_matrix()
517
522
@. ∂ᶠ𝕄ₜ∂ᶜρ =
518
- - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅ ᶠgradᵥ_matrix () ⋅
523
+ - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) *
524
+ ᶠgradᵥ_matrix () *
519
525
DiagonalMatrixRow (R_d * (- (ᶜK + ᶜΦ) / cv_d + T_tri)) +
520
- DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) ⋅ ᶠinterp_matrix ()
526
+ DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) * ᶠinterp_matrix ()
521
527
elseif flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :hydrostatic_balance
522
528
# same as above, but we assume that ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) =
523
529
# -ᶠgradᵥ(ᶜΦ) and that ᶜK is negligible compared ot ᶜΦ
524
530
@. ∂ᶠ𝕄ₜ∂ᶜρ =
525
- - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅ ᶠgradᵥ_matrix () ⋅
531
+ - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) *
532
+ ᶠgradᵥ_matrix () *
526
533
DiagonalMatrixRow (R_d * (- (ᶜΦ) / cv_d + T_tri)) -
527
- DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) ⋅ ᶠinterp_matrix ()
534
+ DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) * ᶠinterp_matrix ()
528
535
end
529
536
elseif :ρe_int in propertynames (Y. c)
530
537
# ᶠwₜ = -ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) - ᶠgradᵥ(ᶜK + ᶜΦ)
531
538
# ∂(ᶠwₜ)/∂(ᶜρe_int) = ∂(ᶠwₜ)/∂(ᶠgradᵥ(ᶜp)) * ∂(ᶠgradᵥ(ᶜp))/∂(ᶜρe_int)
532
539
# ∂(ᶠwₜ)/∂(ᶠgradᵥ(ᶜp)) = -1 / ᶠinterp(ᶜρ)
533
540
# ∂(ᶠgradᵥ(ᶜp))/∂(ᶜρe_int) = ᶠgradᵥ_matrix() * R_d / cv_d
534
541
@. ∂ᶠ𝕄ₜ∂ᶜ𝔼 =
535
- DiagonalMatrixRow (- 1 / ᶠinterp (ᶜρ)) ⋅ (ᶠgradᵥ_matrix () * R_d / cv_d)
542
+ DiagonalMatrixRow (- 1 / ᶠinterp (ᶜρ)) * (ᶠgradᵥ_matrix () * R_d / cv_d)
536
543
537
544
if flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :exact
538
545
# ᶠwₜ = -ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) - ᶠgradᵥ(ᶜK + ᶜΦ)
@@ -544,16 +551,16 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
544
551
# ∂(ᶠwₜ)/∂(ᶠinterp(ᶜρ)) = ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ)^2
545
552
# ∂(ᶠinterp(ᶜρ))/∂(ᶜρ) = ᶠinterp_matrix()
546
553
@. ∂ᶠ𝕄ₜ∂ᶜρ =
547
- - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅
554
+ - DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) *
548
555
(ᶠgradᵥ_matrix () * R_d * T_tri) +
549
- DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) ⋅ ᶠinterp_matrix ()
556
+ DiagonalMatrixRow (ᶠgradᵥ (ᶜp) / ᶠinterp (ᶜρ)^ 2 ) * ᶠinterp_matrix ()
550
557
elseif flags.∂ᶠ𝕄ₜ∂ᶜρ_mode == :hydrostatic_balance
551
558
# same as above, but we assume that ᶠgradᵥ(ᶜp) / ᶠinterp(ᶜρ) =
552
559
# -ᶠgradᵥ(ᶜΦ)
553
560
@. ∂ᶠ𝕄ₜ∂ᶜρ =
554
- DiagonalMatrixRow (- 1 / ᶠinterp (ᶜρ)) ⋅
561
+ DiagonalMatrixRow (- 1 / ᶠinterp (ᶜρ)) *
555
562
(ᶠgradᵥ_matrix () * R_d * T_tri) -
556
- DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) ⋅ ᶠinterp_matrix ()
563
+ DiagonalMatrixRow (ᶠgradᵥ (ᶜΦ) / ᶠinterp (ᶜρ)) * ᶠinterp_matrix ()
557
564
end
558
565
end
559
566
@@ -571,13 +578,14 @@ function implicit_equation_jacobian!(j, Y, p, δtγ, t)
571
578
# ∂(ᶠwₜ)/∂(ᶠgradᵥ(ᶜK + ᶜΦ)) = -1
572
579
# ∂(ᶠgradᵥ(ᶜK + ᶜΦ))/∂(ᶜK) = ᶠgradᵥ_matrix()
573
580
if :ρθ in propertynames (Y. c) || :ρe_int in propertynames (Y. c)
574
- @. ∂ᶠ𝕄ₜ∂ᶠ𝕄 = - (ᶠgradᵥ_matrix ()) ⋅ ∂ᶜK∂ᶠw
581
+ @. ∂ᶠ𝕄ₜ∂ᶠ𝕄 = - (ᶠgradᵥ_matrix ()) * ∂ᶜK∂ᶠw
575
582
elseif :ρe in propertynames (Y. c)
576
583
@. ∂ᶠ𝕄ₜ∂ᶠ𝕄 =
577
584
- (
578
- DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) ⋅ ᶠgradᵥ_matrix () ⋅
585
+ DiagonalMatrixRow (1 / ᶠinterp (ᶜρ)) *
586
+ ᶠgradᵥ_matrix () *
579
587
DiagonalMatrixRow (- (ᶜρ * R_d / cv_d)) + ᶠgradᵥ_matrix ()
580
- ) ⋅ ∂ᶜK∂ᶠw
588
+ ) * ∂ᶜK∂ᶠw
581
589
end
582
590
583
591
I = one (∂R∂Y)
0 commit comments