Domain: Physics — Physics (general)

Problem:
Consider the 1-D wave equation on $[0,1]$,
\[
u_{tt} = u_{xx},
\]
with Dirichlet boundaries $u(0,t)=0$, $u(1,t)=0$. A restoring nonlinear point-attachment acts at $x_0 = 0.5$ and enters the PDE as a negative point force,
\[
u_{tt}(x,t)=u_{xx}(x,t)-F(u(x_0,t))\delta(x-x_0),
\]
where $F(u)=k_1 u+k_3 u^3$ with $k_1=1.0$, $k_3=10^4$. The delta is discretized using a collocated, lumped approximation: on a uniform grid of $N=4001$ nodes with $dx=1/(N-1)$, $x_j=j\,dx$, the point force is applied as
\[
-\frac{F(u_{j_0})}{dx} \quad\text{at } j_0=\mathrm{round}(x_0/dx)=2000,
\]
and zero elsewhere. Initial conditions are $u(x,0)=0$ and
\[
u_t(x,0)=A\exp\left[-\frac{(x-0.3)^2}{2(0.005)^2}\right],
\]
where $A$ is chosen so that the discrete kinetic energy
\[
E_0=\frac{1}{2}\sum_{j=0}^{N-1} u_t(x_j,0)^2\,dx
\]
equals $5.0$. Evolve the semi-discrete system using $dt=0.3\,dx$ until $T=30.0$. The displacement is measured at $x_B=0.4$, which coincides with node $j_B=\mathrm{round}(x_B/dx)=1600$. Report
\[
\max_{0\le t\le T} |u(x_B,t)|,
\]
rounded to three decimal point, as a single numerical value (dimensionless).

Answer type: Numerical value (dimensionless)

Answer: \(0.243\)

Solution code:
import numpy as np

# -------------------------
# Simulation configuration
# -------------------------
L = 1.0
x0 = 0.5
k1 = 1.0
k3 = 1e4        # ONLY nonlinear case
E0 = 5.0
sigma = 0.005

# Single scenario:
xA, xB = 0.3, 0.4

# Grid and time step (higher time resolution)
N = 4001
x = np.linspace(0.0, L, N)
dx = x[1] - x[0]
dt = 0.3 * dx      # smaller dt → smoother waveform
T = 30.0
Nt = int(T / dt)

def idx_of(xpos):
    return int(round((N-1) * xpos / L))

j0 = idx_of(x0)
jA, jB = idx_of(xA), idx_of(xB)

# -----------------------------------
# Initial velocity scaled to E0
# -----------------------------------
def initial_velocity(x, center, sigma, E0, dx):
    g = np.exp(-0.5 * ((x - center) / sigma)**2)
    I = np.sum(g**2) * dx
    A = np.sqrt(2 * E0 / I)
    return A * g

# -----------------------------------
# Simulation function
# -----------------------------------
def run(ximp_idx, xmeas_idx):
    u = np.zeros(N)
    v = initial_velocity(x, x[ximp_idx], sigma, E0, dx)
    u_prev = u.copy()
    u_curr = u + dt * v

    idx_i = np.arange(1, N-1)

    out = np.empty(Nt)
    out[0] = u_curr[xmeas_idx]

    for n in range(1, Nt):
        lap = (u_curr[idx_i-1] - 2*u_curr[idx_i] + u_curr[idx_i+1]) / dx**2
        rhs = np.zeros(N)
        rhs[idx_i] = lap

        uj = u_curr[j0]
        rhs[j0] += -(k1*uj + k3*uj**3) / dx

        u_next = 2*u_curr - u_prev + (dt**2) * rhs
        u_next[0] = 0.0
        u_next[-1] = 0.0

        u_prev, u_curr = u_curr, u_next
        out[n] = u_curr[xmeas_idx]

    t = np.arange(Nt) * dt
    return t, out

# -------------------------
# Run the single scenario and report max |u|
# -------------------------
t, y = run(jA, jB)

max_abs_disp = np.max(np.abs(y))
print(f"Max displacement amplitude at xB (|u|): {max_abs_disp:.3g}")