Skip to content

Commit

Permalink
recent bug when running model with a single snowpack
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainp committed Dec 2, 2020
1 parent 2fbbc6f commit 1bc69e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion smrt/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def prepare_simulations(self, sensor, snowpack, snowpack_dimension):
if snowpack_dimension[1] is None:
snowpack_dimension = snowpack_dimension[0], range(len(snowpack))

if len(snowpack) != len(snowpack_dimension[1]):
if (snowpack_dimension is not None) and (len(snowpack) != len(snowpack_dimension[1])):
raise SMRTError("The list of snowpacks must have the same length as the snowpack_dimension")

if isinstance(snowpack_dimension, tuple) and not isinstance(snowpack_dimension[0], str):
Expand Down
5 changes: 2 additions & 3 deletions smrt/microstructure_model/sticky_hard_spheres.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def ft_autocorrelation_function(self, k):
# set limit value at k=0 manually, Eq. 33, LP2015
# zerok = np.isclose(X, 0)
# Ctilde[zerok] = (n * vd**2 / (phi_2 / (1-phi_2) * ((1 - t*phi_2 + 3 * phi_2 / (1 - phi_2)) + (3 - t * (1 - phi_2))) + 1)**2)
Ctilde[zerok] = (phi_2 * vd / (phi_2 / (1-phi_2) * ((1 - t*phi_2 + 3 * phi_2 / (1 - phi_2)) + (3 - t * (1 - phi_2))) + 1)**2)
Ctilde[zerok] = (phi_2 * vd / (phi_2 / (1 - phi_2) * ((1 - t * phi_2 + 3 * phi_2 / (1 - phi_2)) + (3 - t * (1 - phi_2))) + 1)**2)

return Ctilde

Expand All @@ -133,8 +133,7 @@ def compute_t(self):
c = (1 + f / 2) / (1 - f)**2

discr2 = b**2 - 4 * a * c
# TODO Ghi: convert the conditions to be numpy friendly. Currently, only work with scalar
if discr2 < 0:
if np.any(discr2 < 0):
raise SMRTError("negative discriminant")

discr = np.sqrt(discr2)
Expand Down

0 comments on commit 1bc69e5

Please sign in to comment.