Second order derivatives in the PDE Toolbox
7 views (last 30 days)
Show older comments
ADSW121365 on 25 Mar 2020
Commented: J. Alex Lee on 22 Apr 2020
The PDE toolbox is pretty brilliant in that it evaluates the spatial derivitives of your function as well as the function itself in PDE results. Say you have an electric field problem, the PDE toolbox can be used to solve for the electric potential, then combined with evaluateGradient, this can be used to calculate the electric field (See 3:68 in the PDE documentation for a 2D example).
My specific problem used the toolbox for a system of 3 equations in three dimensions. The solution is of the form 3xN_nodes, (ux,uy,uz) leading to gradx being an matrix of the same size with components of the form dux/dx, duy/dx, duz/dx.
It is a useful problem then to find the second order derivatives (d2ux/d2x etc) for a whole host of problems e.g finding the turning points in the electric field.
I wondered then if the PDE toolbox (or any other toolbox which can deal with the results of this form) had any tools similar to evaluateGradient for the second order derivatives. I have searched the documentation but didn't see anything useful.
Any suggestions or direction greatly appreciated. I think perhaps the optimisation toolbox would use these derivatives to find maxima or minima but I wouldn't know where to start (or if different toolboxes can even be interfaced).
J. Alex Lee on 22 Apr 2020
What exactly do you mean by "second derivative"? For a scalar field u the "gradient" is a vector field whose components in the reference XY coordinate system are presumably the scalar fields ux and uy you can obtain from results.XGradients and results.YGradients, which are the indepdenet "derivatives" in those orthogoal directions. So if you want to take the gradient again, you'd get another pair of XY derivatives for each of the first X and Y derivatives. That's probably not what you want.
So likely you are both looking for the Laplacian of the scalar field u, which is the divergence of the gradient. Does the pde toolbox give you access to either of these quantities? Maybe it has a field called "Laplacian" or a method to compute "divergence" of an arbitrary vector quantity on the mesh? (Sorry I don't have pde toolbox, nor does it appear super well documented).
But I guess that a problem is that if the toolbox likes to give you solutions only on the nodes (makes sense for visualization purposes), and the underlying method is a second order finite element method (typical, and would make sense since the class of problems TMW can solve looks limited to elliptic scalar equations), you cannot compute unique FEM-consistent approximations to these quantities on the (shared) nodes between elements, because second derivatives on an element are piecewise constant (only first derivatives are continuous on the nodes). That is, each shared node would have different approximations of the Laplacian from the different elements that it belongs to. So there would need to be an extra step to compute the node values from the elemental values by some kind of interpolation or averaging.
Maybe it should be a feature request if it doesn't exist - it does seem like a useful quantity to have access to.
Find more on Electromagnetics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!