2. Let $a \geqslant 0$, solve the equation $2|z|+a z+\mathrm{i}=0$ in the set of complex numbers.
2. Let $z|z|+a z+\mathrm{i}=0$,

Taking the conjugate of both sides of the original equation, we get
$$
\bar{z}|\bar{z}|+a \bar{z}-\mathrm{i}=0 \text {. }
$$
Adding (1) and (2) gives $\quad(z+\bar{z})(|z|+a)=0$,

From the original equation, $z \neq 0$, and since $a \geqslant 0$, then $|z|+a>0$,
Thus, $z+\bar{z}=0$, which means $z$ is a pure imaginary number.
Let $z=y i(y \in \mathbf{R})$, then the original equation can be transformed into $y \mathrm{i}|y|+a y \mathrm{i}+\mathrm{i}=0$, or $y(|y|+a)=-1$.
Since $|y|+a>0$, then $y<0$.
Therefore, $y^{2}-a y-1=0$.

Solving it, we get $y=\frac{a-\sqrt{a^{2}+4}}{2}$. Hence, the solution to the original equation is $z=\frac{a-\sqrt{a^{2}+4}}{2} \mathrm{i}$.