Curvature

In MembraneCurvature, we calculate curvature from a height field \(z = f(x,y)\) using the Monge gauge formulas, where partial derivatives are estimated from the derived surface.

With the Monge gauge formulas, we map first derivatives \((\partial_x, \partial_y)\), and second and mixed derivatives \((\partial_{xx}, \partial_{yy}, \partial_{xy})\) to the definitions of curvature.

Mean curvature \(H\), defined by:

\[H = \frac{(1+\partial_x^2)\partial_{yy}+(1+\partial_y^2)\partial_{xx}-2\partial_x\partial_y\partial_{xy}} {2(1+\partial_x^2+\partial_y^2)^{3/2}},\]

and Gaussian curvature \(K\), defined by:

\[K = \frac{\partial_{xx}\partial_{yy}-\partial_{xy}^2} {(1+\partial_x^2+\partial_y^2)^2}.\]

The Monge gauge formulas are implemented separately in the helpers mean_curvature_monge() and gaussian_curvature_monge(), which accept precomputed partial derivatives as arguments. This approach intends to separate the curvature algebra from the derivative estimation.

To estimate partial derivatives, we use mean_curvature() and gaussian_curvature() from the discrete height field using numpy.gradient(), then pass them to the Monge gauge functions above. Optional spacing arguments (dx, dy) are forwarded to numpy.gradient() for physical-unit calculations.

Since the mean curvature calculates the arithmetic mean of two principal curvatures, the default units of \(H\) are Å-1. On the other hand, Gaussian curvature calculates the geometric mean of the two principal curvatures. Therefore, the default units of \(K\) are Å-2. In general, units of mean curvature are [length] -1, and units of Gaussian curvature are [length] -2.

Note

When spacing is provided to numpy.gradient() (for example, dx and dy from the simulation box and grid definition), curvature calculations are performed in physical units and are less sensitive to grid bin count than with implicit unit spacing. However, results are not exactly bin-independent because finite-difference discretization error increases for coarse grids.

Warning

Numpy cannot calculate the gradient for arrays with inner array of length==1 unless axis=0 is specified. Therefore in the functions here included for mean and Gaussian curvature, shape of arrays must be at least (2,2). In general, to calculate a numerical gradients shape of arrays must be >=(edge_order + 1).

For a periodic Fourier fit to atom heights, use fourier_height_from_atoms() or fourier_height_derivatives_from_atoms() (surface only in fourier_surface), then fourier_curvature() for Monge \(H\) and \(K\) in one call.

Functions

membrane_curvature.curvature.fourier_curvature(positions, x_range, y_range, n_x_bins, n_y_bins, M, N, rcond=None)[source]

Bin-centre height and Monge mean / Gaussian curvature from a Fourier fit to atoms.

Runs fourier_height_derivatives_from_atoms() once, then mean_curvature_monge() and gaussian_curvature_monge().

Parameters:
  • positions (ndarray, shape (n_atoms, 3)) – Atom coordinates in the same length unit as the box (typically Å).

  • x_range, y_range (tuple of float) – (min, max) domain extents.

  • n_x_bins, n_y_bins (int) – Output grid size at bin centres.

  • M, N (int) – Maximum Fourier mode indices; see fourier_mode_list().

  • rcond (float or None, optional) – Passed to singular-value truncation for the Fourier fit. See _solve_design_least_squares_svd().

Returns:

z_surface, mean_H, gaussian_K – Each array has shape (n_x_bins, n_y_bins).

Return type:

ndarray

Warns:

UserWarning – If the Fourier least-squares system is rank-deficient or underdetermined.

membrane_curvature.curvature.gaussian_curvature(Z, *varargs)[source]

Calculate Gaussian curvature from Z cloud points.

Uses numpy.gradient() on Z, then gaussian_curvature_monge().

Parameters:
  • Z (np.ndarray.) – Multidimensional array of shape (n,n).

  • varargs (list of scalar or array, optional) – Spacing between f values. Default unitary spacing for all dimensions. See np.gradient docs for more information.

Returns:

K – The result of Gaussian curvature of Z. Returns multidimensional array object with values of Gaussian curvature of shape (n, n).

Return type:

np.ndarray.

membrane_curvature.curvature.gaussian_curvature_monge(fx, fy, fxx, fyy, fxy)[source]

Helper to calculate Gaussian curvature \(K\) from partial derivatives of \(z = f(x, y)\).

Same expression as in gaussian_curvature() once first derivatives \((\partial_x, \partial_y)\) and second and mixed derivatives \((\partial_{xx}, \partial_{yy}, \partial_{xy})\) of \(z\) are known, supplied as fx, fy, fxx, fyy, fxy (see the module equations above). This function does not compute gradients.

Parameters:
  • fx (np.ndarray.) – Values of \(\partial_x\) on the grid.

  • fy (np.ndarray.) – Values of \(\partial_y\) on the grid.

  • fxx (np.ndarray.) – Values of \(\partial_{xx}\) on the grid.

  • fyy (np.ndarray.) – Values of \(\partial_{yy}\) on the grid.

  • fxy (np.ndarray.) – Values of \(\partial_{xy}\) on the grid.

Returns:

K – Gaussian curvature, same shape as the input arrays.

Return type:

np.ndarray.

membrane_curvature.curvature.mean_curvature(Z, *varargs)[source]

Calculates mean curvature from Z cloud points.

Uses numpy.gradient() on Z, then mean_curvature_monge().

Parameters:
  • Z (np.ndarray.) – Multidimensional array of shape (n,n).

  • varargs (list of scalar or array, optional) – Spacing between f values. Default unitary spacing for all dimensions. See np.gradient docs for more information.

Returns:

H – The result of mean curvature of Z. Returns multidimensional array object with values of mean curvature of shape (n, n).

Return type:

np.ndarray.

membrane_curvature.curvature.mean_curvature_monge(fx, fy, fxx, fyy, fxy)[source]

Helper to calculate mean curvature \(H\) from partial derivatives of \(z = f(x, y)\).

Same expression as in mean_curvature() once first derivatives \((\partial_x, \partial_y)\) and second and mixed derivatives \((\partial_{xx}, \partial_{yy}, \partial_{xy})\) of \(z\) are known, supplied as fx, fy, fxx, fyy, fxy (see the module equations above). This function does not compute gradients.

Parameters:
  • fx (np.ndarray.) – Values of \(\partial_x\) on the grid.

  • fy (np.ndarray.) – Values of \(\partial_y\) on the grid.

  • fxx (np.ndarray.) – Values of \(\partial_{xx}\) on the grid.

  • fyy (np.ndarray.) – Values of \(\partial_{yy}\) on the grid.

  • fxy (np.ndarray.) – Values of \(\partial_{xy}\) on the grid.

Returns:

H – Mean curvature, same shape as the input arrays.

Return type:

np.ndarray.