예제 #1
0
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 get_inputs_fixed_configurations(self, index, config):
        """
        Sets up the input for the fixed density matrix calculation.
        """

        remote_data = None
        if self.ctx.scf_no_ldau_needed:
            try:
                fleurinp = self.ctx.scf_no_ldau.outputs.fleurinp
                remote_data = load_node(
                    self.ctx.scf_no_ldau.outputs.output_scf_wc_para['last_calc_uuid']).outputs.remote_folder
            except NotExistent:
                error = 'Fleurinp generated in the SCF calculation is not found.'
                self.control_end_wc(error)
                return {}, self.exit_codes.ERROR_SCF_NOLDAU_FAILED
        else:
            remote_data = self.inputs.remote
            if 'fleurinp' not in self.inputs:
                fleurinp = get_fleurinp_from_remote_data(remote_data, store=True)
                self.report(f'INFO: generated FleurinpData from {fleurinp.files}')
            else:
                fleurinp = self.inputs.fleurinp

        inputs = self.inputs

        label = f'Fixed_{index}'
        description = f'LDA+U with fixed nmmpmat for config {index}'

        if 'settings' not in inputs:
            settings = {}
        else:
            settings = inputs.settings.get_dict()

        if 'remove_from_remotecopy_list' not in settings:
            settings['remove_from_remotecopy_list'] = []
        settings['remove_from_remotecopy_list'].append('mixing_history*')

        self.report(f'INFO: create fleurinp for config {index}')
        fm = FleurinpModifier(fleurinp)

        fm.set_inpchanges({'itmax': self.ctx.wf_dict['iterations_fixed'], 'l_linMix': True, 'mixParam': 0.0})

        for atom_species, ldau_dict in self.ctx.wf_dict['ldau_dict'].items():
            fm.set_species(species_name=atom_species, attributedict={'ldaU': ldau_dict})

        for config_index, config_species in config.items():
            orbital = config_index.split('-')[-1]
            atom_species = '-'.join(config_index.split('-')[:-1])
            for spin, config_spin in enumerate(config_species):
                if self.ctx.wf_dict['use_orbital_occupation']:
                    fm.set_nmmpmat(species_name=atom_species,
                                   orbital=int(orbital),
                                   spin=spin + 1,
                                   orbital_occupations=config_spin)
                else:
                    fm.set_nmmpmat(species_name=atom_species,
                                   orbital=int(orbital),
                                   spin=spin + 1,
                                   state_occupations=config_spin)

        try:
            fm.show(display=False, validate=True)
        except etree.DocumentInvalid:
            error = ('ERROR: input, inp.xml changes did not validate')
            self.control_end_wc(error)
            return self.exit_codes.ERROR_INVALID_INPUT_FILE
        except ValueError as exc:
            error = ('ERROR: input, inp.xml changes could not be applied.' f'The following error was raised {exc}')
            self.control_end_wc(error)
            return self.exit_codes.ERROR_CHANGING_FLEURINPUT_FAILED

        fleurinp_fixed = fm.freeze()

        input_fixed = get_inputs_fleur(inputs.fleur,
                                       remote_data,
                                       fleurinp_fixed,
                                       self.ctx.options,
                                       label,
                                       description,
                                       settings=settings)

        return input_fixed, None
예제 #5
0
fleurmode.set_inpchanges({})
fleurmode.set_inpchanges({'dos': True})
tria = True
nkpts = 800

change_dict = {'dos': True, 'ndir' : -1, 'minEnergy' : -0.8,
               'maxEnergy' : 0.8, 'sigma' : 0.005}

fleurmode.set_inpchanges(change_dict)
if tria:
    change_dict = {'mode': 'tria'}
    fleurmode.set_inpchanges(change_dict)
if nkpts:
    fleurmode.set_nkpts(count=nkpts)

'''
fleurmode.set_species('W-1', {'radius' : 3.5})
fleurmode.change_atom('forces', True, position=(0.0, 0.0, 0.0))
fleurmode.set_xpath('/fleurinput/@dos', True)
'''
'''
name = 'Na-1'
xpathn = '/fleurInput/atomSpecies/species[@name = "{}"]/mtSphere'.format(name)# 'radius':
attributename = 'radius'
attribv = 0.0000
fleurmode.xml_set_all_attribv(xpathn, attributename, attribv)

xpathn = '/fleurInput/atomSpecies/species/mtSphere'
xpathn = '/fleurInput'
#attribv = [0.0000, '1.2', 3.4]
#fleurmode.xml_set_all_attribv(xpathn, attributename, attribv)