CliMA / Cloudy.jl

:cloud_with_rain: Multi-moment cloud microphysics toy model
Apache License 2.0
15 stars 3 forks source link

Make ParticleDistribution structs immutable #153

Closed nefrathenrici closed 2 months ago

nefrathenrici commented 2 months ago

Content

More to do on the particledistributions:

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 97.61905% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 98.13%. Comparing base (29b59bb) to head (ab1d5d0). Report is 6 commits behind head on main.

Files Patch % Lines
src/ParticleDistributions/ParticleDistributions.jl 97.56% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #153 +/- ## ========================================== - Coverage 98.17% 98.13% -0.04% ========================================== Files 8 9 +1 Lines 493 537 +44 ========================================== + Hits 484 527 +43 - Misses 9 10 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nefrathenrici commented 2 months ago

function rhs_coal!(coal_type::CoalescenceStyle, dmom, mom, p)
    mom_norms = get_moments_normalizing_factors(p.NProgMoms, p.norms)
    mom_normalized = tuple(mom ./ mom_norms...)
    p.pdists = ntuple(length(p.pdists)) do i
        ind_rng = get_dist_moments_ind_range(p.NProgMoms, i)
        update_dist_from_moments(p.pdists[i], mom_normalized[ind_rng])
    end
    update_coal_ints!(coal_type, p.pdists, p.coal_data)
    dmom .= p.coal_data.coal_ints .* mom_norms
end

function rhs_condensation!(dmom, mom, p, s)
    mom_norms = get_moments_normalizing_factors(p.NProgMoms, p.norms)
    mom_normalized = tuple(mom ./ mom_norms...)
    p.pdists = ntuple(length(p.pdists)) do i
        ind_rng = get_dist_moments_ind_range(p.NProgMoms, i)
        update_dist_from_moments(p.pdists[i], mom_normalized[ind_rng])
    end
    dmom .= get_cond_evap(s, p) .* mom_norms
end