Skip to content

Commit

Permalink
use vectorbasis instead of three individual bases for the poynting ve…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
HelgeGehring committed Jan 10, 2024
1 parent 98cb853 commit 9f0397a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions femwell/maxwell/waveguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,34 @@ def poynting(self):
(Hx, Hy), Hz = self.basis.interpolate(self.H)

# New basis will be the discontinuous variant used by the solved Ez-field
poynting_basis = self.basis.with_element(ElementDG(self.basis.elem.elems[1]))
poynting_basis = self.basis.with_element(
ElementVector(ElementDG(self.basis.elem.elems[1]), 3)
)

# Calculation of the Poynting vector
Px = Ey * Hz - Ez * Hy
Py = Ez * Hx - Ex * Hz
Pz = Ex * Hy - Ey * Hx

# Projection of the Poynting vector on the new basis
Px_proj = poynting_basis.project(Px, dtype=np.complex64)
Py_proj = poynting_basis.project(Py, dtype=np.complex64)
Pz_proj = poynting_basis.project(Pz, dtype=np.complex64)
P_proj = poynting_basis.project(np.stack([Px, Py, Pz], axis=0), dtype=np.complex64)

return poynting_basis, np.array([Px_proj, Py_proj, Pz_proj])
return poynting_basis, P_proj

@cached_property
def Px(self):
basis, _P = self.poynting
return basis, _P[0]
return basis.split_bases()[0], _P[basis.split_indices()[0]]

@cached_property
def Py(self):
basis, _P = self.poynting
return basis, _P[1]
return basis.split_bases()[1], _P[basis.split_indices()[1]]

@cached_property
def Pz(self):
basis, _P = self.poynting
return basis, _P[2]
return basis.split_bases()[2], _P[basis.split_indices()[2]]

@cached_property
def te_fraction(self):
Expand Down

0 comments on commit 9f0397a

Please sign in to comment.