:mod:`atsim.potentials.spline` ============================== .. py:module:: atsim.potentials.spline Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: atsim.potentials.spline.Spline_Point atsim.potentials.spline.Exp_Spline atsim.potentials.spline.Buck4_Spline atsim.potentials.spline.Custom_SplinePotential atsim.potentials.spline.SplinePotential atsim.potentials.spline.Buck4_SplinePotential Functions ~~~~~~~~~ .. autoapisummary:: atsim.potentials.spline.gradient .. function:: gradient(func, h=1e-06) Function wrapper that returns derivative of func. If the callable, `func` provides a `.deriv(r)` method this will be used to evaluate the derivative of the function, if not the returned function will use num_deriv() in gradient evaluation. If the callable additionally provides a `.deriv2(r)` method, representing its second derivative, the function returned by this routine will have a `deriv()` method which will delegate to func.deriv2() when called. By providing .deriv() and .deriv2() on the `func` callable analytical descriptions of a potential's first and second derivatives may be specified. :param func: Function to be wrapped :param h: Step size used when performing numerical differentiation :return: Function that returns derivative of func .. data:: polynomial .. data:: exp_spline .. py:class:: Spline_Point(potential_function, r) Bases: :class:`object` Class for the attachment and detachment points of potential objects and region to be splined .. attribute:: potential_function Potential function .. attribute:: r Value at which splining takes place .. attribute:: v Value of `potential_function` at `r` .. attribute:: deriv First derivative of `potential_function`: dv/dr(r) .. attribute:: deriv2 Second derivative of `potential_function`: d2v/dr^2(r) .. attribute:: deriv_callable .. attribute:: deriv2_callable .. py:class:: Exp_Spline(detach_point, attach_point) Bases: :class:`object` Class for represention splines of the form: .. math:: U(r_{ij}) = \exp \left( B_0 + B_1 r_{ij} + B_2 r_{ij}^2 + B_3 r_{ij}^3 + B_4 r_{ij}^4 + B_5 r_{ij}^5 \right) + C The spline coefficients :math:`B_{0...5}` and `C` can be obtained using the :meth:`~atsim.potentials.Exp_Spline.spline_coefficients` property. .. attribute:: detach_point Spline_Point giving start of splined region .. attribute:: attach_point Spline_Point giving end of splined region .. attribute:: spline_coefficients Coefficients for spline_function .. method:: __call__(self, r) .. method:: deriv(self, r) .. method:: deriv2(self, r) .. py:class:: Buck4_Spline(detach_point, attach_point, r_min) Bases: :class:`object` Class for representing the splined part of the four ranged Buckingham potential. Between the detachment point and `r_min` this is a 5th order polynomial: .. math:: U(r_{ij}) = A_0 + A_1 r_{ij} + A_2 r_{ij}^2 + A_3 r_{ij}^3 + A_4 r_{ij}^4 + A_5 r_{ij}^5 and between `r_min` and the re-attachment point a 3rd order spline is used: .. math:: U(r_{ij}) = B0 + B_1 r_{ij} + B_2 r_{ij}^2 + B_3 r_{ij}^3 The spline coefficients :math:`A_{0..5}` and :math:`B_{0..3}` are solved such that the the spline values match with the potential functions at the detach and re-attachment points and r_min. They are continuous in their first and second derivatives across these points and where the two splines meet at `r_min`. Finally, the derivative at `r_min` is set to be 0 with the aim of creating a minimum. .. attribute:: detach_point Spline_Point giving start of splined region .. attribute:: attach_point Spline_Point giving end of splined region .. attribute:: r_min Position of minimum .. attribute:: spline_coefficients Spline coefficients as list of form [A_0, A_1, A_2, A_3, A_4, A_5, B_0, B_1, B_2, B_3] .. attribute:: spline5 Callable (atsim.potentials.potentialfunctions.polynomial) object representing the fifth order section of the buck4 spline - between `detach_point` and `r_min` .. attribute:: spline3 Callable (atsim.potentials.potentialfunctions.polynomial) object representing the fifth order section of the buck4 spline - between `detach_point` and `r_min` .. method:: __call__(self, r) .. method:: deriv(self, r) .. method:: deriv2(self, r) .. py:class:: Custom_SplinePotential(spline) Bases: :class:`object` Callable to allow splining of one potential to another .. attribute:: startPotential :return: Function defining potential for separations < ``detachmentX`` .. attribute:: endPotential :return: Function defining potential for separations > ``attachmentX`` .. attribute:: interpolationFunction :return: Spline object connecting startPotential and endPotential for separations ``detachmentX`` < rij < ``attachmentX`` .. attribute:: detachmentX :return: Point at which spline should start .. attribute:: attachmentX :return: Point at which spline should end .. attribute:: splineCoefficients :return: Tuple containing the seven coefficients of the spline polynomial .. method:: __call__(self, rij) :param rij: separation at which to evaluate splined potential :return: spline value .. py:class:: SplinePotential(startPotential, endPotential, detachmentX, attachmentX) Bases: :class:`atsim.potentials.spline.Custom_SplinePotential` Callable to allow splining of one potential to another using an exponential spline .. py:class:: Buck4_SplinePotential(startPotential, endPotential, detachmentX, attachmentX, r_min) Bases: :class:`atsim.potentials.spline.Custom_SplinePotential` Callable to allow splining of one potential to another using the Buck4 spline type