Stage_2 module¶
- class Stage_2.Stage_2(Locp, grid_density, psi0_dic, allmin=None, allmax=None, To_plot=False, Nt=500, dt=0.01, multi_left=2, multi_right=2, is2d=False, Has_interface=True, limits_for_itself=None, ref_point=None)[source]¶
Bases:
object
This class aimed to locate the initial wavefunction we created at stage_1, on the relevant material from stage_1, in the middle of the material in the interface system.
- __init__(Locp, grid_density, psi0_dic, allmin=None, allmax=None, To_plot=False, Nt=500, dt=0.01, multi_left=2, multi_right=2, is2d=False, Has_interface=True, limits_for_itself=None, ref_point=None)[source]¶
Initilization:
- Parameters
Locp (Locpot_yair.object) – Locpot object that holds the information about the interface system.
grid_density (float) – grid density factor calculated in stage_1
psi0_dic (dict) – psi0 parameters given in a dictionary form. Necessary to reconstruct the initial wave function in the interface system.
allmin (np.array, array_like, optional, default: None) – Not necessary for the intialization. Holds all the minimum peaks of the local potential.
allmax (np.array, array_like, optional, default: None) – Not necessary for the intialization. Holds all the maximum peaks of the local potential.
To_plot (bool, optional, default: False) – A flag to determine whether to plot when this option is availale.
Nt (int) – The number of time steps we would like to have in the propagation proccess.
dt (float) – The size of the time step in
sec
.multi_left (int, optional, default: 2) – How many times we wish add a unit cell length to the left side of the interface. Namely, for
multi_left = 2
, we are adding2*a_left
to the locpot vector.multi_right (int, optional, default: 2) – How many times we wish add a unit cell length to the right side of the interface. Namely, for
multi_right = 2
, we are adding2*a_right
to the locpot vector.Has_interface (bool, optional, default: True) – A flag indicates whether the system conatains an interface or not. For a surface, it is recomended to relate the vaccum as the interface.
limits_for_itself (list [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
.ref_point (float, optional, default: None) – If the current system does not have an interface, and we want to treat it as it as a reference point for later calculations.
- elongate_interface_potential(from_iteslf=False, side_from_itself='both', interface_position=None, manual=False, z_in=None, v_in=None, multi_manual=1, pos_to_insert=None, locpot_vector=None, To_update=True, original_interface=None)[source]¶
- Parameters
from_iteslf (bool, optional, default: True) – This flag indicates whether to take the bulk-like potential that is going to be multiplied and then inserted - from itself - namely - from the middle of the local potnetial - far from the interface positions (since it satisfies periodic condition). Otherwise - it is taken from outer-scope file - supplied in the same directory and is referred to the bulk-material locpot file - obtained from VASP.
side_from_itself ({'both', 'right', 'left'}, optional, default: 'both') – Choices in brackets. This flag is being active only when the flag
from_iteslf=True
.from_iteslf – It indicates where we wish to elngate our local potential vector. -> From both side, or only from only one side of the interface.
interface_position (np.float, optional, default: None) – Enables to input the interface position manually. It refers to the spaciol coordinates. If your system does not have an interface, you should supply this argument with ‘’0’’.
manual (bool, optional, default: False) – Enables the user to elongate its locpot vector’s system manually. If this flag is turned on by supplying
manual = True
, the user must also supplyz_in
andv_in
vectors.z_in (np.array, array_like, optional, default: None) – When the user decides on elongating manually its locpot vector’s system, he should supplied also
z_in
andv_in
as the spatial gridcoordinates vector and the local potential vector respectively.v_in (np.array, array_like, optional, default: None) – When the user decides on elongating manually its locpot vector’s system, he should supplied also
z_in
andv_in
as the spatial gridcoordinates vector and the local potential vector respectively.multi_manual (int, optional, default: 1) – When the user decides on elongating manually its locpot vector’s system, it enables him to determine how many times to multiply the inserted locpot vector. This flag is also used in the case when to option of
from_itself
is turned on.pos_to_insert (float, optional, default: None) – When this argument is supplied, is enables determine the position where to insert the locpot vector during the elongation proccess.
locpot_vector (numpy.ndarray, (N, 2), optional, default: None) – The first column is the spatial grid/coordinates vector, and the second vector is local potential. It enables to elongate a locpot vector that is not related to the class instance attributes.
To_update (bool, optional, default: True) – A flag indicates if the changes that have being made are going to be updated as the instance attributes.
original_interface (float, optional, default: None) – If specified, all the extention procedure will be considering this interface position during all the procedure.
- Returns
Elongated locpot_vec (numpy.ndarray, (N, 2)) – It consists of 2 columns. First column is the spatial coordinates, the second column is the local potential values.
- update_converged_spatial_grid(vecor_to_update=None, update_converged_vec=True, update_interface=False)[source]¶
Calculate spatial grid applying the converged grid density, for the interface system.
- Parameters
vecor_to_update (numpy.ndarray, (N, 2), optional, default: None) – This is a 2 column matrix. First colmn is
z
, the spatial coordinates vector and second isv
, the local potential vector. If we wish apply this method on not related vector, not an object attribute.update_converged_vec (bool, optional, default: True) – A flag indicates whether to update the instance attribute with the new converged vector we obatin through this method.
update_interface (bool, optional, default: False) – A flag indicates whether to update the instance attribute of the new interface found with the new interface position as we get by applying this method.
- Returns
None
- find_initial_position_to_center_psi0(init_side='Left', manual=False, manual_pos=None, index=False)[source]¶
- Parameters
init_side (str, {'Left', 'Right'}, Optional, default: 'Left') – The Choices are in the brackets. Determines what side of the interface to look for the inialization position.
manual (int or float, optional, default: None) – It can be int for index insertion or a float for position insertion. Instead for automatically look for initial position, you can supply it directly via this argument. Also it assume that it is given as a spatial position.
manual_pos (int or float, optional, default: None) – If specified, this will be the actual position that corresponding the local potential vector - where the wave-function will be initialized at.
index (bool, optional, default: False) – If it is
True
, then the manual argument will be read as index instead of spatial position.
- Returns
z0_position, z0_index (float, int) – The position and the matching index in the interfce system locpot vector, where psi0 will be initialized at. By default it will be at the middle of the left-side material.
- find_new_interface()[source]¶
After updating our spcial grid, and applying the grid density that we calculated at `stage_1`, this method aims to point out the new interface of the updated locpot vector.
- Returns
The new interface position. (in Angstrum).
- initialize_psi0(init_side='Left', manual_center=False, manual_z0=None, manual_z=None, manual_v=None, To_update=True, manual_psi_dic=None)[source]¶
- Parameters
init_side (str, {'Left', 'Right'}, optional, default: 'Left') – Enables to choose from what side of the interface to initialize the wave function.
manual_center (bool, optional, default: False) – Enables th choose whether to initialize the wave function at a certain
z
coordinate as an input from the user.manual_z0 (float, optional, default: None) – Manual input for initializing the wave function at a certain desired location. The wave function will be centered at z0_manual.
manual_z (np.array, array_like, optional, default: None) – Enables flexibility in initializing psi0 at a given locpot vector, as
z_input
andv_input
.manual_v (np.array, array_like, optional, default: None) – Enables flexibility in initializing psi0 at a given locpot vector, as
z_input
andv_input
.To_update (bool, optional, default: True) – A flag to indicate if the changes that have being made are going to be updated as the instance attributes.
manual_psi_dic (dict, optional, default: None) – The dictionary has to be from the structure of : {‘sigma’: np.float , ‘k0’: np.float, … } It enables to initilize the psi0 as we wish by giving it an input for the relevant parameters.
- Returns
psi0 (np.array, array_like) – Wave-function values vector.
locpot (numpy.ndarray, (N,2)) – The corresponding spatial coordinates vector
- get_most_relevant_z_coordinate_vec()[source]¶
- Returns
z, v (np.array, np.array) – z coordinate vector and v potential vector. It chooses the most relvant z and v vectors according to the steps that have already taken when running this function.
- calculate_E0(psi=None, z_in=None, v_in=None)[source]¶
- Parameters
psi (np.array, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance.
z_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,0] attribute of Stage_2 instance. Vector of the spatial grid. (spatial coordinates)
v_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,1] attribute of Stage_2 instance. Vector of the local potential.
- Returns
E0 (float) – The expectation values of the total energy.
T0 (float) – The expectation values of the kinetic energy.
V0 (float) – The expectation values of the potnetial energy and potential energy, in [Joul].
- propagate_psi(psi=None, Nt=None, dt=None, z_in=None, v_in=None, path_to_save=None)[source]¶
- Parameters
psi (np.array, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance.
Nt (int, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance. The number of time-steps.
dt (float, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance The size of each time step the wave-function is propagated.
z_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,0] attribute of Stage_2 instance. Vector of the spatial grid. (spatial coordinates)
v_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,1] attribute of Stage_2 instance. Vector of the local potential.
path_to_save (string, optional, default:None) – The absolute path to save the figure obtained from the calculation
- Returns
None – This method was built mainly to produce the simulation animation. If
To_plot
is not set to True, then this function does not take any action.
- set_To_plot(To_plot)[source]¶
- Parameters
To_plot (bool) – The input from the user, this method aims to set the
To_plot
attribute of the instance and enables the plotting feature that implemented in some of the class methods.- Returns
None
- cumulative_probabilty_through_interface(psi=None, Nt=None, dt=None, z_in=None, v_in=None, check_pos=None, path_to_save=None)[source]¶
- Parameters
psi (np.array, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance.
Nt (int, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance. The number of time-steps.
dt (float, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance The size of each time step the wave-function is propagated.
z_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,0] attribute of Stage_2 instance. Vector of the spatial grid. (spatial coordinates)
v_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,1] attribute of Stage_2 instance. Vector of the local potential.
check_pos (float, optional, default: None) – In cases where we don’t have an interface and we wish supply a position where the cumulative probability is ggoing to be calculated.
path_to_save (string, optional, default:None) – The absolute path to save the figure obtained from the calculation
- Returns
results (numpy.ndarray, (N,2)) – This is a 2 columns vector, the first column vector represents the # of the time step. The second column vector represents the cumulative probabilty through interface.
- converge_system_size(psi=None, Nt=None, dt=None, z_in=None, v_in=None, To_update=True, Elongate_from_itself=True, Multi=2, iteration_num=1, init_side='Left', manual_center=False, manual_z0=None, manual_z=None, manual_v=None, manual_psi_dic=None, path_to_save=None)[source]¶
More accurate name - converge simulation overall time :param psi: If not supplied, the default is the wave-function vector attribute of Stage_2 instance. :type psi: np.array, optional, default: None :param Nt: If not supplied, the default is the wave-function vector attribute of Stage_2 instance.
The number of time-steps.
- Parameters
dt (float, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance The size of each time step the wave-function is propagated.
z_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,0] attribute of Stage_2 instance. Vector of the spatial grid. (spatial coordinates)
v_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,1] attribute of Stage_2 instance. Vector of the local potential.
To_update (bool, optional, default: True) – A flag that indicates whether to update the instance attributes with the calculated converged parameters.
Elongate_from_itself (bool, optional, default: True) – A flag that tells from where to take the bulk-like potential to be inserted during the elongation proccess.
Multi (int, optional, default: 2) – A flag that tells how many time to multiply the inserted potenial during the elongation proccess.
iteration_num (int, optional, default: 20) – How many iteration the convergence proccess will be hold. manual_center : bool, optional, default: False Enables th choose whether to initialize the wave function at a certain
z
coordinate as an input from the user. manual_center : bool, optional, default: False Enables th choose whether to initialize the wave function at a certainz
coordinate as an input from the user.init_side (str, {'Left', 'Right'}, optional, default: 'Left') – For the psi0 initialization. Enables to choose from what side of the interface to initialize the wave function.
manual_center (bool, optional, default: False) – For the psi0 initialization. Enables th choose whether to initialize the wave function at a certain
z
coordinate as an input from the user.manual_z0 (float, optional, default: None) – For the psi0 initialization. Manual input for initializing the wave function at a certain desired location. The wave function will be centered at z0_manual.
manual_z (np.array, array_like, optional, default: None) – For the psi0 initialization. Enables flexibility in initializing psi0 at a given locpot vector, as
z_input
andv_input
.manual_v (np.array, array_like, optional, default: None) – For the psi0 initialization. Enables flexibility in initializing psi0 at a given locpot vector, as
z_input
andv_input
.manual_psi_dic (dict, optional, default: None) – For the psi0 initialization. The dictionary has to be from the structure of : {‘sigma’: np.float , ‘k0’: np.float, … } It enables to initilize the psi0 as we wish by giving it an input for the relevant parameters.
path_to_save (string, optional, default:None) – The absolute path to save the figure obtained from the calculation
- Returns
converged_z (np.array) – The converged vector of the spatial grid. (spatial coordinates)
converged_v (np.array) – The converged vector of the local potential
converged_psi (np.array) – The converged wave-function vector.
converged_Nt (int) – The converged time steps that were being made.
results (numpy.ndarray, (N,2)) – This is a 2 columns vector, the first column vector represents the # of the time step. The second column vector represents the cumulative probabilty through interface.
simulation_time (float) – The total time of the simulation. It is given in units of seconds. It is the multiplication of
Nt*dt
.
- converge_time_step(psi=None, Nt=None, dt=None, time_sim=None, z_in=None, v_in=None, To_update=True, To_plot=False, iterations=8, check_pos=None, tol=0.005, path_to_save=None)[source]¶
- Parameters
psi (np.array, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance.
Nt (int, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance. The number of time-steps.
dt (float, optional, default: None) – If not supplied, the default is the wave-function vector attribute of Stage_2 instance The size of each time step the wave-function is propagated.
time_sim (float, optional, default: None) – If not supplied, it will be calculated from the product
Nt*dt
. However, it is supplied, it will be taken into account, and the dt will be taken into account too. Then Nt will be recalculated.z_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,0] attribute of Stage_2 instance. Vector of the spatial grid. (spatial coordinates)
v_in (np.array, optional, default: None) – If not supplied, the default is taken from locpot_vec[:,1] attribute of Stage_2 instance. Vector of the local potential.
To_update (bool, optional, default: True) – A flag that indicates whether to update the instance attributes with the calculated converged parameters.
To_plot (bool, optional, defulat: False) – A flag to determine whether to plot or not.
iterations (int, optional, default: 40) – A flag the enables the user define how many times the converges test will run.
check_pos (float, optional, default: None) – In cases where we do not have an interface and we wish supply a position where the cumulative probability is ggoing to be calculated at.
tol (float, optional, default: 0.005) – The tolerance value which will be used as the criteria for the convergence test main loop. It compares the relevant values between two consecutive iterations and demands that the difference between them won’t exceeed the tolerance value.
path_to_save (string, optional, default:None) – The absolute path to save the figure obtained from the calculation
- Returns
dt (float) – The converged size of the time step.
Nt (int) – The converged number of the time steps that were being made through the simulation.
Total_Energy (list, [[],[],[],[np.array]]) – The first cell is the totoal magnitude at the end of the simulation, the second cell hold the first energy value at the beginning of the simulation, and the third cell holds the size of the time_step = dt at each iteration. The last cell hold the array with all the calculated energies along the convergence test.
Kinetic_Energy (list, [[],[],[],[np.array]]) – The same data structure as the Total_Energy.
Potential_Energy (list, [[],[],[],[np.array]]) – The same data structure as the Total_Energy.
prob_current (list, [[],[],[],[np.array]]) – The same data structure as the Total_Energy.
Cumulative_Prob (list, [[],[],[],[np.array]]) – The same data structure as the Total_Energy.
- model_interface(interface_initial_pos, interface_final_pos, region_initial_pos, region_final_pos, Delta_pos, z_in=None, v_in=None, interface_pos=None, path_to_save=None)[source]¶
- Parameters
interface_initial_pos –
interface_final_pos –
region_initial_pos –
region_final_pos –
Delta_pos –
z_in –
v_in –
interface_pos –
path_to_save –