mythos.observables.wlc ====================== .. py:module:: mythos.observables.wlc .. autoapi-nested-parse:: Utility functions for computing worm-like chain (WLC) fit. Functions --------- .. autoapisummary:: mythos.observables.wlc.coth mythos.observables.wlc.calculate_extension mythos.observables.wlc.loss mythos.observables.wlc.fit_wlc Module Contents --------------- .. py:function:: coth(x: mythos.utils.types.ARR_OR_SCALAR) -> mythos.utils.types.ARR_OR_SCALAR Hyperbolic cotangent function. .. py:function:: calculate_extension(force: mythos.utils.types.ARR_OR_SCALAR, l0: mythos.utils.types.ARR_OR_SCALAR, lp: mythos.utils.types.ARR_OR_SCALAR, k: mythos.utils.types.ARR_OR_SCALAR, kT: float) -> mythos.utils.types.ARR_OR_SCALAR Computes the extension under a specified force under the wormlike chain (WLC) model. Via the model of Odijk, the extension of an extensible wormlike chain (WLC) under a force F can be computed as .. math:: x = L_0 \left (1 + \frac{F}{K} - \frac{kT}{2F} [1 + y\coth y] \right) where .. math:: y = \left( \frac{FL_0^2}{L_p kT} \right)^{1/2} where `L_0` is the contour length and `L_p` is the persistence length. This function computes implements this model for computing the extension. :param force: the force applied to the duplex :type force: jd_types.ARR_OR_SCALAR :param l0: the contour length :type l0: jd_types.ARR_OR_SCALAR :param lp: the persistence length :type lp: jd_types.ARR_OR_SCALAR :param k: the extensional modulus :type k: jd_types.ARR_OR_SCALAR :param kT: the temperature :type kT: float :returns: the predicted extension :rtype: jd_types.ARR_OR_SCALAR .. py:function:: loss(coeffs: jax.numpy.ndarray, extensions: jax.numpy.ndarray, forces: jax.numpy.ndarray, kT: float) -> jax.numpy.ndarray An objective function for the WLC model compatible with JAX solvers. :param coeffs: The parameters of the WLC model, ordered as [L_0, L_p, K] :type coeffs: jnp.ndarray :param extensions: The measured extensions (via simulation) to which we are fitting the model :type extensions: jnp.ndarray :param forces: The forces under which the extensions were measured :type forces: jnp.ndarray :param kT: the temperature :type kT: float :returns: the residual for each measured extension :rtype: jnp.ndarray .. py:function:: fit_wlc(extensions: jax.numpy.ndarray, forces: jax.numpy.ndarray, init_guess: jax.numpy.ndarray, kT: float, *, implicit_diff: bool = True) -> jax.numpy.ndarray Fit the WLC model via nonlinear least squares given a set of forces and measured extensions. :param extensions: The measured extensions (via simulation) to which we are fitting the model :type extensions: jnp.ndarray :param forces: The forces under which the extensions were measured :type forces: jnp.ndarray :param init_guess: An initial guess for the parameters of the WLC model, ordered as [L_0, L_p, K] :type init_guess: jnp.ndarray :param kT: the temperature :type kT: float :param implicit_diff: Whether or not to use implicit differentiation for the numerical solver :type implicit_diff: bool :returns: the fit parameters of the WLC model, ordered as [L_0, L_p, K] :rtype: jnp.ndarray