  Under the Franck-Condon approximation, we systematically validated the
performance of density functional theory (DFT) and the effects of anharmonicity
in simulating C/N/O K-edge vibrationally-resolved X-ray spectra of common
diatomic molecules. To get ``transparent'' validations, vibronic fine
structures of only the lowest 1s excited or ionized state in the X-ray
absorption (XAS) or photoelectron (XPS) spectra were investigated. All 6
systems (N$_2$, N$_2^+$; NO, NO$^+$; CO, CO$^+$) were studied within the
harmonic oscillator (HO) approximation using DFT with four functionals (BLYP,
BP86, B3LYP, M06-2X) for 10 XAS and 4 XPS spectra, and excellent agreement
between theoretical and experimental spectra was found in most systems, except
O1s XAS of NO, CO, and NO$^+$. We analyzed and established a connection between
their complex vibronic structures (many weak oscillating features within a
broad peak) and the significant geometrical changes induced by the O1s hole.
The three spectra were well reproduced with anharmonic (AH) calculations by
using quantum wavepacket dynamics based on potential energy curves (PECs)
generated by DFT methods or multiconfigurational levels, highlighting
sensitivity to the anharmonic effect and the PEC quality. In other examples of
XAS (CO$^+$, C1s and O1s; NO, N1s) corresponding to smaller structural changes,
HO and AH approaches lead to similar fine structures, which are dominated by
0-0 and 0-1 transitions. This study highlights the use of DFT with selected
functionals for such diatomic calculations due to its easy execution and
generally reliable accuracy. Functional dependence in diatomic systems is
generally more pronounced than in polyatomic ones. We found that BLYP, BP86,
and B3LYP functionals consistently exhibited high accuracy in predicting
spectral profiles, bond lengths, and vibrational frequencies, which slightly
outperformed M06-2X.
