numpy - Solve ode in python with complex matrix as initial value -
I have a von Neumann equation that looks: dr / dt = - i [h, r] < / Em>, where square of r and h complex numbers are matrix and i need to find r (t) to use Python scripts.
Is there a standart tool for integrating such equations?
When I was solving another solution as a starting value with a vector, such as the equation of Shradingger: dy / dt = - Ihy , I get the following error by trying to use the same function for the SPP.integrate.ode function ('zvode'), but for Von Newman equation:
** Native / Integrated / _ode.py: 869: UserWarning: zvode: Invalid input detected LENZW (= I1) (see printed message.) ZVODE-- ZWORK length is required, LZW (= I2) self.messages .g Et (istate, 'unexpected istate =% s'% istate)) is more in the above message, I1 = 72 I2 = 24 **
Here is the code:
<0> def integrated (r, t0, t1, dt): e = linspace (t0, t1, (t1 - t0) / dt + 10) g = linspace (t0, t1, (t1 - t0) / dt + 10) U = linspace (t0, t1, (t1 - t0) / dt + 10) while r. Successful () and RT & lt; T1: RNETGrite (RT + DT) E [RT / DT] = ABB (RI [0] [0]) ** 2G [RT / DT] = ABB (RI [1] [1]) ** 2 [RT / DT] = ABS (RE [2] [2]) ** 2 Return E, G, U # Von Newman Def Write-Part of Equation (T, RO): Hamiltonian = (H / 2) * Aray [[Delta, omega_s, omega_p / 2.0 * sin (t * w_p)], [omega_s, 0.0, 0.0], [omega_p / 2.0 * sin (t * w_p), 0.0, 0.0]], dtype = complex128 return ( Dot (row, hamiltonian)) / (1j * h) def create_integrator (): r = psd (right_part) .set_integrator ('zvode', method = 'bdf', with_jacobian = false) psi_init = Array ([[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], dtype = complex128) t0 = 0 r.set_initial_value (psi_init, t0) return r, t0 def main () : R, t0 = create_integrator () t1 = 10 ** -6 dt = 10 ** -11e, g, u = integrated (r, t, t1, dt) main ()
I have said that it can create a cover of the Andell complex matrix equation such as this. For other questions related to the matrix differential equation, see.
Here is a simplified version of your code that shows how you can use it. (For simplicity, I am getting rid of most constants from your example).
Sol is a complex numerical array with the form
(101, 3, 3)
, holding row (t)
is the first index time index, and Second two in Dex are 3x3 matrix.
Comments
Post a Comment