The solver successfully reached the end of the integration interval.
The solver successfully reached the end of the integration interval.
The solver successfully reached the end of the integration interval.
The solver successfully reached the end of the integration interval.

Independent tests

zero Hamiltonian with identity unitary

zero_ham[source]

zero_ham(t)

zero_ham(3)
array([[0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j]])
zero_ham(3).dtype
dtype('complex128')
u0
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])

u_series, result = ihu(ham_func, u0, T, no_time_step_for_eval,)

The solver successfully reached the end of the integration interval.
u_series.shape
(2, 2, 100)
u_series[:, :, 0]
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])
u_series[:, :, -1]
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])
-1j*zero_ham(3)@u0
array([[0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j]])

zero Hamiltonian

zero_ham[source]

zero_ham(t)

zero_ham(3)
array([[0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j]])
zero_ham(3).dtype
dtype('complex128')
u0
array([[ 0.68822171+0.24596959j, -0.53173385+0.42791233j],
       [ 0.37819631+0.56817022j,  0.73034536-0.0273097j ]])

u_series, result = ihu(ham_func, u0, T, no_time_step_for_eval,)

The solver successfully reached the end of the integration interval.
u_series.shape
(2, 2, 100)
u_series[:, :, 0]
array([[ 0.68822171+0.24596959j, -0.53173385+0.42791233j],
       [ 0.37819631+0.56817022j,  0.73034536-0.0273097j ]])
u_series[:, :, -1]
array([[ 0.68822171+0.24596959j, -0.53173385+0.42791233j],
       [ 0.37819631+0.56817022j,  0.73034536-0.0273097j ]])
-1j*zero_ham(3)@u0
array([[0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j]])

Identity Hamiltonian

identity_ham[source]

identity_ham(t)

identity_ham(3)
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])
identity_ham(3).dtype
dtype('complex128')
u0
array([[0.93595888-0.35210932j, 0.        +0.j        ],
       [0.        +0.j        , 0.73122666-0.68213457j]])

u_series, result = ihu(ham_func, u0, T, no_time_step_for_eval,)

The solver successfully reached the end of the integration interval.
u_series.shape
(2, 2, 100)
u_series[:, :, 0]
array([[0.93595888-0.35210932j, 0.        +0.j        ],
       [0.        +0.j        , 0.73122666-0.68213457j]])
u_series[:, :, -1]
array([[0.60442674+0.79664107j, 0.        +0.j        ],
       [0.        +0.j        , 0.86234617+0.5062882j ]])
-1j*identity_ham(3)@u0
array([[-0.35210932-0.93595888j,  0.        +0.j        ],
       [ 0.        +0.j        , -0.68213457-0.73122666j]])

Sigma xyz Hamiltonian

Tests against mesolve of QuTiP

Mesolve part

len(mere_result.states)
20

ihu part

q_ham[source]

q_ham(t)

q_ham(2)
array([[0.        +0.j, 0.62831853+0.j],
       [0.62831853+0.j, 0.        +0.j]])
u0
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])

u_series, result = ihu(ham_func, u0, T, no_time_step_for_eval,)

The solver successfully reached the end of the integration interval.
u_series.shape
(2, 2, 20)

Transformations for comparison

psi0_ndarray
array([1.+0.j, 0.+0.j])
psi0_ndarray.shape
(2,)
upsi[:, 0]
array([1.+0.j, 0.+0.j])
mere_result.states[0]
Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\begin{equation*}\left(\begin{array}{*{11}c}1.0\\0.0\\\end{array}\right)\end{equation*}

Comparison


AssertionError Traceback (most recent call last)

<ipython-input-101-486ddf98e48b> in 1 for i in range(u_series.shape[-1]): ----> 2 assert_allclose(upsi[:, i], mere_result.states[i].full().ravel(), 3 rtol=1e-02, atol=1e-03)

[... skipping hidden 1 frame]

~/anaconda3/envs/nbdev/lib/python3.8/site-packages/numpy/testing/_private/utils.py in assert_array_compare(comparison, x, y, err_msg, verbose, header, precision, equal_nan, equal_inf) 838 verbose=verbose, header=header, 839 names=('x', 'y'), precision=precision) --> 840 raise AssertionError(msg) 841 except ValueError: 842 import traceback

AssertionError: Not equal to tolerance rtol=0.01, atol=0.001

Mismatched elements: 1 / 2 (50%) Max absolute difference: 0.00150303 Max relative difference: 1084.59125754 x: array([0.999917+0.j , 0. -0.001502j]) y: array([1.+0.0000e+00j, 0.+1.3858e-06j])

Fails for atol < 1e-02