Skip to content

Commit

Permalink
Renamed parallel direction to poloidal in SOLPSMesh to match SOLPS no…
Browse files Browse the repository at this point in the history
…tations.
  • Loading branch information
vsnever committed Sep 7, 2020
1 parent 9b0e9c1 commit b840d3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions cherab/solps/mesh_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def __init__(self, r, z, vol):

self.vessel = None

# Calculating parallel basis vector
self._parallel_basis_vector = np.zeros((self._nx, self._ny, 2))
# Calculating poloidal basis vector
self._poloidal_basis_vector = np.zeros((self._nx, self._ny, 2))
vec_r = r[:, :, 1] - r[:, :, 0]
vec_z = z[:, :, 1] - z[:, :, 0]
vec_magn = np.sqrt(vec_r**2 + vec_z**2)
self._parallel_basis_vector[:, :, 0] = vec_r / vec_magn
self._parallel_basis_vector[:, :, 1] = vec_z / vec_magn
self._poloidal_basis_vector[:, :, 0] = vec_r / vec_magn
self._poloidal_basis_vector[:, :, 1] = vec_z / vec_magn

# Calculating radial basis vector
self._radial_basis_vector = np.zeros((self._nx, self._ny, 2))
Expand All @@ -83,14 +83,14 @@ def __init__(self, r, z, vol):
self._radial_basis_vector[:, :, 1] = vec_z / vec_magn

# For convertion from Cartesian to poloidal
self._inv_det = 1. / (self._parallel_basis_vector[:, :, 0] * self._radial_basis_vector[:, :, 1] -
self._parallel_basis_vector[:, :, 1] * self._radial_basis_vector[:, :, 0])
self._inv_det = 1. / (self._poloidal_basis_vector[:, :, 0] * self._radial_basis_vector[:, :, 1] -
self._poloidal_basis_vector[:, :, 1] * self._radial_basis_vector[:, :, 0])

# Test for basis vector calculation
# plt.quiver(self._cr[:, 0], self._cz[:, 0], self._radial_basis_vector[:, 0, 0], self._radial_basis_vector[:, 0, 1], color='k')
# plt.quiver(self._cr[:, 0], self._cz[:, 0], self._parallel_basis_vector[:, 0, 0], self._parallel_basis_vector[:, 0, 1], color='r')
# plt.quiver(self._cr[:, 0], self._cz[:, 0], self._poloidal_basis_vector[:, 0, 0], self._poloidal_basis_vector[:, 0, 1], color='r')
# plt.quiver(self._cr[:, -1], self._cz[:, -1], self._radial_basis_vector[:, -1, 0], self._radial_basis_vector[:, -1, 1], color='k')
# plt.quiver(self._cr[:, -1], self._cz[:, -1], self._parallel_basis_vector[:, -1, 0], self._parallel_basis_vector[:, -1, 1], color='r')
# plt.quiver(self._cr[:, -1], self._cz[:, -1], self._poloidal_basis_vector[:, -1, 0], self._poloidal_basis_vector[:, -1, 1], color='r')
# plt.gca().set_aspect('equal')
# plt.show()

Expand Down Expand Up @@ -187,26 +187,26 @@ def triangles(self):
return self._triangles

@property
def parallel_basis_vector(self):
def poloidal_basis_vector(self):
"""
Array of 2D parallel basis vectors for grid cells.
Array of 2D poloidal basis vectors for grid cells.
For each cell there is a parallel and radial basis vector.
For each cell there is a poloidal and radial basis vector.
Any vector on the poloidal grid can be converted to cartesian with the following transformation.
bx = (p_x r_x) ( b_p )
by (p_y r_y) ( b_r )
:return: ndarray with shape (nx, ny, 2).
"""
return self._parallel_basis_vector
return self._poloidal_basis_vector

@property
def radial_basis_vector(self):
"""
Array of 2D radial basis vectors for grid cells.
For each cell there is a parallel and radial basis vector.
For each cell there is a poloidal and radial basis vector.
Any vector on the poloidal grid can be converted to cartesian with the following transformation.
bx = (p_x r_x) ( b_p )
Expand Down Expand Up @@ -248,13 +248,13 @@ def to_cartesian(self, vec_pol):
"""
Converts the 2D vector defined on mesh from poloidal to cartesian coordinates.
:param ndarray vec_pol: Array of 2D vector with with shape (nx, ny, 2).
[:, :, 0] - parallel component, [:, :, 1] - radial component
[:, :, 0] - poloidal component, [:, :, 1] - radial component
:return: ndarray with shape (nx, ny, 2)
"""
vec_cart = np.zeros((self._nx, self._ny, 2))
vec_cart[:, :, 0] = self._parallel_basis_vector[:, :, 0] * vec_pol[:, :, 0] + self._radial_basis_vector[:, :, 0] * vec_pol[:, :, 1]
vec_cart[:, :, 1] = self._parallel_basis_vector[:, :, 1] * vec_pol[:, :, 0] + self._radial_basis_vector[:, :, 1] * vec_pol[:, :, 1]
vec_cart[:, :, 0] = self._poloidal_basis_vector[:, :, 0] * vec_pol[:, :, 0] + self._radial_basis_vector[:, :, 0] * vec_pol[:, :, 1]
vec_cart[:, :, 1] = self._poloidal_basis_vector[:, :, 1] * vec_pol[:, :, 0] + self._radial_basis_vector[:, :, 1] * vec_pol[:, :, 1]

return vec_cart

Expand All @@ -269,8 +269,8 @@ def to_poloidal(self, vec_cart):
vec_pol = np.zeros((self._nx, self._ny, 2))
vec_pol[:, :, 0] = self._inv_det * (self._radial_basis_vector[:, :, 1] * vec_cart[:, :, 0] -
self._radial_basis_vector[:, :, 0] * vec_cart[:, :, 1])
vec_pol[:, :, 1] = self._inv_det * (self._parallel_basis_vector[:, :, 0] * vec_cart[:, :, 1] -
self._parallel_basis_vector[:, :, 1] * vec_cart[:, :, 0])
vec_pol[:, :, 1] = self._inv_det * (self._poloidal_basis_vector[:, :, 0] * vec_cart[:, :, 1] -
self._poloidal_basis_vector[:, :, 1] * vec_cart[:, :, 0])

return vec_pol

Expand Down
2 changes: 1 addition & 1 deletion cherab/solps/solps_plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def total_radiation_volume(self):
@property
def b_field(self):
"""
Magnetic B field at each mesh cell in mesh cell coordinates (b_parallel, b_radial, b_toroidal).
Magnetic B field at each mesh cell in mesh cell coordinates (b_poloidal, b_radial, b_toroidal).
"""
if self._b_field_vectors is None:
raise RuntimeError("Magnetic field not available for this simulation.")
Expand Down

0 comments on commit b840d3f

Please sign in to comment.