Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
085cddc
Add the option to remove a dynamic from builder
Oct 14, 2022
493901c
Merge branch 'main' of https://github.com/atmos-cloud-sim-uj/PySDM
Oct 31, 2022
5973b25
Merge branch 'main' of https://github.com/atmos-cloud-sim-uj/PySDM
Nov 8, 2022
94aad02
Merge branch 'main' of https://github.com/atmos-cloud-sim-uj/PySDM
Feb 8, 2023
81eb1d4
Revisions to JOSS v2 paper
Feb 9, 2023
75a33cf
updated references in JOSS v2 paper
slayoo Feb 9, 2023
4bbb108
grant number, mention of PyPartMC, remove melting, OB contribs, break…
slayoo Feb 9, 2023
aa2e76a
fix PyPartMC_AMS ref
slayoo Feb 9, 2023
5eee349
make math usable within Formulae (test to be added)
slayoo Feb 9, 2023
4db1add
Merge branch 'slayoo-patch-37' of https://github.com/atmos-cloud-sim-…
Feb 9, 2023
bedaf6f
make math available in cpp2python
slayoo Feb 9, 2023
0875848
Update collisions_methods.py
abulenok Feb 10, 2023
6ea71e4
Merge branch 'abulenok-patch-1' of https://github.com/open-atmos/PySD…
Feb 10, 2023
8f179e4
Merge branch 'slayoo-patch-37' of https://github.com/open-atmos/PySDM…
Feb 10, 2023
f4372bc
Switch from tanh to erf in gaussian CDF
Feb 10, 2023
8c1611f
Rename breakup subfunctions in CPU backend
Feb 10, 2023
48ba0d3
reassign attributes[a,j] in case of new_nj == 0 (breakup1)
Feb 10, 2023
0341a07
Remove redundant checks, add logic comments, clean up breakup CPU bac…
Feb 10, 2023
d9fc399
Add Ben's Scripps affiliation
Feb 10, 2023
208bc45
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/br…
Feb 13, 2023
9989efe
Linting
Feb 13, 2023
f902547
Merge branch 'ej/breakup_issues' of github.com:edejong-caltech/PySDM …
slayoo Feb 14, 2023
6f622e7
removing spurious bib entry
slayoo Feb 14, 2023
5937fe7
rename codecov workflow to highlight that it uses nojit
slayoo Feb 14, 2023
969bcb3
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/br…
Feb 14, 2023
fa9e5da
Revisions to JOSS v2 paper
Feb 9, 2023
fd0f63a
make math usable within Formulae (test to be added)
slayoo Feb 9, 2023
3ef73af
make math available in cpp2python
slayoo Feb 9, 2023
71a7d4d
Switch from tanh to erf in gaussian CDF
Feb 10, 2023
bf98184
Rename breakup subfunctions in CPU backend
Feb 10, 2023
f631f4a
reassign attributes[a,j] in case of new_nj == 0 (breakup1)
Feb 10, 2023
97b8ac7
Remove redundant checks, add logic comments, clean up breakup CPU bac…
Feb 10, 2023
a152424
Linting
Feb 13, 2023
49fb978
removing spurious bib entry
slayoo Feb 14, 2023
7925a9e
rename codecov workflow to highlight that it uses nojit
slayoo Feb 14, 2023
74e9ad8
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/br…
Feb 19, 2023
3b0ec3b
Merge branch 'ej/breakup_issues' of https://github.com/edejong-caltec…
Feb 19, 2023
e0c43cd
Remove old docstring
Feb 19, 2023
7ceb588
WIP on LL82 fragmenttion fucntion
Feb 21, 2023
07c90b0
include math pkg name replacement in formula c_inline
slayoo Feb 21, 2023
cb56394
sorting out CUDA problem with log(int)
slayoo Feb 21, 2023
2067f36
make Straub formulae CUDA-compatible
slayoo Feb 21, 2023
db98cd1
pre-commit cleanup
slayoo Feb 21, 2023
2bc2ce4
fix erf support in FakeThrust
slayoo Feb 21, 2023
febbb30
WIP on LL82 fragmentation function
Feb 22, 2023
33c96f8
Attempt at CDF sampling for ll82
Feb 22, 2023
d8fffc0
WIP on testing ll82
Feb 27, 2023
2bc8874
Merge branch 'main' of https://github.com/open-atmos/PySDM
Feb 27, 2023
46cc1d8
Merge branch 'ej/breakup_issues' of https://github.com/edejong-caltec…
Feb 27, 2023
dd20975
WIP to satisfy numba's needs
Feb 28, 2023
6ae2a9c
Some fixes to LL82
Mar 1, 2023
60dd8ea
Testing & debugging
Mar 2, 2023
58b7723
Adding limiting cases to LL82
Mar 3, 2023
0f6afc9
Update fragmentation unit tests
Mar 3, 2023
9866cec
Implement LL82 coalescence efficiency
Mar 3, 2023
db532e9
Final fixes on LL82 efficiency
Mar 7, 2023
9358a10
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/ll82
Mar 7, 2023
1a8dee7
Merge branch 'main' of https://github.com/open-atmos/PySDM
Mar 7, 2023
9f69935
Merge branch 'ej/ll82' of https://github.com/edejong-caltech/PySDM in…
Mar 7, 2023
1763590
Fixes to MP distribution
Mar 7, 2023
645862e
remove MP separate file
Mar 8, 2023
bace062
Fixing issues with LL82
Mar 8, 2023
583538d
Add'l limiters in LL82
Mar 8, 2023
3f1ddba
Test LowList82 distribution
abulenok Mar 11, 2023
72f6480
Refactor Straub -> mass weighting
Mar 14, 2023
0239839
Remove unnecessary limiter
Mar 14, 2023
8051f9f
Factor 2 in CKE, factor CM in straub delta D's
Mar 14, 2023
d854234
Enhance prints in test_fragmentation_fn_distribution
abulenok Mar 14, 2023
4d7af69
Merge branch 'ob/ll82-test' of https://github.com/abulenok/PySDM into…
Mar 15, 2023
13caca3
Swap out erfinv approx
Mar 15, 2023
6533e57
Fix error in straub p4
Mar 15, 2023
ade98db
Fixes to straub and fragmentation limiters
Mar 23, 2023
376eefe
Reorder limiters & fix fragmentation tests
Mar 23, 2023
45d2931
Make pylint happy
Mar 24, 2023
281587d
Small modifications to tests
Mar 24, 2023
9cba18e
make isort happy
slayoo Apr 14, 2022
cab269c
Attempting to fix GPU straub backend
Mar 27, 2023
0a50a1a
Merge branch 'main' into ej/schlottke
slayoo Apr 1, 2023
fc08e36
Merge branch 'ej/schlottke' of github.com:edejong-caltech/PySDM into …
slayoo Apr 1, 2023
6bba2d2
precommit formatting change
slayoo Apr 1, 2023
1b68af9
reinstantiate changes in paper files
slayoo Apr 1, 2023
fbafd6b
adapting products test_impl to work with the new NumberSizeSpectrum p…
slayoo Apr 2, 2023
5d1f0c8
erfinv cleanup (introducing Vedder 1987 approximation to Trivia)
slayoo Apr 2, 2023
3b4bf67
make erfinv test work with JIT disabled
slayoo Apr 2, 2023
7ad73c8
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/sc…
Apr 5, 2023
9f51534
Rewrite straub2010 as one-liners
Apr 7, 2023
a359106
Fix physics unit test
Apr 7, 2023
3d48334
Remove unused import
Apr 7, 2023
6370177
Add new test on efficiencies
Apr 7, 2023
5ac513f
Make pylint happy
Apr 9, 2023
d79541b
remove getitem from float reference
slayoo Apr 9, 2023
8c973f6
speeding up lowlist efficiencies by replacing [:] with fill()
slayoo Apr 9, 2023
ee4bf4b
speeding up lowlist fragmentation func. by replacing [:] with fill()
slayoo Apr 9, 2023
d91836b
fix C syntax
slayoo Apr 9, 2023
3ebf0ff
Fix fig5 dJ smoke test
Apr 10, 2023
5dc9964
remove GPU-xfail in deJong fig 5 smoke test
slayoo Apr 11, 2023
485e6a0
remove unused import
slayoo Apr 11, 2023
f84cb4f
one more unused import
slayoo Apr 11, 2023
fb71658
Use fill command in straub Ec
Apr 11, 2023
04bd2c6
Merge branch 'ej/schlottke' of https://github.com/edejong-caltech/PyS…
Apr 11, 2023
5fa2190
Update smoke test
Apr 11, 2023
4ae6e98
dJ smoke test + case for x_plus_y = 0
Apr 11, 2023
357bf89
'pointless statement'
Apr 12, 2023
630b94a
bring back y-assert code in test_fig_5 smoke test as commented out an…
slayoo Apr 13, 2023
a84531d
reinstantiate test_fragmentation_nf_and_frag_size_equals
slayoo Apr 13, 2023
bc85acb
add missing white spaces (pre commit)
slayoo Apr 13, 2023
b528479
white-space cleanup
slayoo Apr 13, 2023
c04168a
bring back ConstantSize import
slayoo Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
309 changes: 261 additions & 48 deletions PySDM/backends/impl_numba/methods/collisions_methods.py

