示例#1
0
 def test_spherical_radial_divergence(self):
     v_funct = (s_grid.mesh[0], np.zeros(s_grid.shape),
                np.zeros(s_grid.shape))
     vector_grid = gr.VectorGrid(v_funct,
                                 s_grid,
                                 operator_type=la.SphericalSpinOperator)
     expected_data = 3 * np.ones(s_grid.shape)
     data_grid = gr.DataGrid(expected_data, s_grid)
     self.assertAlmostEqual(data_grid, vector_grid.divergence())
示例#2
0
 def test_vector_grid_cartesian_vectors(self):
     ops = []
     for xx in r:
         for yy in t:
             for zz in p:
                 ops.append(la.SphericalSpinOperator((0, xx, yy, zz)))
     ops = np.reshape(ops, s_grid.shape)
     vector_grid = gr.VectorGrid(ops, s_grid)
     vectors = vector_grid.cartesian_vectors
     self.assertTrue(np.array_equal(vectors, s_grid.cartesian))
示例#3
0
 def test_spherical_gradient(self):
     funct = s_grid.mesh[0]
     data_grid = gr.DataGrid(funct, s_grid)
     ops = []
     for xx in r:
         for yy in t:
             for zz in p:
                 ops.append(la.SphericalSpinOperator((0, 1, 0, 0)))
     ops = np.reshape(ops, s_grid.shape)
     vector_grid = gr.VectorGrid(ops, s_grid)
     self.assertAlmostEqual(
         vector_grid, data_grid.gradient(la.SphericalSpinOperator, tuple))
示例#4
0
 def test_vector_grid_init_from_spherical_operator_mesh(self):
     ops = []
     for xx in r:
         for yy in t:
             for zz in p:
                 ops.append(la.SphericalSpinOperator((0, xx, yy, zz)))
     ops = np.reshape(ops, s_grid.shape)
     vector_grid = gr.VectorGrid(ops, s_grid)
     self.assertIs(vector_grid._operator_type, la.SphericalSpinOperator)
     self.assertIs(vector_grid._container_type, tuple)
     self.assertEqual(vector_grid._operator_dim, 4)
     self.assertTrue(np.array_equal(ops, vector_grid.data))
     self.assertEqual(vector_grid[0, 0, 0], (la.SphericalSpinOperator(
         (0, 0, 0, 0)), (0, 0, 0)))
示例#5
0
 def test_vector_grid_init_from_cartesian_operator_mesh(self):
     ops = []
     for xx in x:
         for yy in y:
             for zz in z:
                 ops.append(la.CartesianSpinOperator((0, xx, yy, zz)))
     ops = np.reshape(ops, c_grid.shape)
     vector_grid = gr.VectorGrid(ops, c_grid)
     self.assertIs(vector_grid._operator_type, la.CartesianSpinOperator)
     self.assertIs(vector_grid._container_type, tuple)
     self.assertEqual(vector_grid._operator_dim, 4)
     self.assertTrue(np.array_equal(ops, vector_grid.data))
     self.assertEqual(vector_grid[0, 0, 0], (la.CartesianSpinOperator(
         (0, -1, -1, -1)), (-1, -1, -1)))
示例#6
0
 def test_vector_grid_init_from_spherical_coordinate_mesh(self):
     ops_e = []
     for xx in r:
         for yy in t:
             for zz in p:
                 ops_e.append(la.SphericalSpinOperator((0, xx, yy, zz)))
     ops_e = np.reshape(ops_e, s_grid.shape)
     vector_grid = gr.VectorGrid(list(s_grid.mesh),
                                 s_grid,
                                 operator_type=la.SphericalSpinOperator)
     self.assertIs(vector_grid._operator_type, la.SphericalSpinOperator)
     self.assertIs(vector_grid._container_type, list)
     self.assertEqual(vector_grid._operator_dim, 4)
     self.assertTrue(np.array_equal(ops_e, vector_grid.data))
     self.assertEqual(vector_grid[0, 0, 0], (la.SphericalSpinOperator(
         (0, 0, 0, 0)), (0, 0, 0)))
示例#7
0
z = np.linspace(-0.5, 0.5, res_z)
cart_grid = gr.CartesianGrid((x, y, z))

# Make Spherical Grid
res_r = 5
res_theta = 5
res_phi = 5

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