Ejemplo n.º 1
0
def test_set_nmmpmat_file(load_inpxml, file_regression):
    """Test setting of nmmpmat with initial nmmpmat file given"""
    from masci_tools.util.xml.xml_setters_nmmpmat import set_nmmpmat

    xmltree, schema_dict = load_inpxml(TEST_INPXML_LDAU_PATH)

    with open(TEST_NMMPMAT_PATH, mode='r') as nmmpfile:
        nmmp_lines = nmmpfile.read().split('\n')

    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             species_name='Ga-1',
                             orbital=2,
                             spin=1,
                             state_occupations=[1, 2, 3, 4, 5])
    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             'As-2',
                             orbital=1,
                             spin=1,
                             denmat=[[1, -2, 3], [4, -5, 6], [7, -8, 9]])

    file_regression.check(prepare_for_file_dump(nmmp_lines))
Ejemplo n.º 2
0
def test_set_nmmpmat_file_get_wigner_matrix(load_inpxml, file_regression):
    """Test get_wigner_matrix by calling set_nmmpmat_file with theta, or phi != None"""
    from masci_tools.util.xml.xml_setters_nmmpmat import set_nmmpmat

    xmltree, schema_dict = load_inpxml(TEST_INPXML_LDAU_PATH)

    nmmp_lines = None
    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             species_name='Ga-1',
                             orbital=1,
                             spin=1,
                             state_occupations=[1, 0, 1],
                             theta=np.pi / 2.0)
    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             'As-2',
                             orbital=1,
                             spin=1,
                             denmat=[[1, 0, 1], [0, 0, 0], [1, 0, 1]],
                             phi=np.pi / 4.0,
                             theta=np.pi / 2.0)

    file_regression.check(prepare_for_file_dump(nmmp_lines))
Ejemplo n.º 3
0
def test_validate_nmmpmat(load_inpxml):
    """Test validation method of nmmpmat file together with inp.xml file"""
    from masci_tools.util.xml.xml_setters_nmmpmat import set_nmmpmat, validate_nmmpmat

    xmltree, schema_dict = load_inpxml(TEST_INPXML_LDAU_PATH)

    with open(TEST_NMMPMAT_PATH, mode='r') as nmmpfile:
        nmmp_lines_orig = nmmpfile.read().split('\n')

    validate_nmmpmat(xmltree, nmmp_lines_orig, schema_dict)  #should not raise

    #Test number of lines error
    nmmp_lines = nmmp_lines_orig.copy()
    nmmp_lines.append('0.0')
    with pytest.raises(ValueError):
        validate_nmmpmat(xmltree, nmmp_lines, schema_dict)
    nmmp_lines.remove('0.0')

    #Test invalid diagonal element error
    nmmp_lines = nmmp_lines_orig.copy()
    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             species_name='Ga-1',
                             orbital=2,
                             spin=1,
                             state_occupations=[1, 2, 3, 4, 5])
    nmmp_lines = set_nmmpmat(xmltree,
                             nmmp_lines,
                             schema_dict,
                             'As-2',
                             orbital=1,
                             spin=1,
                             denmat=[[1, -2, 3], [4, -5, 6], [7, -8, 9]])
    with pytest.raises(ValueError):
        validate_nmmpmat(xmltree, nmmp_lines, schema_dict)

    #Test invalid outsied value error
    nmmp_lines = nmmp_lines_orig.copy()
    nmmp_lines[
        0] = '     0.0000000000000     9.0000000000000     0.0000000000000     0.0000000000000     0.0000000000000     0.0000000000000     0.0000000000000'

    with pytest.raises(ValueError):
        validate_nmmpmat(xmltree, nmmp_lines, schema_dict)