Locpot_class module

Created on Sun Oct 3 12:11:13 2021

@author: Yair Reichman

class Locpot_class.Locpot_yair(input_locpot=None, axis_index=None, is_2D=False, is_bulk_material=False, Has_interface=True, Locpot_file_name=None, Locpot_file_directory=None, Bulk_Locpot_file_name=None, Bulk_Locpot_file_directory=None, Locpot_Full_path=None, Locpot_bulk_materials_full_path=None, to_flip=False, has_flipped=False)[source]

Bases: object

Class of locpot where all its properties and its methods can be found

__init__(input_locpot=None, axis_index=None, is_2D=False, is_bulk_material=False, Has_interface=True, Locpot_file_name=None, Locpot_file_directory=None, Bulk_Locpot_file_name=None, Bulk_Locpot_file_directory=None, Locpot_Full_path=None, Locpot_bulk_materials_full_path=None, to_flip=False, has_flipped=False)[source]
Parameters
  • input_locpot (pymatgen.io.vasp.outputs.Locpot, optional, default: None) – Can be initialized with an existing pymatgen locpot object.

  • axis_index (int,{0: x, 1: y, 2: z}, optional, default: 2) – The axis index to be averaged along. (for x, insert axis_index=0, for y axis insert axis_index=1, and for z axis insert axis_index=2).

  • is_2D (bool, optional, default: False) – A flag that enables to perform 2D calculations. Not all functions support 2D calculations yet.

  • bulk_material (bool, optional, default: False) – Aims to skip unecessary steps in the initializtion process for loading bulk materials.

  • Locpot_file_name (str, optional, default: None) – Supply the string for the name of the locpot file, and also a string for the full path of the directory where the locpot files are located.

  • Locpot_file_directory (str, optional, default: None) – Supply the string for the name of the locpot file, and also a string for the full path of the directory where the locpot files are located.

  • Bulk_Locpot_file_name (list/tuple (str,str), optional, default: None) – For two different bulk locpot file names and full paths - supply it in a form of a list uple. The first place is for the first bulk material and the second place is for the second bulk material.

  • Bulk_Locpot_file_directory (list/tuple (str,str), optional, default: None) – For two different bulk locpot file names and full paths - supply it in a form of a list uple. The first place is for the first bulk material and the second place is for the second bulk material.

  • Locpot_Full_pat (str, optional, default: None) – Supply the string for the the full path of the Locpot file.

  • Locpot_bulk_materials_full_path (list/tuple (str,str), optional, default: None) – For two different bulk locpot full paths - supply it in a form of a list uple. The first place is for the first bulk material and the second place is for the second bulk material.

get_atoms_position()[source]
Parameters

self

Returns

numpy.ndarray, (N,5) – A matrix of the the coordinates of the atoms. There are 5 columns, the first three are the spatial coordinates of the atoms, as the first column is for x axis, the scond column is for the y axis, and the third column is for the z axis. The fourth column contains the atoms symbols, and the fifth and the last column has the atomic radius of the atoms.

averaging_along_axis(locpot_vec=None, to_plot=False, to_plot_atoms=False, to_plot_widths=False, to_plot_heights=False, to_plot_cursor_choice=False)[source]
Parameters
  • locpot_vec (np.array, optional. default : None) – 2 Columns arrays for the spatial coordinates and the local potential values.

  • to_plot (bool, optional, default: False) – A flag to determine whether to plot or not.

  • to_plot_atoms (bool, optional, default: False) – A flag that represents the choice whether to plot or not another plot of the atoms arrangement in 1D.

  • to_plot_widths (bool, optional, default: False) – A flag that represents the choice whether to annotate or not the peaks widths of the locpot.

  • to_plot_heights (bool, optional, default: False) – A flag that represents the choice whether to annotate or not the peaks heights of the locpot.

  • to_plot_cursor_choice (bool, optional, default: False) – A flag that represents the choice whether to show cursor lines and annotate each click with box.

Returns

numpy.ndarray, (N,2) – It returns a locpot matrix.The first column is the vector that contains the spatial coordinates of system. The second column is the averaged potential along the desires axis.

