Domain: Physics — Condensed Matter Physics

Problem:
Compute the signed x-component of the Molecular Augmented Dynamics (MAD) neutron-diffraction experimental force on atom 2, \( \tilde f_{2}^{x,N} \) (units: eV/nm) for a periodic cubic box with side \( L = 2.000 \, \mathrm{nm} \) and atoms at \( \vec{r}_1 = (-0.150, 0.020, 0.000) \, \mathrm{nm} \) (species C), \( \vec{r}_2 = (0.000, 0.000, 0.000) \, \mathrm{nm} \) (species D), \( \vec{r}_3 = (0.160, -0.010, 0.010) \, \mathrm{nm} \) (species C). Use minimum-image convention. \( N=3 \), \( \Omega=L^3 \), \( \rho=N/\Omega \), \( c_a=N_a/N \), \( \rho_a=c_a\rho \).

Given:

Kernel PDFs for \( a,b \in \{C,D\} \) with \( r_{\mathrm{cut}} = 1.000 \, \mathrm{nm} \) and \( \sigma_{CC} = 0.010 \, \mathrm{nm} \), \( \sigma_{CD} = \sigma_{DC} = 0.012 \, \mathrm{nm} \), \( \sigma_{DD} = 0.014 \, \mathrm{nm} \):

\[ \hat g_{ab}(r) = \frac{1}{\sqrt{2\pi}} \frac{1}{4\pi r^2 N_a \rho_b} \sum_{i: s(i)=a} \sum_{\substack{j \ne i \\ s(j)=b}} \frac{1}{\sigma_{ij}} \exp \left[ -\frac{(r-r_{ij})^2}{2\sigma_{ij}^2} \right], \qquad r_{ij} = |\mathbf{r}_j - \mathbf{r}_i|. \]

Windowed partial structure factors for one \( Q \):

\[ \hat S_{ab}(Q) = \delta_{ab} + 4\pi\rho(c_a c_b)^{1/2} \int_0^{r_{\mathrm{cut}}} dr \, r^2 \frac{\sin(Qr)}{Qr} \frac{\sin(\pi r/r_{\mathrm{cut}})}{\pi r/r_{\mathrm{cut}}} [\hat g_{ab}(r)-1]. \]

Neutron intensity:

\[ \hat I_N(Q) = \sum_{a,b} \bar b_a \bar b_b (c_a c_b)^{1/2} [\hat S_{ab}(Q) - \delta_{ab}] + \sum_a c_a \bar b_a^2. \]

Experimental potential (single \( Q \)):

\[ \tilde V = \frac{\gamma}{2} [\hat I_N(Q) - I^{\mathrm{exp}}_N(Q)]^2, \qquad \gamma = 0.040 \, \mathrm{eV/atom}, \quad \Delta I \equiv \hat I_N(Q) - I^{\mathrm{exp}}_N(Q) = -1.000 \times 10^{11}. \]

Force:

\[ \tilde f_{k}^{\alpha,N} = -\gamma \frac{\partial \hat I_N(Q)}{\partial r_k^\alpha} \Delta I, \qquad Q = 31.00 \, \mathrm{nm^{-1}}, \quad \alpha = x, \quad k = 2. \]

Numerics: use Gauss–Legendre quadrature on \( [0, r_{\mathrm{cut}}] \) with \( n=2048 \); use numerically safe \( \mathrm{sinc} \) for both \( \sin(Qr)/(Qr) \) and the window. Mean coherent neutron scattering lengths (nm): \( \bar b_C = 6.65 \times 10^{-6} \), \( \bar b_D = 6.67 \times 10^{-6} \).

Output: a single number \( \tilde f_{2}^{x,N} \) in \( \mathrm{eV/nm} \) to three decimals.

Hints:

1. Use the minimum-image convention both for \( r_{ij} \) and for \( \partial r_{ij}/\partial r_2^x = \frac{r_j^x - r_i^x}{r_{ij}}(\delta_{2j} - \delta_{2i}) \), with the same wrapped displacement used to compute \( r_{ij} \).
2. Treat cross-species channels as ordered pairs and include both \( CD \) and \( DC \) terms; keep the \( N_a \) and \( \rho_b \) normalizations in \( \hat g_{ab}(r) \) exactly as written.
3. Perform Gauss–Legendre quadrature with \( n=2048 \) on \( [0, r_{\mathrm{cut}}] \) and use a numerically safe \( \mathrm{sinc} \) for both factors.
4. Only pairs with \( r_{ij} < r_{\mathrm{cut}} \) contribute; each pair’s kernel derivative carries \( \frac{r - r_{ij}}{\sigma_{ij}^2} \frac{\partial r_{ij}}{\partial r_2^x} \).
5. Verify the sign by a tiny forward finite difference on \( \hat I_N(Q) \) with \( r_2^x \to r_2^x + \varepsilon \).

