The anisotropic magnetocaloric effect described by Maxwell formulation: Application to DyAl2 and TbNi2