find_interface(x=None, y=None)[source]
Parameters
  • x (np.array, array_like, optional, default: None) – It stands for the spatial coordinates array. If not supplied, is calcualted from the instance attribute self.locpot.

  • y (np.array, array_like, optional, default: None) – The local potential vector. If not supplied, is calcualted from the instance attribute self.locpot.

Returns

float, float – It returns the interface index in the locpot vector, and its z’s position If the system does not contain an interface, it just returns the last spatial grid coordinate position and its corresponded index. -> [index,position] ==> [len(z)-1,z[-1]]

approximately(compare_to, *args, tol=5)[source]
Parameters
  • compare_to (int/float) – The value we wish to compare to.

  • *args (int/float/array_like) – The values we wish to compare to.

  • tol (int/float, optional, default: 5) – In precents. The tolerance level we wish to apply. The default value is set to 5% tolerance.

Returns

bool – It returns True or False whether the input value is in the proxmity range of the tolerance with respect to the the values supplied.

find_unit_cell_lattice_parameter(is_axis_rel=True)[source]
Parameters

is_axis_rel (bool, optional, default: True) – A flag that tells if the class object attribute - axis_index is the relevant to return the appropriate lattice parameter in that direction.

Returns

float – The relevant lattice parameter.

find_all_permutations(materials_list_strings)[source]
Parameters

materials_list_strings (array_like,type: str) – The input of the species names / materials names whithin the system

Returns

res (array_like,type: str) – It returns all the combinations of materials or species that can be found. It suppose to locate locpot files of the bulk materials in the current working directory to be loaded into the interface Locpot object. It meant to answer cases where we have a material constructed of several species such as GaAsAlNand so on..

set_locpot_bulk_materials(bulk_material=False)[source]

Loading the bulk materials’ locpots of the two materials involved in the interface system. :param bulk_material: Can be given for skipping to load another level of bulk material. :type bulk_material: bool, optional, default: False

set_axis_index(axis_ind=None)[source]
Parameters

axis_ind (int, {0: x, 1: y, 2: z}, optional, default: None) – The axis index we desire to update our object attribute.

Returns

NoneJust set up a new axis index property of the object instance.

set_is_2D(is2d=False)[source]
Parameters

is2d (bool, optional, default: False) – A flag to determine whether the calculation should be performed in 2D. This is an editing method for the class object.

Returns

None

find_position_to_insert(zz=None, vv=None)[source]

Gets Locpot object. Using the interface and bulk materials’ locpots. Look for the best place to insert the bulk locpot into the interface system locpot. Can be supplied in advance zz - spatial coordinates vector, and vv - local potential vector, to be referenced as the main vector to be searched to position to insert.

Parameters
  • zz (np.array, optional, default: None) – If not supplied, the default is taken from self.locpot_vec[:, 0] attribute of Locpot_yair instance. Vector of the spatial grid. (spatial coordinates)

  • vv (np.array, optional, default: None) – If not supplied, the default is taken from self.locpot_vec[:, 1] attribute of Locpot_yair instance. Vector of the local potential.

Returns

float, int – It returns the position, and its corresponding index in the interface locpot interface. Regarding both the left side materials and the right side material. These 2 arrays of the form [,,] -> where [start_ind, finish_ind, minima_position, max_R_sqrd] If we don’t have an interface, it returns the last index,position of the spatial grid vector.

set_locpot_vec()[source]

A method aims to initialize Locpot vector of the Locpot object.

Returns

None

