Example #1
0
 def test_get_value(self):
     p = kkrparams(LMAX=3)
     # check for KeyError if wrong key is checked
     known_error = False
     try:
         p.get_value('something_wrong')
     except KeyError:
         known_error = True
     assert known_error
     # check for returning unset value
     npol = p.get_value('NPOL')
     assert npol == None
     # check correct LMAX value
     lmax = p.get_value('LMAX')
     assert lmax == 3
     # check for returning lists for RUNOPT and TESTOPT
     runopt = p.get_value('RUNOPT')
     testopt = p.get_value('TESTOPT')
     assert runopt == []
     assert testopt == []
     p = kkrparams(TESTOPT=['test1', 'test2'], RUNOPT=['NEWSOSOL'])
     runopt = p.get_value('RUNOPT')
     testopt = p.get_value('TESTOPT')
     assert runopt == ['NEWSOSOL']
     assert set(testopt) == set(['test1', 'test2'])
Example #2
0
 def test_read_unsorted_inputfile(self):
     p = kkrparams(ZATOM=26.,
                   LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                   RCLUSTZ=1.5,
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1,
                   RMAX=7,
                   GMAX=65)
     p.fill_keywords_to_inputfile(output='input.temp.txt')
     txt = open('input.temp.txt', 'r').readlines()
     # exchange some lines
     tmp = txt[0]
     txt[0] = txt[5]
     txt[5] = tmp
     tmp = txt[-1]
     txt[-1] = txt[-2]
     txt[-2] = tmp
     tmp = txt[-2]
     txt[-2] = txt[-4]
     txt[-4] = tmp
     tmp = txt[-3]
     txt[-3] = txt[-1]
     txt[-1] = tmp
     with open('input.temp_unsorted.txt', 'w') as f:
         f.writelines(txt)
     p2 = kkrparams()
     p2.read_keywords_from_inputcard(inputcard='input.temp_unsorted.txt')
     print(p2.get_dict())
     print(dict(p2.get_set_values()))
     check_full_dict(p, p2)
    def test_get_missing_keys(self):
        p = kkrparams()
        missing = p.get_missing_keys()
        assert set(missing) == set(
            ['<ZATOM>', 'BRAVAIS', 'LMAX', 'GMAX', 'RMAX', 'NAEZ', '<RBASIS>', 'NSPIN', 'ALATBASIS'])
        missing = p.get_missing_keys(use_aiida=True)
        assert set(missing) == set(['LMAX', 'GMAX', 'RMAX', 'NSPIN'])

        p = kkrparams(params_type='voronoi', EMIN=-2, LMAX=3)
        missing = p.get_missing_keys()
        assert set(missing) == set(['<ZATOM>', 'BRAVAIS', 'RCLUSTZ', 'NAEZ', '<RBASIS>', 'NSPIN', 'ALATBASIS'])
Example #4
0
 def test_read_minimal_inputfile(self):
     p = kkrparams(ZATOM=26.,
                   LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                   RCLUSTZ=1.5,
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1)
     p.fill_keywords_to_inputfile(is_voro_calc=True)
     p2 = kkrparams(params_type='voronoi')
     p2.read_keywords_from_inputcard()
     check_full_dict(p, p2)
    def test_set_kkrimp_params_full(self, file_regression):
        p = kkrparams(params_type='kkrimp')
        p.set_multiple_values(CALCORBITALMOMENT=0,
                              RUNFLAG='',
                              QBOUND=10**-7,
                              NSPIN=1,
                              TESTFLAG='',
                              NPAN_EQ=7,
                              CALCFORCE=0,
                              NPAN_LOGPANELFAC=2,
                              SPINORBIT=0,
                              ITDBRY=20,
                              NPAN_LOG=5,
                              INS=1,
                              ICST=2,
                              CALCJIJMAT=0,
                              NCHEB=10,
                              HFIELD=[0.00, 0],
                              BRYMIX=0.05,
                              KVREL=1,
                              IMIX=0,
                              RADIUS_MIN=-1,
                              NCOLL=0,
                              RADIUS_LOGPANELS=0.6,
                              MIXFAC=0.05,
                              SCFSTEPS=1,
                              XC='LDA-VWN')
        with tempfile.NamedTemporaryFile('r') as tmp:
            p.fill_keywords_to_inputfile(output=tmp.name)
            file_content = tmp.read()

        file_regression.check(file_content)
