Compare commits
2 Commits
5c3b3532a9
...
107c0fcd7e
Author | SHA1 | Date | |
---|---|---|---|
107c0fcd7e | |||
c3b6fd94a6 |
@ -26,6 +26,8 @@ def test_poynting_planes(sim: 'FDResult') -> None:
|
||||
# for dxa in dxg:
|
||||
# if not (dxa == sim.dxes[0][0][0]).all():
|
||||
# pytest.skip('test_poynting_planes skips nonuniform dxes')
|
||||
|
||||
# pick only the second point
|
||||
points = numpy.where(mask)
|
||||
mask[points[0][0], points[1][0], points[2][0]] = 0
|
||||
|
||||
@ -43,10 +45,14 @@ def test_poynting_planes(sim: 'FDResult') -> None:
|
||||
s[1, mask].sum(), -s[1, my].sum(),
|
||||
s[2, mask].sum(), -s[2, mz].sum()]
|
||||
|
||||
e_dot_j = sim.e * sim.j * sim.dxes[0][0][:, None, None] * sim.dxes[0][1][None, :, None] * sim.dxes[0][2][None, None, :]
|
||||
src_energy = -e_dot_j[:, mask].real / 2
|
||||
e_dot_j = sim.e * sim.j.conj()
|
||||
dv = (sim.dxes[0][0][:, None, None]
|
||||
* sim.dxes[0][1][None, :, None]
|
||||
* sim.dxes[0][2][None, None, :]
|
||||
)
|
||||
src_energy = -(e_dot_j.real * dv)[:, mask] / 2
|
||||
|
||||
assert_close(sum(planes), src_energy.sum())
|
||||
assert_close(sum(planes), src_energy.sum(), rtol=1e-6) # TODO improve energy calculation accuracy?
|
||||
|
||||
|
||||
#####################################
|
||||
@ -88,8 +94,8 @@ def j_distribution(
|
||||
if request.param == 'center':
|
||||
j[center_mask] = j_mag
|
||||
elif request.param == 'diag':
|
||||
j[numpy.roll(center_mask, [1, 1, 1], axis=(1, 2, 3))] = j_mag
|
||||
j[numpy.roll(center_mask, [-1, -1, -1], axis=(1, 2, 3))] = -1j * j_mag
|
||||
j[numpy.roll(center_mask, [1, 1, 1], axis=(1, 2, 3))] = (1 + 1j) * j_mag
|
||||
j[numpy.roll(center_mask, [-1, -1, -1], axis=(1, 2, 3))] = (1 - 1j) * j_mag
|
||||
yield j
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user