elongate_locpot(multi_left=1, multi_right=1, manual=False, pos_to_insert=None, multi_manual=1, z_to_insert_manual=None, v_to_insert_manual=None, locpot_vec=None, return_left_increment=False, return_right_increment=False)[source]
Parameters
  • multi_left (int, optional, default: 1) – It determines how many times to multiply the repeated locpot that will be inserted.

  • multi_right (int, optional, default: 1) – It determines how many times to multiply the repeated locpot that will be inserted.

  • manual (bool, optional, default: False) – This is a flag the tells if we are going to treat the elongation manually or automatically. If it is set to True, we should supply more arguments as desribed in the next lines.

  • pos_to_insert (float, optional, default: None) – If manual = True, then it must be supplied. It determines where to insert the multiplied repeated locpot. It is a position in the spatial grid.

  • multi_manual (int, optional, default: None) – If manual = True, then it must be supplied. It determines how many times to multiply the repeated locpot that will be inserted manually.

  • z_to_insert_manual (np.array, optional, default: None) – If manual = True, then it must be supplied. The manully inserted spatial coordinates vector.

  • v_to_insert_manual (np.array, optional, default: None) – If manual = True, then it must be supplied. The manully inserted local potential vector.

  • locpot_vec (numpy.ndarray, (N,2), optional, default: None) – It is not necessarily goes with the ‘manual’ option. It just gives more flexibilty whether the elongation will be held on the class instance locpot attribute, or on an external locpot vector supplied as an argument. This is a two-column vector, the first column is for the spatial coordinates and the second column is for the local potential.

  • return_left_increment (bool, optional, default : False) – If it is set to True, the difference between the original and the elongated local potential vectors will be returned together with the reference point.

  • return_right_increment (bool, optional, default : False) – If it is set to True, the difference between the original and the elongated local potential vectors will be returned together with the reference point.

Returns

  • z_Locp, v_Locp (np.array, np.array) – The new elongated spatial grid vector, the new elongated local potential vector.

  • z_Locp, v_Locp, delta, ref point (np.array, np.array, float, float) – If return_right_increment or return_right_increment == True It returns also difference between the original and the elongated local potential vectors will be returned together with the reference point, if it was specified to return those.

find_locpot_shift(locpot_vec=None, bulk_locpot_vec_first=None, bulk_locpot_vec_second=None)[source]

Finds the relative vertical shifts between the materials in the interface system and their corresponding bulk materials locpot. Afterwards, these value have to be substracted from the potential vector of the interface system in order to be inserted in the elongation procedure.

Notes

If your system does not have an interface, you should supply one of the arguments bulk_locpot_vec_first or bulk_locpot_vec_second with a locpot-formed vector.

Parameters
  • locpot_vec (numpy.ndarray, (N,2), optional, default: None) – This is a two-column vector, the first column is for the spatial coordinates and the second column is for the local potential.

  • bulk_locpot_vec_first (numpy.ndarray, (N,2), optional, default: None) – This is a two-column vector, the first column is for the spatial coordinates and the second column is for the local potential. This locpot matrix should describe the locpot matrix of the first bulk material.

  • bulk_locpot_vec_second (numpy.ndarray, (N,2), optional, default: None) – This is a two-column vector, the first column is for the spatial coordinates and the second column is for the local potential. This locpot matrix should describe the locpot matrix of the second bulk material.

Returns

list, [float, float] – The relative shifts of both the left and the right side materials. In the form of 2 floats -> [,] -> where [left_shift,right_shift]. If the system does not contain an interface, it returns the shift only from the one part that was supplied.

Locpot_class.find_bulk_like_potential(z, v, interface_position, num_of_peaks=3, limits=None, left=False, right=False)[source]

Notice that this is not a class method, it outside the scope of the class.

Parameters
  • z (np.array) – Should be as the same size as wave_function vector. spatial coordinates vector.

  • v (np.array) – Should be as the same size as wave_function vector. Local potential vector.

  • interface_position (float) – The position where the interface is located. If you dont have an interface in your system, just input the 0 or the beginning position of the system.

  • num_of_peaks (int, optional, default: 3) – If you have an interface, you can choose how many peaks to look for in the system locpot.

  • limits (listrray_like, (float, float), optional, default: None) – This parameter is an optional for flexibility for chosing the range of where the pick the bulk-like potential. This should be input as a list of two floats, the first one is for the left limit and the second one is for the left limit. Should be given as the same units of the spatial coordainates vector, z.

  • left (bool, optional, default: False) – A flag that determines whether to look at the left side hand of the system.

  • right (bool, optional, default: False) – A flag that determines whether to look at the right side hand of the system.

