-
Notifications
You must be signed in to change notification settings - Fork 53
Add the Long 1974 piecewise collision kernel #1785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
77bea54
Add functionality for Long 1974
ekdejong 0f41bf5
Add unit tests
ekdejong 6f838ca
linting
ekdejong b482c85
fix output size in test
ekdejong 02cedda
fix unit test again
ekdejong ed76d2d
run pre-commit (Black)
ekdejong c5163dc
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/ad…
ekdejong d98a620
fix paper link, add entry to docs bib file
slayoo babf080
missing https:// added
slayoo b082716
add equation #; remove extraneous array allocation
ekdejong 5489b83
Change condition array to bool
ekdejong c2cfc8d
add GPU storage methods; switch to bool condition
ekdejong c516183
add GPU testing to kernel unit test
ekdejong 2d32565
black
ekdejong c6c4ce1
more black
ekdejong 3e6865c
add example for Long kernel
ekdejong 820a89b
black & badges
ekdejong 4ac08bf
parameterize backend for long unit test
ekdejong 593a009
fix the backend pytest oops
ekdejong ec94f73
add long to bib
ekdejong c86207e
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/ad…
ekdejong f8b462e
add missing comma
ekdejong 5ad9b13
update link in example init
ekdejong 36785c1
remove unused import
ekdejong 0695067
Merge branch 'main' of https://github.com/open-atmos/PySDM into ej/ad…
ekdejong 155dbfa
black
ekdejong acab174
update url to match bibliography
ekdejong 16f6d73
linting
ekdejong 347b352
update bib
ekdejong f1fbd59
lint
ekdejong 5a91044
fix where, isless Thrust backends
ekdejong 2b30ba5
black
ekdejong aefa58a
add small tolerance to test for float conversion on GPU
ekdejong f7c3b68
add new Long_1974 dir to conftest.py
slayoo debdd7c
refactor: reduce code repetitions in the notebook
slayoo a2efc23
remove unused import
slayoo f8030ee
remove unused vars
slayoo fddd1b8
fix k specification
ekdejong e9120fc
add smoke test for Long's
ekdejong e32cf11
black
ekdejong cb52e0f
Fix notebook path in test_collisions.py
slayoo 66eb701
adapt smoke-test tolerances, reduce n_sd for CI runs, fine-tune plot …
slayoo 9a4c747
code formatting
slayoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """ | ||
| piecewise kernel from Eq (11) in | ||
| [Long 1974](https://doi.org/10.1175/1520-0469%281974%29031%3C1040%3ASTTDCE%3E2.0.CO%3B2) | ||
|
|
||
| Default parameters are: | ||
| lin_coeff = 5.78e3 / s | ||
| sq_coeff = 9.44e15 / m^3 / s | ||
| r_thresh = 5e-5 m | ||
| """ | ||
|
|
||
|
|
||
| class Long1974: | ||
|
slayoo marked this conversation as resolved.
|
||
| def __init__(self, lin_coeff=5.78e3, sq_coeff=9.44e15, r_thres=5e-5): | ||
| self.lc = lin_coeff | ||
| self.sc = sq_coeff | ||
| self.rt = r_thres | ||
| self.particulator = None | ||
| self.largeR = None | ||
| self.arrays = {} | ||
|
|
||
| def register(self, builder): | ||
| self.particulator = builder.particulator | ||
| builder.request_attribute("volume") | ||
| builder.request_attribute("radius") | ||
| for key in ( | ||
|
ekdejong marked this conversation as resolved.
|
||
| "r_lg", | ||
| "v_lg", | ||
| "v_sm", | ||
| "v_ratio", | ||
| "tmp", | ||
| "tmp1", | ||
| ): | ||
| self.arrays[key] = self.particulator.PairwiseStorage.empty( | ||
| self.particulator.n_sd // 2, dtype=float | ||
| ) | ||
| self.arrays["condition"] = self.particulator.PairwiseStorage.empty( | ||
| self.particulator.n_sd // 2, dtype=bool | ||
| ) | ||
|
|
||
| def __call__(self, output, is_first_in_pair): | ||
| # get smaller and larger radii, volume | ||
| self.arrays["r_lg"].max( | ||
| self.particulator.attributes["radius"], is_first_in_pair | ||
| ) | ||
| self.arrays["v_lg"].max( | ||
| self.particulator.attributes["volume"], is_first_in_pair | ||
| ) | ||
| self.arrays["v_sm"].min( | ||
| self.particulator.attributes["volume"], is_first_in_pair | ||
| ) | ||
|
|
||
| # compute volume ratio | ||
| self.arrays["v_ratio"].fill(self.arrays["v_sm"]) | ||
| self.arrays["v_ratio"].divide_if_not_zero(self.arrays["v_lg"]) | ||
|
|
||
| # compute small radius limit | ||
| self.arrays["tmp1"].fill(self.arrays["v_ratio"]) | ||
| self.arrays["tmp1"] **= 2.0 | ||
| self.arrays["tmp1"] += 1.0 | ||
| self.arrays["tmp"].fill(self.arrays["v_lg"]) | ||
| self.arrays["tmp"] **= 2.0 | ||
| self.arrays["tmp1"] *= self.arrays["tmp"] | ||
| self.arrays["tmp1"] *= self.sc | ||
|
|
||
| # compute large radius (linear) limit | ||
| self.arrays["v_ratio"] += 1.0 | ||
| self.arrays["v_ratio"] *= self.arrays["v_lg"] | ||
| self.arrays["v_ratio"] *= self.lc | ||
|
|
||
| # apply piecewise | ||
| self.arrays["condition"].isless(self.arrays["r_lg"], self.rt) | ||
| output.where( | ||
| self.arrays["condition"], self.arrays["tmp1"], self.arrays["v_ratio"] | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # pylint: disable=invalid-name | ||
| """ | ||
| piecewise collision-coalescence example from | ||
| [Long 1974 (JAS)](https://doi.org/10.1175/1520-0469%281974%29031%3C1040%3ASTTDCE%3E2.0.CO%3B2) | ||
| """ | ||
|
|
||
| from .settings import Settings | ||
| from .simulation import Simulation |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.