Example #6
0
 def test_get_mandatory(self):
     p = kkrparams()
     manlist = p.get_all_mandatory()
     assert set(manlist) == set([
         'LMAX', 'NAEZ', 'BRAVAIS', 'RMAX', 'GMAX', 'NSPIN', '<RBASIS>',
         'ALATBASIS', '<ZATOM>'
     ])
Example #7
0
    def _check_and_extract_input_nodes(self, tempfolder):
        """
        Extract input nodes from inputdict and check consitency of input nodes
        :param inputdict: dict of inputnodes
        :returns:
            * parameters (aiida_kkr.tools.kkr_params.kkrparams), optional: parameters of KKRimp that end up in config.cfg
            * code (KKRimpCodeNode): code of KKRimp on some machine
            * imp_info (DictNode): parameter node of the impurity information, extracted from host_parent_calc
            * kkrflex_file_paths (dict): dictionary of {filenames: absolute_path_to_file} for the kkrflex-files
            * shapfun_path (str): absolute path of the shapefunction of the host parent calculation
            * host_parent_calc (KkrCalculation): node of the parent host calculation where the kkrflex-files were created
            * impurity_potential (SinglefileData): single file data node containing the starting potential for the impurity calculation
            * parent_calc_folder (RemoteData): remote directory of a parent KKRimp calculation
        """

        # get mandatory input nodes (extract code)
        code = self.inputs.code

        # now check for optional nodes
        if 'parameters' in self.inputs:
            parameters = self.inputs.parameters
        else:
            parameters = None
        if parameters is not None:  # convert to kkrparams instance
            parameters = kkrparams(params_type='kkrimp',
                                   **parameters.get_dict())

        # get hostfiles
        imp_info, kkrflex_file_paths, shapfun_path, shapes, host_parent_calc, params_host, structure = self._get_and_verify_hostfiles(
            tempfolder)

        # check impurity potential or parent calculation input
        # impurity_potential
        if 'impurity_potential' in self.inputs:
            impurity_potential = self.inputs.impurity_potential
            found_imp_pot = True
        else:
            impurity_potential = None
            found_imp_pot = False
        # parent calculation folder
        if 'parent_calc_folder' in self.inputs:
            parent_calc_folder = self.inputs.parent_calc_folder
            found_parent_calc = True
        else:
            parent_calc_folder = None
            found_parent_calc = False
        # consistency checks
        if not found_parent_calc and not found_imp_pot:
            raise InputValidationError(
                "Neither impurity_potential nor parent_calc_folder specified for this calculation.\n"
                "Please provide either impurity_potential or parent_calc_folder."
            )
        elif found_parent_calc and found_imp_pot:
            raise InputValidationError(
                "Both impurity_potential and parent_calc_folder specified for this calculation.\n"
                "Please provide one one, i.e. either impurity_potential or parent_calc_folder."
            )

        # Done checking inputs, returning...
        return parameters, code, imp_info, kkrflex_file_paths, shapfun_path, shapes, host_parent_calc, params_host, impurity_potential, parent_calc_folder, structure