Large diffs are not rendered by default.

83 changes: 47 additions & 36 deletions PySDM/backends/impl_thrust_rtc/methods/collisions_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,23 +521,24 @@ def __init__(self):
param_names=(
"n_fragment",
"frag_size",
"v_max",
"x_plus_y",
"vmin",
"nfmax",
"nfmax_is_not_none",
),
name_iter="i",
body="""
frag_size[i] = min(frag_size[i], v_max[i]);
frag_size[i] = max(frag_size[i], vmin);
frag_size[i] = min(frag_size[i], x_plus_y[i])

if (nfmax_is_not_none) {
if (x_plus_y[i] / frag_size[i] > nfmax) {
frag_size[i] = x_plus_y[i] / nfmax;
}
}
if (frag_size[i] == 0.0) {
else if (frag_size[i] < vmin) {
frag_size[i] = x_plus_y[i];
}
else if (frag_size[i] == 0.0) {
frag_size[i] = x_plus_y[i];
}
n_fragment[i] = x_plus_y[i] / frag_size[i];
Expand All @@ -549,10 +550,8 @@ def __init__(self):
param_names=("mu", "sigma", "frag_size", "rand"),
name_iter="i",
body=f"""
frag_size[i] = {self.formulae.fragmentation_function.frag_size.c_inline(
mu="mu",
sigma="sigma",
rand="rand[i]"
frag_size[i] = mu + sigma * {self.formulae.trivia.erfinv_approx.c_inline(
c="rand[i]"
)};
""".replace(
"real_type", self._get_c_type()
Expand Down Expand Up @@ -610,6 +609,20 @@ def __init__(self):
Nrt[i] = Nr1[i] + Nr2[i] + Nr3[i] + Nr4[i];
"""

self.__straub_mass_remainder = """
Nr1[i] = Nr1[i] * exp(3 * mu1 + 9 * pow(sigma1, 2.0) / 2);
Nr2[i] = Nr2[i] * (pow(mu2, 3.0) + 3 * mu2 * pow(sigma2, 2.0));
Nr3[i] = Nr3[i] * (pow(mu3, 3.0) + 3 * mu3 * pow(sigma3, 2.0));
Nr4[i] = v_max[i] * 6.0 / 3.141592654 + pow(ds[i], 3.0) - Nr1[i] - Nr2[i] - Nr3[i];
if Nr4[i] <= 0.0 {
d34[i] = 0;
Nr4[i] = 0;
}
else {
d34[i] = exp(log(Nr4[i]) / 3);
}
"""

if self.formulae.fragmentation_function.__name__ == "Straub2010Nf":
self.__straub_fragmentation_body = trtc.For(
param_names=(
Expand All @@ -624,41 +637,44 @@ def __init__(self):
"Nr3",
"Nr4",
"Nrt",
"d34",
),
name_iter="i",
body=f"""
{self.__straub_Nr_body}
auto sigma1 = {self.formulae.fragmentation_function.params_sigma1.c_inline(CW="CW[i]")};
auto mu1 = {self.formulae.fragmentation_function.params_mu1.c_inline(sigma1="sigma1")};
auto sigma2 = {self.formulae.fragmentation_function.params_sigma2.c_inline(CW="CW[i]")};
auto mu2 = {self.formulae.fragmentation_function.params_mu2.c_inline(ds="ds[i]")};
auto sigma3 = {self.formulae.fragmentation_function.params_sigma3.c_inline(CW="CW[i]")};
auto mu3 = {self.formulae.fragmentation_function.params_mu3.c_inline(ds="ds[i]")};
{self.__straub_mass_remainder}
Nrt[i] = Nr1[i] + Nr2[i] + Nr3[i] + Nr4[i]

if (rand[i] < Nr1[i] / Nrt[i]) {{
auto sigma1 = {self.formulae.fragmentation_function.sigma1.c_inline(CW="CW[i]")};
frag_size[i] = {self.formulae.fragmentation_function.p1.c_inline(
sigma1="sigma1",
rand="rand[i] * Nrt[i] / Nr1[i]"
auto X = rand[i] * Nrt[i] / Nr1[i];
auto lnarg = mu1 + sqrt(2.0) * sigma1 * {self.formulae.trivia.erfinv_approx.c_inline(
c="X"
)};
frag_size[i] = exp(lnarg);
}}
else if (rand[i] < (Nr2[i] + Nr1[i]) / Nrt[i]) {{
frag_size[i] = {self.formulae.fragmentation_function.p2.c_inline(
CW="CW[i]",
rand="(rand[i] * Nrt[i] - Nr1[i]) / (Nr2[i] - Nr1[i])"
auto X = (rand[i] * Nrt[i] - Nr1[i]) / Nr2[i];
frag_size[i] = mu2 + sqrt(2.0) * sigma2 * {self.formulae.trivia.erfinv_approx.c_inline(
c="X"
)};
}}
else if (rand[i] < (Nr3[i] + Nr2[i] + Nr1[i]) / Nrt[i]) {{
frag_size[i] = {self.formulae.fragmentation_function.p3.c_inline(
CW="CW[i]",
ds="ds[i]",
rand="(rand[i] * Nrt[i] - Nr2[i]) / (Nr3[i] - Nr2[i])"
auto X = (rand[i] * Nrt[i] - Nr1[i] - Nr2[i]) / Nr3[i];
frag_size[i] = mu3 + sqrt(2.0) * sigma3 * {self.formulae.trivia.erfinv_approx.c_inline(
c="X"
)};
}}
else {{
frag_size[i] = {self.formulae.fragmentation_function.p4.c_inline(
CW="CW[i]",
ds="ds[i]",
v_max="v_max[i]",
Nr1="Nr1[i]",
Nr2="Nr2[i]",
Nr3="Nr3[i]"
)};
frag_size[i] = d34[i];
}}

frag_size[i] = pow(frag_size[i], 3.0) * 3.141592654 / 6.0
""".replace(
"real_type", self._get_c_type()
),
Expand Down Expand Up @@ -910,7 +926,6 @@ def exp_fragmentation(
n_fragment,
scale,
frag_size,
v_max,
x_plus_y,
rand,
vmin,
Expand All @@ -932,7 +947,6 @@ def exp_fragmentation(
args=(
n_fragment.data,
frag_size.data,
v_max.data,
x_plus_y.data,
self._get_floating_point(vmin),
self._get_floating_point(nfmax if nfmax else -1),
Expand All @@ -941,7 +955,7 @@ def exp_fragmentation(
)

def gauss_fragmentation(
self, *, n_fragment, mu, sigma, frag_size, v_max, x_plus_y, rand, vmin, nfmax
self, *, n_fragment, mu, sigma, frag_size, x_plus_y, rand, vmin, nfmax
):
self.__gauss_fragmentation_body.launch_n(
n=len(frag_size),
Expand All @@ -958,7 +972,6 @@ def gauss_fragmentation(
args=(
n_fragment.data,
frag_size.data,
v_max.data,
x_plus_y.data,
self._get_floating_point(vmin),
self._get_floating_point(nfmax if nfmax else -1),
Expand All @@ -967,7 +980,7 @@ def gauss_fragmentation(
)

def slams_fragmentation(
self, n_fragment, frag_size, v_max, x_plus_y, probs, rand, vmin, nfmax
self, n_fragment, frag_size, x_plus_y, probs, rand, vmin, nfmax
): # pylint: disable=too-many-arguments
self.__slams_fragmentation_body.launch_n(
n=(len(n_fragment)),
Expand All @@ -985,7 +998,6 @@ def slams_fragmentation(
args=(
n_fragment.data,
frag_size.data,
v_max.data,
x_plus_y.data,
self._get_floating_point(vmin),
self._get_floating_point(nfmax if nfmax else -1),
Expand All @@ -999,7 +1011,6 @@ def feingold1988_fragmentation(
n_fragment,
scale,
frag_size,
v_max,
x_plus_y,
rand,
fragtol,
Expand All @@ -1022,7 +1033,6 @@ def feingold1988_fragmentation(
args=(
n_fragment.data,
frag_size.data,
v_max.data,
x_plus_y.data,
self._get_floating_point(vmin),
self._get_floating_point(nfmax if nfmax else -1),
Expand All @@ -1049,6 +1059,7 @@ def straub_fragmentation(
Nr3,
Nr4,
Nrt,
d34,
):
self.__straub_fragmentation_body.launch_n(
n=len(frag_size),
Expand All @@ -1064,6 +1075,7 @@ def straub_fragmentation(
Nr3.data,
Nr4.data,
Nrt.data,
d34.data,
),
)

Expand All @@ -1072,7 +1084,6 @@ def straub_fragmentation(
args=(
n_fragment.data,
frag_size.data,
v_max.data,
x_plus_y.data,
self._get_floating_point(vmin),
self._get_floating_point(nfmax if nfmax else -1),
Expand Down
2 changes: 1 addition & 1 deletion PySDM/backends/impl_thrust_rtc/test_helpers/cpp2python.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def to_numba(name, args, iter_var, body):
f"""
def make(self):
import numpy as np
from numpy import floor, ceil, exp, log, power, sqrt, arctanh
from numpy import floor, ceil, exp, log, power, sqrt, arctanh, sinh, arcsinh
import numba

@numba.njit(parallel=False, {JIT_OPTS})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
from .exponential import ExponFrag
from .feingold1988 import Feingold1988Frag
from .gaussian import Gaussian
from .lowlist82 import LowList1982Nf
from .slams import SLAMS
from .straub2010 import Straub2010Nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,22 @@ def __init__(self, scale, vmin=0.0, nfmax=None):
self.scale = scale
self.vmin = vmin
self.nfmax = nfmax
self.max_size = None
self.sum_of_volumes = None

def register(self, builder):
self.particulator = builder.particulator
self.max_size = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)
self.sum_of_volumes = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)

def __call__(self, nf, frag_size, u01, is_first_in_pair):
self.max_size.max(self.particulator.attributes["volume"], is_first_in_pair)
self.sum_of_volumes.sum(
self.particulator.attributes["volume"], is_first_in_pair
)
self.particulator.backend.exp_fragmentation(
n_fragment=nf,
scale=self.scale,
frag_size=frag_size,
v_max=self.max_size,
x_plus_y=self.sum_of_volumes,
rand=u01,
vmin=self.vmin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,23 @@ def __init__(self, scale, fragtol=1e-3, vmin=0.0, nfmax=None):
self.fragtol = fragtol
self.vmin = vmin
self.nfmax = nfmax
self.max_size = None
self.sum_of_volumes = None

def register(self, builder):
self.particulator = builder.particulator
builder.request_attribute("volume")
self.max_size = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)
self.sum_of_volumes = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)

def __call__(self, nf, frag_size, u01, is_first_in_pair):
self.max_size.max(self.particulator.attributes["volume"], is_first_in_pair)
self.sum_of_volumes.sum(
self.particulator.attributes["volume"], is_first_in_pair
)
self.particulator.backend.feingold1988_fragmentation(
n_fragment=nf,
scale=self.scale,
frag_size=frag_size,
v_max=self.max_size,
x_plus_y=self.sum_of_volumes,
rand=u01,
fragtol=self.fragtol,
Expand Down
6 changes: 0 additions & 6 deletions PySDM/dynamics/collisions/breakup_fragmentations/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ def __init__(self, mu, sigma, vmin=0.0, nfmax=None):
self.sigma = sigma
self.vmin = vmin
self.nfmax = nfmax
self.max_size = None
self.sum_of_volumes = None

def register(self, builder):
self.particulator = builder.particulator
self.max_size = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)
self.sum_of_volumes = self.particulator.PairwiseStorage.empty(
self.particulator.n_sd // 2, dtype=float
)

def __call__(self, nf, frag_size, u01, is_first_in_pair):
self.max_size.max(self.particulator.attributes["volume"], is_first_in_pair)
self.sum_of_volumes.sum(
self.particulator.attributes["volume"], is_first_in_pair
)
Expand All @@ -32,7 +27,6 @@ def __call__(self, nf, frag_size, u01, is_first_in_pair):
mu=self.mu,
sigma=self.sigma,
frag_size=frag_size,
v_max=self.max_size,
x_plus_y=self.sum_of_volumes,
rand=u01,
vmin=self.vmin,
Expand Down
Loading