### Install masci-tools with pip Source: https://github.com/judftteam/masci-tools/blob/develop/README.md This command installs the masci-tools package using pip, the standard Python package installer. Ensure you have Python and pip configured on your system. ```bash pip install masci-tools ``` -------------------------------- ### HDF5 Reader Recipe Structure Example (Python) Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/hdf5_parser.md An example illustrating the structure of a recipe entry for the FleurBands recipe within the HDF5Reader. It shows how to define the 'h5path', 'description', and 'transforms' for extracting specific data like Fermi energy. ```python "fermi_energy": { "h5path": "/general", "description": "fermi_energy of the system", "transforms": [ Transformation(name='get_attribute', args=('lastFermiEnergy',), kwargs={}), Transformation(name='get_first_element', args=(), kwargs={}) ] } ``` -------------------------------- ### Python Data Transformation Example Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/hdf5_parser.md Demonstrates the definition of a transformation using the Transformation namedtuple for applying operations like 'get_attribute' and 'get_first_element' to HDF5 datasets within a recipe. ```python Transformation(name='get_attribute', args=('lastFermiEnergy',), kwargs={}) ``` ```python Transformation(name='get_first_element', args=(), kwargs={}) ``` -------------------------------- ### Fleur Input Generation Example Source: https://github.com/judftteam/masci-tools/blob/develop/tests/io/test_fleur_inpgen/test_mag_mom_list_write_inpgen_roundtrip.txt This snippet demonstrates the structure of a typical Fleur input file. It includes parameters for the calculation type, lattice vectors, atomic positions, and species-specific settings. Ensure correct formatting for successful parsing by Fleur. ```fleur &input cartesian=F / 4.822468380 0.000000000 0.000000000 0.000000000 4.822468380 0.000000000 0.000000000 0.000000000 6.820000000 1.0000000000 1.000000000 1.000000000 1.000000000 2 26.1 0.0000000000 0.0000000000 0.0000000000 1 : 0.0000 0.0000 2.2000 26.2 0.5000000000 0.5000000000 0.5000000000 2 : 0.0000 0.0000 -2.2000 ``` -------------------------------- ### Command-Line File Parsing with masci-tools Source: https://context7.com/judftteam/masci-tools/llms.txt Provides examples of using the `masci-tools` command-line interface to parse Fleur XML files and extract various types of information. This allows for quick inspection and data extraction without writing Python scripts. ```bash # Parse complete input file to JSON masci-tools parse inp-file /path/to/inp.xml # Parse output file masci-tools parse out-file /path/to/out.xml # Extract specific information masci-tools parse structure /path/to/inp.xml # Output: # Info: Atoms found: # Si Si-1 [0.678, 0.678, 0.678] # Si Si-2 [0.322, 0.322, 0.322] # Extract cell parameters masci-tools parse cell /path/to/inp.xml # Extract k-points masci-tools parse kpoints /path/to/inp.xml # Extract calculation parameters masci-tools parse parameters /path/to/inp.xml # Extract symmetry information masci-tools parse symmetry /path/to/inp.xml # Query specific attribute masci-tools parse attrib -n "Kmax" /path/to/inp.xml # Output: 4.5 # Query text content masci-tools parse text -n "comment" /path/to/inp.xml # Output: Si bulk calculation # Get all attributes of specific tag masci-tools parse all-attribs -n "species" /path/to/inp.xml # Parse constants (like Pi, Bohr radius) masci-tools parse constants /path/to/inp.xml ``` -------------------------------- ### Fleur Input Generator Configuration (&input, &qss, &soc, &comp, &kpt) Source: https://github.com/judftteam/masci-tools/blob/develop/tests/io/test_fleur_inpgen/test_write_inpgen_file_soc_qss.txt This snippet defines the structure of a Fleur input file, including lattice vectors, atomic positions, k-point division, spin-orbit coupling parameters, and computational settings. It's essential for setting up material science calculations. ```fleur &input cartesian=F / 0.000000000 5.130606429 5.130606429 5.130606429 0.000000000 5.130606429 5.130606429 5.130606429 0.000000000 1.0000000000 1.000000000 1.000000000 1.000000000 2 14 0.0000000000 0.0000000000 0.0000000000 14 0.2500000000 0.2500000000 0.2500000000 &qss 1.0 2.0 3.0 / &soc 3.141592653589793 1.5707963267948966 / &comp gmax=15.0 gmaxxc=12.5 kmax=5.0 / &kpt div1=17 div2=17 div3=17 tkb=0.0005 / ``` -------------------------------- ### Plot multiple datasets with consistent styling Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/plotting.md Illustrates plotting multiple datasets with a single set of styling parameters (linestyle, marker) applied to all plots. The `multiple_scatterplots` function allows for consistent styling across all provided data series. This example uses the Matplotlib backend. ```ipython3 from masci_tools.vis.plot_methods import multiple_scatterplots import numpy as np x = np.linspace(-1,1,100) y = np.exp(x) y2 = x**2 y3 = np.sin(x) ax = multiple_scatterplots([x, x, x], [y, y2, y3], linestyle='--', marker=None) ``` -------------------------------- ### Plot KKR Bandstructure with Custom Colormap Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/kkr_plots.md Customizes the visualization of KKR bandstructures using specific colormaps and color limits. This example demonstrates how to apply a 'binary' colormap and set color bar limits and visibility using the `dispersionplot` function. ```ipython3 from masci_tools.vis.kkr_plot_bandstruc_qdos import dispersionplot dispersionplot('files/kkr_bandstruc/', ptitle='bulk Cu', cmap='binary', clims=[-2,2], clrbar=False) ``` -------------------------------- ### Generate Fleur Input with AiiDA Source: https://github.com/judftteam/masci-tools/blob/develop/tests/io/test_fleur_inpgen/test_write_inpgen_file_film.txt Example of generating a Fleur calculation input using AiiDA. This snippet demonstrates how to define the crystal structure, lattice parameters, and other settings required for a Fleur calculation within an AiiDA workflow. It assumes the necessary AiiDA plugins and Fleur code are configured. ```python from aiida.engine import run from aiida.orm import Dict, Structure, Code from masci_tools.io.fleur.fleurinput import Fleurinput # Assume 'fleur_code' is an AiiDA Code object configured for Fleur # Assume 'structure' is an AiiDA StructureData object # Define calculation parameters calc_parameters = Dict({ 'input_params': { 'cartesian': False, 'film': True, }, 'atoms': [ {'label': 'X', 'positions': [6.267994178, 0.000000000, 0.000000000]}, {'label': 'Y', 'positions': [3.133997089, 4.432141188, 0.000000000]}, {'label': 'Z', 'positions': [0.000000000, 0.000000000, 25.226097765]}, ], 'atomic_structure': { 'lattice': [ [1.0000000000, 1.000000000, 1.000000000], [1.000000000, 1.000000000, 1.000000000], [1.000000000, 1.000000000, 1.000000000] ], 'sites': [ {'species': '26', 'position': [1.000000000, 1.000000000, 1.000000000]}, {'species': '41', 'position': [1.000000000, 1.000000000, 1.000000000]}, {'species': '41', 'position': [1.000000000, 1.000000000, 1.000000000] ] } }) comp_parameters = Dict({ 'gmax': 15.0, 'gmaxxc': 12.5, 'kmax': 5.0 }) # Example of running a Fleur calculation using AiiDA (requires setup) # inputs = { # 'code': fleur_code, # 'structure': structure, # 'parameters': calc_parameters, # 'comp_parameters': comp_parameters # } # result = run(FleurCalculation, **inputs) # For demonstration, we will just show the generated input string # This part requires instantiating Fleurinput and setting parameters manually # This is a simplified representation and may not cover all edge cases from masci_tools.io.fleur.fleurinput import Fleurinput # Placeholder for parameters that would be loaded or set input_dict = { 'cartesian': False, 'film': True, 'atomic_species': [ {'Z': 26, 'వల': 0.5, 'spin': 0.0, 'xc': 15.5124941569}, {'Z': 41, 'వల': 0.0, 'spin': 0.0, 'xc': 19.0793868509}, {'Z': 41, 'వల': 0.5, 'spin': 0.0, 'xc': 23.5617139284} ], 'cell': [ [6.267994178, 0.000000000, 0.000000000], [3.133997089, 4.432141188, 0.000000000], [0.000000000, 0.000000000, 25.226097765] ], 'scale': 1.0, 'lcore': [1, 1, 1], 'ncore': [1, 1, 1] } fleur_input_generator = Fleurinput() fleur_input_generator.from_dict(input_dict) # For comp parameters, they might be set separately or within the main dict # This example shows how to add them if they are part of the overall configuration fleur_input_generator.set_comp_params({ 'gmax': 15.0, 'gmaxxc': 12.5, 'kmax': 5.0 }) # Get the formatted input string input_string = str(fleur_input_generator) print(input_string) ``` -------------------------------- ### Plot multiple datasets with specific styling per dataset Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/plotting.md Shows how to apply distinct styling parameters (color, linewidth) to individual datasets within a multi-plot using `multiple_scatterplots`. Parameters can be provided as lists or dictionaries to target specific data series, while unspecified parameters inherit defaults. This example uses the Matplotlib backend. ```ipython3 from masci_tools.vis.plot_methods import multiple_scatterplots import numpy as np x = np.linspace(-1,1,100) y = np.exp(x) y2 = x**2 y3 = np.sin(x) ax = multiple_scatterplots([x, x, x], [y, y2, y3], linestyle='--', marker=None, color=['darkgreen', None, 'darkred'], linewidth={0: 10}) ``` -------------------------------- ### Read Configuration Parameters Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt This snippet shows the reading of configuration parameters for the MASCI-Tools project. It includes settings like ICST, INS, KVREL, NSRA, NSPIN, IMIX, MIXFAC, FCM, QBOUND, and SCFSTEPS. These parameters are crucial for defining the simulation's behavior and computational settings. ```text ICST = 4 INS = 1 KVREL = 1 NSRA = 2 NSPIN = 1 IMIX = 0 MIXFAC = 0.050 FCM = 2.000 QBOUND = 0.100E-06 SCFSTEPS = 1 ``` -------------------------------- ### Plot multiple datasets with default styling Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/plotting.md Demonstrates the `multiple_scatterplots` function to plot multiple sets of data on the same axes with default styling applied to all. It takes lists of x and y data arrays. This example uses the Matplotlib backend. ```ipython3 from masci_tools.vis.plot_methods import multiple_scatterplots import numpy as np x = np.linspace(-1,1,100) y = np.exp(x) y2 = x**2 y3 = np.sin(x) ax = multiple_scatterplots([x, x, x], [y, y2, y3]) ``` -------------------------------- ### Plot Spin-Polarized DOS for Fe fcc Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md Reads spin-polarized density of states data from an HDF5 file and plots it. This example uses a Fe fcc structure and demonstrates plotting spin-polarized DOS with specified energy limits. ```python from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurDOS from masci_tools.vis.fleur import plot_fleur_dos #Read in data with HDF5Reader('files/banddos_spinpol_dos.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurDOS) #Plot the data #Notice that you get the axis object of this plot is returned #if you want to make any special additions ax = plot_fleur_dos(data, attributes, limits={'energy': (-9,4)}) ``` -------------------------------- ### RHOVAL Subroutine Call and Output (Fortran) Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt Demonstrates the Fortran syntax for calling the RHOVAL subroutine and the typical output format, which includes Born values for different indices. This subroutine is called multiple times with varying 'iatom' values. ```Fortran call RHOVAL, iatom: 9 Born 0 2.397405527360883E-002 Born 1 2.392603264640363E-002 Born 2 4.834792547076390E-005 Born 3 5.237556458360943E-008 Born 4 3.491563909458649E-011 end RHOVAL ``` ```Fortran call RHOVAL, iatom: 1 Born 0 292.047500099087 Born 1 1.960482916329082E-002 Born 2 4.093093096802389E-005 Born 3 4.509859224517493E-008 Born 4 3.035412098290990E-011 end RHOVAL ``` -------------------------------- ### Plot Non-Spinpolarized DOS for Bulk Si Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md Reads density of states data from an HDF5 file and plots it using `plot_fleur_dos`. This example focuses on non-spinpolarized data for a bulk Silicon structure and sets specific energy limits for the plot. ```python from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurDOS from masci_tools.vis.fleur import plot_fleur_dos #Read in data with HDF5Reader('files/banddos_dos.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurDOS) #Plot the data #Notice that you get the axis object of this plot is returned #if you want to make any special additions ax = plot_fleur_dos(data, attributes, limits={'energy': (-13,5)}) ``` -------------------------------- ### Plotting with MatplotlibPlotter defaults Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/devel_guide/plotting.md Demonstrates how to use the MatplotlibPlotter class locally for creating a single scatterplot. It shows instantiation, parameter setting, plot preparation, keyword argument retrieval for the plotting function, and axis manipulation (scale, limits). Dependencies include numpy and masci_tools.vis.matplotlib_plotter. ```python def plot_with_defaults(x,y,**kwargs): from masci_tools.vis.matplotlib_plotter import MatplotlibPlotter #First we instantiate the MatplotlibPlotter class plot_params = MatplotlibPlotter() #Now we process the given arguments plot_params.set_parameters(**kwargs) #Set up the axis, on which to plot the data ax = plot_params.prepare_plot(xlabel='X', ylabel='Y', title='Single Scatterplot') #The plot_kwargs provides a way to get the keyword arguments for the #actual plotting call to `plot` in this case. plot_kwargs = plot_params.plot_kwargs() ax.plot(x, y, **plot_kwargs) #The MatplotlibPlotter has a lot of small helper functions #In this case we just want to set the limits and scale of the #axis if they were given plot_params.set_scale(ax) plot_params.set_limits(ax) plot_params.save_plot('figure') return ax import numpy as np x = np.linspace(-1, 1, 10) y = x**2 #Some examples plot_with_defaults(x, y) plot_with_defaults(x, y, limits={'x': (0,1)}) plot_with_defaults(x, y, marker='s', markersize=20) ``` -------------------------------- ### Plot Selected DOS Components (Si) Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md Generates a density of states plot for a bulk Si structure, displaying only atom and l-channel projected DOS. This example customizes the plot by hiding the total and interstitial contributions and enabling l-resolved components. ```python from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurDOS from masci_tools.vis.fleur import plot_fleur_dos #Read in data with HDF5Reader('files/banddos_dos.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurDOS) ax = plot_fleur_dos(data, attributes, show_total=False, show_interstitial=False, show_lresolved='all', limits={'energy': (-13,5)}) ``` -------------------------------- ### Si Bulk Input Configuration Source: https://github.com/judftteam/masci-tools/blob/develop/tests/io/test_fleur_inpgen/test_get_parameter_write_inpgen_roundtrip.txt This snippet shows the input file structure for a Silicon (Si) bulk calculation. It defines the lattice type, atomic coordinates, and simulation parameters like cutoff energies and exchange-correlation functional. ```input &input cartesian=F / 0.000000000 5.130608534 5.130608534 5.130608534 0.000000000 5.130608534 5.130608534 5.130608534 0.000000000 1.0000000000 1.000000000 1.000000000 1.000000000 2 14.1 0.1250000000 0.1250000000 0.1250000000 1 14.1 -0.1250000000 -0.1250000000 -0.1250000000 1 &atom dx=0.016 element="Si" id=14.1 jri=717 lmax=8 lnonsph=6 lo="2s 2p" rmt=2.17 / &comp ctail=T frcor=F gmax=11.1 gmaxxc=9.2 jspins=1 kcrel=0 kmax=3.5 / &exco xctyp="pbe" / ``` -------------------------------- ### CALCTMAT Subroutine Call and Output (Fortran) Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt Illustrates the Fortran usage of the CALCTMAT subroutine, which appears to be part of an energy calculation loop. The output shows 'Born' values, possibly related to matrix elements or derived quantities. ```Fortran [energyloop] Energy ie= 35 call CALCTMAT Born 0 90.6986949152372 Born 1 1.960482916329082E-002 Born 2 4.093093096802389E-005 Born 3 4.509859224517493E-008 Born 4 3.035412098290990E-011 ``` ```Fortran call CALCTMAT Born 0 1.964539600100335E-002 Born 1 1.960482916329082E-002 Born 2 4.093093096802389E-005 Born 3 4.509859224517493E-008 Born 4 3.035412098290990E-011 ``` -------------------------------- ### Set and use default plot parameters Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/plotting.md Shows how to set default plotting parameters for all subsequent plots using `set_mpl_plot_defaults`. These defaults can be overridden by passing specific parameters to plotting functions. The function `reset_mpl_plot_defaults` can be used to revert to the original Matplotlib defaults. This example uses the Matplotlib backend. ```ipython3 from masci_tools.vis.plot_methods import single_scatterplot, set_mpl_plot_defaults import numpy as np x = np.linspace(-10, 10, 100) y = np.exp(x) set_mpl_plot_defaults(color='darkblue', linestyle='--', marker=None) ax = single_scatterplot(x,y, scale={'y': 'log'}) ``` -------------------------------- ### Energy and Weight Data Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt Presents the energy and weight pairs read during the preconditioning process. This includes the number of energy points, spins, and host atoms, along with the real and imaginary components of energies and their corresponding weights. This data is used for integration and further calculations. ```text [read_energy] number of energy points 43 [read_energy] number of spins 1 [read_energy] number of host atoms 13 [read_energy] maximum number of host atoms 13 [read_energy] host lmsizehost 9 [read_energy] Spin orbit coupling used? (1=yes,0=no) 0 [read_energy] energies and weights are: [read_energy] energie weights [read_energy] real imag real imag -------------------------------------------- 1 -0.5000000000000000 0.0251161406545832 0.0000000000000000 -0.0394094337777778 2 -0.5000000000000000 0.1114275488745601 0.0000000000000000 -0.0630550940444444 3 -0.5000000000000000 0.1977389570945370 0.0000000000000000 -0.0394094337777778 4 -0.4984831014391768 0.2228550977491202 -0.0024769822541747 0.0000000000000000 5 -0.4920252138125773 0.2228550977491202 -0.0057404630128926 0.0000000000000000 6 -0.4804788460927884 0.2228550977491202 -0.0089479779326236 0.0000000000000000 ``` -------------------------------- ### CLSGEN_TB: Cluster Generation Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkr/kkr_run_slab_nosoc/output.0.txt Details the generation of spherical clusters with specified cut-off radii (RCUT, RCUTXY) and calculates cluster sizes and touching RMT for each site. ```APIDOC ## CLSGEN_TB: Cluster Generation ### Description Generates spherical clusters and provides information about their size and the radii of the nearest neighbors for each site. ### Method N/A (Informational Output) ### Endpoint N/A ### Parameters **RCUT**: The radial cut-off for cluster generation. **RCUTXY**: The cut-off in the XY plane for cluster generation. ### Request Example None ### Response **cluster size of site**: The number of atoms within the cluster for a given site. **Touching RMT of site**: The radius of the touching muffin-tin orbital for a given site. ``` -------------------------------- ### Plot Selected Spin-Polarized DOS Components (Fe) Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md Plots spin-polarized density of states for an Fe fcc structure, focusing on atom and l-channel projected contributions. This example demonstrates how to selectively display DOS components by disabling total and interstitial contributions and enabling l-resolved ones. ```python from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurDOS from masci_tools.vis.fleur import plot_fleur_dos #Read in data with HDF5Reader('files/banddos_spinpol_dos.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurDOS) ax = plot_fleur_dos(data, attributes, show_total=False, show_interstitial=False, show_lresolved='all', limits={'energy': (-13,5)}) ``` -------------------------------- ### Plot Bandstructure Spin Down Channel Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md This example shows how to plot only the spin-down channel of a bandstructure by setting the `only_spin` argument to 'down'. It reads data using HDF5Reader and FleurBands, then plots it with plot_fleur_bands, with options for marker size and color customization. The function returns an axis object for further edits. ```ipython3 from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurBands from masci_tools.vis.fleur import plot_fleur_bands #Read in data with HDF5Reader('files/banddos_spinpol_bands.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurBands) #Plot the data #Notice that you get the axis object of this plot is returned #if you want to make any special additions ax = plot_fleur_bands(data, attributes, limits={'y': (-9,4)}, only_spin='down', markersize=10, color='darkred') ``` -------------------------------- ### Process data arguments using dictionary input - Python Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/devel_guide/plot_data.md Shows how to use the `process_data_arguments` function with a data dictionary `d` to prepare data for plotting. This function acts as a flexible wrapper for initializing plotting data, accepting keyword arguments that define the data source and corresponding column names. ```python from masci_tools.vis.data import process_data_arguments d = { 'x': [1, 2, 3], 'y1': [4, 5, 6], 'y2': [7, 8, 9] } plot_data = process_data_arguments(data=d, x='x', y=['y1','y2']) ``` -------------------------------- ### Write Sorted JSON File (Python) Source: https://github.com/judftteam/masci-tools/blob/develop/masci_tools/io/data_kkrparams/add_to_defaults.ipynb Writes a Python dictionary to a new JSON file named 'defaults_kkrhost_new.json' with an indent of 2 spaces for readability. The keys of the dictionary are sorted alphabetically before writing. This ensures consistent output. ```python # write out sorted with open('defaults_kkrhost_new.json', 'w') as _f: json.dump({k:d[k] for k in sorted(d.keys())}, _f, indent=2) ``` -------------------------------- ### Gdyson Call with RHOVAL and CALCTMAT Interactions (Fortran) Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test2/out_log.000.txt This snippet illustrates a sequence involving a 'gdyson' call, preceded by multiple CALCTMAT calls and followed by RHOVAL calls. This suggests a complex computational workflow where gdyson might be a main routine orchestrating or interacting with matrix calculations (CALCTMAT) and atomic value retrievals/calculations (RHOVAL). ```Fortran call CALCTMAT call CALCTMAT Born 0 1.964539600100335E-002 Born 1 1.960482916329082E-002 Born 2 4.093093096802389E-005 Born 3 4.509859224517493E-008 Born 4 3.035412098290990E-011 call CALCTMAT call gdyson end call gdyson ``` -------------------------------- ### Atomic Information Extraction Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt Extracts detailed atomic information, including the number of atoms (NATOM, NTOTATOM), maximum L-value (LMAXD), and individual atom properties like coordinates (x, y, z), atomic number (Z), and flags for VATOM and KILLATOM. This data is essential for setting up the physical model. ```text NATOM is 13 NTOTATOM is 13 LMAXD is 2 ------------------------------------------- No. x y z Z VATOM? KILLATOM? LMAX ------------------------------------------- 1 0.00 0.00 0.00 29.0 0 0 2 2 0.220E-14-0.707 -0.707 29.0 0 0 2 3-0.707 0.220E-14-0.707 29.0 0 0 2 4 0.707 0.220E-14-0.707 29.0 0 0 2 5 0.220E-14 0.707 -0.707 29.0 0 0 2 6-0.707 -0.707 0.220E-14 29.0 0 0 2 7 0.707 -0.707 0.220E-14 29.0 0 0 2 8-0.707 0.707 0.220E-14 29.0 0 0 2 9 0.707 0.707 0.220E-14 29.0 0 0 2 10 0.220E-14-0.707 0.707 29.0 0 0 2 11-0.707 0.220E-14 0.707 29.0 0 0 2 12 0.707 0.220E-14 0.707 29.0 0 0 2 13 0.220E-14 0.707 0.707 29.0 0 0 2 ``` -------------------------------- ### Plot Bandstructure Weighted Non Spinpolarized Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_plots.md This example shows how to plot a non-spinpolarized bandstructure while highlighting specific components, such as the 'MT:1d' (d-like character inside the Muffin-tin sphere). It utilizes the `weight` argument in conjunction with `spinpol=False`. Data is read using HDF5Reader and FleurBands, and plotted with plot_fleur_bands. The function returns an axis object for customization. ```ipython3 from masci_tools.io.parsers.hdf5 import HDF5Reader from masci_tools.io.parsers.hdf5.recipes import FleurBands from masci_tools.vis.fleur import plot_fleur_bands #Read in data with HDF5Reader('files/banddos_spinpol_bands.hdf') as h5reader: data, attributes = h5reader.read(recipe=FleurBands) #Plot the data #Notice that you get the axis object of this plot is returned #if you want to make any special additions ax = plot_fleur_bands(data, attributes, limits={'y': (-9,4)}, weight='MT:1d', spinpol=False) ``` -------------------------------- ### KKR Convergence Utilities Parsing Source: https://context7.com/judftteam/masci-tools/llms.txt Illustrates how to parse KKR output files to extract convergence information such as RMS errors, Fermi energy, total energy, and spin moments per atom. It also shows how to plot the convergence of RMS errors over SCF iterations. ```python from masci_tools.io.parsers.kkrparser_functions import ( parse_kkr_outputfile, get_rms, get_EF, get_Etot, get_spinmom_per_atom ) # Full parsing out_dict = {} success, msg_list, out_dict = parse_kkr_outputfile( out_dict, outfile='/path/to/out_kkr', outfile_0init='/path/to/output.0.txt', outfile_000='/path/to/output.000.txt' ) # Quick extraction functions with open('/path/to/out_kkr', 'r') as f1: with open('/path/to/output.000.txt', 'r') as f2: # RMS error (charge and spin) rms_charge, rms_spin = get_rms(f1, f2) # Fermi energy ef = get_EF(f1) # Total energy etot = get_Etot(f1) # Spin moments per atom spin_moments = get_spinmom_per_atom(f1, natom=4) print(f"RMS charge: {rms_charge}") print(f"RMS spin: {rms_spin}") print(f"E_F = {ef} Ry") print(f"E_tot = {etot} Ry") print(f"Spin moments: {spin_moments}") # Plot convergence import matplotlib.pyplot as plt iterations = out_dict['convergence_group']['rms_all_iterations'] plt.semilogy(iterations) plt.xlabel('Iteration') plt.ylabel('RMS error') plt.title('KKR Convergence') plt.show() ``` -------------------------------- ### SCALEVEC: Scale Site Coordinates to Cartesian Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkr/kkr_run_slab_nosoc/output.0.txt Scales site coordinates and converts them to the Cartesian system, measured in ALAT units. It checks if transformation is required. The output is a list of site positions in Cartesian coordinates. ```text =============================================================================== SCALEVEC: scale site coordinates bring all to CARTESIAN system =============================================================================== Site coordinates will not be scaled CARTESIAN coordinates ---> No transformation required --------------------------------------------- Positions of ALL generated sites in CARTESIAN coordinates (ALAT units) --------------------------------------------- IQ x y z IT **************** Left Host *************** 10 0.000000 7.778175 -7.071068 1 9 0.000000 7.071068 -6.363961 1 8 0.000000 6.363961 -5.656854 1 7 0.000000 5.656854 -4.949747 1 6 0.000000 4.949747 -4.242641 1 5 0.000000 4.242641 -3.535534 1 4 0.000000 3.535534 -2.828427 1 3 0.000000 2.828427 -2.121320 1 2 0.000000 2.121320 -1.414214 1 1 0.000000 1.414214 -0.707107 1 **************** S L A B *************** 1 0.000000 0.707107 0.000000 1 2 0.000000 0.000000 0.707107 2 3 0.000000 0.707107 1.414214 3 4 0.000000 0.000000 2.121320 4 5 0.000000 0.707107 2.828427 5 6 0.000000 0.000000 3.535534 6 **************** Right Host *************** 1 0.000000 -0.707107 4.242641 1 2 0.000000 -1.414214 4.949747 1 3 0.000000 -2.121320 5.656854 1 4 0.000000 -2.828427 6.363961 1 5 0.000000 -3.535534 7.071068 1 6 0.000000 -4.242641 7.778175 1 7 0.000000 -4.949747 8.485281 1 8 0.000000 -5.656854 9.192388 1 9 0.000000 -6.363961 9.899495 1 10 0.000000 -7.071068 10.606602 1 --------------------------------------------- ``` -------------------------------- ### SCALEVEC: Scale Site Coordinates Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkr/kkr_run_slab_nosoc/output.0.txt Describes the process of scaling site coordinates to a Cartesian system. In this case, no transformation is required. ```APIDOC ## SCALEVEC: Scale Site Coordinates ### Description Scales site coordinates to bring them into a Cartesian system. This output indicates that no transformation was necessary. ### Method N/A (Informational Output) ### Endpoint N/A ### Parameters None ### Request Example None ### Response **Positions of ALL generated sites in CARTESIAN coordinates (ALAT units)**: A table listing the IQ, x, y, z coordinates, and IT for each site. ``` -------------------------------- ### Concise Fleur XML Parsing with FleurXMLContext Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/user_guide/fleur_parser.md Utilizes the `FleurXMLContext` manager for a more streamlined approach to parsing Fleur XML files. This context simplifies attribute retrieval and element searching, reducing code verbosity compared to direct `schema_dict_util` usage. ```python from masci_tools.io.fleur_xml import load_inpxml, FleurXMLContext xmltree, schema_dict = load_inpxml('/path/to/inp.xml') with FleurXMLContext(xmltree, schema_dict) as root: spins = root.attribute('jspins') noco = root.attribute('l_noco', default=False) #Not nesting the context we need to specify which elements are meant mt_radii = root.attribute('radius', contains='species') #Nesting using find (the first element is return) with root.find('atomspecies') as all_species: mt_radii = all_species.attribute('radius') #Nesting using iter (each iteration returns a new context for the next element) mt_radii = [] for species in root.iter('species'): mt_radii.append(species.attribute('radius')) ``` -------------------------------- ### XML Context Manager for Navigation Source: https://context7.com/judftteam/masci-tools/llms.txt Enables context-managed XML traversal with schema validation for safe attribute and element access. It supports type conversion and default value handling, simplifying the process of reading and manipulating XML files like Fleur's inp.xml. Requires 'masci_tools.io.fleur_xml.load_inpxml', 'masci_tools.io.fleur_xml.FleurXMLContext', and 'masci_tools.util.xml.xml_getters.get_fleur_modes'. ```Python from masci_tools.io.fleur_xml import load_inpxml, FleurXMLContext from masci_tools.util.xml.xml_getters import get_fleur_modes xmltree, schema_dict = load_inpxml('/path/to/inp.xml') # Using context manager with FleurXMLContext(xmltree, schema_dict) as root: # Get attributes with type conversion spins = root.attribute('jspins') noco = root.attribute('l_noco', default=False) kmax = root.attribute('Kmax') # Nested context for specific elements with root.find('atomspecies') as all_species: # Get all species elements species_list = [] for species in all_species.iter('species'): species_data = { 'name': species.attribute('name'), 'element': species.attribute('element'), 'radius': species.attribute('radius') } species_list.append(species_data) # Get calculation modes modes = get_fleur_modes(root) print(f"SOC enabled: {modes['soc']}") print(f"Non-collinear: {modes['noco']}") print(f"Found {len(species_list)} species") print(f"Number of spins: {spins}") ``` -------------------------------- ### Initialize PlotData with dictionary and specify x/y columns - Python Source: https://github.com/judftteam/masci-tools/blob/develop/docs/source/devel_guide/plot_data.md Demonstrates initializing the PlotData class with a dictionary `d` and specifying which keys ('x', 'y1', 'y2') should be used for plotting. The `PlotData` class iterates through the specified data, yielding `namedtuple` entries containing the data for each plot, alongside the source mapping. ```python from masci_tools.vis.data import PlotData d = { 'x': [1, 2, 3], 'y1': [4, 5, 6], 'y2': [7, 8, 9] } plot_data = PlotData(d, x='x', y=['y1', 'y2']) for entry, source in plot_data.items(): # entry has the keys needed to get the data from the source # and source is the mapping to use print(entry.x, entry.y) # Yields x, y1 in the first loop and x, y2 in the second # Now we can plot the data # for example plt.plot(entry.x, entry.y, data=source) ``` -------------------------------- ### T-Matrix Information and Preconditioning Source: https://github.com/judftteam/masci-tools/blob/develop/tests/files/kkrimp_parser/test1/out_log.000.txt Displays information read from the T-matrix file during the preconditioning phase. It includes details like the total number of atoms, spin information, and flags related to elasticity and host atom configuration. This data is vital for subsequent calculations. ```text [preconditioning_readtmatinfo] NTOTATOMIMP 13 [preconditioning_readtmatinfo] NSPIN 1 [preconditioning_readtmatinfo] IELAST 43 [preconditioning_readtmatinfo] lmsizehost 9 [preconditioning_readtmatinfo] KGREFSOC 0 ``` -------------------------------- ### Parse KKR Output Files with masci-tools Source: https://context7.com/judftteam/masci-tools/llms.txt Provides a comprehensive parser for juKKR output files, extracting convergence information, magnetic moments, total energies, Fermi energy, and electronic structure properties from multiple output files. It utilizes the parse_kkr_outputfile function from masci_tools.io.parsers.kkrparser_functions and requires several input file paths. ```python from masci_tools.io.parsers.kkrparser_functions import parse_kkr_outputfile # Parse KKR calculation out_dict = {} success, msg_list, out_dict = parse_kkr_outputfile( out_dict, outfile='/path/to/out_kkr', outfile_0init='/path/to/output.0.txt', outfile_000='/path/to/output.000.txt', timing_file='/path/to/out_timing.000.txt', potfile_out='/path/to/out_potential', nonco_out_file='/path/to/nonco_angle_out.dat' ) if success: # Convergence data rms_errors = out_dict['convergence_group']['rms_all_iterations'] charge_neutrality = out_dict['convergence_group']['charge_neutrality'] # Energies total_energy = out_dict['total_energy_Ry'] fermi_energy = out_dict['fermi_energy'] # Magnetic properties spin_moments = out_dict['magnetism_group']['spin_moment_per_atom'] orbital_moments = out_dict['magnetism_group']['orbital_moment_per_atom'] print(f"Total Energy: {total_energy} Ry") print(f"RMS error: {rms_errors[-1]}") print(f"Spin moments: {spin_moments}") else: print(f"Parsing errors: {msg_list}") ```