Skip to content

Commit

Permalink
calibration: expose surface drag models
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Oct 7, 2024
1 parent f0146bd commit 0c15377
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions lumicks/pylake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
density_of_water,
viscosity_of_water,
coupling_correction_2d,
surface_drag_correction,
)
from .force_calibration.power_spectrum_calibration import (
fit_power_spectrum,
Expand Down
32 changes: 32 additions & 0 deletions lumicks/pylake/force_calibration/calibration_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,38 @@ def viscosity_of_water(temperature, molarity_nacl=None, pressure=None):
return _poly((temperature + 273.15) / 300, bi, ai) * 1e-6


def surface_drag_correction(distance_to_surface, bead_diameter, axial=False):
"""Calculate a correction factor for the drag coefficient due to a nearby surface [1]_.
Parameters
----------
distance_to_surface : array_like | float
Distance from the center of the bead to the surface
bead_diameter : float
Bead diameter
axial : bool
Compute the correction factor for axial drag
References
----------
.. [1] Schäffer, E., Nørrelykke, S. F., & Howard, J. "Surface forces and drag coefficients of
microspheres near a plane surface measured with optical tweezers." Langmuir, 23(7), 3654-3665
(2007).
"""
distance_to_surface = np.asarray(distance_to_surface)

if np.any(distance_to_surface <= 0.5 * bead_diameter):
raise ValueError(
f"Bead is inside the surface. you specified a distance of {distance_to_surface}, while"
f"the bead radius is {bead_diameter / 2}"
)

if axial:
return brenner_axial(distance_to_surface, bead_diameter / 2)
else:
return faxen_factor(distance_to_surface, bead_diameter / 2)


def coupling_correction_2d(dx, dy, bead_diameter, is_y_oscillation=False, allow_rotation=True):
"""Calculates the coupling correction factor for a 2D problem.
Expand Down
6 changes: 3 additions & 3 deletions lumicks/pylake/force_calibration/detail/drag_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def faxen_factor(distance_to_surface_m, radius_m):
Parameters
----------
distance_to_surface_m : float
distance_to_surface_m : array_like | float
Distance from the center of the bead to the surface [m]
radius_m : float
Radius of the bead [m]
Expand All @@ -31,7 +31,7 @@ def faxen_factor(distance_to_surface_m, radius_m):


def brenner_axial(distance_to_surface_m, radius_m):
"""Brenner factor for lateral drag coefficient.
"""Brenner factor for axial drag coefficient.
This factor provides a correction to the drag force for a nearby wall.
Expand All @@ -41,7 +41,7 @@ def brenner_axial(distance_to_surface_m, radius_m):
Parameters
----------
distance_to_surface_m : float
distance_to_surface_m : array_like | float
Distance from the center of the bead to the surface [m]
radius_m : float
Radius of the bead [m]
Expand Down
11 changes: 11 additions & 0 deletions lumicks/pylake/force_calibration/tests/test_hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from lumicks.pylake.force_calibration.calibration_models import (
ActiveCalibrationModel,
PassiveCalibrationModel,
surface_drag_correction,
)
from lumicks.pylake.force_calibration.detail.drag_models import *
from lumicks.pylake.force_calibration.detail.power_models import g_diode
Expand Down Expand Up @@ -492,6 +493,11 @@ def test_faxen(bead_radius, result):
np.testing.assert_allclose(
faxen_factor(bead_radius + np.arange(40, 250, 80) * 1e-9, bead_radius), result
)
np.testing.assert_allclose(
surface_drag_correction(bead_radius + np.arange(40, 250, 80) * 1e-9, bead_radius),
result,
False,
)


@pytest.mark.parametrize(
Expand All @@ -505,6 +511,11 @@ def test_brenner(bead_radius, result):
np.testing.assert_allclose(
brenner_axial(bead_radius + np.arange(40, 250, 80) * 1e-9, bead_radius), result
)
np.testing.assert_allclose(
surface_drag_correction(bead_radius + np.arange(40, 250, 80) * 1e-9, bead_radius),
result,
True,
)


def test_near_surface_consistency():
Expand Down

0 comments on commit 0c15377

Please sign in to comment.