From 2ccb2d79fd50fabd603a34676319bf4c3b61c1f0 Mon Sep 17 00:00:00 2001 From: Robert Moerland Date: Thu, 14 Nov 2024 23:17:14 +0100 Subject: [PATCH] rearrange calculation of matrix terms --- src/lumicks/pyoptics/trapping/interface.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lumicks/pyoptics/trapping/interface.py b/src/lumicks/pyoptics/trapping/interface.py index a7f69ba..42e4dc7 100644 --- a/src/lumicks/pyoptics/trapping/interface.py +++ b/src/lumicks/pyoptics/trapping/interface.py @@ -111,17 +111,20 @@ def force_on_bead(bead_center: Tuple[float, float, float], num_threads: Optional Ex, Ey, Ez, Hx, Hy, Hz = external_fields_func(bead_center, True, True, True, num_threads) Te11 = np.atleast_2d(_eps * 0.5 * (np.abs(Ex) ** 2 - np.abs(Ey) ** 2 - np.abs(Ez) ** 2)) + Te22 = np.atleast_2d(_eps * 0.5 * (np.abs(Ey) ** 2 - np.abs(Ex) ** 2 - np.abs(Ez) ** 2)) + Te33 = np.atleast_2d(_eps * 0.5 * (np.abs(Ez) ** 2 - np.abs(Ey) ** 2 - np.abs(Ex) ** 2)) + Te12 = np.atleast_2d(_eps * np.real(Ex * np.conj(Ey))) Te13 = np.atleast_2d(_eps * np.real(Ex * np.conj(Ez))) - Te22 = np.atleast_2d(_eps * 0.5 * (np.abs(Ey) ** 2 - np.abs(Ex) ** 2 - np.abs(Ez) ** 2)) Te23 = np.atleast_2d(_eps * np.real(Ey * np.conj(Ez))) - Te33 = np.atleast_2d(_eps * 0.5 * (np.abs(Ez) ** 2 - np.abs(Ey) ** 2 - np.abs(Ex) ** 2)) + Th11 = np.atleast_2d(_mu * 0.5 * (np.abs(Hx) ** 2 - np.abs(Hy) ** 2 - np.abs(Hz) ** 2)) + Th22 = np.atleast_2d(_mu * 0.5 * (np.abs(Hy) ** 2 - np.abs(Hx) ** 2 - np.abs(Hz) ** 2)) + Th33 = np.atleast_2d(_mu * 0.5 * (np.abs(Hz) ** 2 - np.abs(Hy) ** 2 - np.abs(Hx) ** 2)) + Th12 = np.atleast_2d(_mu * np.real(Hx * np.conj(Hy))) Th13 = np.atleast_2d(_mu * np.real(Hx * np.conj(Hz))) - Th22 = np.atleast_2d(_mu * 0.5 * (np.abs(Hy) ** 2 - np.abs(Hx) ** 2 - np.abs(Hz) ** 2)) Th23 = np.atleast_2d(_mu * np.real(Hy * np.conj(Hz))) - Th33 = np.atleast_2d(_mu * 0.5 * (np.abs(Hz) ** 2 - np.abs(Hy) ** 2 - np.abs(Hx) ** 2)) T = np.empty((len(bead_center), x.size, 3, 3)) T[..., 0, 0] = Te11 + Th11