Skip to content

Commit

Permalink
Raise an error if ice density is calculated as negative (#8)
Browse files Browse the repository at this point in the history
* raises an error if ice density is negative (for example due to porosity > 1) and fixed porosity documentation from percent to fractional
  • Loading branch information
robbiemallett committed Jun 16, 2020
1 parent a2665d8 commit 9d222f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions smrt/inputs/make_medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def make_ice_column(ice_type,
:param salinity: salinity of ice/water in kg/kg (see PSU constant in smrt module). Default is 0. If neither salinity nor brine_volume_fraction are given, the ice column is considered to consist of fresh water ice.
:param brine_volume_fraction: brine / liquid water fraction in sea ice, optional parameter, if not given brine volume fraction is calculated from temperature and salinity in ~.smrt.permittivity.brine_volume_fraction
:param density: density of ice layer in kg m :sup:`-3`
:param porosity: porosity of ice layer (in %). Default is 0.
:param porosity: porosity of ice layer (0 - 1). Default is 0.
:param add_water_substrate: Adds a substrate made of water below the ice column.
Possible arguments are True (default) or False. If True looks for ice_type to determine if a saline or fresh water layer is added and/or uses the
optional arguments 'water_temperature', 'water_salinity' of the water substrate.
Expand Down Expand Up @@ -479,6 +479,10 @@ def bulk_ice_density(temperature, salinity, porosity):

# Density of mixture:
rho = (1. - porosity) * (rho_ice * F1 / (F1 - rho_ice * salinity * PSU**-1 * F2)) * 1e3 # in kg/m3 (eq. 15, C&W, 1983)

if rho < 0:
raise SMRTError("Ice density may not be negative.")

return rho


Expand Down Expand Up @@ -599,4 +603,4 @@ def compute_thickness_from_z(z):
else:
raise SMRTError("The z argument is not sorted")

return np.diff(z)
return np.diff(z)

0 comments on commit 9d222f4

Please sign in to comment.