Ejemplo n.º 1
0
    def _inner(system,quantities,fout_name,Efermi,comparer,
               parallel=None,
               numproc=0,
               grid_param={'NK':[6,6,6],'NKFFT':[3,3,3]},additional_parameters={},adpt_num_iter=0,
               suffix="", suffix_ref="",
               extra_precision={} ):

        grid = wberri.Grid(system, **grid_param)
        result = wberri.integrate(system,
                grid = grid,
                Efermi = Efermi,
                smearEf = 600.0,
    #            omega = omega,
                quantities = quantities,
                parallel=parallel,
                numproc=numproc,
                adpt_num_iter = adpt_num_iter,
                parameters = additional_parameters,
                fout_name = os.path.join(output_dir, fout_name),
                suffix=suffix,
                restart = False,
                )
        if len(suffix)>0:
            suffix="-"+suffix
        if len(suffix_ref)>0:
            suffix_ref="-"+suffix_ref

        for quant in quantities:
            data=result.results.get(quant).data
            assert data.shape[0] == len(Efermi)
            assert np.all( np.array(data.shape[1:]) == 3)
            prec=extra_precision[quant] if quant in extra_precision else None
            comparer(fout_name, quant+suffix,  adpt_num_iter , suffix_ref=compare_quant(quant)+suffix_ref ,precision=prec )
Ejemplo n.º 2
0
def test_fourier(system_Fe_W90):
    """Compare slow FT and FFT."""
    system = system_Fe_W90

    k = np.array([0.1, 0.2, -0.3])

    grid = wberri.Grid(system, NKFFT=[4, 3, 2], NKdiv=1)

    dK = 1. / grid.div
    NKFFT = grid.FFT
    factor = 1./np.prod(grid.div)

    kpoint = KpointBZ(K=k, dK=dK, NKFFT=NKFFT, factor=factor, symgroup=None)

    assert kpoint.Kp_fullBZ == approx(k / grid.FFT)

    data_fftw  = Data_K(system, kpoint.Kp_fullBZ, grid=grid, Kpoint=kpoint, npar=0, fftlib='fftw')
    data_slow  = Data_K(system, kpoint.Kp_fullBZ, grid=grid, Kpoint=kpoint, npar=0, fftlib='slow')
    data_numpy = Data_K(system, kpoint.Kp_fullBZ, grid=grid, Kpoint=kpoint, npar=0, fftlib='numpy')

    test_fields = ["E_K", "D_H", "V_H", "shc_B_H"]

    for field in test_fields:
        assert getattr(data_fftw,  field) == approx(getattr(data_slow, field)), "fftw  does not match slow for {} ".format(field)
        assert getattr(data_numpy, field) == approx(getattr(data_slow, field)), "numpy does not match slow for {}".format(field)
        assert getattr(data_numpy, field) == approx(getattr(data_slow, field)), "numpy does not match fftw for {}".format(field)
Ejemplo n.º 3
0
#!/usr/bin/env python3
import os
os.environ['OPENBLAS_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'

num_proc = 16

import wannierberri as wberri
import numpy as np

system = wberri.System_tb(tb_file='Fe_tb.dat', getAA=True)

generators = ['Inversion', 'C4z', 'TimeReversal*C2x']
system.set_symmetry(generators)

grid = wberri.Grid(system, length=100)

wberri.integrate(
    system,
    grid=grid,
    Efermi=np.linspace(12., 13., 1001),
    smearEf=10,
    quantities=["ahc", "dos", "cumdos"],
    numproc=num_proc,
    adpt_num_iter=10,
    libfft='fftw',  #default.  alternative  option - 'numpy'
    fout_name='Fe',
    restart=False,
)

wberri.tabulate(system,
Ejemplo n.º 4
0
    haldane.set_hop(t2 , 0, 0, [ -1, 1])
    haldane.set_hop(t2 , 1, 1, [ -1, 0])

    haldane.set_hop(t2 , 1, 1, [ 1,-1])
    haldane.set_hop(t2 , 1, 1, [ 0, 1])
    return haldane

# Define the model for a fixed set of parameters
haldane=HaldanePTB(2,1,1/3,np.pi/10)
# Call the interface for TBmodels to define the system class
syst=wb.System_PythTB(haldane,getAA=True)
Efermi=np.linspace(-4,6,1000)
# Define some symmetries
syst.set_symmetry(['C3z'])
# After defining the symmetries, create the grid class
grid=wb.Grid(syst,NK=(200,200,1))
# Define which quantities are going to be integrated
q_int=["dos","ahc"]
seedname="pythtb_Haldane"
num_iter=10
wb.integrate(syst,
            grid=grid,
            Efermi=Efermi,
            smearEf=300,
            quantities=q_int,
            numproc=8,
            adpt_num_iter=num_iter,
            fout_name=seedname,
            restart=False )

# Plot the quantities
Ejemplo n.º 5
0
    haldane.set_hop(t2, 1, 1, [-1, 0])

    haldane.set_hop(t2, 1, 1, [1, -1])
    haldane.set_hop(t2, 1, 1, [0, 1])
    return haldane


# Define the model for a fixed set of parameters
haldane = HaldanePTB(2, 1, 1 / 3, np.pi / 10)
# Call the interface for TBmodels to define the system class
syst = wb.System_PythTB(haldane, berry=True, morb=True)
Efermi = np.linspace(-4, 6, 1000)
# Define some symmetries
syst.set_symmetry(['C3z'])
# After defining the symmetries, create the grid class
grid = wb.Grid(syst, NK=(200, 200, 1), NKFFT=(20, 20, 1))
# Define which quantities are going to be integrated
q_int = ["dos", "ahc", "Morb"]
seedname = "pythtb_Haldane"
num_iter = 10
wb.integrate(syst,
             grid=grid,
             Efermi=Efermi,
             smearEf=300,
             quantities=q_int,
             numproc=8,
             adpt_num_iter=num_iter,
             fout_name=seedname,
             restart=False)

# Plot the quantities
Ejemplo n.º 6
0
if 'Fe_tb.dat' not in os.listdir():
    os.system('tar -xvf ../../data/Fe_tb.dat.tar.gz')

import wannierberri as wberri

import numpy as np

SYM = wberri.symmetry

Efermi = np.linspace(12., 13., 1001)
system = wberri.System_tb(tb_file='Fe_tb.dat', berry=True)

generators = [SYM.Inversion, SYM.C4z, SYM.TimeReversal * SYM.C2x]
system.set_symmetry(generators)
grid = wberri.Grid(system, NKdiv=16, NKFFT=16)

parallel = wberri.Parallel(method='ray', ray_cluster=True)

wberri.integrate(
    system,
    grid=grid,
    Efermi=Efermi,
    smearEf=10,
    quantities=["ahc", "dos", "cumdos"],
    adpt_num_iter=0,
    parallel=parallel,
    fftlib='fftw',  #default.  alternative  option - 'numpy'
    fout_name='Fe',
    suffix=sys.argv[1],
    restart=False,
Ejemplo n.º 7
0
import numpy as np


SYM = wberri.symmetry

Efermi = np.linspace(12., 13., 101)
system = wberri.System_tb(tb_file='data/Fe_tb.dat', berry=True)
# read all information from a file Fe_tb.dat, which is also written by Wannier90, or maybe composed by user from any tight-binding model.

# system = wberri.System_w90('Fe', berry=True)
# read the information about Wanier functions
generators = [SYM.Inversion, SYM.C4z, SYM.TimeReversal*SYM.C2x]
# B_ext along z => inversion, 4fold rotation around z and TR combined with 2fold rotation around x-axis
system.set_symmetry(generators)

grid = wberri.Grid(system, length=20) # spacing is approx 2pi/length - here grid of 52^3 for length=200 and depends on unit cell size

wberri.integrate(system, grid=grid, Efermi=Efermi,
            smearEf=10, # 10K = 10 Kelvin to avoid strong jittering of the curve
            quantities=["ahc","dos","cumdos"], # calculation of AHC, DOS and cumulated DOS
            numproc=num_proc,
            adpt_num_iter=10, # number of iterations for an adaptive recursive refinement algorithm to make the calculation more precise around those points where it diverges,
            fftlib='fftw', #default.  alternative  option - 'numpy'
            fout_name='Fe',
            restart=False,
            )


# wberri.tabulate(system, grid=grid, quantities=["berry"],
#              frmsf_name='Fe',
#              numproc=num_proc,
Ejemplo n.º 8
0
system=wb.System_PythTB(my_model,berry=True)
Efermi=np.linspace(-7,16,1000)
# Define the generators of the point group of the crystal (Im-3m)
# generators extracted from Bilbao Crystallographic Center
# (using same notation as https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-point_genpos?w2do=gens&num=32&what=)
# C2z axis (predefined): ITA200z=SYM.Rotation(2,[0,0,1])
# C2y axis (predefined): ITA20y0=SYM.Rotation(2,[0,1,0])
# Inversion (predefined)
ITA3M111=SYM.Rotation(3,[1,1,1])# C3 axis along 111
ITA2xx0=SYM.Rotation(2,[1,1,0])# C2 axis along 110
generators=['C2z','C2y','Inversion',ITA3M111,ITA2xx0]
system.set_symmetry(generators)
seedname='pythtbLi'
q_int=['dos','cumdos','conductivity_ohmic','conductivity_ohmic_fsurf']
num_iter=1
grid=wb.Grid(system,length=200,NKFFT=20)
parallel=wb.Parallel(num_cpus=8,method='ray')
start_int=time.time()
wb.integrate(system,
            grid=grid,
            Efermi=Efermi,
            smearEf=300,
            quantities=q_int,
            parallel=parallel,
            adpt_num_iter=num_iter,
            fout_name=seedname,
            restart=False )
end_int=time.time()
q_tab=["V"]
start_tab=time.time()
wb.tabulate(system,
Ejemplo n.º 9
0
system = wb.System_TBmodels(tbmodel, getAA=True)
Efermi = np.linspace(-7, 16, 5000)
# Define the generators of the point group of the crystal (Im-3m)
# generators extracted from Bilbao Crystallographic Center
# (using same notation as https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-point_genpos?w2do=gens&num=32&what=)
# C2z axis (predefined): ITA200z=SYM.Rotation(2,[0,0,1])
# C2y axis (predefined): ITA20y0=SYM.Rotation(2,[0,1,0])
# Inversion (predefined)
ITA3M111 = SYM.Rotation(3, [1, 1, 1])  # C3 axis along 111
ITA2xx0 = SYM.Rotation(2, [1, 1, 0])  # C2 axis along 110
generators = ['C2z', 'C2y', 'Inversion', ITA3M111, ITA2xx0]
system.set_symmetry(generators)
seedname = 'tbmodelsLi'
q_int = ['dos', 'cumdos', 'conductivity_ohmic', 'conductivity_ohmic_fsurf']
num_iter = 30
grid = wb.Grid(system, length=600, NKFFT=40)
start_int = time.time()
wb.integrate(system,
             grid=grid,
             Efermi=Efermi,
             smearEf=300,
             quantities=q_int,
             numproc=16,
             adpt_num_iter=num_iter,
             fout_name=seedname,
             restart=False)
end_int = time.time()
q_tab = ["V"]
start_tab = time.time()
wb.tabulate(system,
            grid=grid,
Ejemplo n.º 10
0
import numpy as np

SYM = wberri.symmetry

Efermi = np.linspace(18.1299, 18.1300, 2)
omega = np.linspace(0.0125, 7., 560)
#omega=np.linspace(11.1299,21.1299,1001)

system = wberri.System_w90(seedname='pt', SHC=True, use_ws=False)

#generators=[SYM.Inversion,SYM.C4z,SYM.TimeReversal*SYM.C2x]
generators = []
system.set_symmetry(generators)
#grid=wberri.Grid(system,length=100)
grid = wberri.Grid(system, NK=np.array([1, 1, 1]))

wberri.integrate(
    system,
    grid=grid,
    Efermi=Efermi,
    omega=omega,
    #            smearEf=0.1,
    #            smearW=0.1,
    quantities=["opt_SHC"],
    numproc=num_proc,
    adpt_num_iter=0,
    fout_name='pt',
    restart=False,
)