### Install AiiDA-KKR with Testing Extras Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Installs the AiiDA-KKR package with the necessary dependencies for running tests. This includes setting up the testing environment and potentially fake executables for specific calculations. ```bash pip install -e .[testing] cd tests mkdir -p jukkr; cd jukkr && export PATH="$PWD:$PATH"; touch kkr.x; touch voronoi.exe; touch kkrflex.exe; chmod +x kkr.x voronoi.exe kkrflex.exe ``` -------------------------------- ### Install Documentation Build Dependencies Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Installs the necessary Python packages required to build the project's documentation using Sphinx. This involves installing the 'docs' extra for the AiiDA-KKR package. ```bash pip install -e .[docs] ``` -------------------------------- ### Install AiiDA-KKR from PyPI Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Installs the latest stable release of the AiiDA-KKR plugin from the Python Package Index (PyPI). This is the standard method for end-users to install the package. ```bash pip install aiida-kkr ``` -------------------------------- ### Full KKR Workflow Example Script Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst This Python script provides a comprehensive example for setting up and running a Voronoi-KKR-KKRimp calculation workflow. It includes structure setup, Voronoi calculation, initial KKR calculation, convergence continuation, host GF writing, and a simple impurity calculation. The script requires AiiDA and the aiida-kkr plugin. ```python #!/usr/bin/env python # connect to aiida db from aiida import load_profile load_profile() # load essential aiida classes from aiida.orm import Code from aiida.orm import DataFactory StructureData = DataFactory('structure') Dict = DataFactory('parameter') # load kkrparms class which is a useful tool to create the set of input parameters for KKR-family of calculations from aiida_kkr.tools.kkr_params import kkrparams # load some python modules from numpy import array # helper function def wait_for_it(calc, maxwait=300): from time import sleep N = 0 print 'start waiting for calculation to finish' while not calc.has_finished() and N<(maxwait/2.): N += 1 if N%5==0: print('.') sleep(2.) print('waiting done after {} seconds: {} {}'.format(N*2, calc.has_finished(), calc.has_finished_ok())) ################################################### # initial structure ################################################### # create Copper bulk aiida Structure alat = 3.61 # lattice constant in Angstroem bravais = alat*array([[0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5]]) # Bravais matrix in Ang. units Cu = StructureData(cell=bravais) # Cu is Copper Cu.append_atom(position=[0,0,0], symbols='Cu') ``` -------------------------------- ### Install aiida-kkr developer version Source: https://github.com/judftteam/aiida-kkr/blob/master/README.md This command installs the developer version of aiida-kkr after cloning the repository. It uses `pip install -e` for an editable installation and includes optional dependencies for testing, development tools, and documentation. `reentry scan -r aiida` is required to update entry points. ```shell git clone https://github.com/JuDFTteam/aiida-kkr.git pip install -e aiida-kkr[testing,devtools,docs] reentry scan -r aiida ``` -------------------------------- ### Initialize AiiDA Profile Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/AiiDA-KKR_STM_Tutorial.ipynb Loads the AiiDA profile and imports necessary modules for AiiDA operations. This is a standard setup step for interacting with AiiDA. ```python from aiida import load_profile, orm, engine import numpy as np profile = load_profile() ``` -------------------------------- ### Install AiiDA-KKR with Pre-commit Hooks Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Installs the AiiDA-KKR package with the 'pre-commit' extra, which sets up automatic code checks for sanity and coding style using tools like yapf and pylint. It also installs the git pre-commit hook. ```bash pip install -e .[pre-commit] pre-commit install ``` -------------------------------- ### Initialize KKRnanoCalculation Builder Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/01_KKRnano_tutorial_simple_calculation.ipynb Initializes the process builder for the KKRnanoCalculation, preparing it to set up and run a KKRnano calculation. This is the starting point for configuring the main KKRnano simulation. ```python from aiida_kkr.calculations.kkrnano import KKRnanoCalculation builder = KKRnanoCalculation.get_builder() ``` -------------------------------- ### Setup and Run KKR SCF Workflow Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst This snippet demonstrates how to set up KKR parameters, load previous calculation outputs, and run a KKR SCF workflow. It requires the 'kkr_scf_wc' workflow and optionally uses previous calculation results for starting potential and remote data. ```python from aiida_kkr.tools.kkr_params import kkrparams kkmr_settings = kkrparams(NSPIN=1, LMAX=2) from aiida.orm import load_node kkr_startpot = load_node(22586) last_vorono_remote = kkr_startpot.get_outputs_dict().get('last_voronoi_remote') from aiida_kkr.workflows.kkr_scf import kkr_scf_wc from aiida.work import run from aiida.orm import DataFactory ParameterData = DataFactory('parameter') run(kkr_scf_wc, kkr=kkrcode, calc_parameters=ParameterData(dict=kkr_settings.get_dict()), remote_data=last_vorono_remote) ``` -------------------------------- ### Initialize AiiDA Profile and Load Modules Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/04_KKRnano_tutorial_StrucWithPotData.ipynb Initializes the AiiDA profile and loads necessary modules for interacting with AiiDA data structures and calculations. This is a common setup step for AiiDA-based Python scripts. ```python from aiida.orm import StructureData, load_node, CalcJobNode, Dict, RemoteData, StructureData, Bool, SinglefileData, Int, Float, Code import numpy as np from aiida import load_profile _ = load_profile() ``` -------------------------------- ### AIIDA-KKR: Example Workflow Execution Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst Demonstrates how to set up and run the kkr_startpot_wc workflow. This involves loading AiiDA codes, defining KKR parameters using kkrparams, creating a structure node, and executing the workflow with specified inputs. ```python from aiida.orm import Code kkrcode = Code.get_from_string('KKRcode@my_mac') vorocode = Code.get_from_string('voronoi@my_mac') from aiida_kkr.tools.kkr_params import kkrparams kkr_settings = kkrparams(NSPIN=1, LMAX=2) from aiida.orm import DataFactory StructureData = DataFactory('structure') alat = 3.61 # lattice constant in Angstroem bravais = alat*array([[0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5]]) # Bravais matrix in Ang. units Cu = StructureData(cell=bravais) Cu.append_atom(position=[0,0,0], symbols='Cu') from aiida_kkr.workflows.voro_start import kkr_startpot_wc from aiida.work import run ParameterData = DataFactory('parameter') run(kkr_startpot_wc, structure=Cu, voronoi=vorocode, kkr=kkrcode, calc_parameters=ParameterData(dict=kkr_settings.get_dict())) ``` -------------------------------- ### Voronoi Step Preparation for Starting Potential Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst This snippet prepares and sets up a Voronoi calculation for generating a starting potential. It involves creating KKR parameters, setting mandatory values, creating an AiiDA Dict node, and configuring the Voronoi calculation instance with structure, parameters, and resources. It then stores and submits the calculation. ```python # Voronoi step (preparation of starting potential) ################################################### # create empty set of KKR parameters (LMAX cutoff etc. ) for voronoi code params = kkrparams(params_type='voronoi') # and set at least the mandatory parameters params.set_multiple_values(LMAX=2, NSPIN=1, RCLUSTZ=2.3) # finally create an aiida Dict node and fill with the dictionary of parameters ParaNode = Dict(dict=params.get_dict()) # choose a valid installation of the voronoi code ### !!! adapt to your code name !!! ### codename = 'voronoi@my_mac' code = Code.get_from_string(codename) # create new instance of a VoronoiCalculation voro_calc = code.new_calc() # and set resources that will be used (here serial job) voro_calc.set_resources({'num_machines':1, 'tot_num_mpiprocs':1}) ### !!! use queue name if necessary !!! ### # voro_calc.set_queue_name('') # then set structure and input parameter voro_calc.use_structure(Cu) voro_calc.use_parameters(ParaNode) # store all nodes and submit the calculation voro_calc.store_all() voro_calc.submit() wait_for_it(voro_calc) # for future reference voronoi_calc_folder = voro_calc.outputs.remote_folder voro_params = voro_calc.inputs.parameters ``` -------------------------------- ### Build HTML Documentation with Sphinx Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Generates the HTML documentation for the AiiDA-KKR project using Sphinx. This command should be run from the 'docs' directory and produces the documentation in the 'build/html' folder. ```bash cd docs make html ``` -------------------------------- ### Setup and Submit DOS Calculations Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb This snippet sets up a Density of States (DOS) calculation builder using `kkr_dos_wc`. It configures parameters like number of energy points, temperature, energy range, and k-mesh. It then iterates through finished SCF nodes, assigns their `RemoteData` to the DOS builder, and submits the DOS calculations to a specified group. Dependencies include `kkr_dos_wc`, `orm.Dict`, `orm.KkrCode`, and `options`. ```python # set up dos builder builder = kkr_dos_wc.get_builder() # overview DOS in -10..5 eV range around EF builder.wf_parameters = orm.Dict(dict({'nepts': 96, 'tempr': 200.0, 'emin': -10.0, 'emax': 5.0, 'kmesh': [50, 50, 50]})) builder.kkr = kkr_code builder.options = options grouplabel_dos = 'Fe_bcc:dos' # prepare process builders for missing jobs for scf in group_scf.nodes: if scf.is_finished_ok: builder.remote_data = scf.outputs.last_RemoteData group_dos = submit_to_group(scf.label, grouplabel_dos, builder, dry_run=False) ``` -------------------------------- ### Setup and Submit Jij Calculations Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb This snippet configures and submits calculations for exchange interaction parameters (Jij). It initializes a builder using `kkr_jij_wc`, setting parameters like `jijrad_ang` and accuracy settings. For Fe-Co systems, it also activates the SOC solver. The snippet iterates through finished SCF nodes, attaches their `RemoteData` to the Jij builder, and submits the calculations to a specified group. Dependencies include `kkr_jij_wc`, `orm.Dict`, `orm.KkrCode`, `options`, and `kkrparams`. ```python # set up Jij calculation builder builder = kkr_jij_wc.get_builder() # calculate Jij's up to a distance of 10 Ang., this requires increasing max array sizes builder.wf_parameters = orm.Dict({ 'jijrad_ang': 10.0, 'accuracy': {'NATOMIMPD': 5000, 'NSHELD': 5000} }) builder.kkr = kkr_code builder.options = options grouplabel_Jij = 'Fe_bcc:Jij' # prepare process builders for missing jobs for scf in group_scf.nodes: if scf.is_finished_ok: builder.remote_data = scf.outputs.last_RemoteData if 'Fe_Co' in scf.label: # activate SOC solver for CPA calculations for proper parsing of results builder.params_kkr_overwrite = orm.Dict(dict(kkrparams(USE_CHEBYCHEV_SOLVER=True, NCHEB=12, NPAN_EQ=8, NPAN_LOG=17, R_LOG=0.6, SET_CHEBY_NOSOC=True).get_set_values())) group_Jij = submit_to_group(scf.label, grouplabel_Jij, builder, dry_run=False) ``` -------------------------------- ### Setup and Run Voronoi Calculation Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/kkr_plugins_test.ipynb This snippet demonstrates how to set up and run a single Voronoi calculation using AiiDA. It involves defining the code, calculation parameters, resources, and structure, then submitting the calculation. ```python code = Code.get_from_string('voro@local_mac') calc = VoronoiCalculation() calc.label = 'Test voronoi' calc.set_withmpi(False) calc.set_resources({"num_machines" : 1}) calc.set_max_wallclock_seconds(300) calc.set_computer('local_mac') calc.use_code(code) calc.use_structure(Cu) calc.use_parameters(keyw) ``` -------------------------------- ### Setup and Submit DFT Calculations for Fe and FeCo Alloys Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb Configures and submits AIIDA KKR SCF calculations for BCC Fe and Fe-Co alloys with varying lattice constants. It sets up calculation parameters, resources, queues, and submits jobs to a specified group, with an option for dry runs. ```python # prepare kkr_scf builder builder = kkr_scf_wc.get_builder() # scf settings scf_settings = kkr_scf_wc.get_wf_defaults(silent=True)[0] scf_settings['mag_init'] = True scf_settings['check_dos'] = False scf_settings['nsteps'] = 200 # code that uses intel nodes kkr_code = orm.load_code('kkrhost_3.5_intel@iffslurm') voronoi_code = orm.load_code('voronoi@localhost') builder.kkr = kkr_code builder.voronoi = voronoi_code options = orm.Dict({ 'withmpi': True, 'resources': {'num_machines': 1, 'tot_num_mpiprocs': 12, 'num_cores_per_mpiproc': 1}, 'queue_name': 'oscar', # select intel nodes 'custom_scheduler_commands': 'export OMP_NUM_THREADS=1\n', 'max_wallclock_seconds': 3600 # 1 hour max runtime }) builder.options = options # calculation parameters: KEXCOR=4 means GGA (PBE) builder.calc_parameters = orm.Dict(kkrparams(NSPIN=2, LMAX=3, RMAX=10, GMAX=100, KEXCOR=4)) # get original lattice constant for Fe from ase structure builder alat0 = bulk('Fe').cell[0][1]*2 #submit calculation for scaled lattice constants to group grouplabel_scf = 'Fe_bcc:scf' for scale_fac in [0.98, 1.0]: # create bcc Fe structure with scaled lattice constant struc = orm.StructureData(ase=bulk('Fe', 'bcc', a = alat0*scale_fac)) builder.structure = struc # submit calculation to group (calclabel determines if a calculation exists in group or not yet) calclabel = f'alat_scale={scale_fac:.3f}' group_scf = submit_to_group(calclabel, grouplabel_scf, builder, dry_run=True) # CPA structures for 50/50 Fe Co struc = orm.StructureData(cell=struc.cell) struc.append_atom(position=[0,0,0], symbols=('Fe', 'Co'), weights=(0.5, 0.5)) builder.structure = struc # submit calculation to group (calclabel determines if a calculation exists in group or not yet) calclabel = f'Fe_Co:alat_scale={scale_fac:.3f}' group_scf = submit_to_group(calclabel, grouplabel_scf, builder, dry_run=False) # [(i.label, i.pk, i.process_state, i.exit_status) for i in group_scf.nodes] ``` -------------------------------- ### AiiDA KKR and Voronoi Setup and Imports Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/kkr_plugins_test.ipynb Initializes the AiiDA database environment and imports necessary modules for AiiDA calculations, data handling, and specific KKR/Voronoi functionalities. This snippet is crucial for setting up the environment before any calculations can be performed. ```python %load_ext autoreload %autoreload 2 %matplotlib notebook import time import os from aiida import load_dbenv, is_dbenv_loaded if not is_dbenv_loaded(): load_dbenv() from aiida.orm import Code, load_node from aiida.orm import DataFactory, CalculationFactory from aiida_kkr.tools.kkrcontrol import write_kkr_inputcard_template, fill_keywords_to_inputcard, create_keyword_default_values from pprint import pprint from scipy import array from aiida_kkr.calculations.kkr import KkrCalculation from aiida_kkr.calculations.voro import VoronoiCalculation from aiida_kkr.parsers.voro import VoronoiParser from aiida_kkr.parsers.kkr import KkrParser ParameterData = DataFactory('parameter') StructureData = DataFactory('structure') ``` -------------------------------- ### Generate KKR Start Potential Workflow with AIIDA-KKR Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst Defines the inputs required for the `kkr_startpot_wc` workflow, which generates the starting potential for KKR calculations. Key inputs include the structure, KKR code, and optional parameters for the workflow and calculation. ```python # Inputs for kkr_startpot_wc workflow: # structure: StructureData # voronoi: Code # kkr: Code # wf_parameters: ParameterData (optional) # options: ParameterData (optional) # calc_parameters: ParameterData (optional) # label: str (optional) # description: str (optional) ``` -------------------------------- ### Install aiida-kkr using pip Source: https://github.com/judftteam/aiida-kkr/blob/master/README.md This command installs the latest stable version of the aiida-kkr package from PyPI. After installation, `reentry scan -r aiida` is necessary to update AiiDA's entry points, ensuring that the kkr.* entry points are recognized. ```shell pip install aiida-kkr reentry scan -r aiida ``` -------------------------------- ### Display Content of Retrieved File Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/02_KKRnano_tutorial_continue_calculations.ipynb Illustrates how to retrieve and display the content of a specific file from the retrieved outputs of a KKR calculation, using 'vpot.00001' as an example. This allows for direct examination of raw output data. ```python print(kkr_conv.outputs.retrieved.get_object_content('vpot.00001')) ``` -------------------------------- ### Import AIIDA-KKR and ASE Modules Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb Imports necessary libraries from AIIDA-KKR and ASE for setting up and running KKR calculations, including workflow definitions, parameter tools, and plotting utilities. It also loads the AIIDA profile. ```python import numpy as np import matplotlib.pyplot as plt from ase.build import bulk from aiida import load_profile, orm, engine from aiida_kkr.tools import plot_kkr, kkrparams from aiida_kkr.workflows import kkr_scf_wc, kkr_dos_wc, kkr_jij_wc _ = load_profile() ``` -------------------------------- ### Setup and Submit KKR Calculation Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/Basic_calculations.html Configures and submits a KKR calculation using an AiiDA builder. It sets the parameters, parent folder, and metadata options. The calculation can be submitted to the daemon using `submit()` or run directly using `run()`. ```python code = Code.get_from_string('code_name@computer') builder = code.get_builder() builder.parameters = ParaNode builder.parent_folder = voronoi_calc_folder builder.metadata.options = {'resources' :{'num_machines': 1, 'num_mpiprocs_per_machine':1}} kkr_calc = submit(builder) # or kkr_calc = run(builder) ``` -------------------------------- ### Parse KKRnano Input File Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/01_KKRnano_tutorial_simple_calculation.ipynb Retrieves the remote folder and parameters from a completed Voronoi calculation. It then uses a custom ParseInput script to parse an example KKRnano input configuration file, extracting parameters into a dictionary. ```python import ParseInput import os voronoi_calc_folder = voro_calc.outputs.remote_folder voro_params = voro_calc.inputs.parameters filename = os.getcwd()+"/example_Cu_input.conf" inputdict = ParseInput.get_inputdict_nano(filename) # Display the parsed input dictionary inputdict ``` -------------------------------- ### Import AiiDA SPIRIT Plotting Tools (Python) Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb This snippet imports necessary plotting functions from the `aiida_spirit.tools.plotting` module. Specifically, it imports `init_spinview` and `show_spins`, which are likely used for visualizing spin configurations from SPIRIT calculations. ```python from aiida_spirit.tools.plotting import init_spinview, show_spins ``` -------------------------------- ### Recreate Test Export Files with Real Executables Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst This script is used to download and compile the necessary JuKKR executables (voronoi, kkrhost, kkrimp) to recreate test export files. It ensures that the tests can run with actual code, not just fakes, for more accurate results. ```bash cd tests ./jukkr_installation.sh -f cd jukkr && export PATH="$PWD:$PATH" && cd .. ``` -------------------------------- ### Start KKR Calculation from Voronoi Parent Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst This snippet demonstrates how to initiate a KKR calculation using the output of a previous Voronoi calculation as the parent. It involves retrieving parameters from the Voronoi calculation, updating them for KKR, and then submitting the new KKR calculation using the AIIDA builder. ```python voronoi_calc_folder = voro_calc.out.remote_folder voro_params = voro_calc.inputs.parameters # new kkrparams instance for KKR calculation params = kkrparams(params_type='kkr', **voro_params.get_dict()) # set the missing values params.set_multiple_values(RMAX=7., GMAX=65.) # choose 20 simple mixing iterations first to preconverge potential (here 5% simple mixing) params.set_multiple_values(NSTEPS=20, IMIX=0, STRMIX=0.05) # create aiida Dict node from the KKR parameters ParaNode = Dict(dict=params.get_dict()) code = Code.get_from_string('KKRcode@localhost') builder = code.get_builder() # set input Parameter, parent calulation (previous voronoi calculation), computer resources builder.parameters = ParaNode builder.parent_folder = voronoi_calc_folder builder.metadata.options = {'resources' :{'num_machines': 1, 'num_mpiprocs_per_machine':1}} kkr_calc = submit(builder) ``` -------------------------------- ### Create Impurity Starting Potential with neworder_potential_wf (Python) Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst This example demonstrates using the `neworder_potential_wf` workfunction to construct an impurity starting potential. It combines a converged host potential with a new impurity potential from a Voronoi calculation, using specified replacement rules and settings. ```python from aiida_kkr.tools.common_workfunctions import neworder_potential_wf potname_converged = kkrcalc_converged._POTENTIAL potname_imp = 'potential_imp' neworder_pot1 = [int(i) for i in loadtxt(GF_host_calc.outputs.retrieved.get_abs_path('scoef'), skiprows=1)[:,3]-1] potname_impvorostart = voro_calc_aux._OUT_POTENTIAL_voronoi replacelist_pot2 = [[0,0]] settings_dict = {'pot1': potname_converged, 'out_pot': potname_imp, 'neworder': neworder_pot1, 'pot2': potname_impvorostart, 'replace_newpos': replacelist_pot2, 'label': 'startpot_KKRimp', 'description': 'starting potential for Au impurity in bulk Cu'} settings = Dict(dict=settings_dict) startpot_Au_imp_sfd = neworder_potential_wf(settings_node=settings, parent_calc_folder=kkrcalc_converged.outputs.remote_folder, parent_calc_folder2=voro_calc_aux.outputs.remote_folder) ``` -------------------------------- ### Get AIIDA Codes Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst Retrieves instances of 'KKRimpcode' and 'vorocode' from the AIIDA Code environment. Assumes these codes are configured and available in the AIIDA installation. ```python from aiida.orm import Code kkrimpcode = Code.get_from_string('KKRimpcode@my_mac') vorocode = Code.get_from_string('vorocode@my_mac') ``` -------------------------------- ### Setting up KKRnano Calculation Builder Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/04_KKRnano_tutorial_StrucWithPotData.ipynb This snippet initializes an AiiDA builder for the KKRnano calculation. It sets essential parameters such as the calculation code, input parameters node, and the previously created `supercell` object. ```python from aiida_kkr.calculations.kkrnano import KKRnanoCalculation builder=KKRnanoCalculation.get_builder() #Using suitable parameters builder.parameters=load_node("ec6dab6f-a72e-4159-b5b6-df7da1a8fcff") builder.metadata.options= {'resources': {'num_machines': 1, 'tot_num_mpiprocs': 40}, 'queue_name': 'th1-2020-64', 'withmpi': True} builder.code = Code.get_from_string("KKRnanoVersuch2@iffslurm") builder.strucwithpot=supercell ``` -------------------------------- ### Get KKR Code Instance Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/Basic_calculations.ipynb Retrieves an instance of the KKR code from the AIIDA environment. This code must be installed and configured on the target computer. It takes a string representation of the code name and computer. ```python from aiida.orm import Code kkrcode = Code.get_from_string('code_name@computer') ``` -------------------------------- ### Get SPIRIT Calculation Data (Python) Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb This function retrieves a specific calculation from the AiiDA database based on group labels. It constructs group labels from provided parameters like `alat_scale`, `T`, and `Fe_Co` status, and then uses `get_calc_from_group` to fetch the calculation. This is useful for accessing pre-computed results for plotting and analysis. ```python def get_spirit_calc(alat_scale=1.0, T=100., Fe_Co=False): grouplabel_spirit = f'Fe_bcc:spirit:alat_scale={alat_scale:.3f}' if Fe_Co: grouplabel_spirit = grouplabel_spirit.replace('spirit:', 'spirit:Fe_Co:') calclabel = f'T={T:.1f}' return get_calc_from_group(calclabel, grouplabel_spirit) ``` -------------------------------- ### Configure and Launch KKRnano DOS Workflow Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/03_KKRnano_tutorial_DOSworkchain.ipynb This snippet completes the configuration of the KKRnano DOS workflow builder. It assigns the workflow parameters, specifies the KKRnano code to use, sets the parent folder (likely from a previous Voronoi calculation), defines job options like resources and queue, and enables DOS calculation. Finally, it would be followed by `builder.submit()` to launch the workflow. ```python builder.wf_parameters = wfParamsNode builder.code = Code.get_from_string("KKRnanoVersuch2@iffslurm") builder.parent_folder = voronoi_calc_folder builder.options = Dict(dict={ 'resources': {'num_machines': 1, 'num_mpiprocs_per_machine': 3, }, 'queue_name': 'viti', # the 'withmpi' key controls whether or not mpi is used in the jobscript 'withmpi': True, }) builder.calculate_DOS = Bool(True) ``` -------------------------------- ### Creating StrucWithPotData Objects Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/04_KKRnano_tutorial_StrucWithPotData.ipynb This snippet illustrates the creation of StrucWithPotData objects, which combine structural information with potential files. It shows how to instantiate these objects for both regular and antisite structures, ensuring correct potential assignments for subsequent calculations. ```python stwpd_CPA1=StrucWithPotData(passedStructure=Bi2Te3_struc, list_of_shapes=CPA_calc.shapes, list_of_pots=Bi_pots+regular_Te_sites) stwpd_CPA_antisite=StrucWithPotData(passedStructure=Bi2Te3_antisite_struc, list_of_shapes=CPA_calc.shapes, list_of_pots=Bi_pots+regular_Te_sites) ``` -------------------------------- ### KKR Start Potential Generation (kkr_startpot_wc) Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst This workflow generates the starting potential for KKR calculations. It takes a structure and KKR code as input. ```APIDOC ## POST /kkr_startpot_wc ### Description Generates the starting potential for KKR calculations using the `kkr_startpot_wc` workflow. ### Method POST ### Endpoint /kkr_startpot_wc ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **structure** (StructureData) - The crystal structure for which to generate the start potential. - **voronoi** (Code) - The Voronoi code to be used. - **kkr** (Code) - The KKR code to be used. - **wf_parameters** (ParameterData, optional) - Workflow parameters. - **options** (ParameterData, optional) - Computer and scheduler settings. - **calc_parameters** (ParameterData, optional) - Calculation specific parameters for the KKR calculation. - **label** (str, optional) - Label for the WorkChainNode. - **description** (str, optional) - Description for the WorkChainNode. ### Request Example ```json { "structure": "", "voronoi": "VoronoiCode@COMPUTERNAME", "kkr": "KKRcode@COMPUTERNAME", "wf_parameters": { "some_setting": true }, "options": { "resources": {"num_cores": 4} } } ``` ### Response #### Success Response (200) - **potstart** (FolderData) - The generated start potential files. - **results** (Dict) - Dictionary containing results of the workflow. #### Response Example ```json { "potstart": "", "results": { "message": "Starting potential generated successfully." } } ``` ``` -------------------------------- ### Import Aiida Modules for KKRnano Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/01_KKRnano_tutorial_simple_calculation.ipynb Imports necessary modules from Aiida for interacting with KKRnano calculations, including data structures for structures, calculations, and parameters, as well as profile loading. ```python from aiida.orm import StructureData, load_node, CalcJobNode, Dict, RemoteData, StructureData, Bool, SinglefileData, Int, Float import numpy as np from aiida import load_profile _ = load_profile() ``` -------------------------------- ### Prepare Potential and Shape Files for StrucWithPotData Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/04_KKRnano_tutorial_StrucWithPotData.ipynb Prepares lists of `SinglefileData` objects representing potential and shape files. These files are typically output from previous calculations and are used to initialize `StrucWithPotData`. ```python from aiida_kkr.data.strucwithpot import StrucWithPotData from aiida.orm import SinglefileData import os #Preparing lists from existing file in tutorial subdirectory path=os.getcwd()+"/example_shapes_pots/" list1=[SinglefileData(path+"shape.0000001"),SinglefileData(path+"shape.0000002")] list2=[SinglefileData(path+"vpot.00001"),SinglefileData(path+"vpot.00002")] ``` -------------------------------- ### Configure and Prepare kkr_STM_wc Builder Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/AiiDA-KKR_STM_Tutorial.ipynb Sets up the builder for the kkr_STM_wc workflow, populating it with essential inputs such as impurity information, host remote data, impurity potential, and tip positioning parameters including calculated scan positions. ```python from aiida_kkr.workflows import kkr_STM_wc builder = kkr_STM_wc.get_builder() # The impurity info is a dictionary containing the impurity type, it's position and cluster radius builder.imp_info = imp_info # Host remote is the RemoteData containing information about the structure of the host system builder.host_remote = host_remote # The impurity potential node contains a file where all the information about the potential generated by an impurity. builder.imp_potential_node = imp_potential_node # The tip position is where we want to scan with the STM. # ilayer is the z position of the tip # nx and ny are the number of sites to be scanned in the unit of the in-plane Bravais lattice (da and db respectively) # NOTE: The automatic submission is broken at this moment since the ASE tool doesn't return the correct rotation matrix # Instead use the parameter "scan positions" builder.tip_position = orm.Dict({'ilayer': 0, 'nx': 10, 'ny': 10, 'scan_positions':coeff}) # This paramters controls the cluster radius on the KKR level, sometimes it must be increased in order to allow for ``` -------------------------------- ### Generate Starting Potential for KKR Impurity Calculation Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst Generates a starting potential for KKR impurity calculations using the `neworder_potential_wf` function. This involves specifying converged host potentials, impurity potential names, and replacement lists. It takes converged host calculation remote folder and auxiliary Voronoi calculation remote folder as inputs. ```python from aiida_kkr.tools.common_workfunctions import neworder_potential_wf import numpy as np from aiida.orm import ParameterData # Assume kkrcalc_converged, GF_host_calc, and voro_calc_aux are defined elsewhere # potname_converged = kkrcalc_converged._POTENTIAL # potname_imp = 'potential_imp' # neworder_pot1 = [int(i) for i in np.loadtxt(GF_host_calc.out.retrieved.get_abs_path('scoef'), skiprows=1)[:,3]-1] # potname_impvorostart = voro_calc_aux._OUT_POTENTIAL_voronoi # replacelist_pot2 = [[0,0]] # Example placeholder values for demonstration potname_converged = 'converged_host_pot' potname_imp = 'potential_imp' neworder_pot1 = [1, 2, 3] potname_impvorostart = 'voronoi_potential' replacelist_pot2 = [[0,0]] settings_dict = {'pot1': potname_converged, 'out_pot': potname_imp, 'neworder': neworder_pot1, 'pot2': potname_impvorostart, 'replace_newpos': replacelist_pot2, 'label': 'startpot_KKRimp', 'description': 'starting potential for Au impurity in bulk Cu'} settings = ParameterData(dict=settings_dict) # Assume kkrcalc_converged and voro_calc_aux are valid AiiDA nodes with remote_folder output # startpot_Au_imp_sfd = neworder_potential_wf(settings_node=settings, # parent_calc_folder=kkrcalc_converged.out.remote_folder, # parent_calc_folder2=voro_calc_aux.out.remote_folder) # Placeholder for the actual workflow call output startpot_Au_imp_sfd = 'generated_startpot_node' ``` -------------------------------- ### Get Sites as Dictionary Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKRnano_Tutorial/04_KKRnano_tutorial_StrucWithPotData.ipynb Retrieves the sites of a StrucWithPotData object as a dictionary. This provides a structured way to access information about each site in the material. ```python stwpd_kkrnano.sites() ``` -------------------------------- ### Get AiiDA Code Node for Voronoi Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/Basic_calculations.html Retrieves an AiiDA Code node from the database using its string representation. This code node represents the executable for the Voronoi calculation. ```python from aiida.orm import Code codename = 'code_name@computer' # Replace with your actual code name and computer code = Code.get_from_string(codename) ``` -------------------------------- ### Get Default Workflow Parameters for KKR Jij Calculation Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst This snippet shows how to retrieve the default workflow parameters for the kkr_jij_wc workchain using the get_wf_defaults() method. These parameters can then be modified. ```python kkr_jij_wc.get_wf_defaults() ``` -------------------------------- ### AIIDA-KKR: Get Workflow Defaults Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/workflows.rst Retrieves the default settings for the kkr_dos_wc workflow. These defaults cover general, computer, and DOS check settings. Users can customize these parameters for specific calculations. ```python kkr_dos_wc.get_wf_defaults() ``` -------------------------------- ### Get AiiDA Code Node Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/Basic_calculations.ipynb Retrieves an AiiDA Code node from the database using its string representation. This node represents the executable code (e.g., Voronoi) configured in AiiDA. ```python from aiida.orm import Code codename = 'code_name@computer' code = Code.get_from_string(codename) ``` -------------------------------- ### Configure and Run Spirit LLG Calculations Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb Sets up a builder for Spirit calculations, loads the 'spirit@iffslurm' code, and configures metadata options including MPI, resources, queue, and wallclock time. It also defines run options for the simulation method and solver, and iterates through temperature values to submit multiple LLG calculations. ```python from aiida_spirit.calculations import SpiritCalculation from aiida import orm import numpy as np builder = SpiritCalculation.get_builder() builder.code = orm.load_code('spirit@iffslurm') builder.metadata.options = { 'withmpi': True, 'resources': {'num_machines': 1, 'tot_num_mpiprocs': 1, 'num_cores_per_mpiproc': 1}, 'queue_name': 'oscar', 'max_wallclock_seconds': 3600, 'custom_scheduler_commands': '#SBATCH --exclusive\n\nexport OMP_NUM_THREADS=12' } builder.run_options = orm.Dict({ 'simulation_method': 'llg', 'solver': 'depondt', # Depondt solver to take temperature into account }) parameters_llg = { # temperature noise (in K) 'llg_temperature': 100., # small external field of 5 mT 'external_field_magnitude': 0.005, # external field points in z direction 'external_field_normal': [0.0, 0.0, 1.0], # change spin moment to have the right size for Fe, not used though 'mu_s': [2.2], # limit the number of LLG iterations 'llg_n_iterations': 10000, 'llg_n_iterations_log': 500, # periodic boundary conditions 'boundary_conditions': [True, True, True], # size of spirit supercell 'n_basis_cells': [20, 20, 20], } # Assuming 'group_Jij', 'average_jij', 'get_calc_from_group', and 'submit_to_group' are defined elsewhere # for jij_calc in list(group_Jij.nodes): # if jij_calc.is_finished_ok: # # individual groups for each lattice constant # grouplabel_spirit = 'Fe_bcc:spirit:'+jij_calc.label # print(grouplabel_spirit) # # # set builder and submit to group # builder.structure = jij_calc.outputs.structure_jij_sites # jij_data = jij_calc.outputs.jij_data # if 'Co' in jij_calc.label: # jij_data = average_jij(jij_data) # builder.jij_data = jij_data # for T in np.linspace(0., 2000., 21): # ms = get_calc_from_group(jij_calc.label, grouplabel_scf).outputs.last_calc_out['magnetism_group']['spin_moment_per_atom'] # if 'Co' in jij_calc.label: # ms = [np.mean(ms)] # parameters_llg['mu_s'] = ms # set list of spin moments # parameters_llg['llg_temperature'] = T # builder.parameters = orm.Dict(parameters_llg) # calclabel = f'T={T:.1f}' # # submit to group # group_spirit = submit_to_group(calclabel, grouplabel_spirit, builder, dry_run=False) ``` -------------------------------- ### Setup and Submit KKR Calculation in Python Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/kkr_plugins_test.ipynb This Python snippet demonstrates how to configure and submit a KKR calculation using the AiiDA framework. It involves setting up calculation parameters, resources, and code, then either submitting a test job or storing and submitting the actual calculation. It requires the 'Code', 'KkrCalculation', and 'os' modules. ```python code = Code.get_from_string('kkr1@local_mac')#'kkrimp@local_mac') calc1 = KkrCalculation() calc1.label = 'Test kkr' calc1.set_withmpi(False) calc1.set_resources({"num_machines" : 1}) calc1.set_max_wallclock_seconds(300) calc1.set_computer('local_mac') calc1.use_code(code) #calc1.use_structure(Cu) calc1.use_parameters(keyw2) calc1.use_parent_folder(remote) submit_test = False if submit_test: subfolder, script_filename = calc1.submit_test() print "Test_submit for calculation (uuid='{}')".format( calc1.uuid) print "Submit file in {}".format(os.path.join( os.path.relpath(subfolder.abspath), script_filename )) else: calc1.store_all() print "created calculation; calc=Calculation(uuid='{}') # ID={}".format( calc1.uuid, calc.dbnode.pk) calc1.submit() print "submitted calculation; calc=Calculation(uuid='{}') # ID={}".format( calc.uuid, calc.dbnode.pk) ``` -------------------------------- ### Skip Pre-commit Hooks During Commit Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst A Git command option to bypass the pre-commit hooks when making a commit. This is typically used in specific scenarios where running the hooks is not desired or necessary. ```bash git commit -n ``` -------------------------------- ### Run Pre-commit Hooks Manually Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/developer_guide/index.rst Executes all pre-commit hooks across all files in the repository without requiring a commit. This is useful for checking code quality and style adherence before committing changes. ```bash pre-commit run --all-files ``` -------------------------------- ### KKR Step with Simple Mixing Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst This snippet sets up and runs an initial KKR calculation using simple mixing for pre-convergence. It reuses parameters from the Voronoi step, sets KKR-specific values like RMAX and GMAX, configures simple mixing with NSTEPS and STRMIX, and then submits the calculation. It also uses the output from the Voronoi calculation as a parent folder. ```python # KKR step (20 iterations simple mixing) ################################################### # create new set of parameters for a KKR calculation and fill with values from previous voronoin calculation params = kkrparams(params_type='kkr', **voro_params.get_dict()) # and set the missing values params.set_multiple_values(RMAX=7., GMAX=65.) # choose 20 simple mixing iterations first to preconverge potential (here 5% simple mixing) params.set_multiple_values(NSTEPS=20, IMIX=0, STRMIX=0.05) # create aiida Dict node from the KKR parameters ParaNode = Dict(dict=params.get_dict()) # get KKR code and create new calculation instance ### !!! use your code name !!! ### code = Code.get_from_string('KKRcode@my_mac') kkr_calc = code.new_calc() # set input Parameter, parent calulation (previous voronoi calculation), computer resources kkr_calc.use_parameters(ParaNode) kkr_calc.use_parent_folder(voronoi_calc_folder) kkr_calc.set_resources({'num_machines': 1, 'num_mpiprocs_per_machine':1}) ### !!! use queue name if necessary !!! ### # kkr_calc.set_queue_name('') # store nodes and submit calculation kkr_calc.store_all() kkr_calc.submit() # wait for calculation to finish wait_for_it(kkr_calc) ``` -------------------------------- ### KKR Host GF Writeout: Setup and Submission Source: https://github.com/judftteam/aiida-kkr/blob/master/docs/source/user_guide/calculations.rst Sets up and submits a KKR calculation for host Green function writeout, reusing settings from a converged calculation. It involves extracting parameters, modifying run options, and preparing impurity information for KKRimp. Dependencies include AiiDA core ORM and Dict nodes. ```python from aiida.orm import Dict from aiida.plugins import CalculationFactory from aiida.engine import submit KKRCalculation = CalculationFactory('kkr.kkr') kkr_converged_parent_folder = kkr_calc_continued.outputs.remote_folder kkrcalc_converged = kkr_converged_parent_folder.get_incoming().first().node kkr_params_dict = kkrcalc_converged.inputs.parameters.get_dict() kkr_params_dict['RUNOPT'] = ['KKRFLEX'] ParaNode = Dict(dict=kkr_params_dict) code = kkrcalc_converged.inputs.code builder= code.get_builder() resources = kkrcalc_converged.attributes['resources'] builder.metadata.options = {'resources': resources} builder.parameters = ParaNode builder.parent_folder = kkr_converged_parent_folder imp_info = Dict(dict={'Rcut':4.0, 'ilayer_center': 0, 'Zimp':[79.]}) builder.impurity_info = imp_info GF_host_calc = submit(builder) ``` -------------------------------- ### Capture Output Source: https://github.com/judftteam/aiida-kkr/blob/master/examples/KKR_Jij_spirit_example.ipynb This magic command is used to capture the output of subsequent cells, preventing it from being displayed directly. It's often used in notebooks for cleaner output management. ```python %%capture --no-display ```