The sequences converges only for $x=0$, even when allowing all real $x$.
Note that $r_n(x):=\Re(a_n(x)) = \cos(2\pi x\sqrt{n})$, and that if $a_n(x)$ converges, then $r_n(x)$ must do so as well. If $x \neq 0$, then the argument $s_n(x):=2\pi x\sqrt{n}$ of the cosine function tends monotonically to $\pm\infty$, the sign being the same sign as $x$ has. Because $r_n(x)=r_n(-x)$, we can from now on w.l.o.g. assume $x>0$.
Because of $\sqrt{n+1}-\sqrt{n}=\frac{1}{\sqrt{n+1}+\sqrt{n}} < \frac{1}{2\sqrt{n}}$, we get
$$\lvert s_{n+1}(x) - s_n(x)\rvert = \lvert2\pi x(\sqrt{n+1}-\sqrt{n})\rvert < \lvert\pi x\rvert\frac1{\sqrt{n}}. \tag{1}\label{eq1}$$
The right hand side of that inequality tends to $0$ as $n$ tends to $\infty$, so does the left hand side.
Intuitively, that means that $s_n(x)$, on it's way to infinity, makes decreasingly smaller steps, so will again and again have values that are near $2k\pi$ for some $k \in \mathbb Z$, but also again and again have values that are near $(2k+1)\pi$ for some $k \in \mathbb Z$. That in turn means $r_n(x)$ will have again and again have values near $\cos(2k\pi)=1$, but also again and again have values near $\cos((2k+1)\pi)=-1$, so $r_n(x)$ cannot converge.
To put that more formally:
\eqref{eq1} means there is an $N$ such that
$$\lvert s_{n+1}(x) - s_n(x)\rvert < \frac{\pi}3 \text{ for } N \ge n.$$
The $y$-values where $\cos(y)\ge \frac12$ are exactly $2k\pi-\frac{\pi}6 \le y \le 2k\pi+\frac{\pi}6$ for $k \in \mathbb Z$, while similiarly $\cos(y)\le -\frac12$ for exactly $(2k+1)\pi-\frac{\pi}6 \le y \le (2k+1)\pi+\frac{\pi}6$ for $k \in \mathbb Z$.
Note that the length of each such interval is exactly $\frac{\pi}3$. So for for all $k \in \mathbb Z$ with $2k\pi > s_N(x)$, there must be at least one index $i_k$ such that $s_{i_k}(x) \in [2k\pi-\frac{\pi}6,2k\pi+\frac{\pi}6]$ and another index $j_k$ with $s_{j_k}(x) \in [(2k+1)\pi-\frac{\pi}6,(2k+1)\pi+\frac{\pi}6]$.
That implies $r_{i_k}(x) \ge \frac12$ and $r_{j_k}(x) \le -\frac12$. Since there are infinitly many such indices ("for all $k \in \mathbb Z$ with $2k\pi > s_N(x)$"), r_n(x) cannot converge.