Example #8
0
 def test_fill_inputfile_minimal_Voronoi(self):
     p = kkrparams(ZATOM=29.,
                   LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                   RCLUSTZ=1.5,
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1)
     p.fill_keywords_to_inputfile(is_voro_calc=True)
     txt = open('inputcard').readlines()
     ref = [
         'ALATBASIS= 1.00000000000000\n', 'BRAVAIS\n',
         '1.00000000000000 0.00000000000000 0.00000000000000\n',
         '0.00000000000000 1.00000000000000 0.00000000000000\n',
         '0.00000000000000 0.00000000000000 1.00000000000000\n',
         'NAEZ= 1\n', '<RBASIS>\n',
         '0.00000000000000 0.00000000000000 0.00000000000000\n',
         '<ZATOM>\n', '29.00000000000000\n', 'NSPIN= 2\n', 'LMAX= 2\n',
         'RCLUSTZ= 1.50000000000000\n'
     ]
     done = False
     while not done:
         try:
             txt.remove('\n')
         except ValueError:
             done = True
     assert len(txt) == len(ref)
     txt.sort()
     ref.sort()
     print(txt, ref)
     for i in range(len(txt)):
         print(i, txt[i], ref[i])
         assert set(txt[i].split()) == set(ref[i].split())
    def test_read_slab(self, data_regression):
        from numpy import array, ndarray
        from masci_tools.io.common_functions import get_aBohr2Ang
        p = kkrparams(params_type='kkr')

        # automatically read keywords from inpucard
        p.read_keywords_from_inputcard(inputcard='../tests/files/kkr/import_calc_old_style/inputcard')
        # convert some read-in stuff back from Ang. units to alat units
        rbl = p.get_value('<RBLEFT>')
        rbr = p.get_value('<RBRIGHT>')
        zper_l = p.get_value('ZPERIODL')
        zper_r = p.get_value('ZPERIODR')
        ang2alat = 1 / (p.get_value('ALATBASIS') * get_aBohr2Ang())
        if rbl is not None:
            p.set_value('<RBLEFT>', array(rbl) * ang2alat)
        if rbr is not None:
            p.set_value('<RBRIGHT>', array(rbr) * ang2alat)
        if zper_l is not None:
            p.set_value('ZPERIODL', array(zper_l) * ang2alat)
        if zper_r is not None:
            p.set_value('ZPERIODR', array(zper_r) * ang2alat)

        # check all values, replace arrays by lists to make data-regression work
        d_check = p.get_dict()
        for k, v in d_check.items():
            if type(v) == ndarray:
                d_check[k] = v.tolist()
        data_regression.check(d_check)
Example #10
0
    def test_set_rmtcore(self):
        #test rmtcore
        from numpy import array
        from masci_tools.io.common_functions import search_string

        para_dict = dict([
            (u'INS', 0), (u'RCLUSTZ', 1.69), (u'LMAX', 2), (u'GMAX', 65.0),
            (u'<RMTCORE>',
             [0.3535533906, 0.3535533906, 0.3535533906, 0.3535533906]),
            (u'RMAX', 7.0), (u'NSPIN', 1)
        ])
        zatom = array([47., 47., 47., 47.])
        alat = 7.8692316414074615
        natom = 4
        positions = array([[0., 0., 0.], [0., 0.5, 0.5], [0.5, 0., 0.5],
                           [0.5, 0.5, 0.]])
        bravais = array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
        k = kkrparams(**para_dict)
        k.set_multiple_values(ZATOM=zatom,
                              NAEZ=natom,
                              ALATBASIS=alat,
                              RBASIS=positions,
                              BRAVAIS=bravais)
        k.fill_keywords_to_inputfile()

        txt = open('inputcard').readlines()
        naez = int(txt[search_string('NAEZ', txt)].split()[-1])
        rmtcore = []
        l_offset = search_string('RMTCORE', txt)
        for iatom in range(naez):
            rmtcore_at = float(txt[l_offset + 1 + iatom].split()[-1])
            rmtcore.append(rmtcore_at)
        maxdiff = (max(abs(array(para_dict['<RMTCORE>']) - array(rmtcore))))
        assert maxdiff < 10**-6
Example #11
0
 def test_fill_inputfile_KKR(self):
     reffile = [
         'ALATBASIS= 1.00000000000000\n', 'BRAVAIS\n',
         '1.00000000000000 0.00000000000000 0.00000000000000\n',
         '<ZATOM>\n', '29.00000000000000\n',
         '0.00000000000000 1.00000000000000 0.00000000000000\n',
         '0.00000000000000 0.00000000000000 1.00000000000000\n',
         'NAEZ= 1\n', '<RBASIS>\n',
         '0.00000000000000 0.00000000000000 0.00000000000000\n',
         'NSPIN= 2\n', 'LMAX= 2\n', 'RCLUSTZ= 1.50000000000000\n',
         'RMAX=      7.00000000000000\n', 'GMAX=      65.00000000000000\n'
     ]
     p = kkrparams(ZATOM=29.,
                   LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                   RMAX=7,
                   GMAX=65,
                   RCLUSTZ=1.5,
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1)
     p.fill_keywords_to_inputfile()
     txt = open('inputcard').readlines()
     done = False
     while not done:
         try:
             txt.remove('\n')
         except ValueError:
             done = True
     assert len(txt) == len(reffile)
     txt.sort()
     reffile.sort()
     for i in range(len(txt)):
         assert set(txt[i].split()) == set(reffile[i].split())
    def test_wrong_input_type(self):
        p = kkrparams()
        with pytest.raises(TypeError):
            p.set_value('EMIN', '2')

        with pytest.raises(TypeError):
            p.set_value('EMIN', False)
