3131
3232def get_cubic_sigma (uvw , m , n = 1 ):
3333 """
34- CSL analytical formula based on the book: 'Interfaces in crystalline materials',
34+ CSL analytical formula based on the book:
35+ 'Interfaces in crystalline materials',
3536 Sutton and Balluffi, clarendon press, 1996.
3637 generates possible sigma values.
3738 arguments:
@@ -81,17 +82,19 @@ def get_theta_m_n_list(uvw, sigma):
8182 thetas .sort (key = lambda x : x [0 ])
8283 return thetas
8384
85+
8486def print_list (uvw , limit ):
8587 """
8688 prints a list of smallest sigmas/angles for a given axis(uvw).
8789 """
8890 for i in range (limit ):
8991 tt = get_theta_m_n_list (uvw , i )
9092 if len (tt ) > 0 :
91- theta , m , n = tt [0 ]
93+ theta , _ , _ = tt [0 ]
9294 print ("Sigma: {0:3d} Theta: {1:5.2f} "
9395 .format (i , degrees (theta )))
9496
97+
9598def rot (a , Theta ):
9699 """
97100 produces a rotation matrix.
@@ -112,28 +115,31 @@ def rot(a, Theta):
112115
113116
114117# Helpful Functions:
115- #-------------------#
118+ # -------------------#
116119
117120def integer_array (A , tol = 1e-7 ):
118121 """
119122 returns True if an array is ineteger.
120123 """
121124 return np .all (abs (np .round (A ) - A ) < tol )
122125
126+
123127def angv (a , b ):
124128 """
125129 returns the angle between two vectors.
126130 """
127131 ang = acos (np .round (dot (a , b )/ norm (a )/ norm (b ), 8 ))
128132 return round (degrees (ang ), 7 )
129133
134+
130135def ang (a , b ):
131136 """
132137 returns the cos(angle) between two vectors.
133138 """
134139 ang = np .round (dot (a , b )/ norm (a )/ norm (b ), 7 )
135140 return abs (ang )
136141
142+
137143def CommonDivisor (a ):
138144 """
139145 returns the common factor of vector a and the reduced vector.
@@ -146,6 +152,7 @@ def CommonDivisor(a):
146152 CommFac .append (i )
147153 return (a .astype (int ), (abs (np .prod (CommFac ))))
148154
155+
149156def SmallestInteger (a ):
150157 """
151158 returns the smallest multiple integer to make an integer array.
@@ -157,12 +164,13 @@ def SmallestInteger(a):
157164 break
158165 return (testV , i ) if integer_array (testV ) else None
159166
167+
160168def integerMatrix (a ):
161169 """
162170 returns an integer matrix from row vectors.
163171 """
164172 Found = True
165- b = np .zeros ((3 ,3 ))
173+ b = np .zeros ((3 , 3 ))
166174 a = np .array (a )
167175 for i in range (3 ):
168176 for j in range (1 , 2000 ):
@@ -175,6 +183,7 @@ def integerMatrix(a):
175183 print ("Can not make integer matrix!" )
176184 return (b ) if Found else None
177185
186+
178187def SymmEquivalent (arr ):
179188 """
180189 returns cubic symmetric eqivalents of the given 2 dimensional vector.
@@ -213,6 +222,7 @@ def SymmEquivalent(arr):
213222 Result = np .array (Result )
214223 return np .unique (Result , axis = 0 )
215224
225+
216226def Tilt_Twist_comp (v1 , uvw , m , n ):
217227 """
218228 returns the tilt and twist components of a given GB plane.
@@ -270,7 +280,7 @@ def Create_Possible_GB_Plane_List(uvw, m=5, n=1, lim=5):
270280 [1 , 1 , 0 ],
271281 [0 , 1 , 1 ],
272282 [1 , 0 , 1 ],
273- ], dtype = 'float' )
283+ ], dtype = 'float' )
274284 # Find GB plane coordinates:
275285 for i in range (len (indice_0 )):
276286 if CommonDivisor (indice_0 [i ])[1 ] <= 1 :
@@ -302,6 +312,7 @@ def Create_Possible_GB_Plane_List(uvw, m=5, n=1, lim=5):
302312
303313 return (V1 , V2 , MeanPlanes , GBtype )
304314
315+
305316def Create_minimal_cell_Method_1 (sigma , uvw , R ):
306317 """
307318 finds Minimal cell by means of a numerical search.
@@ -376,6 +387,7 @@ def MiniCell_search(indices, MiniCell_1, R, sigma):
376387 else :
377388 return Found
378389
390+
379391def Basis (basis ):
380392 """
381393 defines the basis.
@@ -407,6 +419,7 @@ def Basis(basis):
407419
408420 return basis
409421
422+
410423def Find_Orthogonal_cell (basis , uvw , m , n , GB1 ):
411424 """
412425 finds Orthogonal cells from the CSL minimal cells.
@@ -473,7 +486,7 @@ def Find_Orthogonal_cell(basis, uvw, m, n, GB1):
473486 OrthoCell_1 = OrthoCell_1 .astype (float )
474487 OrthoCell_2 = OrthoCell_2 .astype (float )
475488
476- if basis == 'sc' or basis == 'diamond' :
489+ if basis == 'sc' or basis == 'diamond' :
477490
478491 return ((OrthoCell_1 .astype (float ),
479492 OrthoCell_2 .astype (float ), Num .astype (int )))
@@ -487,17 +500,18 @@ def Find_Orthogonal_cell(basis, uvw, m, n, GB1):
487500 else :
488501 return None
489502
503+
490504def print_list_GB_Planes (uvw , basis , m , n , lim = 3 ):
491505 """
492506 prints lists of GB planes given an axis, basis, m and n.
493507 """
494508 uvw = np .array (uvw )
495- V1 , V2 , Mean , Type = Create_Possible_GB_Plane_List (uvw , m , n , lim )
509+ V1 , V2 , _ , Type = Create_Possible_GB_Plane_List (uvw , m , n , lim )
496510 for i in range (len (V1 )):
497511 Or = Find_Orthogonal_cell (basis , uvw , m , n , V1 [i ])
498512 if Or :
499- print ("{0:<20s} {1:<20s} {2:<20s} {3:<10s}"
500- .format (str (V1 [i ]), str (V2 [i ]), Type [i ], str (Or [2 ])))
513+ print ("{0:<20s} {1:<20s} {2:<20s} {3:<10s}"
514+ .format (str (V1 [i ]), str (V2 [i ]), Type [i ], str (Or [2 ])))
501515
502516
503517# ___CSL/DSC vector construction___#
@@ -608,6 +622,7 @@ def face_centering(a):
608622
609623 return z_f if det (z_f ) == 0.25 else None
610624
625+
611626def DSC_vec (basis , sigma , minicell ):
612627 """
613628 a discrete shift complete (DSC)
@@ -626,6 +641,7 @@ def DSC_vec(basis, sigma, minicell):
626641 D = dot (D_sc , face_centering (D_sc ))
627642 return D
628643
644+
629645def CSL_vec (basis , minicell ):
630646 """
631647 CSL minimal cell for sc, fcc and bcc.
@@ -642,6 +658,7 @@ def CSL_vec(basis, minicell):
642658 C = dot (C_sc , face_centering (C_sc ))
643659 return C
644660
661+
645662def DSC_on_plane (D , Pnormal ):
646663 """
647664 projects the given DSC network on a given plane.
@@ -668,8 +685,10 @@ def CSL_density(basis, minicell, plane):
668685 density = 1 / (hnorm * det (C ))
669686 return (abs (density ), 1 / hnorm )
670687
671- # An auxilary function to help reduce the size of the small orthogonal cell that
672- # is decided otherwise based on Sc for fcc and bcc
688+ # An auxilary function to help reduce the size of the small orthogonal cell
689+ # that is decided otherwise based on Sc for fcc and bcc
690+
691+
673692def Ortho_fcc_bcc (basis , O1 , O2 ):
674693 ortho1 = np .zeros ((3 , 3 ))
675694 ortho2 = np .zeros ((3 , 3 ))
@@ -685,15 +704,17 @@ def Ortho_fcc_bcc(basis, O1, O2):
685704 ortho1 [:, i ] = O1 [:, i ] / Min_d
686705 ortho2 [:, i ] = O2 [:, i ] / Min_d
687706 return (ortho1 , ortho2 )
688-
689707# Writing to a yaml file that will be read by gb_generator
708+
709+
690710def Write_to_io (axis , m , n , basis ):
691711 """
692712 an input file for gb_generator.py that can be customized.
693713 It also contains the output from the usage of csl_generator.py.
694714 """
695715
696- my_dict = {'GB_plane' : str ([axis [0 ], axis [1 ], axis [2 ]]), 'lattice_parameter' : '4' ,
716+ my_dict = {'GB_plane' : str ([axis [0 ], axis [1 ], axis [2 ]]),
717+ 'lattice_parameter' : '4' ,
697718 'overlap_distance' : '0.0' , 'which_g' : 'g1' ,
698719 'rigid_trans' : 'no' , 'a' : '10' , 'b' : '5' ,
699720 'dimensions' : '[1,1,1]' ,
@@ -743,8 +764,8 @@ def Write_to_io(axis, m, n, basis):
743764 f .write ('# File type, either VASP or LAMMPS input \n ' )
744765 f .write (list (my_dict .keys ())[8 ] + ': ' + list (my_dict .values ())[8 ] +
745766 '\n \n \n ' )
746- f .write ('# The following is your csl_generator output. YOU DO NOT NEED '
747- 'TO CHANGE THEM! \n \n ' )
767+ f .write ('# The following is your csl_generator output.'
768+ ' YOU DO NOT NEED TO CHANGE THEM! \n \n ' )
748769 f .write ('axis' + ': ' + str ([axis [0 ], axis [1 ], axis [2 ]]) + '\n ' )
749770 f .write ('m' + ': ' + str (m ) + '\n ' )
750771 f .write ('n' + ': ' + str (n ) + '\n ' )
@@ -763,7 +784,6 @@ def main():
763784 uvw = np .array ([int (sys .argv [1 ]), int (sys .argv [2 ]), int (sys .argv [3 ])])
764785 uvw = CommonDivisor (uvw )[0 ]
765786
766-
767787 if len (sys .argv ) == 4 :
768788 limit = 100
769789 print (" List of possible CSLs for {} axis sorted by Sigma "
@@ -792,7 +812,7 @@ def main():
792812 sigma = int (sys .argv [5 ])
793813
794814 try :
795- t , m , n = get_theta_m_n_list (uvw , sigma )[0 ]
815+ _ , m , n = get_theta_m_n_list (uvw , sigma )[0 ]
796816 Write_to_io (uvw , m , n , basis )
797817
798818 print ("----------List of possible CSL planes for Sigma {}---------"
@@ -814,7 +834,7 @@ def main():
814834
815835 try :
816836
817- t , m , n = get_theta_m_n_list (uvw , sigma )[0 ]
837+ _ , m , n = get_theta_m_n_list (uvw , sigma )[0 ]
818838 lim = int (sys .argv [6 ])
819839
820840 if lim > 10 :
@@ -839,10 +859,3 @@ def main():
839859
840860if __name__ == '__main__' :
841861 main ()
842-
843-
844-
845-
846-
847-
848-
0 commit comments