User Tools

Site Tools


soft:siman:mae:calculation_of_mae_using_k-shifts

This Tutorial shows how to calculate MAE for iron using averaging of energy over k-shifts. To control calculation use step and run arguments. The pipeline is

  1. step = 1, run = 1
  2. step = 1, run = 0
  3. step = 2, run = 1
  4. step = 2, run = 0

Be sure that you have copied siman folder to ~/tools on cluster; check that you have ~/tools/siman/cluster_runners/shiftk.py file on cluster

def single_volume(step = 1, run = 1, mk = 2, ngkpt = None, filename = None):
    """
    step (int) - 1 - calculate charge density, 2 - calculate mae
    run (bool) - 1 to submit calculations, 0 - read results
    mk (int) - dimensionality of shift mesh, , e.g. 2 means 2x2x2
    ngkpt (list) - list of k-points
    filename (str) - path to POSCAR file with geometry
 
    """
    if not ngkpt:
        ngkpt = [20,20,20]
    #Define new sets
 
    read_vasp_sets([('mag', 'static', 
        {'ISPIN':2, 'LORBIT':11, 'magnetic_moments':{'Fe':5},
        'EDIFF':'1E-7', 'LREAL': '.FALSE.', 'LASPH':'.TRUE.', 'PREC':'Accurate',
        'ISMEAR':0, 'SIGMA':0.01, 'KSPACING':None,  }, 'override')])
 
    noncoliniar_pack = {'LNONCOLLINEAR':True,'LSORBIT':'.TRUE.', 'LASPH':'.TRUE.', 
    'LORBMOM':'.TRUE.', 'ICHARG':11, 'EDIFF':'1E-8', 'ISYM':-1, 'KGAMMA':False,
    'magnetic_moments':{'Fe':2.186}} # non-selfconsistent
 
    read_vasp_sets([('ncl', 'mag', noncoliniar_pack, 'override')])
 
    st = smart_structure_read(filename)
    #ngkpt = [20,20,20]
    #mk = 2 # dimensionality of shift mesh, e.g. 2x2x2
 
    #run = 1 # put to zero to read results
 
 
    if step == 1:
        #step 1. Calculate magnetic charge density
 
        if run:
            add('Fe1bcc', 'mag', 1, input_st = st, it_folder = 'Fe/MAE',
            params = {'ngkpt':ngkpt},
            )
        else:
            cl_mag = db['Fe1bcc', 'mag', 1]
            cl_mag.res()
            cl_mag.get_file('1.CHGCAR')
 
 
    elif step == 2:
        #step 2. Calculate MAE using non-selfconsitent calculations
        # be sure that you have copied siman folder to ~/tools; 
        # check that you have ~/tools/siman/cluster_runners/shiftk.py file on cluster
        cl_mag = db['Fe1bcc', 'mag', 1]
 
 
        energies = []
        for d in '0 0 1', '1 1 1':
            dns = d.replace(" ", "")
            if run:
                add('Fe1bcc_'+dns, 'ncl', 1, input_st = st, it_folder = 'Fe/MAE',
                    calc_method = 'shiftk_average', 
                    params = {'shiftk_average':{'mk':mk},'ngkpt':ngkpt, 'chgcar':cl_mag.path['charge']},
                    update_set = {'SAXIS':d}
                    )
            else:
                cl_ncl = db['Fe1bcc_'+dns, 'ncl', 1]
                cl_ncl.res()
                average_energy = sum(cl_ncl.shiftk_energies) / len(cl_ncl.shiftk_energies)
                energies.append(average_energy)
        if not run:
            print('MAE is {:.1f} ueV'.format( (energies[0]-energies[1])*1e6  ) )
 
single_volume(step = 1, run = 1, mk = 2, ngkpt = [20,20,20], filename = 'siman/tests/t9_mae/POSCAR_Fe1bcc')
soft/siman/mae/calculation_of_mae_using_k-shifts.txt · Last modified: 2025/06/05 17:51 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki