def datamining(filep):
    """
    Read some output variables from abinit-o_OUT.nc
    """
    print('Extracting ecut and etotal')
    if os.path.isfile(filep + os.sep + 'abinit-o_OUT.nc'):
        data = netcdf2dict(filep + os.sep + 'abinit-o_OUT.nc')
    else:
        data = netcdf2dict(path + os.sep + 'abinit_04' + os.sep + 'abinit-o_OUT.nc')
    print(data)
    print(data['ecut'], data['etotal'])
    return data['ecut'], data['etotal']
Exemple #2
0
def datamining(filep):
    """
    Read some output variables from abinit-o_OUT.nc
    """
    print('Extracting ecut and etotal')
    if os.path.isfile(filep + os.sep + 'abinit-o_OUT.nc'):
        data = netcdf2dict(filep + os.sep + 'abinit-o_OUT.nc')
    else:
        data = netcdf2dict(path + os.sep + 'abinit_04' + os.sep +
                           'abinit-o_OUT.nc')
    print(data)
    print(data['ecut'], data['etotal'])
    return data['ecut'], data['etotal']
Exemple #3
0
def test_abinit_utils():
    """
    Test (pychemia.code.abinit) [utils]                         :
    """
    from pychemia.utils.netcdf import netcdf2dict
    from pychemia.code.abinit import xyz2input, psp_name

    filename = "tests/data/abinit_05/abinit-o_OUT.nc"
    print(len(netcdf2dict(filename)))
    assert len(netcdf2dict(filename)) == 45
    assert psp_name(1, 'LDA', 'FHI') == '01-H.LDA.fhi'
    filename = "tests/data/abinit_01/abinit_DS11.xyz"
    assert xyz2input(filename).variables['natom'] == 2
def test_abinit_utils():
    """
    Tests (pychemia.code.abinit) [utils]                         :
    """
    from pychemia.utils.netcdf import netcdf2dict
    from pychemia.code.abinit import xyz2input, psp_name

    filename = "tests/data/abinit_05/abinit-o_OUT.nc"
    print(len(netcdf2dict(filename)))
    assert len(netcdf2dict(filename)) == 45
    assert psp_name(1, 'LDA', 'FHI') == '01-H.LDA.fhi'
    filename = "tests/data/abinit_01/abinit_DS11.xyz"
    assert xyz2input(filename).variables['natom'] == 2
Exemple #5
0
 def __init__(self, input_filename=None):
     CodeInput.__init__(self)
     if input_filename is None:
         self.input_file = 'abinit.in'
     else:
         self.input_file = input_filename
     if os.path.isfile(self.input_file):
         if self.input_file[-6:] == 'OUT.nc':
             self.variables = netcdf2dict(self.input_file)
         else:
             self.read()
Exemple #6
0
 def __init__(self, input_filename=None):
     CodeInput.__init__(self)
     if input_filename is None:
         self.input_file = 'abinit.in'
     else:
         self.input_file = input_filename
     if os.path.isfile(self.input_file):
         if self.input_file[-6:] == 'OUT.nc':
             self.variables = netcdf2dict(self.input_file)
         else:
             self.read()
Exemple #7
0
def test_example2():
    """
    Example of a multiple calc                                   :
    """
    path = 'tests/data'
    assert (os.path.isdir(path))

    if which('abinit') is None:
        print('The executable "abinit" is not in the PATH')
        print('Using the results of a previous calc')
        check_results(path + os.sep + 'abinit_04')
        return

    workdir = tempfile.mkdtemp()
    print("Work directory: %s" % workdir)
    assert (os.path.isfile(path + '/abinit_04/t44.in'))
    av = pychemia.code.abinit.AbinitInput(path + '/abinit_04/t44.in')
    print('Original input:\n%s' % av)
    abifiles = pychemia.code.abinit.AbiFiles(workdir)
    abifiles.set_input(av)
    abifiles.set_psps('LDA', 'FHI')
    abifiles.create()

    res = []
    wf = open(workdir + '/results.json', 'w')
    cwd = os.getcwd()
    os.chdir(workdir)

    for i in range(3):
        av.set_value('ecut', av.get_value('ecut') + 3)
        print('Computing convergence study with ecut=%f ' %
              av.get_value('ecut'),
              end='')
        if i > 0:
            av.set_value('irdwfk', 1)
        av.write(abifiles.get_input_filename())
        abifile = open(workdir + '/abinit.files')
        logfile = open(workdir + '/abinit.log', 'w')
        subprocess.call(['abinit'], stdin=abifile, stdout=logfile)
        if os.path.isfile('abinit-o_WFK'):
            shutil.copyfile('abinit-o_WFK', 'abinit-i_WFK')
        data = netcdf2dict(workdir + '/abinit-o_OUT.nc')
        os.rename(workdir + '/abinit-o_OUT.nc',
                  '%s/abinit-o_OUT.nc_%d' % (workdir, i))
        res.append({'ecut': data['ecut'], 'etotal': data['etotal']})
        print('Total energy: %f' % data['etotal'])
    os.chdir(cwd)
    json.dump(res, wf)
    wf.close()
    check_results(workdir)
    shutil.rmtree(workdir)
def test_example2():
    """
    Example of a multiple calc                                   :
    """
    path = 'tests/data'
    assert (os.path.isdir(path))

    if which('abinit') is None:
        print('The executable "abinit" is not in the PATH')
        print('Using the results of a previous calc')
        check_results(path + os.sep + 'abinit_04')
        return

    workdir = tempfile.mkdtemp()
    print("Work directory: %s" % workdir)
    assert (os.path.isfile(path + '/abinit_04/t44.in'))
    av = pychemia.code.abinit.AbinitInput(path + '/abinit_04/t44.in')
    print('Original input:\n%s' % av)
    abifiles = pychemia.code.abinit.AbiFiles(workdir)
    abifiles.set_input(av)
    abifiles.set_psps('LDA', 'FHI')
    abifiles.create()

    res = []
    wf = open(workdir + '/results.json', 'w')
    cwd = os.getcwd()
    os.chdir(workdir)

    for i in range(3):
        av.set_value('ecut', av.get_value('ecut') + 3)
        print('Computing convergence study with ecut=%f ' % av.get_value('ecut'), end='')
        if i > 0:
            av.set_value('irdwfk', 1)
        av.write(abifiles.get_input_filename())
        abifile = open(workdir + '/abinit.files')
        logfile = open(workdir + '/abinit.log', 'w')
        subprocess.call(['abinit'], stdin=abifile, stdout=logfile)
        if os.path.isfile('abinit-o_WFK'):
            shutil.copyfile('abinit-o_WFK', 'abinit-i_WFK')
        data = netcdf2dict(workdir + '/abinit-o_OUT.nc')
        os.rename(workdir + '/abinit-o_OUT.nc', '%s/abinit-o_OUT.nc_%d' % (workdir, i))
        res.append({'ecut': data['ecut'], 'etotal': data['etotal']})
        print('Total energy: %f' % data['etotal'])
    os.chdir(cwd)
    json.dump(res, wf)
    wf.close()
    check_results(workdir)
    shutil.rmtree(workdir)