Skip to content

Commit

Permalink
cleanups, null default for freezing spectrum, README update
Browse files Browse the repository at this point in the history
  • Loading branch information
slayoo committed Oct 18, 2021
1 parent a383324 commit 155ef06
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
5 changes: 4 additions & 1 deletion PySDM/environments/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def __getitem__(self, item):
return self._ambient_air[item]

def __setitem__(self, key, value):
self._ambient_air[key] = self.particulator.backend.Storage.from_ndarray(np.array([value]))
if key not in self._ambient_air:
self._ambient_air[key] = self.particulator.backend.Storage.from_ndarray(np.array([value]))
else:
self._ambient_air[key][:] = value

def register(self, builder):
self.particulator = builder.particulator
Expand Down
2 changes: 1 addition & 1 deletion PySDM/initialisation/multiplicities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def discretise_n(y_float):
raise Exception(f"{percent_diff}% error in total real-droplet number due to casting multiplicities to ints")

if not (y_int > 0).all():
raise Exception("int-casting resulted in multiplicity of zero")
raise Exception(f"int-casting resulted in multiplicity of zero (min(y_float)={min(y_float)})")

return y_int
4 changes: 2 additions & 2 deletions PySDM/physics/formulae.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _pick(value: str, choices: dict):
for name, cls in choices.items():
if name == value:
return cls()
raise ValueError(f"Unknown setting: '{value}';, choices are: {tuple(choices.keys())}")
raise ValueError(f"Unknown setting: '{value}'; choices are: {tuple(choices.keys())}")


def _choices(module):
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self, *,
state_variable_triplet: str = 'RhodThdQv',
particle_advection: str = 'ImplicitInSpace',
hydrostatics: str = 'Default',
freezing_temperature_spectrum: str = 'Niemand_et_al_2012',
freezing_temperature_spectrum: str = 'Null',
heterogeneous_ice_nucleation_rate: str = 'Null'
):
self.seed = seed
Expand Down
2 changes: 2 additions & 0 deletions PySDM/physics/freezing_temperature_spectrum/null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Null:
pass
4 changes: 2 additions & 2 deletions PySDM/products/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def __init__(self, **args):
self.source = None

def register(self, builder):
assert isinstance(builder.particulator.env, _Moist)
super().register(builder)
self.particulator.observers.append(self)
self.environment = builder.particulator.env
self.source = self.environment[self._name]

def notify(self):
self.source = self.environment.get_predicted(self._name)
if isinstance(self.environment, _Moist):
self.source = self.environment.get_predicted(self._name)

def get(self):
self.download_to_buffer(self.source)
Expand Down
3 changes: 3 additions & 0 deletions PySDM/state/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def keys(self):
def __getitem__(self, item):
return self.attributes[item].get()

def __contains__(self, key):
return key in self.attributes

def permutation(self, u01, local):
if local:
"""
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ the license of the contributed code must be compatible with GPL v3.

Developing the code, we follow [The Way of Python](https://www.python.org/dev/peps/pep-0020/) and
the [KISS principle](https://en.wikipedia.org/wiki/KISS_principle).
The codebase has greatly benefited from [PyCharm code inspections](https://www.jetbrains.com/help/pycharm/code-inspection.html).
The codebase has greatly benefited from [PyCharm code inspections](https://www.jetbrains.com/help/pycharm/code-inspection.html)
and [Pylint](https://pylint.org) code analysis (which constitutes one of the CI workflows).

Issues regarding any incorrect, unintuitive or undocumented bahaviour of
PySDM are best to be reported on the [GitHub issue tracker](https://github.com/atmos-cloud-sim-uj/PySDM/issues/new).
Expand All @@ -616,10 +617,24 @@ We look forward to your contributions and feedback.

## Credits:

Development of PySDM is supported by the EU through a grant of the Foundation for Polish Science (POIR.04.04.00-00-5E1C/18).

copyright: Jagiellonian University
licence: GPL v3
The development and maintenance of PySDM is led by [Sylwester Arabas](https://github.com/slayoo/).
[Piotr Bartman](https://github.com/piotrbartman/) had been the architect and main developer
of technological solutions in PySDM.
The suite of examples shipped with PySDM includes contributions from researchers
from [Jagiellonian University](https://en.uj.edu.pl/en) departments of computer science, physics and chemistry;
and from
[Caltech's Climate Modelling Alliance](https://clima.caltech.edu/).

Development of PySDM had been initially supported by the EU through a grant of the
[Foundation for Polish Science](https://www.fnp.org.pl/)) (POIR.04.04.00-00-5E1C/18)
realised at the [Jagiellonian University](https://en.uj.edu.pl/en).
The immersion freezing support in PySDM is developed with support from the
US Department of Energy [Atmospheric System Research](https://asr.science.energy.gov/) programme
through a grant realised at the
[University of Illinois at Urbana-Champaign](https://illinois.edu/).

copyright: [Jagiellonian University](https://en.uj.edu.pl/en)
licence: [GPL v3](https://www.gnu.org/licenses/gpl-3.0.html)

## Related resources and open-source projects

Expand Down

0 comments on commit 155ef06

Please sign in to comment.