Compensation of external magnetic field by an internal field in a superconductor