Example #13
0
 def test_get_set_values2(self):
     from numpy import array
     p = kkrparams()
     p.set_multiple_values(EMIN=1, EMAX=2)
     setlist = p.get_set_values()
     assert set(array(setlist).flatten()) == set(
         array([['EMIN', 1.], ['EMAX', 2.]]).flatten())
Example #14
0
 def test_fill_inputfile_empty_check(self):
     p = kkrparams(LMAX=2, NAEZ=1)
     known_error = False
     try:
         p.fill_keywords_to_inputfile()
     except ValueError:
         known_error = True
     assert known_error
    def test_read_minimal_inputfile(self):
        p = kkrparams(ZATOM=26.,
                      LMAX=2,
                      NAEZ=1,
                      BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                      RCLUSTZ=1.5,
                      NSPIN=2,
                      RBASIS=[0, 0, 0],
                      ALATBASIS=1)
        cwd = os.getcwd()
        with tempfile.TemporaryDirectory() as td:
            os.chdir(td)
            p.fill_keywords_to_inputfile(is_voro_calc=True)
            p2 = kkrparams(params_type='voronoi')
            p2.read_keywords_from_inputcard()
            os.chdir(cwd)

        check_full_dict(p, p2)
Example #16
0
    def test_set_value_None(self):
        p = kkrparams()
        p.set_value('EMIN', -1)
        assert p.values['EMIN'] == -1

        p.set_value('EMIN', None)
        assert p.values['EMIN'] == -1

        p.remove_value('EMIN')
        assert p.values['EMIN'] is None
Example #17
0
    def test_startpot_Cu_simple(self):
        """
        simple Cu noSOC, FP, lmax2 full example
        """
        from aiida.orm import Code
        from aiida.plugins import DataFactory
        from masci_tools.io.kkr_params import kkrparams
        from aiida_kkr.calculations.voro import VoronoiCalculation

        Dict = DataFactory('dict')
        StructureData = DataFactory('structure')

        # create StructureData instance for Cu
        alat = 3.61  # lattice constant in Angstroem
        bravais = [[0.5 * alat, 0.5 * alat, 0], [0.5 * alat, 0, 0.5 * alat],
                   [0, 0.5 * alat, 0.5 * alat]]  # Bravais matrix in Ang. units
        Cu = StructureData(cell=bravais)
        Cu.append_atom(position=[0, 0, 0], symbols='Cu')

        # create Dict input node using kkrparams class from masci-tools
        params = kkrparams(params_type='voronoi')
        params.set_multiple_values(LMAX=2, NSPIN=1, RCLUSTZ=2.3)
        Dict = DataFactory(
            'dict')  # use DataFactory to get ParamerterData class
        ParaNode = Dict(dict=params.get_dict())

        # import computer etc from database dump
        from aiida.tools.importexport import import_data
        import_data('files/db_dump_vorocalc.tar.gz')

        # prepare computer and code (needed so that
        prepare_code(voro_codename, codelocation, computername, workdir)

        # load code from database and create new voronoi calculation
        #code = Code.get_from_string(codename)
        code = Code.get_from_string(voro_codename + '@' + computername)

        #code = Code.get_from_string('voronoi@localhost_new')
        options = {
            'resources': {
                'num_machines': 1,
                'tot_num_mpiprocs': 1
            },
            'queue_name': queuename
        }
        builder = VoronoiCalculation.get_builder()
        builder.code = code
        builder.metadata.options = options
        builder.parameters = ParaNode
        builder.structure = Cu
        builder.metadata.dry_run = True
        from aiida.engine import run
        run(builder)
 def test_inconsistency_bulk_mode_bravais(self):
     p = kkrparams(LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 0]],
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1,
                   RMAX=7,
                   GMAX=65,
                   ZATOM=29.)
     with pytest.raises(ValueError):
         p.fill_keywords_to_inputfile()
    def test_get_value(self):
        p = kkrparams(LMAX=3)
        # check for KeyError if wrong key is checked
        with pytest.raises(KeyError):
            p.get_value('something_wrong')

        # check for returning unset value
        npol = p.get_value('NPOL')
        assert npol is None
        # check correct LMAX value
        lmax = p.get_value('LMAX')
        assert lmax == 3
        # check for returning lists for RUNOPT and TESTOPT
        runopt = p.get_value('RUNOPT')
        testopt = p.get_value('TESTOPT')
        assert runopt == []
        assert testopt == []
        p = kkrparams(TESTOPT=['test1', 'test2'], RUNOPT=['NEWSOSOL'])
        runopt = p.get_value('RUNOPT')
        testopt = p.get_value('TESTOPT')
        assert runopt == ['NEWSOSOL']
        assert set(testopt) == set(['test1', 'test2'])
    def test_input_consistency_check_fail(self):

        p = kkrparams(ZATOM=29.,
                      LMAX=2,
                      NAEZ=1,
                      BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                      RMAX=7,
                      GMAX=65,
                      NSPIN=2,
                      RBASIS=[0, 0, 0],
                      ALATBASIS=1)
        p.set_value('LDAU_PARA', [1, 2])
        with pytest.raises(TypeError):
            p._check_input_consistency()
