{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reconstruction of surface with MC" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this tutorial we show how to make DFT Monte-Carlo for surfaces. The Monte Carlo method creates anti-site defects near surface.\n", "\n", "In order to use MC:\n", "\n", "1. Install Siman version >0.9.5 \n", "\n", "*sudo python -m pip install siman*\n", "\n", "2. Copy installed siman *.py soruces to cluster ~/tools/siman" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Reading /home/aksenov/simanrc.py\n" ] } ], "source": [ "from siman import header\n", "from siman.calc_manage import add, res, smart_structure_read\n", "from siman.geo import create_surface2, ortho_vec, create_supercell\n", "from siman.header import db\n", "from siman.analysis import suf_en\n", "from siman.classes import CalculationVasp\n", "from siman.set_functions import read_vasp_sets\n", "header.PATH2POTENTIALS = '/home/aksenov/scientific_projects/PAW_PBE_VASP'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Read bulk structure and create new set" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Warning! You did not change AMIX in 1u6 set\n", " \n", "\n", "Warning! You did not change AMIN in 1u6 set\n", " \n", "\n", "Warning! You did not change BMIX in 1u6 set\n", " \n", "\n", "Warning! You did not change NELM in 1u6 set\n", " \n", "\n", "Warning! You did not change NELMIN in 1u6 set\n", " \n", "\n" ] }, { "data": { "text/plain": [ "{'1u6': ,\n", " None: ,\n", " 'opt': ,\n", " 'static': }" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "st = smart_structure_read('NaNiO2/POSCAR_NaNiO2_c2_m_su_4uiAg_100_end') # read bulk NaNiO2 with c2/m structure\n", "sconv = st.get_conventional_cell()\n", "\n", "\n", "dftu_packet = {'ISTART' :1, 'ICHARG':1, 'LDAUTYPE':2, 'LASPH':'.TRUE.', \n", " 'LDAUPRINT':2, 'LMAXMIX' :4, 'LDAU' :'.TRUE.',\n", " 'LDAUL':{'Ti':2, 'Co':2 , 'Fe':2 , 'Ni':2 , 'Mn':2 , 'V':2 , 'Cr':2 },\n", " 'LDAUU':{'Ti':0, 'Co':3.4, 'Fe':4.0, 'Ni':6.2, 'Mn':3.9, 'V':3.1 , 'Cr':3.5, 'Fe/S':1.9 },\n", " 'LDAUJ':{'Ti':0.0, 'Co':0.0, 'Fe':0.0, 'Ni':0.0, 'Mn':0.0, 'V':0.0 , 'Cr':0.0, 'Fe/S':0 } }\n", "\n", "mag_packet = {\n", " 'GGA_COMPAT': '.FALSE.',\n", " 'ISPIN':2,\n", " 'LORBIT':11, #more info\n", " 'magnetic_moments':{'Ti':0.6, 'V':5, 'Fe':5, 'Co':5, 'Mn':5, 'Ni':5, 'Cr':5 }\n", "}\n", "\n", "calc_pack = {'KSPACING':0.3, 'ENCUT':400, 'ENAUG':400*1.75, }\n", "\n", "surface_pack4 = {'ISYM':0, 'PREC':'Accurate', 'NSW':50, 'NELM':100, 'EDIFF':1e-04, 'ISMEAR':0, 'SIGMA':0.1, 'IBRION':2, 'EDIFFG':-0.05, 'POTIM':0.2,\n", " 'AMIN':None, 'AMIX':None, 'BMIX':None, 'NELMIN':4, 'IDIPOL':3, 'LDIPOL':'.TRUE.', 'LVTOT':'.TRUE.', 'ICHARG':1} # \n", "\n", "pack = {}\n", "pack.update(dftu_packet)\n", "pack.update(mag_packet)\n", "pack.update(calc_pack)\n", "pack.update(surface_pack4)\n", "# print(pack)\n", "read_vasp_sets([('1u6', 'static', pack)])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Create slab with surface surface\n", "Here the second argument provide the Miller indexes of required surface\n", " - 'shift' is additional shift of input cell along R3\n", " - 'cut_thickness' allows to remove layers from the top of slab after its construction\n", " - 'surface_i' is choosing the required termination if more than one exists\n", " - 'symmetrize' is symmetrizing the slab to find the surface primitive cell \n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-- 1 surfaces were generated, choose required surface using *surface_i* argument \n", "\n", "Final structure contains 32 atoms\n" ] } ], "source": [ "st_sufNa = create_surface2(sconv, [1, 0, -1], shift = 0.0, \n", " return_one = 1, write_poscar = 0, cut_thickness = 0, \n", " min_vacuum_size = 10, symmetrize = 0, \n", " min_slab_size = 16, surface_i = 0, oxidation = {'Na':'Na+', 'Ni':'Ni3+', 'O':'O2-' })\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3. Fix bottom layers of the slab\n", "Here we selective dynamics to fix bottom layers of the slab. This allows to speed up relaxation of atomic \n", "positions. \n", "The *higlight* argument allow to write xyz file to check which atoms would be fixed." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "st_sufNaf = st_sufNa.fix_layers(xcart_range = [0, 6.8], highlight = 0) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 4. Submit Monte-Carlo job\n", "Choose MC regime with *calc_method* argument. \n", "The parameters of MC simulation are given in params dic with 'monte' section\n", " - 'normal' - choose vector normal to surface\n", " - 'thickness' - thickness of slice where Monte-Carlo changes are allowed (from the top surface)\n", " - 'mcsteps' - number of Monte-Carlo steps\n", " - 'temp' - temperature (K) for Metropolis Algorithm" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-- Attention!, cluster None is not found, using default CEE \n", "\n", "-- check_kpoints(): Kpoint mesh is: [8, 5, 1] \n", "\n", "-- check_kpoints(): The actual k-spacings are [0.27 0.24 0.2 ] \n", "\n", "-- actualize_set(): Magnetic moments are determined from self.init.magmom: [0.6, 0.6, 5, 5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 5, 5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 5, 5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 5, 5, 0.6, 0.6, 0.6, 0.6] \n", "\n", "-- POSCAR was written to /home/aksenov/Simulation_wrapper/siman/tutorials/NaNiO2/mc1/10-1///NaNiO2.10-1.mc.1u6/1.POSCAR \n", "\n", "-- Attention! ngkpt = [8, 5, 1] is adopted from struct_des which you provided for it NaNiO2.10-1.mc and kspacing = 0.3 \n", "\n", "\n", "Calculation ('NaNiO2.10-1.mc', '1u6', 1) successfully created\n", "\n", " \n", "\n" ] }, { "data": { "text/plain": [ "'NaNiO2.10-1.mc'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "header.warnings = 'yY'\n", "add('NaNiO2.10-1.mc', '1u6', 1, up = 'up2', input_st = st_sufNaf, it_folder = 'NaNiO2/mc1/10-1/', \n", " calc_method = 'monte', run = 0,\n", " params = {'monte':{'normal':2, 'thickness':6, 'mcsteps':20, 'temp':1073}}, show ='fo')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Understanding results\n", "Go to calculation folder on cluster. You can see two new files *monte.log*, *verbose_log*, and *ENERGIES* \n", "*monte.log* gives concise information about calculation, while *verbose_log* contains more details. \n", "\n", "*ENERGIES* file contains number of step and final energy for this step. You can open this file and see if the energy was reduced due to reconstruction\n", "\n", "You can see that for each MC step siman creates OUTCAR-n, CONTCAR-n, OSZICAR-n, n-yes/no.pickle.\n", "n-yes/no.pickle is serialized CalculationVasp object. If the filename contains yes in its name, than it means that this configuration was accepted with Monte-Carlo algorithm.\n", "\n", "To read results use res() as always. To download CONTCAR-n and n-yes/no.pickle files of intermediate steps use 'pickle' value for *show* argument" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res('NaNiO2.10-1.mc', '1u6', 1, show ='pickle')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }