slippy.surface.RandomPerezSurface¶
- class slippy.surface.RandomPerezSurface(target_psd: numpy.ndarray, height_distribution: Optional[Union[scipy.stats._distn_infrastructure.rv_continuous, Sequence]] = None, accuracy: float = 0.001, max_it: int = 100, min_speed: float = 1e-10, generate: bool = False, grid_spacing: Optional[float] = None, exact: str = 'best')[source]¶
Surfaces with set height distribution and PSD found by the Perez method
- Parameters
target_psd (np.ndarray) – The PSD which the surface will approximate, the shape of the surface will be the same as the psd array (the same number of points in each direction)
height_distribution ({scipy.stats.rv_continuous, sequence}) – Either a scipy.stats distribution or a sequence of the same size as the required output
accuracy (float, optional (1e-3)) – The accuracy required for the solution to be considered converged, see the notes of the discretise method for more information
max_it (int, optional (100)) – The maximum number of iterations used to discretise a realisation
min_speed (float, optional (1e-10)) – The minimum speed of the iterations, if the iterations are converging slower than this they are deemed not to converge
generate (bool, optional (False)) – If True the surface profile is found on instantiation
grid_spacing (float, optional (None)) – The distance between grid points on the surface
exact ({'psd', 'heights', 'best'}, optional ('best')) –
Notes
This method iterates between a surface with the exact right height distribution and one with the exact right PSD this method is not guaranteed to converge for all surfaces, for more details see the reference.
Examples
Making a surface with a normal height distribution and a given power spectra.
>>> import numpy as np >>> import scipy.stats as stats >>> import slippy.surface as s >>> # making a surface with an exponential ACF as described in the original paper: >>> beta = 10 # the drop off length of the acf >>> sigma = 1 # the roughness of the surface >>> qx = np.arange(-128,128) >>> qy = np.arange(-128,128) >>> Qx, Qy = np.meshgrid(qx,qy) >>> Cq = sigma**2*beta/(2*np.pi*(beta**2+Qx**2+Qy**2)**0.5) # the PSD of the surface >>> Cq = np.fft.fftshift(Cq) >>> height_distribution = stats.norm() >>> my_surface = s.RandomPerezSurface(target_psd = Cq, height_distribution=height_distribution, >>> grid_spacing=1, >>> generate=True) >>> my_surface.show()
References
Based on the method and code given in:
Francesc Pérez-Ràfols, Andreas Almqvist, Generating randomly rough surfaces with given height probability distribution and power spectrum, Tribology International, Volume 131, 2019, Pages 591-604, ISSN 0301-679X, https://doi.org/10.1016/j.triboint.2018.11.020. (http://www.sciencedirect.com/science/article/pii/S0301679X18305607)
- __init__(target_psd: numpy.ndarray, height_distribution: Optional[Union[scipy.stats._distn_infrastructure.rv_continuous, Sequence]] = None, accuracy: float = 0.001, max_it: int = 100, min_speed: float = 1e-10, generate: bool = False, grid_spacing: Optional[float] = None, exact: str = 'best')[source]¶
Methods
__init__(target_psd[, height_distribution, ...])convert_coordinates(y_coord, x_coord)discretise([return_new, accuracy, max_it, ...])Discretise the surface with a realisation
find_summits([mask, four_nearest, ...])Find summits after low pass filtering
get_acf([profile_in])Find the auto correlation function of the surface
get_fft([profile_in])Find the fourier transform of the surface
get_height_of_mat_vr(ratio[, void, mask, ...])Find the height of a given material or void volume ratio
get_mat_vr(height[, void, mask, ratio])Find the material or void volume ratio for a given height
get_points_from_extent([extent, ...])Gets the grid points from the extent and the grid spacing
get_psd()Find the power spectral density of the surface
get_summit_curvature([summits, mask, ...])Get summit curvatures
interpolate(y_points, x_points[, mode, ...])Easy memoized interpolation on surface objects
low_pass_filter(cut_off_freq[, return_copy])Low pass FIR filter the surface profile
max_shape()mesh(depth[, method, parameters])Returns a Mesh object for the surface
resample([new_grid_spacing, return_profile, ...])Resample or crop the profile by interpolation
roughness(parameter_name[, mask, ...])Find areal roughness parameters
show([property_to_plot, plot_type, ax, ...])Plot surface properties
subtract_polynomial(order[, mask])Flatten the surface by subtracting a polynomial
wear(name, x_pts, y_pts, depth)Add wear / geometry changes to the surface profile
Attributes
acfThe auto correlation function of the surface profile
dimensionsThe number of spatial dimensions that
distextentThe overall dimensions of the surface in the same units as grid spacing
fftThe fast fourier transform of the surface
grid_spacingThe distance between grid points in the x and y directions
is_analyticis_discreteA bool flag, True if there is a profile present
maskA mask used to exclude some values from analysis, a single float or an array of bool the same size as profile Either a boolean array of size self.size or a float of the value to be excluded
materialA material object describing the properties of the surface
moving_surfaceprofileThe height data for the surface profile
psdThe power spectral density of the surface
shapeThe shape of the surface profile array, the number of points in each direction
sizeThe total number of points in the surface
surface_typeA description of the surface type
unworn_profilewear_volumes