diff --git a/blobmodel/blobs.py b/blobmodel/blobs.py index 3b62ea1..f5a67b5 100644 --- a/blobmodel/blobs.py +++ b/blobmodel/blobs.py @@ -156,7 +156,7 @@ def _single_blob( def _drain(self, t: NDArray) -> NDArray: if isinstance(self.t_drain, (int, float)): - return np.exp(-(t - self.t_init) / self.t_drain) + return np.exp(-(t - self.t_init) / float(self.t_drain)) return np.exp(-(t - self.t_init) / self.t_drain[np.newaxis, :, np.newaxis]) def _propagation_direction_shape( diff --git a/tests/test_drain.py b/tests/test_drain.py new file mode 100644 index 0000000..bb5323c --- /dev/null +++ b/tests/test_drain.py @@ -0,0 +1,30 @@ +from blobmodel import Blob, BlobShapeImpl +import numpy as np + + +def test_high_t_drain(): + blob_sp = Blob( + blob_id=0, + blob_shape=BlobShapeImpl("gauss"), + amplitude=1, + width_prop=1, + width_perp=1, + velocity_x=1, + velocity_y=1, + pos_x=0, + pos_y=6, + t_init=0, + t_drain=10**100, + ) + + x = 0 + y = 0 + times = np.arange(1, 5, 0.01) + + mesh_x, mesh_y, mesh_t = np.meshgrid(x, y, times) + blob_values = blob_sp.discretize_blob( + x=mesh_x, y=mesh_y, t=mesh_t, periodic_y=False, Ly=10 + ) + + +test_high_t_drain()