Controlling welding hot cracking based on electromagnetic force