MCPcopy Create free account
hub / github.com/NanoComp/meep / test_transform

Method test_transform

python/tests/test_geom.py:385–429  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

383 check_warnings(sim)
384
385 def test_transform(self):
386
387 e_sus = [
388 mp.LorentzianSusceptibility(
389 sigma_diag=mp.Vector3(1, 2, 3), sigma_offdiag=mp.Vector3(12, 13, 14)
390 ),
391 mp.DrudeSusceptibility(
392 sigma_diag=mp.Vector3(1, 2, 3), sigma_offdiag=mp.Vector3(12, 13, 14)
393 ),
394 ]
395
396 mat = mp.Medium(
397 epsilon_diag=mp.Vector3(1, 2, 3),
398 epsilon_offdiag=mp.Vector3(12, 13, 14),
399 E_susceptibilities=e_sus,
400 )
401
402 rot_angle = math.radians(23.9)
403 rot_matrix = mp.Matrix(
404 mp.Vector3(math.cos(rot_angle), math.sin(rot_angle), 0),
405 mp.Vector3(-math.sin(rot_angle), math.cos(rot_angle), 0),
406 mp.Vector3(0, 0, 1),
407 )
408 mat.transform(rot_matrix)
409
410 expected_diag = mp.Vector3(-7.72552, 10.72552, 3)
411 expected_offdiag = mp.Vector3(7.69024, 6.21332, 18.06640)
412
413 self.assertTrue(mat.epsilon_diag.close(expected_diag, tol=4))
414 self.assertTrue(mat.epsilon_offdiag.close(expected_offdiag, tol=4))
415 self.assertEqual(mat.mu_diag, mp.Vector3(1, 1, 1))
416 self.assertEqual(mat.mu_offdiag, mp.Vector3())
417 self.assertEqual(len(mat.E_susceptibilities), 2)
418 self.assertTrue(
419 mat.E_susceptibilities[0].sigma_diag.close(expected_diag, tol=4)
420 )
421 self.assertTrue(
422 mat.E_susceptibilities[0].sigma_offdiag.close(expected_offdiag, tol=4)
423 )
424 self.assertTrue(
425 mat.E_susceptibilities[1].sigma_diag.close(expected_diag, tol=4)
426 )
427 self.assertTrue(
428 mat.E_susceptibilities[1].sigma_offdiag.close(expected_offdiag, tol=4)
429 )
430
431
432class TestVector3(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

transformMethod · 0.95
closeMethod · 0.80

Tested by

no test coverage detected