File Exchange

image thumbnail

Surface generator: artificial randomly rough surfaces

version 1.1.0.0 (7.27 KB) by Mona Mahboob Kanafi
Generates randomly rough fractal surfaces with different fractal (Hurst) parameters

37 Downloads

Updated 19 Dec 2016

View License

This code generates artificial randomly rough isotropic surfaces. These surfaces could be useful for simulating surface roughness or topographies from nanometre features of engineering surfaces to large-scale topography of mountains, terrains or landscapes. The code is based on simulating the surface topography/roughness by means of fractals. It uses the Fourier concept (specifically the power spectral density) for surface generation.
There are two options for surface generation, either the generated surface has a roll-off region or without a roll-off region. If you are not familiar with the concept of roll-off, refer to the uploaded image for this code.
For the code you need 5 inputs (with no roll-off region), or then 6 inputs (including roll-off wavevector). These inputs are:

1- root-mean-square roughness (Rq), i.e. standard deviation of surface heights (sigma σ)
2- Hurst exponent (H), which is related to the fractal dimension of a surface topography D=3-H. For example, a Brownian surface roughness has H= 0.5. The parameter H can take values between 0 and 1.
3- Lx, which is the length of final topography/image in x direction (it could take any values from nanometre to hundreds of metres)
4- m, which is number of pixels in the x direction of final topography/image
5- n, which is number of pixels in the y direction of final topography/image
6- (OPTIONAL INPUT) qr, which is the roll-off wavevector (check uploaded image for its meaning)

Two examples of generated surfaces:

[z , PixelWidth, PSD] = artificial_surf(1e-2, 0.8, 0.1, 512 , 512);
Generates a surface named z with standard deviation of 1 cm, hurst exponent of 0.8 (i.e. fractal dimension of 2.2), length of final image is 10 cm. It generates a square image with 512 data points in x and y direction. The final resolution (i.e Pixel Width) equals Lx/m = 195.3 micron.

[z , PixelWidth, PSD] = artificial_surf(1e-3, 0.8, 0.1, 1024, 512,1000);
Generates a surface named z with standard deviation of 1mm, Hurst exponent of 0.8 (i.e. fractal dimension of 2.2), length of final image is 10 cm. It generates a rectangular image with 1024 data points in x direction and 512 data points in y direction. The surface has a roll-off region at qr = 1000 (1/m), which equals to a wavelength lambda_r = (2*pi)/qr = 6.3 mm. The final resolution (i.e Pixel Width) equals Lx/m = 97.7 micron.

tips:
- By increasing m and n (don’t go higher than 2048 on a normal computer) or reducing Lx, you can generate surfaces with higher resolution.

- The surface is generated by its surface roughness power spectrum. This data is stored in the structure named PSD. If interested, for instance, you can check the analysis by comparing this PSD with the results you get by applying power spectral method on generated surface:

Radially Averaged Surface Roughness Power Spectrum (PSD)
http://se.mathworks.com/matlabcentral/fileexchange/54297-radially-averaged-surface-roughness-power-spectrum--psd-

Please let me know, if you have any problems or there is a bug!

Cite As

Mona Mahboob Kanafi (2020). Surface generator: artificial randomly rough surfaces (https://www.mathworks.com/matlabcentral/fileexchange/60817-surface-generator-artificial-randomly-rough-surfaces), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

Just thought I'd point out in response to Seok's comment. The code is correct with -2 * (H+1) as can be shown in the following paper: Müser, Martin H., Wolf B. Dapp, Romain Bugnicourt, Philippe Sainsot, Nicolas Lesaffre, Ton A. Lubrecht, Bo NJ Persson et al. "Meeting the contact-mechanics challenge." Tribology Letters 65, no. 4 (2017): 118.

Gregoose

Hi,
Is there a way to convert the output to integers and still have the desired PSD ?

Thanks for the code. There is an error for H.
2*(H+1) -> 2*H + 1

meisam

Marc Ng

Hi,
I am not able to see the surface roughness model when I run this function, does anyone have advice on how to display the surface?

Guangzhi XU

For anyone interested in some maths regarding what's going on in the code, give a read of this paper: Jacobs, Tevis D B and Junge, Till and Pastewka, Lars, 2017: Quantitative characterization of surface topography using spectral analysis. Surface Topography: Metrology and Properties. It basically explains everything.
@Saipraneeth Those lines are computing a scaling factor so the resultant random surface has the desired RMS height. We need this because in constructing the PSD using the power law, the constant C0 (see the paper) is unknown, so the code used C0=1, which would give a RMS height of some other value.

zhibo sun

thanks a lot ,its works well. Did u use the ifft algrorithm to generate this result? Would u like to share some docs about ur algrorithm?

Guangzhi XU

Hi. This is quite cool. Could you give a reference of this method? If I want to use it in my work, how should I cite it?

Hi, thank you very much for this code. This is really help for me. By the way, can I get an anisotropic rough surface through its PSD?

Tzvi

hi,
thanks for this.
how can i plot the surface, like in your image?

Fang Lei

Saipraneeth

Hi, thanks for this. This is hugely helpful for me. I have a few doubts. What does the following piece of code do and why are we doing this?

RMS_F2D = sqrt((sum(sum(Cq)))*(((2*pi)^2)/(Lx*Ly)));
alfa = sigma/RMS_F2D;
Cq = Cq.*alfa^2;

Other thing is, if you could share your notes which this code is based on would be really helpful. Thanks.

Updates

1.1.0.0

Description added.

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux