Skip to content

SVD Call Fail / Initial State Checks #118

@piperfw

Description

@piperfw

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtestingTest cases are needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions