Skip to content

Add forward wave equation example#21

Open
gpartin wants to merge 1 commit intoidrl-lab:masterfrom
gpartin:feature/add-forward-wave-equation
Open

Add forward wave equation example#21
gpartin wants to merge 1 commit intoidrl-lab:masterfrom
gpartin:feature/add-forward-wave-equation

Conversation

@gpartin
Copy link
Copy Markdown

@gpartin gpartin commented Mar 11, 2026

Summary

Adds a forward wave equation example, complementing the existing inverse wave equation example.

Problem

The 1D wave equation u_tt = c^2 * u_xx on [0, 1] x [0, 1] with:

  • Fixed-end BCs: u(0, t) = u(1, t) = 0
  • Initial displacement: u(x, 0) = sin(pi * x)
  • Initial velocity: u_t(x, 0) = 0
  • Wave speed: c = 1.0

Analytical solution: u(x, t) = sin(pi * x) * cos(pi * c * t)

What's included

  • examples/wave_equation/wave_equation.py: Complete forward problem using the built-in WaveNode, with:
    • Interior PDE domain (10k collocation points)
    • Initial displacement condition (u = sin(pi*x) at t=0)
    • Initial velocity condition (u_t = 0 at t=0)
    • Dirichlet boundary conditions
    • Inference, comparison with exact solution, and L2 error computation
    • Three-panel plot (predicted, exact, absolute error)
  • examples/wave_equation/readme.md: Usage instructions

Motivation

The existing inverse_wave_equation example shows parameter inference but there is no forward problem example for the wave equation. The wave equation is one of the most fundamental PDEs in physics (acoustics, electromagnetics, seismology), so having a forward example helps users understand IDRLnet's PDE-solving capability for hyperbolic equations.

Add a forward 1D wave equation example complementing the existing
inverse wave equation. Solves u_tt = c^2 * u_xx on [0,1] x [0,1]
with fixed-end BCs, sinusoidal initial displacement, and zero initial
velocity using the built-in WaveNode PDE.

Includes initial displacement, initial velocity, and boundary
conditions as separate sample domains, inference with exact solution
comparison, and L2 error computation.
Copilot AI review requested due to automatic review settings March 11, 2026 19:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new forward-solve example for the 1D wave equation to complement the existing inverse wave equation example, demonstrating how to set up interior PDE constraints, initial conditions, and boundary conditions with IDRLnet.

Changes:

  • Added examples/wave_equation/wave_equation.py implementing a forward wave-equation PINN workflow (training, inference, exact-solution comparison, plots, L2 error).
  • Added examples/wave_equation/readme.md with problem statement and usage instructions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
examples/wave_equation/wave_equation.py New forward wave-equation example script using WaveNode, including visualization and error reporting.
examples/wave_equation/readme.md Documentation for running and understanding the new example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Exact solution: u(x, t) = sin(pi * x) * cos(pi * c * t)
"""

from sympy import Symbol, sin, cos, pi
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cos is imported from sympy but not used anywhere in this script. Consider removing it to avoid unused-import lint failures and keep dependencies minimal.

Suggested change
from sympy import Symbol, sin, cos, pi
from sympy import Symbol, sin, pi

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants