Esempio n. 1
0
 def test_nonzero_unitary_dynamics(self):
     x1 = (1., 2.)
     x2 = (10., 20.)
     grid = gr.CartesianGrid((x1, x2))
     rhoi = la.CartesianSpinOperator((0.5, 0., 0., 0.))
     rhox = la.CartesianSpinOperator((0.5, 0.5, 0., 0.))
     rhoy = la.CartesianSpinOperator((0.5, 0., 0.5, 0.))
     rhoz = la.CartesianSpinOperator((0.5, 0., 0., 0.5))
     rhos = np.array([[rhoi, rhox], [rhoy, rhoz]])
     rho_grid = gr.GridData(rhos, grid)
     rhoidot_expected = 1 / hbar * la.CartesianSpinOperator((0., 0., 0., 0.))
     rhoxdot_expected = 1 / hbar * la.CartesianSpinOperator((0., 0., 1., 0.))
     rhoydot_expected = 1 / hbar * la.CartesianSpinOperator((0., -1., 0., 0.))
     rhozdot_expected = 1 / hbar * la.CartesianSpinOperator((0., 0., 0., 0.))
     rhodots_expected = np.array([[rhoidot_expected, rhoxdot_expected], [rhoydot_expected, rhozdot_expected]])
     rhodot_expected_grid = rho_grid.like(rhodots_expected)
     ham = la.CartesianSpinOperator((0, 0, 0, 1))
     rhodots_calc_grid = grid_unitary_derivative(rho_grid, ham)
     self.assertEqual(rhodot_expected_grid, rhodots_calc_grid)
Esempio n. 2
0
 def test_bloch_derivative_all(self):
     x1 = (1., 2.)
     x2 = (10., 20.)
     grid = gr.CartesianGrid((x1, x2))
     ham = la.CartesianSpinOperator((0, 0, 0, 1))
     rhoi = la.CartesianSpinOperator((0.5, 0., 0., 0.))
     rhox = la.CartesianSpinOperator((0.5, 0.5, 0., 0.))
     rhoy = la.CartesianSpinOperator((0.5, 0., 0.5, 0.))
     rhoz = la.CartesianSpinOperator((0.5, 0., 0., 0.5))
     rhos = np.array([[rhoi, rhox], [rhoy, rhoz]])
     rho_grid = gr.DataGrid(rhos, grid)
     uds = grid_unitary_derivative(rho_grid, ham)
     nuds = rho_grid.like(
         np.array([[
             la.CartesianSpinOperator((0., 0., 0., 0.)),
             la.CartesianSpinOperator((0., -0.5, 0., 0.))
         ],
                   [
                       la.CartesianSpinOperator((0., 0., -0.5, 0.)),
                       la.CartesianSpinOperator((0., 0., 0., 0.))
                   ]]))
     bd_es = uds + nuds
     bd_cs = grid_bloch_derivative(rho_grid, ham, gdiss=0., gdeph=1.)
     self.assertTrue(np.array_equal(bd_cs, bd_es))
Esempio n. 3
0
r = np.linspace(0.05, 0.5, res_r)
theta = np.linspace(0., np.pi, res_theta)
phi = np.linspace(0., 2 * np.pi, res_phi)
spher_grid = gr.SphericalGrid((r, theta, phi))

# Initialize Operators
cart_ops = gr.VectorGrid(cart_grid.cartesian,
                         cart_grid,
                         operator_type=la.CartesianSpinOperator)
spher_ops = gr.VectorGrid(spher_grid.mesh,
                          spher_grid,
                          operator_type=la.SphericalSpinOperator)

# Calculate Unitary Derivatives for Both Grids
cart_rho_dot = grid_unitary_derivative(cart_ops, ham)
spher_rho_dot = grid_bloch_derivative(spher_ops, ham, g_diss, g_diss, r_pump)

# Mask Cartesian Plots on the Bloch Sphere
x_g, y_g, z_g = cart_grid.mesh
bloch_mask = np.heaviside(1. - 2 * np.sqrt(x_g * x_g + y_g * y_g + z_g * z_g),
                          1)
bloch_mask = gr.DataGrid(bloch_mask, cart_grid)
cart_ops = cart_ops * bloch_mask
cart_rho_dot = cart_rho_dot * bloch_mask

# Set Formatting for Plots
quiver_kwargs = [
    {
        'linewidth': 2.,
        'colors': red