Klein-Gordon 1D¶
| Example | |
|---|---|
| Source | DeepXDE example |
| Problem | Forward and Inverse (the Inverse mode is PINNStudio's addition) |
| Dimension | 1D (x, t) |
| Regime | Time-dependent |
| Geometry | Interval |
| Outputs | u |
| Settings | Default, Tuned |
Governing equations¶
Mathematical form (from the benchmark records):
As typed in PINNStudio's Equations page (each expression is a residual, set to zero):
Constants: alpha = -1, beta = 0, gamma = 1, k = 2
Domain¶
- Interval: \(x \in [-1, 1]\)
- Time interval: \(t \in [0, 10]\)
Initial conditions¶
| Output | Initial value | How it is imposed (Settings: Default) |
|---|---|---|
u |
x |
loss term |
Boundary conditions¶
| Type | Where | Output | Value | Details |
|---|---|---|---|---|
| Dirichlet BC | True (the whole boundary) |
u |
x*cos(t) |
— |
| Operator BC (advanced) | initial time | — | du_t |
applied at the initial time |
Unknowns and measured data (Inverse)¶
| Trainable parameter | Initial value | True value |
|---|---|---|
gamma |
0.5 | 1 |
Measured data (Inverse page, measured-data files):
reference_data/deepxde/klein_gordon_inverse/t_1.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_2.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_3.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_4.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_5.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_6.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_7.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_8.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_9.txt→ outputu, weight 100reference_data/deepxde/klein_gordon_inverse/t_10.txt→ outputu, weight 100
Settings¶
Forward mode¶
Settings: Default — DeepXDE's own settings
- Network: FNN, hidden layers 2 × 40, inputs (x, t), 1 output; activation tanh, initializer Glorot uniform
- Points: 30,000 domain, 1,500 boundary, 1,500 initial, 6,000 test
- Loss weights:
1,1,1,1(equations, then boundary-condition rows, then initial conditions)
| Phase | Optimizer | Iterations | Learning rate | Decay |
|---|---|---|---|---|
| 1 | Adam | 20,000 | 0.001 | inverse time (3000, 0.9) |
| 2 | L-BFGS | 15,000 | — | none |
Settings: Tuned
The Training Log reports: Tuned settings: a larger network (hidden layers twice as wide, one more layer). The change is applied to the example's own settings.
- Network: FNN, hidden layers 3 × 80, inputs (x, t), 1 output; activation tanh, initializer Glorot uniform
- Points: 30,000 domain, 1,500 boundary, 1,500 initial, 6,000 test
- Loss weights:
1,1,1,1(equations, then boundary-condition rows, then initial conditions)
| Phase | Optimizer | Iterations | Learning rate | Decay |
|---|---|---|---|---|
| 1 | Adam | 20,000 | 0.001 | inverse time (3000, 0.9) |
| 2 | L-BFGS | 15,000 | — | none |
Inverse mode¶
Settings: Default — DeepXDE's settings with PINNStudio's Inverse-mode changes (see Notes)
- Network: FNN, hidden layers 2 × 40, inputs (x, t), 1 output; activation tanh, initializer Glorot uniform
- Points: 30,000 domain, 1,500 boundary, 1,500 initial, 6,000 test
- Loss weights:
1,1,1,1(equations, then boundary-condition rows, then initial conditions)
| Phase | Optimizer | Iterations | Learning rate | Decay |
|---|---|---|---|---|
| 1 | Adam | 20,000 | 0.001 | inverse time (3000, 0.9) |
| 2 | L-BFGS | 15,000 | — | none |
Settings: Tuned
The Training Log reports: Tuned settings: 3× iterations, a larger network, 3× points and an L-BFGS phase together. The change is applied to the example's own settings.
- Network: FNN, hidden layers 3 × 80, inputs (x, t), 1 output; activation tanh, initializer Glorot uniform
- Points: 90,000 domain, 4,500 boundary, 4,500 initial, 6,000 test
- Loss weights:
1,1,1,1(equations, then boundary-condition rows, then initial conditions)
| Phase | Optimizer | Iterations | Learning rate | Decay |
|---|---|---|---|---|
| 1 | Adam | 60,000 | 0.001 | inverse time (3000, 0.9) |
| 2 | L-BFGS | 45,000 | — | none |
Results¶
The configuration selected in PINNStudio's benchmark study, run on one RTX 4090. Forward: relative L₂ error of each output at the last reference time. Inverse: each parameter's relative error and, per seed, the largest of them (worst parameter error).
Forward problem¶
Settings: Tuned — Larger network (2× width, one more layer). Values: median over seeds 2026, 1, 2.
| Output | Relative L₂ |
|---|---|
| u | 2.3 × 10⁻³ |
Inverse problem¶
Settings: Tuned — all of the changes together. Values: median over seeds 2026, 1, 2.
| Parameter | True value | Recovered | Relative error |
|---|---|---|---|
| gamma | 1 | 1.00912 | 0.91 % |
Worst parameter error: 0.91 % (the median over the seeds of each seed's largest error).
Full benchmark record: every setting tried, the per-seed values and all figures are in the benchmark records on GitHub.
Loading it in PINNStudio¶
- Forward: toolbar Examples: › Forward › under the ── 1D ── heading, Klein-Gordon 1D › Default or Tuned, then Solve.
- Inverse: toolbar Examples: › Inverse › under the ── 1D ── heading, Klein-Gordon 1D › Default or Tuned, then Solve.
Loading an example fills in every setting; anything you change before Solve is listed in the Training Log. Your save folder, GPU, random-seed and plot-style settings are kept.
Reference solution¶
- Exact solution, Error Analysis › reference from formula:
u = x*cos(t)
Notes¶
- The second initial condition du/dt = 0 is applied at t = 0. (DeepXDE's script passes it to an OperatorBC, which selects spatial-boundary points rather than t = 0.)
- Inverse mode (PINNStudio's addition): the coefficient gamma of the nonlinear term (initial guess 0.5, true 1) is learned from u measured at t = 1, 2, ..., 10 (reference_data/deepxde/klein_gordon_inverse). alpha and beta stay known: the solution u = x cos t has u_xx = 0, so the data cannot tell alpha, and beta = 0.
Definition and records¶
- Definition:
EXAMPLESentry "Klein-Gordon equation" inpinnstudio/core/deepxde_examples.py- Inverse mode (PINNStudio's addition):
ADDED_INVERSE["Klein-Gordon equation"], same file - Settings: Tuned: entry "Klein-Gordon equation" in
pinnstudio/resources/tuned_settings.json
- Inverse mode (PINNStudio's addition):
- Equations: Governing equations on this page
- Reference data: the exact-solution formula under Reference solution (no data files)
- Measured data (Inverse):
reference_data/deepxde/klein_gordon_inverse/, written bytools/make_deepxde_reference_data.py - Benchmark records:
benchmarks/problems/klein-gordon-1d.md, its entry in the examples overview, the benchmark collection - Tuning-study configurations (records of the tuning study; open one with Problem › Open Saved Problem...; not presets of the Examples list):
Klein-Gordon 1D (tuned).pinn.json,Klein-Gordon 1D, inverse mode (tuned).pinn.json - DeepXDE example: Klein_Gordon.py (documentation)
- Cite: Lu et al. 2021 (DeepXDE)
How the benchmark values were measured and checked: Reproducibility.