-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Description
If you pass an initial state of all zeros to Tempo.compute the code fails with an IndexError in node_array.py in an SVD call, presumably because the matrix is rank 0.
I think we should raise an exception early and loudly to the user if initial state is zero rather than letting it propagate and returning a long stack-trace.
The main questions would be where to implement a check and how often e.g. in node_array.py every timestep or closer to the user interface for the initial state only.
I also noticed you can pass an ndarray of boolean values for the state. I suppose this is intentional?
MWE attached.
import numpy as np
import oqupy
# Raises IndexError
initial_state = np.zeros((2,2))
# Fine (but non-physical)
#initial_state = np.array([[0.1,0],[0,0]])
# Fine?
#initial_state = np.array([[True,False],[False,True]])
system = oqupy.System(np.eye(2))
correlations = oqupy.PowerLawSD(alpha=1, zeta=1, cutoff=1)
bath = oqupy.Bath(np.eye(2), correlations)
tempo_params = oqupy.TempoParameters(dt=0.1, epsrel=10**(-7))
tempo_sys = oqupy.Tempo(system,
bath,
tempo_params,
initial_state,
start_time=0.0)
tempo_sys.compute(end_time=1.0)