Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radial basis function for smooth derivatives #41

Closed
kalosu opened this issue Oct 23, 2024 · 4 comments
Closed

Radial basis function for smooth derivatives #41

kalosu opened this issue Oct 23, 2024 · 4 comments

Comments

@kalosu
Copy link

kalosu commented Oct 23, 2024

Hello there,

First at all, thanks a lot for putting this nice tool available for everyone. It is really nice!

I have a question regarding which RBF basis to choose in case I am interested in obtaining smooth derivatives.

I have used your implementation to solve a Poisson boundary value problem with Robin boundary conditions on a circular domain.

The underlying grid is obtained from a concentric distribution of points which was first generated by a mapping function (you can take a look to the mapping function in the following link: https://marc-b-reynolds.github.io/math/2017/01/08/SquareDisc.html)

I use then a polyharmonic of third order as basis function (as suggested in the available examples) with 50 neighboring points and a polynomial of 3 order.

The solutions that I obtain are in general good. However, in a following step I need to take the derivatives of some derived quantities from the solutions to the above mentioned boundary value problem. In this case, again I use RBF-FD to approximate the derivatives in where I compute the weights matrix and approximate the derivatives via the linear combination of my derived quantity and the obtained coefficients. For these derivatives I use the same parameters as for the boundary value problem (polyharmonic of third order but with lower number of neighboring points: roughly 15 to 20)

Now in this case the obtained derivatives are not as smooth as I would need them (I need to perform this evaluation iteratively and the noise in the derivative estimation is being accumulated through the iterations)

I was wondering if in this case I could use a different RBF basis? Do you have anything in mind which can guarantee me that the derivatives will be sufficiently smooth? Something like what would be obtained from calculating the derivatives from bicubic splines.

Or do you have any other suggestion on what could I do in order to improve the quality of the obtained derivativies? Any thoughts?

Thanks a lot for your comments!

@treverhines
Copy link
Owner

Sounds interesting! My first thought would be to increase the number of neighbors used to compute the derivatives to ~50. Global interpolation, like with RBFInterpolant, could be used to guarantee continuous derivatives, but I assume you have too many nodes. Using a larger RBF-FD neighborhood would be the next best thing. If you just need continuous first derivatives, phs3 should be sufficient, but you could also try phs5 along with order=2.

@kalosu
Copy link
Author

kalosu commented Oct 24, 2024

Hi there, thanks a lot for the feedback!

Yes, I notice that the solutions become smoother if I increase the neighborhood. However, this comes always at the price of requiring more time to perform these evaluations. In my algorithm, I need to perform two main things: taking the derivative of some scalar function and performing interpolation. For the derivative part, since I pre-compute the weight matrix at the beginning, on each iteration I just need to take the matrix-vector product. (These derivatives are always evaluated at the same points. Only the values of the underlying function is changing on each iteration).

For the interpolation part the same principle applies. I need to interpolate some functions using the function values at the same exact points for each iteration. At the moment I am using the RBFInterpolant interface to perform these interpolations by setting the neighbors parameter to a smaller value. However, I need to repeat the same thing on every iteration and I was wondering if it could be possible to speed up the interpolation process? Something similar to what you explained in here:

#15

Do you think there would be any benefit from using the same LHS matrices on each iteration and updating the values of the function to interpolate? (In thi case, the locations for performing the interpolation are not always the same, the only thing that remains the same are the location at which the function will be sampled) Do you think I could observe significant speed up in this case?

Again, thanks for the comments.

@treverhines
Copy link
Owner

You should be able to combine the differentiation and interpolation into one step. You just need to set the first argument of weight_matrix to your interpolation points rather than the nodes used to solve the pde.

Also, you could effectively reproduce RBFInterpolant (when using it with the neighbors argument) by dotting the function values with the output of weight_matrix with diff=(0,0). That would be more efficient if you are repeating interpolation from/to the same locations.

@kalosu
Copy link
Author

kalosu commented Oct 28, 2024

Hi there,

Thanks, that worked out really nice.

@kalosu kalosu closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants