Skip to content

Commit

Permalink
mass instead of volume as base attribute (incl. introduction of physi…
Browse files Browse the repository at this point in the history
…cs.particle_shape_and_density) (#1147)

Co-authored-by: Oleksii Bulenok <[email protected]>
Co-authored-by: Agnieszka Makulska <[email protected]>
Co-authored-by: derlk <[email protected]>
  • Loading branch information
4 people authored Oct 17, 2023
1 parent 9e97c39 commit 10a05b1
Show file tree
Hide file tree
Showing 90 changed files with 1,082 additions and 604 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ dmypy.json
.code-workspace

# Mac stuff
**.DS_Store
**.DS_Store

#Jetbrains
.idea/
2 changes: 2 additions & 0 deletions PySDM/attributes/impl/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Temperature,
TerminalVelocity,
Volume,
WaterMass,
WetToCriticalVolumeRatio,
)
from PySDM.attributes.physics.critical_supersaturation import CriticalSupersaturation
Expand Down Expand Up @@ -100,6 +101,7 @@
"critical supersaturation": lambda _, __: CriticalSupersaturation,
"equilibrium supersaturation": lambda _, __: EquilibriumSupersaturation,
"wet to critical volume ratio": lambda _, __: WetToCriticalVolumeRatio,
"water mass": lambda _, __: WaterMass,
}


Expand Down
1 change: 1 addition & 0 deletions PySDM/attributes/physics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .dry_volume import DryVolume
from .equilibrium_supersaturation import EquilibriumSupersaturation
from .heat import Heat
from .mass import WaterMass
from .multiplicities import Multiplicities
from .radius import Radius, SquareRootOfRadius
from .relative_fall_velocity import RelativeFallMomentum, RelativeFallVelocity
Expand Down
11 changes: 11 additions & 0 deletions PySDM/attributes/physics/mass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
particle mass, derived attribute for coalescence
in simulation involving mixed-phase clouds, positive values correspond to
liquid water and negative values to ice
"""
from PySDM.attributes.impl import ExtensiveAttribute


class WaterMass(ExtensiveAttribute):
def __init__(self, builder):
super().__init__(builder, name="water mass")
8 changes: 3 additions & 5 deletions PySDM/attributes/physics/relative_fall_velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ def __init__(self, builder):
class RelativeFallVelocity(DerivedAttribute):
def __init__(self, builder):
self.momentum = builder.get_attribute("relative fall momentum")
self.volume = builder.get_attribute("volume")
self.rho_w = builder.formulae.constants.rho_w # TODO #798
self.water_mass = builder.get_attribute("water mass")

super().__init__(
builder,
name="relative fall velocity",
dependencies=(self.momentum, self.volume),
dependencies=(self.momentum, self.water_mass),
)

def recalculate(self):
self.data.ratio(self.momentum.get(), self.volume.get())
self.data[:] *= 1 / self.rho_w # TODO #798
self.data.ratio(self.momentum.get(), self.water_mass.get())
12 changes: 8 additions & 4 deletions PySDM/attributes/physics/volume.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""
particle (wet) volume, key attribute for coalescence
particle volume (derived from water mass);
in simulation involving mixed-phase clouds, positive values correspond to
liquid water and negative values to ice
"""
from PySDM.attributes.impl.extensive_attribute import ExtensiveAttribute
from PySDM.attributes.impl import DerivedAttribute


class Volume(ExtensiveAttribute):
class Volume(DerivedAttribute):
def __init__(self, builder):
super().__init__(builder, name="volume")
self.water_mass = builder.get_attribute("water mass")
super().__init__(builder, name="volume", dependencies=(self.water_mass,))

def recalculate(self):
self.particulator.backend.volume_of_water_mass(self.data, self.water_mass.get())
4 changes: 2 additions & 2 deletions PySDM/backends/impl_common/freezing_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


class SingularAttributes(
namedtuple("SingularAttributes", ("freezing_temperature", "wet_volume"))
namedtuple("SingularAttributes", ("freezing_temperature", "water_mass"))
):
"""groups attributes required in singular regime"""

__slots__ = ()


class TimeDependentAttributes(
namedtuple("TimeDependentAttributes", ("immersed_surface_area", "wet_volume"))
namedtuple("TimeDependentAttributes", ("immersed_surface_area", "water_mass"))
):
"""groups attributes required in time-dependent regime"""

Expand Down
Loading

0 comments on commit 10a05b1

Please sign in to comment.