The Linear Wave Data Set
The one-dimensional linear wave equation with homogeneous Dirichlet boundary conditions, discretized in space as a Hamiltonian system and integrated with the implicit midpoint rule, for a range of wave speeds. Its solutions are thin pulses travelling at different speeds, a standard test for model reduction because a linear subspace needs many modes to represent them.
linear_wave is one call to GeometricProblems.LinearWave.hodeensemble and one to GeometricIntegrators.integrate; linear_wave_snapshots arranges the result as the tensor a ReducedComplexityModeling.DataLoader takes.
The system
On $\xi \in (-1/2, 1/2)$ the wave equation $\partial_{tt}u = \mu^2\partial_{\xi\xi}u$ with $u(t, \pm 1/2) = 0$ is discretized on the $N$ interior points $\xi_i = i\Delta\xi - 1/2$, $i = 1, \ldots, N$, $\Delta\xi = 1/(N+1)$. With $q_i \approx u(t, \xi_i)$ and $p_i = \dot q_i$ the semi-discrete system is canonical Hamiltonian with
\[H(q, p; \mu) = \frac{1}{2}p^Tp - \frac{\mu^2}{2}q^TD_{\xi\xi}q, \qquad D_{\xi\xi} = \frac{1}{\Delta\xi^2}\,\mathrm{tridiag}(1, -2, 1),\]
the full-order model of [4]. The state $(q, p)$ has $2N$ components.
Each wave speed $\mu$ gets its own initial condition, GeometricProblems.LinearWave.initial_condition: $q(0, \xi) = h(20\mu\,|\xi + \mu/2|)$ with the cubic spline $h$ and $p(0, \xi) = -\mu\,\partial_\xi q(0, \xi)$, so the pulse starts at $\xi = -\mu/2$ and travels to the right at speed $\mu$. For $\mu \in [5/12, 2/3]$ it stays away from the boundary for $t \in [0, 1]$.
Generating the data
The defaults are the training set of the symplectic-autoencoder experiment: twenty equally spaced $\mu \in [5/12, 2/3]$, $N = 128$ and 200 snapshots on $[0, 1]$.
using GMLDatasets, GeometricMachineLearning
solution = linear_wave()
data = linear_wave_snapshots(solution) # 256 × 200 × 20
dl = DataLoader(data; autoencoder = true)The scripts of that experiment, which train symplectic autoencoders on these data and compare them with the proper symplectic decomposition, are in scripts/linear_wave/; its README lists the commands.
Library functions
GMLDatasets.linear_wave — Function
linear_wave(; N, μ, timespan, n_time_steps, integrator)Integrate the discretized linear wave equation for each wave speed in μ and return the GeometricSolutions.EnsembleSolution.
This is GeometricProblems.LinearWave.hodeensemble composed with GeometricIntegrators.integrate and nothing more. The problem is the one GeometricProblems defines: the wave equation $\partial_{tt}u = \mu^2\partial_{\xi\xi}u$ on $\xi \in (-1/2, 1/2)$ with homogeneous Dirichlet boundary conditions, discretized on the N interior points $\xi_i = i\Delta\xi - 1/2$, $\Delta\xi = 1/(N+1)$, with the Hamiltonian
\[H(q, p; \mu) = \frac{1}{2}p^Tp - \frac{\mu^2}{2}q^TD_{\xi\xi}q ,\]
where $D_{\xi\xi}$ is the central-difference matrix. The state has $2N$ components.
Every wave speed gets its own initial condition, GeometricProblems.LinearWave.initial_condition(μ, N): a cubic-spline pulse that starts at $\xi = -\mu/2$ with width $\propto 1/\mu$ and initial momentum $p = -\mu\,\partial_\xi q$, so that it travels to the right at speed $\mu$. Over the default timespan it does not reach the boundary for any $\mu \in [5/12, 2/3]$.
The defaults are the training set of the symplectic-autoencoder experiment: twenty equally spaced values $\mu \in [5/12, 2/3]$, $N = 128$, n_time_steps = 200 snapshots on $t \in [0, 1]$ (so the time step is $1/199$), integrated with the implicit midpoint rule.
Use linear_wave_snapshots to turn the solution into the data tensor a ReducedComplexityModeling.DataLoader takes:
using GeometricMachineLearning
dl = DataLoader(linear_wave_snapshots(linear_wave()); autoencoder = true)GMLDatasets.linear_wave_snapshots — Function
linear_wave_snapshots(solution)The snapshots of a linear_wave solution as one $2N × n_t × n_μ$ array: the rows are $(q_1, …, q_N, p_1, …, p_N)$, one column per time step (the initial condition first) and one slice per wave speed, in the order of μ.
That is the layout every symplectic architecture in GeometricMachineLearning assumes (the first half of the rows is $q$, the second half $p$) and the one DataLoader reads off a tensor.
Given a single GeometricSolution it returns the $2N × n_t$ matrix of that trajectory.
GMLDatasets.linear_wave_parameters — Function
linear_wave_parameters(solution)The wave speeds $\mu$ of a linear_wave solution, one per trajectory and in the order of the slices of linear_wave_snapshots.