def nspin(calc, val):
    """https://www.quantum-espresso.org/Doc/INPUT_PW.html#nspin
    """
    assert val in [2, 4]
    assert calc.get_param('occupations')
    assert calc.get_param('smearing')
    assert calc.get_param('degauss')
    if val == 4:
        assert calc.get_param('noncolin')
    moments = calc.atoms.get_initial_magnetic_moments()
    assert moments.any()