Example #21
0
    def test_wrong_input_type(self):
        p = kkrparams()
        known_error = False
        try:
            p.set_value('EMIN', '2')
        except TypeError:
            known_error = True
        assert known_error

        known_error = False
        try:
            p.set_value('EMIN', False)
        except TypeError:
            known_error = True
        assert known_error
    def test_wrong_input_array_dimension(self):
        p = kkrparams()
        from numpy import array, sqrt
        bravais = array([[0.7071067812, -0.5, 0.0], [0.7071067812, 0.5, 0.0], [sqrt(2), 0.0, 0.866025404]])

        # atom positions in relative coordinates
        basis_vectors = []
        for iatom in range(6):
            tmp = array([0, 0, 0]) + iatom * array([0.5, 0.5, bravais[2, 2]])
            tmp[0] = tmp[0] % 1
            tmp[1] = tmp[1] % 1
            print(iatom, tmp)
            basis_vectors.append(tmp)
        basis_vectors = array(basis_vectors)
        p.set_value('INTERFACE', True)
        p.set_value('<RBLEFT>', array([[1, 1], [0, 1]]))
Example #23
0
 def test_inconsistency_bulk_mode_bravais(self):
     p = kkrparams(LMAX=2,
                   NAEZ=1,
                   BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 0]],
                   NSPIN=2,
                   RBASIS=[0, 0, 0],
                   ALATBASIS=1,
                   RMAX=7,
                   GMAX=65,
                   ZATOM=29.)
     knownError = False
     try:
         p.fill_keywords_to_inputfile()
     except ValueError:
         knownError = True
     assert knownError
    def test_fill_inputfile_minimal_Voronoi(self, file_regression):
        p = kkrparams(ZATOM=29.,
                      LMAX=2,
                      NAEZ=1,
                      BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                      RCLUSTZ=1.5,
                      NSPIN=2,
                      RBASIS=[0, 0, 0],
                      ALATBASIS=1)
        cwd = os.getcwd()
        with tempfile.TemporaryDirectory() as td:
            os.chdir(td)
            p.fill_keywords_to_inputfile(is_voro_calc=True)
            file_content = open('inputcard').read()
            os.chdir(cwd)

        file_regression.check(file_content)
Example #25
0
 def test_input_consistency_check_fail(self):
     knownError = False
     try:
         p = kkrparams(ZATOM=29.,
                       LMAX=2,
                       NAEZ=1,
                       BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                       RMAX=7,
                       GMAX=65,
                       NSPIN=2,
                       RBASIS=[0, 0, 0],
                       ALATBASIS=1)
         p.set_value('LDAU_PARA', [1, 2])
         p._check_input_consistency()
     except TypeError:
         knownError = True
     assert knownError
