# Partial differential equation FEM application

I have a PDE which looks like Helmholtz wave equation on one dimensional domain. $$\dfrac{d^2u(x)}{dx^2}+\pi^2u(x)=f(x)$$ where $$-\infty

Also, $$f(x)= 1$$ for $$-0.25, I call this region "inner region"

$$f(x)=0$$ elsewhere

I truncated the computational domain using absorbing boundary conditions into $$-1

I chose mesh size as $$\lambda/10$$ at 1 GHz.

Finally I plotted the answer as shown below. How can I test its trueness of its? Why do I observe decrease in the inner region? • The decrease in the inner region is due to the source term in the right-hand side, it forces $u''$ to be positive there. For this ODE one can find an analytic solution. Alternatively you can calculate the individual terms by finite difference and see if the equation is satisfied. May 25, 2020 at 14:16

Using the given ODE, the boundary conditions $$u(x)=0$$ at $$x=\pm1$$, and the symmetry of the solution it is easy to write the exact analytic solution:

$$u(x)= a \sin(\pi x)$$, for x $$\in$$ [1/4,1]

$$u(x)=- a \sin(\pi x)$$, for x $$\in$$ [-1,-1/4]

$$u(x) = 1/\pi^2 + b \cos(\pi x)$$, for x $$\in$$ [-1/4,1/4]

The matching condition for the function derivative at x=1/4 yields $$b=-a$$, and the matching condition for the function value at x=1/4 yields $$a \sqrt{2}/2 = b \sqrt{2}/2 + 1/\pi^2$$, so we find $$a=1/(\sqrt{2} \pi^2)$$ and $$b=-1/(\sqrt{2} \pi^2)$$. At the maximum point x=1/2, u(1/2)=a $$\sim$$0.07 which visually matches the plot; and at the minimum point x=0, u(0)=$$(1/\pi^2+b) \sim$$ 0.03 which visually matches the plot; a more detailed comparison could be done comparing the numerical values from the code against the analytic solution.

• I just assumed $u(x)$=0 at those boundaries What is $j$? I am not sure your absorbing boundary conditions are satisfied there, $u(x)$ visually seems to be close to zero there but $u'(x)$ is not close to zero - how can this work unless $j$ is a very large number. May 25, 2020 at 15:51
• $j$ is an imaginary variable like $i$. If we would have solved the question with these boundary conditions, would your answer change? @Maxim Umansky May 25, 2020 at 16:15
• I was assuming $u(x)$ is a real-valued function. Is it complex-valued? May 25, 2020 at 16:22
• Yes, $u(x)$ can be form of a complex valued function. @Maxim Umansky May 25, 2020 at 16:39
• If it is a complex-valued function then what is shown in your plot? Does your code produce complex numbers or real numbers? Probably this ODE describes the real part of the complex-valued function, and I suspect your absorbing boundary conditions mean zero boundary condition values for the real part at $\pm$1. But to say more definitely one needs to know where your ODE comes from and what physics it describes, to see if this interpretation of your absorbing boundary conditions is right. May 25, 2020 at 16:54