---
# System prepended metadata

title: Code snippets to Edwards–Wilkinson (EW) Model | ViaDean

---

# Code snippets to Edwards–Wilkinson (EW) Model
The Edwards–Wilkinson (EW) model is a fundamental mathematical framework in statistical physics for describing the evolution of surface growth. It models how a surface roughens over time, governed by a linear stochastic partial differential equation. The main equation incorporates both random fluctuations (white noise) and a smoothing term represented by the Laplacian, balancing randomness and relaxation effects. Primarily used to study kinetic roughening phenomena, the EW model is pivotal in understanding universality classes of surface growth and interfaces. It serves as a benchmark for comparing real-world surface growth processes, contributing to research in materials science, thin-film deposition, and various natural growth systems.

- [Stochastic partial differential equations in surface growth models](https://viadean.notion.site/Stochastic-partial-differential-equations-in-surface-growth-models-13b1ae7b9a328085a848da3e02e8f498?)

```mermaid
---
config:
 sankey:
  showValues: false
---
sankey-beta
Code snippets,MATLAB,3
MATLAB,KPZ Model,1
MATLAB,EW Model,1
MATLAB,MH Model,1

Code snippets,Python,3
Python,KPZ Model,1
Python,EW Model,1
Python,MH Model,1

Code snippets,Julia,2
Julia,EW Model,1
Julia,MH Model,1

Code snippets,R,1
R,KPZ Model,1

Code snippets,C++,1
C++,KPZ Model,1
```
### :cactus:MATLAB snippet

The **Edwards–Wilkinson (EW) model** is a simpler form of the **KPZ equation** used to describe surface growth. The main difference is that the nonlinear term \( $\left(\nabla h(x, t)\right)^2$ \) is absent. The EW equation can be written as:
$$
\frac{\partial h(x, t)}{\partial t} = \nu \nabla^2 h(x, t) + \eta(x, t),
$$
where:

- \( $\nu$ \) is the surface tension coefficient,
- \( $\eta(x, t)$ \) represents Gaussian white noise.

### MATLAB Implementation Outline

Below is a basic MATLAB implementation to simulate the EW model:

1. **Discretize the spatial domain** using a grid.
2. **Discretize time** using a time step \( $dt$ \).
3. Use finite difference methods for the Laplacian.
4. Include a noise term using a random number generator.

Here's how to implement the EW model in MATLAB:

```matlab
% Parameters
N = 100;        % Number of spatial points
dt = 0.01;      % Time step
dx = 1.0;       % Spatial step
nu = 1.0;       % Diffusion coefficient
noiseStrength = 0.1; % Noise strength
T = 1000;       % Number of time steps

% Initialize the height profile
h = zeros(1, N);

% Time evolution loop
for t = 1:T
    % Compute the Laplacian using finite differences (periodic boundary)
    laplacian = (circshift(h, -1) - 2 * h + circshift(h, 1)) / (dx^2);
    
    % Add noise (scaled by sqrt(dt) for stability)
    noise = noiseStrength * sqrt(dt) * randn(1, N);
    
    % Update the height function
    h = h + dt * (nu * laplacian) + noise;
    
    % Plot the surface at regular intervals
    if mod(t, 100) == 0
        plot(h);
        title(['Surface profile at time step: ', num2str(t)]);
        xlabel('Spatial position');
        ylabel('Height');
        drawnow;
    end
end
```

### Explanation:

- **`circshift`** is used to simulate periodic boundary conditions, where the neighbors of the first and last elements wrap around.
- **`randn`** generates Gaussian random noise for each spatial point.
- The noise is scaled by \( $\sqrt{\text{dt}}$ \) to ensure the noise term behaves correctly over discrete time steps.

### Visualization:

- The code plots the surface profile at regular intervals (`t % 100 == 0`) to visualize how the surface evolves over time.
- Adjust the plotting interval and parameters (e.g., `N`, `dt`, `noiseStrength`) as needed for different simulations or finer control.

This MATLAB script serves as a starting point for simulating the Edwards–Wilkinson model for surface growth. You can enhance it by adding more advanced visualization, saving data, or modifying boundary conditions.

### :cactus:Python snippet

The **Edwards–Wilkinson (EW) model** is another SPDE used to describe surface growth. It's a simpler case compared to the KPZ equation, as it lacks the nonlinear term. The EW model equation is:

$$
\frac{\partial h(x, t)}{\partial t} = \nu \nabla^2 h(x, t) + \eta(x, t),
$$
where:

- \( $h(x, t)$ \) is the height function over space and time,
- \( $\nu$ \) is the surface tension (diffusion coefficient),
- \( $\eta(x, t)$ \) represents Gaussian white noise.

### Python Implementation Approach

We'll use finite differences for spatial derivatives and a simple Euler method for time integration. Here's a Python script that simulates the EW model on a 1D grid:

```python
import numpy as np
import matplotlib.pyplot as plt

# Parameters
N = 100  # Number of spatial points
dx = 1.0  # Space step
dt = 0.01  # Time step
nu = 1.0  # Diffusion coefficient
noise_strength = 0.1  # Noise strength
num_steps = 1000  # Number of time steps

# Initialize height function
h = np.zeros(N)

# Function to compute the Laplacian using finite differences
def laplacian(h):
    lap = np.zeros_like(h)
    for i in range(1, N - 1):
        lap[i] = (h[i - 1] - 2 * h[i] + h[i + 1]) / (dx * dx)
    # Periodic boundary conditions
    lap[0] = (h[-1] - 2 * h[0] + h[1]) / (dx * dx)
    lap[-1] = (h[-2] - 2 * h[-1] + h[0]) / (dx * dx)
    return lap

# Time evolution loop
for step in range(num_steps):
    noise = noise_strength * np.random.normal(0, 1, N) * np.sqrt(dt)
    h += dt * nu * laplacian(h) + noise
    
    # Plotting every 100 steps
    if step % 100 == 0:
        plt.plot(h, label=f'Step {step}')
        plt.xlabel('Position')
        plt.ylabel('Height')

# Show plot
plt.legend()
plt.title('Surface Evolution with the Edwards–Wilkinson Model')
plt.show()
```

### Explanation:

- **Laplacian function** computes the second derivative using central differences.
- **Noise term** is Gaussian with a standard deviation scaled by \(\sqrt{\text{dt}}\) to match the stochastic component.
- **Periodic boundary conditions** ensure continuity at the edges.

### Customization:

- Adjust parameters like `N`, `dt`, `nu`, or `noise_strength` for different behavior.
- For visualization, you can add animations or use libraries like `matplotlib.animation` to create dynamic plots showing surface evolution over time.

This simple simulation helps in understanding how stochastic surface growth evolves according to the EW model, illustrating smoothing and roughening effects due to diffusion and random noise.