  The electronic structure and intrinsic magnetic properties of
$\text{Fe}_2\text{AlB}_2$-related compounds and their alloys have been
investigated using density functional theory. For $\text{Fe}_2\text{AlB}_2$,
the crystallographic $a$ axis is the easiest axis, which agrees with
experiments. The magnetic ground state of $\text{Mn}_2\text{AlB}_2$ is found to
be ferromagnetic in the basal $ab$ plane, but antiferromagnetic along the $c$
axis. All $3d$ dopings considered decrease the magnetization and Curie
temperature in $\text{Fe}_2\text{AlB}_2$. Electron doping with Co or Ni has a
stronger effect on the decreasing of Curie temperature in
$\text{Fe}_2\text{AlB}_2$ than hole doping with Mn or Cr. However, a larger
amount of Mn doping on $\text{Fe}_2\text{AlB}_2$ promotes the ferromagnetic to
antiferromagnetic transition. A very anisotropic magnetoelastic effect is found
in $\text{Fe}_2\text{AlB}_2$: the magnetization has a much stronger dependence
on the lattice parameter $c$ than on $a$ or $b$, which is explained by
electronic-structure features near the Fermi level. Dopings of other elements
on B and Al sites are also discussed.