Answer: \[-0.172\]

Solution code:
# IDEAL RESPONSE

# MAD neutron force (nm units, single-Q, analytic gradient)

import numpy as np

# Spec (nm)
L = 2.000
pos = np.array([[-0.150,  0.020,  0.000],   # C
                [ 0.000,  0.000,  0.000],   # D (atom 2, index 1)
                [ 0.160, -0.010,  0.010]],  # C
               dtype=float)
species = np.array(['C','D','C'])
rcut = 1.000
Q = 31.00
gamma = 0.040
DeltaI = -1.000e11
b = {'C': 6.65e-6, 'D': 6.67e-6}  # nm
sigma = {('C','C'):0.010, ('C','D'):0.012, ('D','C'):0.012, ('D','D'):0.014}

def mic(dr, L): return dr - L*np.round(dr/L)
def safe_sinc(z):
    out = np.ones_like(z)
    nz = np.abs(z) > 1e-14
    out[nz] = np.sin(z[nz])/z[nz]
    return out

# Densities
N = len(pos); Omega = L**3; rho = N/Omega
Na = {'C': int(np.sum(species=='C')), 'D': int(np.sum(species=='D'))}
c = {a: Na[a]/N for a in Na}
rho_b = {a: c[a]*rho for a in Na}

# Quadrature
nq = 2048
x, w = np.polynomial.legendre.leggauss(nq)
r_nodes = 0.5*(x+1.0)*rcut
w_nodes = 0.5*w*rcut
win_sinc = safe_sinc(np.pi*r_nodes/rcut)*safe_sinc(Q*r_nodes)

# Ordered pairs within rcut
pairs = []
for i in range(N):
    for j in range(N):
        if j == i: continue
        si, sj = species[i], species[j]
        dr = mic(pos[j]-pos[i], L)
        rij = float(np.linalg.norm(dr))
        if rij < rcut:
            pairs.append((i, j, si, sj, dr, rij))

# ∂g_ab/∂r_2^x on nodes
pref = {(a,b_): 1.0/(np.sqrt(2.0*np.pi)*4.0*np.pi*Na[a]*rho_b[b_]) for a in ('C','D') for b_ in ('C','D')}
dg = {('C','C'): np.zeros_like(r_nodes),
      ('C','D'): np.zeros_like(r_nodes),
      ('D','C'): np.zeros_like(r_nodes),
      ('D','D'): np.zeros_like(r_nodes)}

def drij_dr2x(i, j, dr_vec, rij):
    if rij == 0.0: return 0.0
    comp = dr_vec[0]/rij
    if j == 1: return  comp  # atom 2 is index 1
    if i == 1: return -comp
    return 0.0

for (i, j, si, sj, dr_vec, rij) in pairs:
    d = drij_dr2x(i, j, dr_vec, rij)
    if d == 0.0: continue
    sig = sigma[(si, sj)]
    gauss = np.exp(-0.5*((r_nodes - rij)/sig)**2)/sig
    mult  = (r_nodes - rij)/(sig**2)*d
    dg[(si, sj)] += gauss*mult

for key in dg:
    a, b_ = key
    if Na[a] and rho_b[b_]:
        dg[key] = pref[(a,b_)]*dg[key]

# ∂S_ab/∂r_2^x
dS = {}
for a in ('C','D'):
    for b_ in ('C','D'):
        integ = np.sum(win_sinc*dg[(a,b_)]*w_nodes)
        dS[(a,b_)] = 4.0*np.pi*rho*np.sqrt(c[a]*c[b_])*integ

# ∂I_N/∂r_2^x and signed force
dI = 0.0
for a in ('C','D'):
    for b_ in ('C','D'):
        dI += b[a]*b[b_]*np.sqrt(c[a]*c[b_])*dS[(a,b_)]

f2x = -gamma*dI*DeltaI
print(f"{f2x:.3f}")