Example #26
0
    def test_host_in_host(self):
        """
        simple Cu noSOC, FP, lmax2
        """
        from aiida.orm import Code, load_node
        from aiida.plugins import DataFactory
        from masci_tools.io.kkr_params import kkrparams
        from aiida_kkr.calculations.kkrimp import KkrimpCalculation
        Dict = DataFactory('dict')

        # first load parent voronoi calculation
        from aiida.tools.importexport import import_data
        import_data('files/db_dump_kkrflex_create.tar.gz')
        GF_host_calc = load_node('baabef05-f418-4475-bba5-ef0ee3fd5ca6')

        # prepare computer and code (needed so that
        prepare_code(kkrimp_codename, codelocation, computername, workdir)

        # now create a SingleFileData node containing the impurity starting potential
        from aiida_kkr.tools.common_workfunctions import neworder_potential_wf
        from numpy import loadtxt
        neworder_pot1 = [int(i) for i in loadtxt(GF_host_calc.outputs.retrieved.open('scoef'), skiprows=1)[:,3]-1]
        settings_dict = {'pot1': 'out_potential',  'out_pot': 'potential_imp', 'neworder': neworder_pot1}
        settings = Dict(dict=settings_dict)
        startpot_imp_sfd = neworder_potential_wf(settings_node=settings, parent_calc_folder=GF_host_calc.outputs.remote_folder)

        # set 1 simple mixing step
        kkrimp_params = kkrparams(params_type='kkrimp')
        kkrimp_params.set_multiple_values(SCFSTEPS=1, IMIX=0, MIXFAC=0.05)
        ParamsKKRimp = Dict(dict=kkrimp_params.get_dict())

        # create new KKRimp calculation
        #kkrimp_code = Code.get_from_string(codename)
        kkrimp_code = Code.get_from_string(kkrimp_codename+'@'+computername)
        options = {'resources': {'num_machines':1, 'tot_num_mpiprocs':1}, 'queue_name': queuename}
        builder = KkrimpCalculation.get_builder()
        builder.code = kkrimp_code
        builder.host_Greenfunction_folder = GF_host_calc.outputs.remote_folder
        builder.impurity_potential = startpot_imp_sfd
        builder.metadata.options = options
        builder.parameters = ParamsKKRimp
        builder.metadata.dry_run = True
        from aiida.engine import run
        run(builder)
    def test_update_params_wf(self):
        from aiida_kkr.tools.common_workfunctions import update_params_wf
        from masci_tools.io.kkr_params import kkrparams
        from aiida.plugins import DataFactory
        Dict = DataFactory('dict')

        k = kkrparams(LMAX=2)
        node1 = Dict(dict=k.values)
        node2 = Dict(
            dict={
                'nodename': 'my_changed_name',
                'nodedesc': 'My description text',
                'EMIN': -1,
                'RMAX': 10.
            })

        unode = update_params_wf(node1, node1)
        assert unode.get_dict() == node1.get_dict()

        unode = update_params_wf(node1, node2)

        d0 = node1.get_dict()
        for i in list(d0.keys()):
            if d0[i] is None:
                d0.pop(i)

        d1 = unode.get_dict()
        for i in list(d1.keys()):
            if d1[i] is None:
                d1.pop(i)

        l_identical, l_diff = [], []
        for i in list(d0.keys()):
            if i in list(d1.keys()):
                l_identical.append([i, d0[i], d1[i]])
            else:
                l_diff.append([0, i, d0[i]])
        for i in list(d1.keys()):
            if i not in list(d0.keys()):
                l_diff.append([1, i, d1[i]])

        assert l_identical == [[u'LMAX', 2, 2]]
        assert l_diff.sort() == [[1, u'RMAX', 10.0], [1, u'EMIN', -1.0]].sort()
        return node1, node2, unode
