Solution (source code)

= Solution

The <Fokker-Planck equation> corresponds to the <Itô diffusion>
$$
\boxed{dX=v(X)dt+\sqrt{2D}\,dW,}
$$
absorbed at $0$ and reflected at $L$.

For $v(x)=x$, an Euler--Maruyama proposal is
$$
Y=X_n+X_n\Delta t+\sqrt{2D\Delta t}\,Z_n,
\qquad Z_n\sim N(0,1).
$$
If $Y\leq0$, kill the path. If $X_n>0$ and $Y>0$, an endpoint-only test can miss a crossing. Conditional on the endpoints, the local <Brownian bridge> crossing probability is
$$
\boxed{p_{\rm cross}=\exp\left(-\frac{X_nY}{D\Delta t}\right).}
$$
Kill the path with this probability; otherwise impose reflection at $L$ by replacing an overshoot $Y>L$ with $2L-Y$ and set $X_{n+1}=Y$. Repeated reflection handles very rare multiple overshoots, and the approximation converges as $\Delta t\to0$.