Exemplo n.º 1
0
 def potential_on_grid(self, r_grid, theta_grid, phi_grid):
     if self.external_field[0] == 0:
         return np.zeros_like(r_grid)
     F_r = np.ones_like(r_grid) * self.external_field[0]
     F_theta = np.ones_like(r_grid) * self.external_field[1]
     F_phi = np.ones_like(r_grid) * self.external_field[2]
     x, y, z = Vectors3D.spherical_to_cartesian(r_grid, theta_grid, phi_grid)
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, F_theta, F_phi)
     angles_grid = Vectors3D.angle_between_vectors((x, y, z), (F_x, F_y, F_z))
     return F_r * r_grid * np.cos(angles_grid)
Exemplo n.º 2
0
 def potential_on_grid(self, r_grid, theta_grid, phi_grid):
     if self.external_field[0] == 0:
         return np.zeros_like(r_grid)
     F_r = np.ones_like(r_grid) * self.external_field[0]
     F_theta = np.ones_like(r_grid) * self.external_field[1]
     F_phi = np.ones_like(r_grid) * self.external_field[2]
     x, y, z = Vectors3D.spherical_to_cartesian(r_grid, theta_grid, phi_grid)
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, F_theta, F_phi)
     angles_grid = Vectors3D.angle_between_vectors((x, y, z), (F_x, F_y, F_z))
     return F_r * r_grid * np.cos(angles_grid)
Exemplo n.º 3
0
 def field(self, r, theta, phi):
     r_grid, theta_grid, phi_grid = np.meshgrid(r, theta, phi)
     x_grid, y_grid, z_grid = Vectors3D.spherical_to_cartesian(r_grid, theta_grid, phi_grid)
     super_x = np.zeros_like(x_grid)
     super_y = np.zeros_like(y_grid)
     super_z = np.zeros_like(z_grid)
     for potential in self.potentials:
         F_r, F_theta, F_phi = potential.field(r, theta, phi)
         F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, F_theta, F_phi)
         super_x += F_x
         super_y += F_y
         super_z += F_z
     super_r, super_theta, super_phi = Vectors3D.cartesian_to_spherical(super_x, super_y, super_z)
     return super_r, super_theta, super_phi
Exemplo n.º 4
0
 def field(self, r, theta, phi):
     r_grid, theta_grid, phi_grid = np.meshgrid(r, theta, phi)
     x_grid, y_grid, z_grid = Vectors3D.spherical_to_cartesian(r_grid, theta_grid, phi_grid)
     super_x = np.zeros_like(x_grid)
     super_y = np.zeros_like(y_grid)
     super_z = np.zeros_like(z_grid)
     for potential in self.potentials:
         F_r, F_theta, F_phi = potential.field(r, theta, phi)
         F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, F_theta, F_phi)
         super_x += F_x
         super_y += F_y
         super_z += F_z
     super_r, super_theta, super_phi = Vectors3D.cartesian_to_spherical(super_x, super_y, super_z)
     return super_r, super_theta, super_phi
Exemplo n.º 5
0
 def field_cartesian(self, x, y, z):
     potential_sign = -1 if self.attractive else 1
     x_grid, y_grid, z_grid = np.meshgrid(x, y, z)
     r_grid, theta_grid, phi_grid = Vectors3D.cartesian_to_spherical(x_grid, y_grid, z_grid)
     F_r = -potential_sign * self.a / r_grid**2
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, theta_grid, phi_grid)
     return F_x, F_y, F_z
Exemplo n.º 6
0
 def field_cartesian(self, x, y, z):
     potential_sign = -1 if self.attractive else 1
     x_grid, y_grid, z_grid = np.meshgrid(x, y, z)
     r_grid, theta_grid, phi_grid = Vectors3D.cartesian_to_spherical(x_grid, y_grid, z_grid)
     F_r = -potential_sign * self.a / r_grid**2
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, theta_grid, phi_grid)
     return F_x, F_y, F_z
Exemplo n.º 7
0
 def field_cartesian(self, x, y, z):
     grid = np.ones((np.array(x).size, np.array(y).size, np.array(z).size), dtype=np.float)
     ex, ey, ez = Vectors3D.spherical_to_cartesian(self.external_field[0],
                                                   self.external_field[1],
                                                   self.external_field[2])
     F_x = grid * ex
     F_y = grid * ey
     F_z = grid * ez
     return F_x, F_y, F_z
Exemplo n.º 8
0
 def field_cartesian(self, x, y, z):
     grid = np.ones((np.array(x).size, np.array(y).size, np.array(z).size), dtype=np.float)
     ex, ey, ez = Vectors3D.spherical_to_cartesian(self.external_field[0],
                                                   self.external_field[1],
                                                   self.external_field[2])
     F_x = grid * ex
     F_y = grid * ey
     F_z = grid * ez
     return F_x, F_y, F_z
Exemplo n.º 9
0
 def field_cartesian(self, x, y, z):
     x_grid, y_grid, z_grid = np.meshgrid(x, y, z)
     r_grid, theta_grid, phi_grid = Vectors3D.cartesian_to_spherical(x_grid, y_grid, z_grid)
     F_r = self.a / r_grid
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, theta_grid, phi_grid)
     return F_x, F_y, F_z
Exemplo n.º 10
0
 def equation(r):
     field = self.field(r, theta, 0)
     field_x, field_y, field_z = Vectors3D.spherical_to_cartesian(field[0][0][0], field[1][0][0], field[2][0][0])
     r_x, r_y, r_z = Vectors3D.spherical_to_cartesian(r, theta, 0)
     F_r = field_x * r_x + field_y * r_y + field_z * r_z
     return F_r
Exemplo n.º 11
0
 def field_cartesian(self, x, y, z):
     x_grid, y_grid, z_grid = np.meshgrid(x, y, z)
     r_grid, theta_grid, phi_grid = Vectors3D.cartesian_to_spherical(x_grid, y_grid, z_grid)
     F_r = self.a / r_grid
     F_x, F_y, F_z = Vectors3D.spherical_to_cartesian(F_r, theta_grid, phi_grid)
     return F_x, F_y, F_z
Exemplo n.º 12
0
 def equation(r):
     field = self.field(r, theta, 0)
     field_x, field_y, field_z = Vectors3D.spherical_to_cartesian(field[0][0][0], field[1][0][0], field[2][0][0])
     r_x, r_y, r_z = Vectors3D.spherical_to_cartesian(r, theta, 0)
     F_r = field_x * r_x + field_y * r_y + field_z * r_z
     return F_r