Example #28
0
 def test_fill_inputfile_filehandle(self):
     p = kkrparams(params_type='kkrimp')
     p.set_multiple_values(CALCORBITALMOMENT=0,
                           RUNFLAG='',
                           QBOUND=10**-7,
                           NSPIN=1,
                           TESTFLAG='',
                           NPAN_EQ=7,
                           CALCFORCE=0,
                           NPAN_LOGPANELFAC=2,
                           SPINORBIT=0,
                           ITDBRY=20,
                           NPAN_LOG=5,
                           INS=1,
                           ICST=2,
                           CALCJIJMAT=0,
                           NCHEB=10,
                           HFIELD=[0.00, 0],
                           BRYMIX=0.05,
                           KVREL=1,
                           IMIX=0,
                           RADIUS_MIN=-1,
                           NCOLL=0,
                           RADIUS_LOGPANELS=0.6,
                           MIXFAC=0.05,
                           SCFSTEPS=1,
                           XC='LDA-VWN')
     out_fhandle = open_general('config.cfg', 'w')
     p.fill_keywords_to_inputfile(output=out_fhandle)
     reftxt = [
         'RUNFLAG=\n', 'TESTFLAG=\n', '\n', 'INS= 1\n', 'KVREL= 1\n',
         'NSPIN= 1\n', '\n', 'SCFSTEPS= 1\n', 'IMIX= 0\n', 'ITDBRY= 20\n',
         'MIXFAC=      0.05000000000000\n',
         'BRYMIX=      0.05000000000000\n', 'QBOUND= 1.000000e-07\n', '\n',
         'XC= LDA-VWN\n', 'ICST= 2\n', 'SPINORBIT= 0\n', 'NCOLL= 0\n',
         'NPAN_LOGPANELFAC= 2\n',
         'RADIUS_LOGPANELS=      0.60000000000000\n', 'RADIUS_MIN= -1\n',
         'NPAN_LOG= 5\n', 'NPAN_EQ= 7\n', 'NCHEB= 10\n', '\n',
         'HFIELD=      0.00000000000000 0\n', '\n',
         'CALCORBITALMOMENT= 0\n', 'CALCFORCE= 0\n', 'CALCJIJMAT= 0\n'
     ]
     txt = open('config.cfg').readlines()
     assert txt == reftxt
Example #29
0
    def check_voro_out(self):
        """
        check outout of vorostart workflow and create input for rest of calculations (rmtcore setting etc.)
        """
        self.report('INFO: checking voronoi output')
        # get output of kkr_startpot
        out_wc = self.ctx.kkr_startpot
        try:
            res = out_wc.outputs.results_vorostart_wc
            voro_params = out_wc.outputs.last_params_voronoi
            smallest_voro_remote = out_wc.outputs.last_voronoi_remote
            smallest_voro_results = out_wc.outputs.last_voronoi_results
            vorostart_success = res.get_dict()['successful']
        except:
            vorostart_success = False

        if vorostart_success:
            rmt = []
            radii = smallest_voro_results.get_dict()['radii_atoms_group']
            for rad_iatom in radii:
                if 'rmt0' in list(rad_iatom.keys()):
                    rmt.append(rad_iatom['rmt0'])
            rmtcore_min = array(rmt) * smallest_voro_results.get_dict().get(
                'alat')  # needs to be mutiplied by alat in atomic units!
            self.report('INFO: extracted rmtcore_min ({})'.format(rmtcore_min))
        else:
            return self.exit_codes.ERROR_VOROSTART_NOT_SUCCESSFUL

        # update parameter node with rmtcore setting
        voro_params_with_rmtcore = kkrparams(**voro_params.get_dict())
        voro_params_with_rmtcore.set_value('<RMTCORE>', rmtcore_min)
        voro_params_with_rmtcore_dict = voro_params_with_rmtcore.get_dict()
        voro_params_with_rmtcore = update_params_wf(
            voro_params, Dict(dict=voro_params_with_rmtcore_dict))
        self.report(
            'INFO: updated kkr_parameters inlcuding RMTCORE setting (uuid={})'.
            format(voro_params_with_rmtcore.uuid))

        # store links to context
        self.ctx.params_kkr_run = voro_params_with_rmtcore
        self.ctx.smallest_voro_remote = smallest_voro_remote
Example #30
0
 def test_set_potname_empty(self):
     p = kkrparams()
     p.set_multiple_values(RMAX=1,
                           GMAX=1,
                           NSPIN=1,
                           RBASIS=[0, 0, 0],
                           LMAX=2,
                           RCLUSTZ=1.2,
                           NAEZ=1,
                           ZATOM=[0],
                           BRAVAIS=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                           ALATBASIS=1,
                           FILES=['', 'shapenew'])
     p.fill_keywords_to_inputfile()
     from masci_tools.io.common_functions import search_string
     txt = open('inputcard').readlines()
     itmp = search_string('FILES', txt)
     potname = txt[itmp + 2].split()[0]
     shapename = txt[itmp + 4].split()[0]
     assert 'potential' == potname
     assert 'shapenew' == shapename