Theory and simulation of electromagnetic dampers for earthquake engineering applications