bspline-fortran icon indicating copy to clipboard operation
bspline-fortran copied to clipboard

Is there a way to impose boundary condition (like derivatives at the edges) with this module?

Open streaver91 opened this issue 8 years ago • 11 comments

streaver91 avatar Nov 18 '15 13:11 streaver91

I believe you can do that by specifying your own knot sequence? You can do this using the subroutine interface (see, for example, the comments in the db2ink routine in bspline_sub_module.f90 (you set iflag=1, and provide your own tx and ty arrays.

jacobwilliams avatar Nov 18 '15 23:11 jacobwilliams

I still can't figure this out. Say a 1d spline interpolated by (x1, y1) (x2, y2) ... (xn, yn) that I want to set its left/right bound derivative (i.e. at x1, xn) to a/b, respectively. How shall I set the knots to achieve that?

streaver91 avatar Nov 19 '15 21:11 streaver91

I'm not sure. You may have to check the references given in the core routines. I've only ever used the default (not-a-knot) end conditions.

jacobwilliams avatar Dec 07 '15 02:12 jacobwilliams

Note: as of 4.1.0 you can now set the knots from the object-oriented interface also.

jacobwilliams avatar Feb 13 '16 19:02 jacobwilliams

~~I'm pretty sure you can't do this by modifying the knot vector alone.~~

Edit: Need to look into this again. The dbint4() routine from CMLIB might give some inspiration.

pbregener avatar Aug 30 '18 11:08 pbregener

Very interesting, I don't think I noticed this routine before. I think we could definitely use it...

jacobwilliams avatar Aug 31 '18 05:08 jacobwilliams

dbint4 is hardcoded to fourth-order, which we probably want to change.

In terms of actual end conditions, it would be great to be able to set first or second derivatives directly (as is possible in dbint4). Periodic boundary conditions would also be extremely useful for me.

For the OO interface, some shortcuts could be great, for example a simple flag that gives a natural spline (second derivatives zero at the ends), or specifying periodicity in individual dimensions.

Not sure how far the original CMLIB routines can help us here, but for more advanced applications, we might be able to leverage some of Dierckx's FITPACK routines.

pbregener avatar Aug 31 '18 10:08 pbregener

As for the dbink4 routine, I've got some experiments going on the dbink4 branch. I'll get it hooked up and working just for 1D and 4th order so I can test it out. Then I can look into the details of:

  • how to generalize it for an order
  • how to call it for any dimension (2D-6D)

I think both are doable.

jacobwilliams avatar Sep 01 '18 01:09 jacobwilliams

Just a feature request along this:

:+1: for periodic boundary conditions

zerothi avatar Sep 06 '18 13:09 zerothi

Hi Jacob, thanks for this library, it's almost exactly what I need for smooth 4D interpolation. Is there any chance of being able to specify natural boundary conditions (second derivative zero at ends) in the near future?

Michael-P-Crisp avatar Apr 24 '19 10:04 Michael-P-Crisp

No promises, but I have started to get back to looking into this.

jacobwilliams avatar Apr 29 '19 16:04 jacobwilliams