From 8d3182c06ca91e4d7ed71d4c13a95b0fa3f92ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20M=2E=20Popoff?= Date: Wed, 22 Nov 2023 11:16:29 +0100 Subject: [PATCH 1/4] add azimuthal_func to data --- pyMMF/solvers/radial_test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyMMF/solvers/radial_test.py b/pyMMF/solvers/radial_test.py index 8c85b51..e75b475 100755 --- a/pyMMF/solvers/radial_test.py +++ b/pyMMF/solvers/radial_test.py @@ -308,7 +308,12 @@ def radial_norm(t, r_vec, d): if save_func: modes.data.append( - {"radial_func": f_r, "r_max": r_max, "norm": norm_fr} + { + "radial_func": f_r, + "r_max": r_max, + "norm": norm_fr, + "azimuthal_func": lambda x: 0, + } ) else: for s, phi_func in zip([-1, 1], phi_funcs): @@ -327,7 +332,12 @@ def radial_norm(t, r_vec, d): if save_func: modes.data.append( - {"radial_func": f_r, "r_max": r_max, "norm": norm_fr} + { + "radial_func": f_r, + "r_max": r_max, + "norm": norm_fr, + "azimuthal_func": phi_func, + } ) m += 1 From 5197efc37e42ee1e73c20fd4d422568d87cd35ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20M=2E=20Popoff?= Date: Wed, 22 Nov 2023 11:34:38 +0100 Subject: [PATCH 2/4] decrease MIN_RADIUS_BC_DEFAULT --- pyMMF/solvers/radial_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyMMF/solvers/radial_test.py b/pyMMF/solvers/radial_test.py index e75b475..05bf893 100755 --- a/pyMMF/solvers/radial_test.py +++ b/pyMMF/solvers/radial_test.py @@ -18,7 +18,7 @@ logger = get_logger(__name__) -MIN_RADIUS_BC_DEFAULT = 1.5 +MIN_RADIUS_BC_DEFAULT = 0.5 CHANGE_BC_RADIUS_STEP_DEFAULT = 0.9 N_BETA_COARSE_DEFAULT = int(1e3) From 7190251e8f7f9bf8dba4e0cdb1bf662dc482154d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20M=2E=20Popoff?= Date: Wed, 22 Nov 2023 12:05:34 +0100 Subject: [PATCH 3/4] DEFAULT_DEGENERATE_MODE --- pyMMF/solvers/radial_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyMMF/solvers/radial_test.py b/pyMMF/solvers/radial_test.py index 05bf893..e5a28db 100755 --- a/pyMMF/solvers/radial_test.py +++ b/pyMMF/solvers/radial_test.py @@ -21,6 +21,7 @@ MIN_RADIUS_BC_DEFAULT = 0.5 CHANGE_BC_RADIUS_STEP_DEFAULT = 0.9 N_BETA_COARSE_DEFAULT = int(1e3) +DEFAULT_DEGENERATE_MODE = "sin" # choice for degenerate subspaces EXP_PHASE_FUNCS = [lambda x: np.exp(1j * x), lambda x: np.exp(-1j * x)] @@ -177,7 +178,7 @@ def binary_search(func, min_val, max_val, sign, beta_tol=1e-12, field_limit_tol= def solve_radial_test(indexProfile, wl, **options): t0 = time.time() - degenerate_mode = options.get("degenerate_mode", "sin") + degenerate_mode = options.get("degenerate_mode", DEFAULT_DEGENERATE_MODE) phi_funcs = EXP_PHASE_FUNCS if degenerate_mode == "exp" else SIN_PHASE_FUNCS min_radius_bc = options.get("min_radius_bc", MIN_RADIUS_BC_DEFAULT) change_bc_radius_step = options.get( From d11c9de9f2a3cac22742f57e60fead29c2e252cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20M=2E=20Popoff?= Date: Wed, 22 Nov 2023 16:39:34 +0100 Subject: [PATCH 4/4] big bug: forgot to put r_max to initial value in iteration --- pyMMF/solvers/radial_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyMMF/solvers/radial_test.py b/pyMMF/solvers/radial_test.py index e5a28db..b177e35 100755 --- a/pyMMF/solvers/radial_test.py +++ b/pyMMF/solvers/radial_test.py @@ -185,7 +185,7 @@ def solve_radial_test(indexProfile, wl, **options): "change_bc_radius_step", CHANGE_BC_RADIUS_STEP_DEFAULT ) N_beta_coarse = options.get("N_beta_coarse", N_BETA_COARSE_DEFAULT) - r_max = options.get("r_max", np.max(indexProfile.R)) + r_max0 = options.get("r_max", np.max(indexProfile.R)) dh = options.get("dh", indexProfile.areaSize / indexProfile.npoints) beta_tol = options.get("beta_tol", np.finfo(np.float64).eps) field_limit_tol = options.get("field_limit_tol", 1e-3) @@ -196,9 +196,9 @@ def solve_radial_test(indexProfile, wl, **options): n_func = indexProfile.radialFunc radius = indexProfile.a - r = np.arange(0, r_max + dh, dh).astype(np.float64) + r = np.arange(0, r_max0 + dh, dh).astype(np.float64) - beta_min = k0 * n_func(r_max) + beta_min = k0 * n_func(r_max0) beta_max = k0 * n_func(0) delta_betas = np.linspace(0, beta_max - beta_min, N_beta_coarse) @@ -230,6 +230,7 @@ def solve_radial_test(indexProfile, wl, **options): for l, iz in enumerate(zero_crossings): logger.info(f"Searching propagation constant for |l| = {l+1}") # find the beta value that satisfies the best the boundary condition + r_max = r_max0 while True: if r_max < min_radius_bc * radius: raise SmallRmaxError(r_max, min_radius_bc)