# [gmx-developers] Re: Cubic splines - again

Mathias PUETZ mpuetz at de.ibm.com
Tue Aug 22 12:32:42 CEST 2006

Hi,

the cubic spline function

spline_i (x) = a+b(x - x_i) + c (x - x_i)**2 + d (x - x_i)**3

has four variable coefficients: a,b,c,d.

For each table segment i you have four linear equations which determine
the coefficients for the spline function spline_i(x)

v(x_i) = spline_i(x_i)
v(x_i+1) = spline_i(x_i+1)
v''(x_i) = spline_i''(x_i)
v''(x_i+1) = spline_i''(x_i+1)

solving these equations for a,b,c,d gives exactly the spline formula you
are using.

Since you force v and v'' to be continous, v' (the forces) cannot be
continuous at x_i
unless v(x) itself is a polynomial function with a degree of less than 4,
which it typically isn't.
The error will be small in most cases, but it is noticable if you print
out the forces
calculated by your spline formula and the exact force function in the
vicinity of the x_i

I believe it would be more appropriate to enforce

v(x_i) = spline_i(x_i)
v(x_i+1) = spline_i(x_i+1)
v'(x_i) = spline_i'(x_i)
v'(x_i+1) = spline_i'(x_i+1)

which will give you slightly different spline coefficients, but guarantees
that both v(x) and v'(x)
will be continuous at x_i.

Viele Grüsse / Best regards,
Dr. Mathias Pütz

IT Specialist for Application Perfomance

Deep Computing - Strategic Growth BusinessDeep
IBM Systems & Technology Group

e-mail:  mpuetz at de.ibm.com
mobile: + 49-(0)160-7120602
fax:         + 49-(0)6131-84-6660

snailmail:
IBM Deutschland GmbH
Department B458
Hechtsheimer Str. 2 / Building 12
55131 Mainz
Germany

gmx-developers-bounces at gromacs.org wrote on 08/22/2006 12:00:05 PM:

> Send gmx-developers mailing list submissions to
>    gmx-developers at gromacs.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>    http://www.gromacs.org/mailman/listinfo/gmx-developers
> or, via email, send a message with subject or body 'help' to
>    gmx-developers-request at gromacs.org
>
> You can reach the person managing the list at
>    gmx-developers-owner at gromacs.org
>
> than "Re: Contents of gmx-developers digest..."
>
>
> Today's Topics:
>
>    1. Cubic splines - again (Mathias PUETZ)
>    2. Re: Cubic splines - again (David van der Spoel)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 21 Aug 2006 11:00:42 +0200
> From: Mathias PUETZ <mpuetz at de.ibm.com>
> Subject: [gmx-developers] Cubic splines - again
> To: gmx-developers at gromacs.org
> Message-ID:
> <OF81900FD8.CA620DB9-ONC12571D1.003013ED-C12571D1.003122B9 at de.ibm.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> I also have a question about the cubic spline formula used for
potentials
> and forces:
>
> As I understand it the spline formula employed by GROMACS enforces that
> potentials and their second derivates are continuous at the tables
sites,
> but the first derivates, hence the forces computed from the tables, are
> not.
> There is always a small discontinuity at the table sites for the first
> derivatives and therefore the forces.
> I stumbled a across this when I used Eric's kernel tester for BlueGene
> optimizations.
>
> I guess my question is: Do you really want a spline formula that makes
the
> forces discontinous ?
> Wouldn't it actually make more sense to use a spline formulat that
forces
> the potential and
> its first derivate to be continuous ? What's the rationale behind making

> the second derivate
> continuous anyway ?
>
> Viele Grüsse / Best regards,
> Dr. Mathias Pütz
>
> IT Specialist for Application Perfomance
>
> Deep Computing - Strategic Growth BusinessDeep
> IBM Systems & Technology Group
>
> e-mail:  mpuetz at de.ibm.com
> mobile: + 49-(0)160-7120602
> fax:         + 49-(0)6131-84-6660
>
> snailmail:
>   IBM Deutschland GmbH
>   Department B458
>   Hechtsheimer Str. 2 / Building 12
>   55131 Mainz
>   Germany
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://www.gromacs.org/pipermail/gmx-
> developers/attachments/20060821/397d4f04/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Mon, 21 Aug 2006 14:40:43 +0200
> From: David van der Spoel <spoel at xray.bmc.uu.se>
> Subject: Re: [gmx-developers] Cubic splines - again
> To: Discussion list for GROMACS development
>    <gmx-developers at gromacs.org>
> Message-ID: <44E9A9CB.20202 at xray.bmc.uu.se>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Mathias PUETZ wrote:
> >
> > Hi,
> >
> > I also have a question about the cubic spline formula used for
> > potentials and forces:
> >
> > As I understand it the spline formula employed by GROMACS enforces
that
> > potentials and their second derivates are continuous at the tables
sites,
> > but the first derivates, hence the forces computed from the tables,
are
> > not.
> > There is always a small discontinuity at the table sites for the first

> > derivatives and therefore the forces.
> > I stumbled a across this when I used Eric's kernel tester for BlueGene

> > optimizations.
> >
> > I guess my question is: Do you really want a spline formula that makes

> > the forces discontinous ?
> > Wouldn't it actually make more sense to use a spline formulat that
> > forces the potential and
> > its first derivate to be continuous ? What's the rationale behind
making
> > the second derivate
> > continuous anyway ?
>
> what makes you think the forces are not continuous?
>
>
> >
> > Viele Grüsse / Best regards,
> > Dr. Mathias Pütz
> >
> > IT Specialist for Application Perfomance
> >
> > Deep Computing - Strategic Growth BusinessDeep
> > IBM Systems & Technology Group
> >
> > e-mail:  mpuetz at de.ibm.com
> > mobile: + 49-(0)160-7120602
> > fax:         + 49-(0)6131-84-6660
> >
> > snailmail:
> >  IBM Deutschland GmbH
> >  Department B458
> >  Hechtsheimer Str. 2 / Building 12
> >  55131 Mainz
> >  Germany
> >
> >
> >
------------------------------------------------------------------------
> >
> > _______________________________________________
> > gmx-developers mailing list
> > gmx-developers at gromacs.org
> > http://www.gromacs.org/mailman/listinfo/gmx-developers
> > Please don't post (un)subscribe requests to the list. Use the
> > www interface or send it to gmx-developers-request at gromacs.org.
>
>
> --
> David.
> ________________________________________________________________________
> David van der Spoel, PhD, Assoc. Prof., Molecular Biophysics group,
> Dept. of Cell and Molecular Biology, Uppsala University.
> Husargatan 3, Box 596,     75124 Uppsala, Sweden
> phone:   46 18 471 4205      fax: 46 18 511 755
> spoel at xray.bmc.uu.se   spoel at gromacs.org   http://folding.bmc.uu.se
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> ------------------------------
>
> _______________________________________________
> gmx-developers mailing list
> gmx-developers at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-developers
>
>
> End of gmx-developers Digest, Vol 28, Issue 19
> **********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20060822/b7950d9a/attachment.html>