def test_fleurinp_modifier1(create_fleurinp):
    """Tests if fleurinp_modifier with various modifations on species"""
    fleurinp_tmp = create_fleurinp(inpxmlfilefolder)

    fm = FleurinpModifier(fleurinp_tmp)
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.shift_value({'Kmax': 0.1}, 'rel')
    fm.shift_value_species_label('                 222', 'radius', 3, mode='abs')
    fm.set_species('all', {'mtSphere': {'radius': 3.333}})
    fm.undo()
    changes = fm.changes()
    assert changes == [('set_inpchanges', {
        'Kmax': 3.9,
        'dos': True
    }), ('shift_value', {
        'Kmax': 0.1
    }, 'rel'), ('shift_value_species_label', '                 222', 'radius', 3, 'abs')]

    fm.show(validate=True)
    fm.freeze()

    fm = FleurinpModifier(fleurinp_tmp)
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.undo(revert_all=True)
    changes = fm.changes()
    assert changes == []
示例#2
0
def test_fleurinp_modifier1(create_fleurinp):
    """Tests if fleurinp_modifier with various modifations on species"""
    from masci_tools.io.fleurxmlmodifier import ModifierTask
    fleurinp_tmp = create_fleurinp(inpxmlfilefolder)

    fm = FleurinpModifier(fleurinp_tmp)
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.shift_value({'Kmax': 0.1}, 'rel')
    fm.shift_value_species_label('                 222', 'radius', 3, mode='abs')
    fm.set_species('all', {'mtSphere': {'radius': 3.333}})
    fm.undo()
    changes = fm.changes()

    assert changes == [
        ModifierTask(name='set_inpchanges', args=({
            'dos': True,
            'Kmax': 3.9
        },), kwargs={}),
        ModifierTask(name='shift_value', args=({
            'Kmax': 0.1
        }, 'rel'), kwargs={}),
        ModifierTask(name='shift_value_species_label',
                     args=('                 222', 'radius', 3),
                     kwargs={'mode': 'abs'})
    ]

    fm.show(validate=True)
    fm.freeze()

    fm = FleurinpModifier(fleurinp_tmp)
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.undo(revert_all=True)
    changes = fm.changes()
    assert changes == []
示例#3
0
def test_fleurinp_modifier_regression(create_fleurinp, inpxml_etree, file_regression):
    """Tests if fleurinp_modifier with various other modifations methods,
    the detailed tests for method functionality is tested elsewhere."""
    fleurinp_tmp = create_fleurinp(inpxmlfilefolder)

    fm = FleurinpModifier(fleurinp_tmp)
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.shift_value({'Kmax': 0.1}, 'rel')
    fm.shift_value_species_label('                 222', 'radius', 3, mode='abs')
    fm.set_species('all', {'mtSphere': {'radius': 3.333}})

    #fm.set_nkpts(500, gamma='T')
    #fm.set_kpath({'gamma': (0, 0, 0), 'L': (0.1, 0.1, 0.1)}, 300)
    with pytest.deprecated_call():
        fm.add_num_to_att('/fleurInput/calculationSetup/scfLoop', 'minDistance', 4)
    #fm.set_species1
    fm.show()

    new_fleurinp = fm.freeze()

    file_regression.check(new_fleurinp.get_content('inp.xml'), extension='.xml')
示例#4
0
def test_fleurinp_modifier_included_files(create_fleurinp, inpxml_etree, file_regression):
    """Tests if fleurinp_modifier with various other modifations methods,
    the detailed tests for method functionality is tested elsewhere."""

    TEST_FOLDER = os.path.dirname(os.path.abspath(__file__))
    TEST_FOLDER = os.path.abspath(os.path.join(TEST_FOLDER, '../files/included_xml_files'))

    INPXML_FILE = os.path.join(TEST_FOLDER, 'inp.xml')
    KPTSXML_FILE = os.path.join(TEST_FOLDER, 'kpts.xml')
    SYMXML_FILE = os.path.join(TEST_FOLDER, 'sym.xml')

    fleurinp_tmp = create_fleurinp(INPXML_FILE, additional_files=[KPTSXML_FILE, SYMXML_FILE])

    fm = FleurinpModifier(fleurinp_tmp)
    #Modify main inp.xml file
    fm.set_inpchanges({'dos': True, 'Kmax': 3.9})
    fm.shift_value({'Kmax': 0.1}, 'rel')

    #Modify included xml files
    fm.delete_tag('symmetryOperations')
    fm.create_tag('symmetryOperations')
    fm.create_tag('kPointList')
    fm.create_tag('kPoint', occurrences=0)
    fm.set_attrib_value('name', 'TEST', contains='kPointList', occurrences=0)
    fm.set_text('kPoint', [0.0, 0.0, 0.0],
                complex_xpath="/fleurInput/cell/bzIntegration/kPointLists/kPointList[@name='TEST']/kPoint")

    fm.show()

    new_fleurinp = fm.freeze()

    assert new_fleurinp.files == ['kpts.xml', 'sym.xml', 'inp.xml']

    file_content = [
        new_fleurinp.get_content('inp.xml'),
        new_fleurinp.get_content('kpts.xml'),
        new_fleurinp.get_content('sym.xml')
    ]

    file_regression.check('\n'.join(file_content), extension='.xml')