Heat flow, special shapes, and Fourier neural operators¶
We want to predict the temperature around a thin metal ring after heat has flowed for a fixed time. Start by observing a temperature profile, then look for shapes whose changes are easier to describe. The six sections keep the same physical problem and add opportunities to predict, compare, and fit its behavior.
All three interactive experiments are embedded in this notebook. Running them requires no companion download or GitHub connection. The calculations use NumPy, and the kernel comparison uses Matplotlib. The editable display sources remain alongside the notebook.
1. Watch heat flow¶
A thin metal ring has warm and cool regions. Its temperature varies with position \(x\) around the ring. The two ends of the profile below refer to the same point on that ring. The vertical axis measures temperature relative to its mean.
Press Play. Heat flows from warmer regions to cooler ones, and the profile becomes smoother. Use Reset and the time slider to compare its initial and final shapes. Leave the component display off for now.
The whole curve changes. Could it be a sum of simpler shapes whose changes we can understand separately?
#@title Explore heat flow
import base64
import json
import zlib
from IPython.display import HTML, display
# Generated from the three editable HTML display sources. No runtime file or network access.
_DISPLAY_SOURCES = json.loads(zlib.decompress(base64.b64decode(
'eNrtfQtz40aS5l+B3d4lqQYhvEFSTfV6euwbX7QfYTti7kJWTIMkKKFFETQA6jFq/ff7MqsAFECApOyeu424iYmxCKAqKyvfVZlV/fTldRTmX060L98s4jstXkx/+3K5Tob0dhg9bFZJGqW/faktwjwcrrf4ahqWW7xYxutwNczj24g/+N5vX57/tta0N1n+uIr4p6a92oGnPWnD4fXtMF7fTO7CtD8c3i6Gi2gZblf5cHk1nCdoposvHzfDbTxcJutcvLb0V7br2K47GJwJKLfbPFpMXnkz3wsc+S58iLPJq5k3W8w9+WoZRys0c8bjaDSW75J1NHnlLkbePJRv8us0wrvFLDTdolUW3UXryatR5I9myzON0ZB4i0kAE0JwYvmbh1PL8LTsMcujWyCuZ+E6A4A0Rsfb8GF4Hy/y68nYMzcP9CK9itcTy948aOaZ9txJrxNQbJY8DLP4n/H6ajJL0kWUDvFmXycDyOHNAj3QnSmI/tHE5rH5+T6Kr67ziW+aJTL0VTM1d3MQdp4kq1lIzFzE2WYVPk6Wq4gg47/D+zTcTOg/Z1q4iq/WwxgEySbz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LkepDsMp2jFFmTnaSGsdewfT0IESED+nbzqjzwHjBqF4VgyAs5WhCjU3RRW1Qfe/t5MmzDTQs3d5OC9AXktniDzAy9caby8mFKXYNw1kmRWZAVwe1FhBcGJ5OaZtLfXZfV/mX3Kax7y6N4iqN+0Lbj7o6g5S9TO+V4Smd7xSXTP8zShNd/BsSZAzy+0Ql3p4LNFjtxf0Z93z4Hjo/Fjo/PpDSM3VLty/rN2S0bAGL7Y2pbb7uYwjH5NIIvhFD3fy9KLM+St5vaLuX+kXBdPGtkN9RLfF3VyT+Hi7rOBx358TrxQNdOzD2QALz5E7ePmD55dUD/La6ZeKPXBqBMV6PahdHjPjf+xJDdt8dcacYnkHn+ftjMCB1Ba9fdHnE8wEpKoeQl3bYrt19Td/3HessVVbV/FKZc5RXsMqgr3bcfSo+th13l82FrWheRlDYpp+Fa6A8ebUYp5UxMG9fDPR2Bmg5ylsNwPXrDRBytZ9J7TVZabFI/wXOnO3fVLOq1D0XxouEJ5B6VyzfuWG4yinNz2sfy9Cq5TW/sRHt0uW89A/fhHO6+I8MhdHrOKcvI77iGgzx2MhHEly7bFKopn3ZaCbDyAYDj0xYHpWUPJCQVNIfqgwcuLtDUuAL+aML3EuyKVPrrB5K/3dKlDz/H6mgArU=')))
def show_experiment(name, configuration=None):
source = _DISPLAY_SOURCES[name]
if configuration is not None:
source = source.replace('/* FNO_LAB_CONFIG */ null', json.dumps(configuration))
display(HTML(source))
show_experiment('heat')
2. Discover special oscillations¶
Choose Compare all three sine waves in the display, press Reset, and predict which wave will shrink fastest. All three start at amplitude one. Play or move the same time slider to compare them at the same instant.
- What stayed at the same positions?
- What changed?
- Why might rapid spatial variations disappear faster?
After observing the waves, reveal the mathematical explanation.
The waves oscillate in space, not in time. Their peaks do not travel under diffusion. Their amplitudes shrink. A sine's second derivative is
The second derivative preserves this spatial shape and multiplies it by \(-k^2\). Such a shape is an eigenfunction of that operator. The heat equation relates temperature change to this derivative, so a larger \(k\) gives a faster decay. The difference between the three waves comes from the factor \(k^2\).
3. Build the field from waves¶
Choose Three waves together, press Reset, and turn on Show components and amplitudes. The green temperature profile contains a broad variation and smaller, more rapid variations. The colored curves separate those contributions.
What does it mean to add waves?¶
Keep the three shapes \(\sin x\), \(\sin3x\), and \(\sin7x\) fixed. Multiply them by \(1\), \(1/2\), and \(1/4\), respectively. Then add their values at each position,
For example, at \(x=\pi/2\) the three sine values are \(1,-1,-1\). The temperature relative to its mean is therefore
The component amplitudes are not temperatures at particular positions. They describe how much of each entire wave contributes to the field. At one position the components reinforce each other; at another they partly cancel. Adding them at every position reconstructs the complete curve.
Click a colored component curve. Its corresponding amplitude bar is highlighted. Click another bar to identify its curve. These are two descriptions of the same temperature field. The curve specifies values by position. The three numbers \((1,1/2,1/4)\) specify that curve by its contributions from the three chosen shapes.
What changes as heat flows?¶
Section 2 showed that an individual sine keeps its wavelength and peak positions under diffusion. Only its amplitude changes. Call the changing amplitudes \(q_1(t)\), \(q_3(t)\), and \(q_7(t)\). The evolving field can therefore be written as
The shapes depend on position \(x\); the amplitudes depend on time \(t\). Heat flow is linear, so evolving the initial sum gives the same answer as evolving each component separately and then adding the results. Thus these three changing numbers determine the entire changing profile.
Before moving time, predict which bar will shrink most. The faint outlines mark the initial amplitudes. At the final time, mode 7 contributes very little. Its disappearance removes the finest variations from the sum, leaving a smoother profile.
What does the FFT compute?¶
So far, the amplitudes were supplied when the profile was constructed. In an actual input we may receive only sampled temperatures \(u(x_j)\). Fourier decomposition recovers the wave coefficients from those samples. For this example it recovers \(1\), \(1/2\), and \(1/4\).
The recovery works because different sine modes are orthogonal. Multiplying the field by a matching sine and averaging isolates that component; contributions from the other sine modes cancel. The FFT efficiently computes Fourier coordinates for all resolved modes. It changes the representation of the field, without evolving it in time.
General periodic fields also need cosine components, or equivalently complex Fourier modes. Our three-wave example uses only sines so that the bars have a direct interpretation.
Why does the next cell use −2 times the imaginary part of the FFT?
With the normalization used here, the complex coefficient is \(\widehat u_k=N^{-1}\sum_j u(x_j)e^{-ikx_j}\). Its imaginary part is minus the average of \(u(x_j)\sin(kx_j)\). The real sine amplitude is
For a unit sine, the average of its square on this grid is \(1/2\), so the factor two returns amplitude one. In this resolved sine-only example, other modes average to zero. The next cell checks that the recovered amplitudes match the three bars at time zero.
import numpy as np
from IPython.display import Markdown
N, NU, T = 128, 0.14, 0.65
MODES = np.array([1, 3, 7])
AMPLITUDES = np.array([1.0, 0.5, 0.25])
x = np.linspace(0, 2*np.pi, N, endpoint=False)
basis = np.sin(MODES[:, None]*x)
initial = AMPLITUDES @ basis
def rfft(u):
return np.fft.rfft(u, axis=-1, norm='forward')
recovered = -2*rfft(initial)[MODES].imag
assert np.allclose(recovered, AMPLITUDES)
display(Markdown('| Sine mode | Amplitude from FFT |\n|---|---|\n' +
'\n'.join(f'| {k} | {a:.2f} |' for k,a in zip(MODES,recovered))))
| Sine mode | Amplitude from FFT |
|---|---|
| 1 | 1.00 |
| 3 | 0.50 |
| 7 | 0.25 |
4. Solve by multiplying the coefficients¶
The previous display reduced an evolving curve to evolving amplitudes. Now determine how each amplitude changes. Heat flow on the ring satisfies
The left side measures temperature change in time. The right side measures spatial curvature, scaled by the diffusivity \(\nu\). Near a warm peak the curvature is negative, so temperature decreases there. Near a cool trough the curvature is positive, so temperature increases.
Follow one component¶
Start with a single shape and an unknown amplitude,
A time derivative changes the amplitude, while a second spatial derivative acts on the sine shape,
Substitute both expressions into the heat equation. Both sides contain the same spatial function, so their coefficients must agree,
The amplitude decreases at a rate proportional to its current size. A fixed fraction remains after a fixed time interval, giving exponential decay,
This explains the earlier observation. Increasing \(k\) increases the decay rate by \(k^2\). Mode 7 has 49 times the fractional decay rate of mode 1. Its peaks do not move; its amplitude decreases faster.
Distinguish the amplitude from its multiplier¶
Here \(\nu=0.14\) and \(T=0.65\). Apply each multiplier to that component's initial amplitude.
| Mode | Initial amplitude \(q_k(0)\) | Multiplier \(e^{-\nu k^2T}\) | Final amplitude \(q_k(T)\) |
|---|---|---|---|
| 1 | 1.00 | 0.913 | 0.913 |
| 3 | 0.50 | 0.441 | 0.220 |
| 7 | 0.25 | 0.0116 | 0.00289 |
For mode 3, \(0.5\times0.441\approx0.220\). The multiplier tells how much of the component remains. The bar height is its resulting amplitude. In the equal-amplitude comparison of Section 2, every initial amplitude was one, so the bar value and multiplier happened to be equal.
Choose Three waves together and Show final state. The reconstruction is approximately
This is the same field shown in green. At the position \(x=\pi/2\) used in Section 3, the temperature is now approximately \(0.913-0.220-0.00289=0.690\), compared with its initial value of \(0.25\). The negative contributions from modes 3 and 7 have moved toward zero. Their changes exceed the decrease of mode 1, so this position warms while other positions cool.
A spectral solution obtains the entire final field by finding the initial coefficients, multiplying them by their decay factors, and adding the resulting waves.
Read the operator as a change of coordinates¶
Call the heat-evolution operator \(\mathcal L_T\). It maps an entire initial field to its field at time \(T\). Its Fourier representation is
Read this expression from right to left. \(F\) obtains the input coefficients. The diagonal matrix \(\Lambda_T\) scales each coefficient without mixing it with another mode. \(F^{-1}\) reconstructs the final field. These coordinates simplify the operator because its eigenfunctions evolve independently.
The same multipliers work for every initial field on this periodic domain with the same \(\nu\) and \(T\). Changing the initial amplitudes changes the answer, but does not change the decay factors. This is a rule for transforming a family of fields. Could examples reveal that rule if the PDE were not supplied to the fitting procedure?
How does one input location affect another?¶
The Fourier description follows whole waves. The same heat operator also has a description in terms of localized inputs. Place a unit amount of initial heat at position \(y\) on the ring. At a positive time \(T\), its influence has spread to other positions. Denote the resulting profile by \(\kappa(x,y)\), where \(y\) is the input location and \(x\) is the location where we measure the response.
This response is the heat equation's Green's function, also called its heat kernel. It answers how much a localized input at \(y\) contributes at \(x\) after time \(T\). Its integral over output positions is one, because heat flow on the ring preserves the total heat.
An arbitrary initial field can be assembled from many small localized inputs. At grid point \(y_j\), a small interval of width \(\Delta x\) contains an amount proportional to \(u_0(y_j)\Delta x\). By linearity, its contribution at \(x\) is \(\kappa(x,y_j)u_0(y_j)\Delta x\). Adding all contributions and taking the continuum limit gives
This is an integral kernel operator. More generally,
The kernel specifies the influence of each input location on each output location. It may come from known physics, as the heat kernel does here, or be part of a learned model. The integral combines those influences with the actual input field.
When is a kernel a convolution?¶
For constant diffusivity on a periodic ring, shifting the input shifts its heat response by the same amount. Only the separation between the two positions matters,
Here the separation is periodic. This integral is circular convolution. Translation invariance is the condition that reduces a general two-location kernel to a function of separation. Fixed boundaries and variable coefficients generally change that condition.
Why do its Fourier weights describe the same operator?¶
Apply a convolution kernel to one wave \(v(y)=e^{iky}\). Changing variables to the separation \(s=x-y\) gives
Periodicity permits the shifted integration interval to be written again as \([0,2\pi)\). The output is the same Fourier wave multiplied by one number. Thus \(R(k)\) is both the convolution's frequency response and its eigenvalue on that wave.
The descriptions are equivalent,
The kernel describes influence between positions. The multipliers describe the action on waves. For heat flow, they are exactly the factors already derived, \(R(k)=e^{-\nu k^2T}\). The next figure shows the heat kernel's point response and those same modal factors.
Kernel normalization with the Fourier convention used here
Field coefficients use \(\widehat v_k=(2\pi)^{-1}\int_0^{2\pi}v(x)e^{-ikx}\,dx\). The multiplier above includes the unnormalized integral of the kernel, so
In the discrete calculation, irfft(R) with its default inverse normalization gives convolution weights whose sum is one. Dividing those weights by \(\Delta x\) gives samples of the physical heat-kernel density. These normalization factors keep the point-influence and multiplier calculations consistent.
import matplotlib.pyplot as plt
kernel_k = np.arange(N//2+1)
heat_response = np.exp(-NU*T*kernel_k**2)
dx = 2*np.pi/N
kernel_weights = np.fft.irfft(heat_response, n=N)
kernel_density = kernel_weights/dx
source_index = N//2
fig, axes = plt.subplots(1, 2, figsize=(11, 3.3))
axes[0].plot(x, np.roll(kernel_density, source_index), color='#399e89', lw=2)
axes[0].axvline(x[source_index], color='#253349', ls=':', lw=1)
axes[0].set(xlabel='Output position x', ylabel='Response per unit initial heat',
title='Heat initially placed at y = π', xticks=[0, np.pi, 2*np.pi],
xticklabels=['0', 'π', '2π'])
axes[1].plot(kernel_k[:13], heat_response[:13], 'o-', color='#7251a1', ms=3)
axes[1].set(xlabel='Mode k', ylabel='Multiplier',
title='The same operator acting on Fourier waves')
fig.tight_layout()
plt.show()
direct_convolution = sum(kernel_weights[j]*np.roll(initial, j) for j in range(N))
spectral_solution = np.fft.irfft(heat_response*np.fft.rfft(initial), n=N)
assert np.isclose(kernel_weights.sum(), 1)
assert np.allclose(direct_convolution, spectral_solution, atol=1e-13)
5. Learn the multipliers¶
Keep the three wave shapes fixed and suppose their decay factors are unknown. The next display gives an initial field and an observed final field. Your task is to determine three numbers \(R(1),R(3),R(7)\) that transform one into the other.
What does a slider change?¶
For the initial field used throughout the lesson, the prediction is
Each slider changes a multiplier, not an output amplitude directly. For example, setting \(R(3)=0.4\) makes the output amplitude of mode 3 equal to \(0.5\times0.4=0.2\). Its wavelength remains unchanged. The display adds the three adjusted waves after every slider movement, so you can see the predicted field immediately.
Start with \(R(1)=R(3)=R(7)=1\). This returns the initial field unchanged. The observed field is smoother, so some components must shrink. First adjust the broad component with \(R(1)\). Then adjust the smaller variations with \(R(3)\) and \(R(7)\).
Can a change in \(R(7)\) repair an error in the broad shape? Can a change in \(R(1)\) remove the finest wiggles? Each slider controls a different spatial shape, which is why separate coordinates make the fitting problem easier to understand.
The reported error compares your predicted field with the observed field over the whole ring. Matching one temperature value is insufficient. The sum of your adjusted waves must match the target at all positions.
What will “Learn from data” do?¶
After trying the sliders, press Learn from data. The button determines the same three numbers automatically. It uses 64 observed initial-final field pairs, each with a different combination of the three sine shapes. The same \(R(k)\) must explain mode \(k\) in every pair.
The data generator uses the heat equation to create the observations. The fitting calculation receives their input and output coefficients. It does not receive the analytical decay factors. Those factors are revealed afterward for comparison.
This is a controlled demonstration with noiseless data and a linear operator on the represented modes. It makes the learned quantities directly inspectable before introducing a larger nonlinear network.
rng = np.random.default_rng(17)
training_amplitudes = rng.normal(size=(64, 3))
train_inputs = training_amplitudes @ basis
decay = np.exp(-NU*T*MODES**2)
train_targets = (training_amplitudes*decay) @ basis
# Extract coordinates from observed fields, then pass only these pairs to the fitting controls.
observed_inputs = -2*rfft(train_inputs)[:, MODES].imag
observed_outputs = -2*rfft(train_targets)[:, MODES].imag
fitted = np.sum(observed_inputs*observed_outputs, axis=0) / np.sum(observed_inputs**2, axis=0)
assert np.allclose(fitted, decay, atol=1e-13)
assert np.allclose((AMPLITUDES*fitted) @ basis, (AMPLITUDES*decay) @ basis)
show_experiment('learning', {
'modes': MODES.tolist(), 'nu': NU, 'time': T,
'amplitudes': AMPLITUDES.tolist(), 'target': (AMPLITUDES*decay).tolist(),
'inputs': observed_inputs.tolist(), 'outputs': observed_outputs.tolist(),
})
Can you match the final temperature field?
| Mode | Fitted from pairs | exp(−νk²T) |
|---|
How does the automatic fit find each number?¶
Take mode 3 in one training pair. Let \(a_3\) be its amplitude in the initial field and \(b_3\) its amplitude in the observed final field. The model says
If \(a_3=0.5\) and the observed \(b_3\) is approximately \(0.2204\), their ratio suggests \(R(3)\approx0.4408\). Another input might contain amplitude \(1.5\) and produce approximately \(0.6613\). It suggests the same ratio. The multiplier is a property of the operator at this fixed \(\nu\) and \(T\), while the initial amplitude changes from example to example.
The code first applies the FFT to the observed fields to read these coordinates. It then fits one input-output scale per mode. For the real sine amplitudes used here, least squares gives
This chooses the scale that minimizes the total squared mismatch \(\sum_j(R(k)a_k^{(j)}-b_k^{(j)})^2\). It combines information from all pairs rather than dividing by a single possibly small amplitude. If a mode were absent from every training input, the denominator would be zero and the data would not identify its multiplier.
The three fitted numbers can now transform a new combination of these modes. Apply the FFT to its initial field, multiply each retained coordinate by its fitted \(R(k)\), and reconstruct. The fit has learned a transformation shared across the input family, rather than storing one final temperature curve.
Which parts are learned?¶
The sine shapes and coordinate transforms stay fixed. The unknowns in this experiment are only the three multipliers. A direct fit suffices because the model is linear in those unknowns. A full FNO has many interacting parameters and is usually trained by gradient-based optimization.
The spectral calculation and the learned layer use the same sequence of operations,
For this example, both should recover the same factors \(0.913\), \(0.441\), and \(0.0116\). The nearly exact agreement is expected because the data are noiseless and the true map has exactly the form being fitted.
The learned computation is FFT, learned multiplication, inverse FFT. The FFT describes the input with wave coordinates. The learned weights transform those coordinates. The inverse FFT returns temperature values around the ring. This is a learned linear Fourier layer on the represented modes. The next section explains which capability must be added for nonlinear physics.
What spatial kernel has the layer learned?¶
Learning frequency multipliers also specifies a convolution kernel once the response at every frequency has been chosen. A truncated Fourier layer sets unretained multipliers to zero. With the normalization above, its spatial kernel is
The retained set \(\mathcal M\) includes matching positive and negative frequencies for real-valued fields. Each Fourier wave extends around the whole ring, so this finite sum generally gives a kernel with global support. Learning only a few modal weights does not restrict the operation to a few neighboring grid points.
Our fit identifies the action on modes 1, 3, and 7. If the other multipliers are set to zero, the resulting global kernel reproduces heat flow on the represented three-wave family. It need not equal the full physical heat kernel on arbitrary inputs. For example, heat preserves a constant input, while setting the unretained mode-zero multiplier to zero removes that constant. Many spatial kernels agree on the action of only those three modes. The data identify that restricted action; the architectural choice specifies what happens at the unretained modes.
This is the kernel connection in the original FNO paper, Section 4. The Fourier branch learns a global convolution through its response to waves. The full nonlinear network then composes such operations with channel transformations and activations.
6. Nonlinear physics and FNO¶
Every multiplier so far changes a mode already present in the input. To see the limitation, use the input \(u(x)=\sin x\) and try to predict the target \(u(x)^2\) in the next display.
First try a linear multiplier¶
Change only \(R_1\). The prediction remains \(R_1\sin x\). You can enlarge the wave, reduce it, or reverse its sign, but it still has one oscillation around the ring. The target has a different shape. It is nonnegative and has two peaks.
Watch the predicted amplitude at mode 2. The input has zero amplitude there. An independent multiplier would produce \(R_2\times0=0\), whatever value \(R_2\) had. Changing the weight on mode 1 cannot supply the missing mode 2 either. This limitation applies to the entire linear Fourier layer, not just to the slider range.
Then change the operation¶
Select Apply pointwise square. “Pointwise” means squaring the value separately at every spatial position. It does not mean squaring the Fourier coefficients. The display now reconstructs the wave, squares its spatial values, and examines the modes of that new field.
What appears at modes 0 and 2? Set \(R_1\) to one to match the target, then return to multiplier only. Observe which frequencies disappear again.
show_experiment('nonlinearity')
Can a multiplier create a missing frequency?
Why did the square introduce new modes?¶
The identity
expresses the squared curve using a constant and a wave with two spatial oscillations. Mode 0 supplies its positive mean. Mode 2 supplies its two peaks. The display shows amplitude magnitudes; the minus sign sets the phase of the cosine component.
For an input \(a\sin x\), the square is \(a^2/2-(a^2/2)\cos2x\). Thus the newly created amplitudes depend on the input amplitude. Nonlinearity changes both which modes are present and how their amplitudes depend on the input. This is what independent, fixed linear multipliers cannot represent.
How does a pseudospectral solver handle this?¶
Burgers' equation combines nonlinear transport and diffusion,
If the Fourier coefficients of \(u\) are known, its derivatives are easy to obtain. Multiply mode \(k\) by \(ik\) for \(u_x\), or by \(-k^2\) for \(u_{xx}\). The product \(u\,u_x\) requires another operation, because it couples modes.
A pseudospectral evaluation proceeds as follows.
- Keep the Fourier coefficients of the current physical field. Use the known derivative multiplier \(ik\) to obtain the coefficients of \(u_x\).
- Apply inverse FFTs to reconstruct \(u\) and \(u_x\) at the grid points.
- Multiply those grid values to form \(u(x_j)u_x(x_j)\). This physical-space product produces the mode interactions.
- FFT the product back to Fourier coordinates. Combine its negative with the viscous term, whose multiplier is \(-\nu k^2\), to obtain the time derivative of the coefficients.
- Use a time integrator to advance the physical solution, then repeat.
The derivatives are spectral operations, while the nonlinear product is evaluated on the grid. That combination is the pseudospectral computation. The FFT of the product contains the newly generated frequencies. It computes the mode coupling through a product of spatial values rather than an explicit sum over pairs of Fourier coefficients.
Every transformation in this solver comes from the PDE. The numerical scheme also chooses its time step and treatment of finite-grid errors. The Burgers notebook is the next application; the companion contains the aliasing exercise.
What changes in an FNO?¶
An FNO keeps the useful alternation between Fourier coordinates and spatial values, but learns transformations for the desired input-output map. It usually starts by converting each scalar input value into several feature values. These define intermediate feature fields, collected in \(v_\ell(x)\) at layer \(\ell\).
The channels provide several fields to process in parallel. Their values are learned representations. They do not need a prescribed meaning such as temperature or velocity. A final projection converts the last feature field back to the desired output, such as temperature or the Burgers solution.
For one block, follow the operations below.
- Decompose each feature field. Apply the FFT to every channel of \(v_\ell\). Each frequency now has a vector of channel coefficients.
- Transform those coefficients. At a retained frequency \(k\), multiply that vector by the learned matrix \(R_\ell(k)\). This can change amplitudes, phases, and the combinations of channels at that frequency. This linear step still does not mix different frequencies.
- Reconstruct transformed fields. The inverse FFT returns those coefficients to spatial feature values. Write this spectral branch as \(z(x)=F^{-1}[R_\ell(k)F(v_\ell)](x)\).
- Add a local transformation. At each position compute \(W_\ell v_\ell(x)+b_\ell\) from the input features at that position. This branch mixes channels locally and can pass information outside the spectral branch's retained frequencies. Adding it to \(z(x)\) combines local and global transformations.
- Apply the nonlinearity. Compute \(\sigma\) separately on the resulting feature values. Like the square in the display, a pointwise nonlinear function can create and couple Fourier modes when its output is decomposed again.
The local matrix \(W_\ell\) is linear. It does not supply the missing nonlinear frequency generation. That role belongs to \(\sigma\). Standard FNO activations need not be literal squares; training chooses weights across several blocks so their combined action approximates the desired map.
These steps give the layer formula,
Compare the two computations¶
| Pseudospectral evaluation of \(u\,u_x\) | FNO feature block |
|---|---|
| Fourier coefficients of the physical field | Feature field \(v_\ell(x)\) |
| Known multipliers \(1\) and \(ik\) | FFT, then learned channel weights \(R_\ell(k)\) |
| IFFT reconstructs \(u\) and \(u_x\) | IFFT, then add local channel mixing \(W_\ell v_\ell+b_\ell\) |
| Multiply \(u\,u_x\) at each grid point | Apply the pointwise activation \(\sigma\) |
| FFT the product; combine the PDE terms and advance in time | Next feature field \(v_{\ell+1}(x)\) |
The common structure is specific. Linear spectral operations act efficiently on mode coefficients, while nonlinear spatial operations couple those modes. In the solver, the PDE specifies the operations and a numerical integrator advances physical time. In an FNO, training adjusts the weights to improve the final field prediction. Its layers advance a feature representation and need not correspond to physical time steps.
The heat experiment needed only a learned diagonal linear map because its modes evolved independently. Nonlinear physics motivates the full architecture because the output can contain modes created through interactions among the input modes.
The page From spectral methods to Fourier neural operators writes out this lesson as one derivation. It works the Burgers term \(u\,u_x\) by hand, couples modes with a variable diffusivity, and lists where the method struggles.
Continue with the existing Burgers and Darcy notebook to implement and train the full FNO. The CNN and discretization companion retains the convolution animation, filter comparisons, spatial kernel widths, least-squares derivation, and grid-refinement experiments.
Li's blog explains the Fourier layer as global convolution. McCabe et al., Section 2 analyze the pseudospectral connection. The original FNO paper gives the full architecture.