Simulation of thermionic cathodes