From 5b359808d8a0b8a2bc8385e7bba717095c3066c2 Mon Sep 17 00:00:00 2001 From: JoepVanlier Date: Mon, 14 Aug 2023 17:51:30 +0200 Subject: [PATCH] fdfit: switch twlc to rootfinding for performance At f_min = 0, numerical difficulties ensue. Considering that the model isn't valid in this range to begin with, we limit the minimum. --- lumicks/pylake/fitting/detail/model_implementation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lumicks/pylake/fitting/detail/model_implementation.py b/lumicks/pylake/fitting/detail/model_implementation.py index a6b33566c..c9f2b9980 100644 --- a/lumicks/pylake/fitting/detail/model_implementation.py +++ b/lumicks/pylake/fitting/detail/model_implementation.py @@ -725,7 +725,7 @@ def twlc_solve_force(d, Lp, Lc, St, C, g0, g1, Fc, kT=4.11): "Persistence length, contour length, stretch modulus and kT must be bigger than 0" ) - f_min = 0 + f_min = 1e-6 f_max = (-g0 + np.sqrt(St * C)) / g1 # Above this force the model loses its validity return invert_function_interpolation( @@ -735,6 +735,8 @@ def twlc_solve_force(d, Lp, Lc, St, C, g0, g1, Fc, kT=4.11): f_max, lambda f_trial: twlc_distance(f_trial, Lp, Lc, St, C, g0, g1, Fc, kT), lambda f_trial: twlc_distance_derivative(f_trial, Lp, Lc, St, C, g0, g1, Fc, kT), + dx=1e-2, + rootfinding=True, )