Returns

np.array, np.array, float – The first argument it returns is the spatial grid range where the bulk-like locpot was evaluated. The second argument it returns is the local potential range where the bulk-like locpot was evaluated. The last argument it returns is the start position where the bulk-like locpot was found.

Locpot_class.find_initial_position_to_initialize_next_to_interface(z, v, pos_inter, initi_side='Left', init_position=None)[source]
Parameters
  • z (np.array) – z spatial coordinates vector

  • v (np.array) – Local potential vector.

  • pos_inter (float) – The position where we want to initialize our wave-function next to. Usually will be the interface position if our system has one, otherwise - you can choose from where it begins.

  • initi_side (str, {'Left', 'Right'}, optional, default: 'Left') – Choices are in the bracket. It tells from where we sholud start and look for the next initialization point.

  • init_position (float, optional, default: None) – In cases when we do not have an interface or want it to be initialized somewhere else. Must accompanied with pos_inter=0

Returns

z0 (float) – The initial position where to wave-fucntion is centered at.

Locpot_class.insert_potential_into_position(z_vec_original, v_vec_original, index_to_insert, z_vec_to_insert, v_vec_to_insert, multi=0)[source]

Very not elegant and complex function. It should be primitive. It does not looking for something, but just gets as input all the needed parameters and insert all the vectors at the right place where it was asked to.

Parameters
  • z_vec_original (np.array) – The coords vector whom we wish to insert the other vector.

  • v_vec_original (np.array) – The potential vector whom we wish to insert the other vector.

  • index_to_insert (int) – The index respect to the z_original_vec where from him and further we are going to insert the desired vector.

  • z_vec_to_insert (np.array) – The new coords vector we wish insert into the original vector.

  • v_vec_to_insert (np.array) – The new potential vector we wish insert into the original vector.

  • multi (int, optional, default: 0) – When the default value is 0, it means that there is no multiplication. Describes how many time we would like to insert the vector.

Returns

np.array, np.array – The first one is the new elongated coords vector. The second one is the new elongated potential vector.

Locpot_class.fix_potential_edges(z, v)[source]
Parameters
  • z (np.array) – Represents the spatial coords vector.

  • v (np.array) – Represnts the v local potential vector.

Returns

  • new_z (np.array) – The new z coordinates with matching number of samples with respect with the fixed potential vector.

  • new_v (np.array) – The new v potential vector after its edges were fixed to be well suitable to be stiched.

Locpot_class.multiply_z_v_vecs(z_vec_original, v_vec_original, multi)[source]
Parameters
  • z_vec_original (np.array) – The spatial coordinates vector whom we wish to multiply.

  • v_vec_original (np.array) – The potential vector whom we wish to multiply.

  • multi (int) – Describes how many time we would like to multiply the vector.

Returns

np.array, np.array – The first array is the new multiplied spatial coordinates vector. The second array is the new multiplied local potential vector.

Locpot_class.is_peak_maximum(peaks, peak)[source]

Notes

Pay attention - the peak is within the range of the peaks and not at its edges. Otherwise it will raise an index out-of-range error.

Parameters
  • peaks (numpt.ndarray, (N,2)) – The first column stands for the spatial poisition of the peaks. The second column is for the height of the peaks.

  • peak (list: [int,float,float]) – The first argument is for the index of the peak inside the peaks array, The second argument is for the position of the peak. The third argument is for the height of the peak.

Returns

bool – This function checks whether a given peak is a maximum point. (or at least a local maximum).

Locpot_class.is_peak_minimum(peaks, peak)[source]

Notes

Pay attention - the peak is within the range of the peaks and not at its edges. Otherwise it will raise an index out-of-range error.

Parameters
  • peaks (numpt.ndarray, (N,2)) – The first column stands for the spatial poisition of the peaks. The second column is for the height of the peaks.

  • peak (list: [int,float,float]) – The first argument is for the index of the peak inside the peaks array, The second argument is for the position of the peak. The third argument is for the height of the peak.

Returns

bool – This function checks whether a given peak is a minimum point. (or at least a local minimum).