Electromagnetic generator for melting metals