Transforms `epsilon`, `mu`, and `sigma` of any [susceptibilities](#susceptibility) by the 3×3 matrix `m`. If `m` is a [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix), then the principal axes of the susceptibilities are rotated by `m`. More generally
(self, m)
| 454 | return "Medium()" |
| 455 | |
| 456 | def transform(self, m): |
| 457 | """ |
| 458 | Transforms `epsilon`, `mu`, and `sigma` of any [susceptibilities](#susceptibility) |
| 459 | by the 3×3 matrix `m`. If `m` is a [rotation |
| 460 | matrix](https://en.wikipedia.org/wiki/Rotation_matrix), then the principal axes of |
| 461 | the susceptibilities are rotated by `m`. More generally, the susceptibilities χ |
| 462 | are transformed to MχMᵀ/|det M|, which corresponds to [transformation |
| 463 | optics](http://math.mit.edu/~stevenj/18.369/coordinate-transform.pdf) for an |
| 464 | arbitrary curvilinear coordinate transformation with Jacobian matrix M. The |
| 465 | absolute value of the determinant is to prevent inadvertent construction of |
| 466 | left-handed materials, which are [problematic in nondispersive |
| 467 | media](FAQ.md#why-does-my-simulation-diverge-if-0). |
| 468 | """ |
| 469 | eps = Matrix( |
| 470 | mp.Vector3( |
| 471 | self.epsilon_diag.x, self.epsilon_offdiag.x, self.epsilon_offdiag.y |
| 472 | ), |
| 473 | mp.Vector3( |
| 474 | self.epsilon_offdiag.x, self.epsilon_diag.y, self.epsilon_offdiag.z |
| 475 | ), |
| 476 | mp.Vector3( |
| 477 | self.epsilon_offdiag.y, self.epsilon_offdiag.z, self.epsilon_diag.z |
| 478 | ), |
| 479 | ) |
| 480 | mu = Matrix( |
| 481 | mp.Vector3(self.mu_diag.x, self.mu_offdiag.x, self.mu_offdiag.y), |
| 482 | mp.Vector3(self.mu_offdiag.x, self.mu_diag.y, self.mu_offdiag.z), |
| 483 | mp.Vector3(self.mu_offdiag.y, self.mu_offdiag.z, self.mu_diag.z), |
| 484 | ) |
| 485 | |
| 486 | new_eps = (m * eps * m.transpose()) / abs(m.determinant()) |
| 487 | new_mu = (m * mu * m.transpose()) / abs(m.determinant()) |
| 488 | self.epsilon_diag = mp.Vector3(new_eps.c1.x, new_eps.c2.y, new_eps.c3.z) |
| 489 | self.epsilon_offdiag = mp.Vector3(new_eps.c2.x, new_eps.c3.x, new_eps.c3.y) |
| 490 | self.mu_diag = mp.Vector3(new_mu.c1.x, new_mu.c2.y, new_mu.c3.z) |
| 491 | self.mu_offdiag = mp.Vector3(new_mu.c2.x, new_mu.c3.x, new_mu.c3.y) |
| 492 | |
| 493 | for s in self.E_susceptibilities: |
| 494 | s.transform(m) |
| 495 | |
| 496 | for s in self.H_susceptibilities: |
| 497 | s.transform(m) |
| 498 | |
| 499 | def rotate(self, axis, theta): |
| 500 | T = get_rotation_matrix(axis, theta) |