5757from warnings import warn
5858
5959# Internal functions
60- from . import functions_general as fg , functions_crystallography as fc
60+ from . import functions_general as fg
6161from . import functions_crystallography as fc
62+ from . import functions_lattice as fl
6263from .classes_orientation import Orientation
6364from .classes_properties import Properties
6465# from .classes_orbitals import CrystalOrbitals
@@ -514,9 +515,10 @@ def __init__(self, a=1.0, b=1.0, c=1.0, alpha=90., beta=90.0, gamma=90.0):
514515 self .alpha = float (alpha )
515516 self .beta = float (beta )
516517 self .gamma = float (gamma )
518+ self ._basis_function = fl .basis_3
517519 self .orientation = Orientation ()
518520
519- def latt (self , lattice_parameters = (), * args , ** kwargs ):
521+ def latt (self , * lattice_parameters , ** kwargs ):
520522 """
521523 Generate lattice parameters with list
522524 latt(1) -> a=b=c=1,alpha=beta=gamma=90
@@ -527,7 +529,7 @@ def latt(self, lattice_parameters=(), *args, **kwargs):
527529 latt(a=1,b=2,c=3,alpha=10,beta=20,gamma=30]) -> a=1,b=2,c=3,alpha=10,beta=20,gamma=30
528530 """
529531
530- lp = fc .gen_lattice_parameters (lattice_parameters , * args , ** kwargs )
532+ lp = fc .gen_lattice_parameters (* lattice_parameters , ** kwargs )
531533 self .a = lp [0 ]
532534 self .b = lp [1 ]
533535 self .c = lp [2 ]
@@ -585,35 +587,46 @@ def lp(self):
585587 """
586588 return self .a , self .b , self .c , self .alpha , self .beta , self .gamma
587589
590+ def choose_basis (self , option = 'default' ):
591+ """
592+ Choose the basis function
593+ Options:
594+ 1. c || z, b* || y - basis choice of Materials Project
595+ 2. a || x, c* || z - basis choice of Vesta
596+ 3. c || z, a* || x - basis choice of Busing & Levy (Default)
597+ :param option: name or number of basis
598+ """
599+ self ._basis_function = fl .choose_basis (option )
600+
588601 def UV (self ):
589602 """
590603 Returns the unit cell as a [3x3] array, [A,B,C]
591604 The vector A is directed along the x-axis
592605 """
593- return self .orientation (fc . latpar2uv_rot (* self .lp ()))
606+ return self .orientation (self . _basis_function (* self .lp ()))
594607
595608 def UVstar (self ):
596609 """
597610 Returns the reciprocal unit cell as a [3x3] array, [A*,B*,C*]
598611 :return: [a*;b*;c*]
599612 """
600- return fc . RcSp (self .UV ())
613+ return fl . reciprocal_basis (self .UV ())
601614
602615 def volume (self ):
603616 """
604617 Returns the volume of the unit cell, in A^3
605618 :return: volume
606619 """
607- return fc . calc_vol ( self .UV ())
620+ return fl . lattice_volume ( * self .lp ())
608621
609622 def Bmatrix (self ):
610623 """
611624 Calculate the Busing and Levy B matrix from a real space UV
612625 "choose the x-axis parallel to a*, the y-axis in the plane of a* and b*, and the z-axis perpendicular to
613626 that plane"
614- W. R. Busing & H. A. Levy, Acta Cryst. (1967). 22, 457
627+ W. R. Busing & H. A. Levy, Acta Cryst. (1967). 22, 457
615628 """
616- return fc . Bmatrix ( self .UV ())
629+ return fl . busingandlevy ( * self .lp ())
617630
618631 def info (self ):
619632 """
@@ -660,7 +673,7 @@ def indexQ(self, Q):
660673 > HKL = [1,0,0]
661674 """
662675 Q = np .reshape (np .asarray (Q , dtype = float ), [- 1 , 3 ])
663- return fc . indx (Q , self .UVstar ())
676+ return fl . index_lattice (Q , self .UVstar ())
664677
665678 def calculateR (self , UVW ):
666679 """
@@ -685,7 +698,7 @@ def indexR(self, R):
685698 > UVW = [0.1,0,0]
686699 """
687700 R = np .reshape (np .asarray (R , dtype = float ), [- 1 , 3 ])
688- return fc . indx (R , self .UV ())
701+ return fl . index_lattice (R , self .UV ())
689702
690703 def moment (self , mxmymz ):
691704 """Calcualte moment from value stored in cif"""
@@ -892,7 +905,7 @@ def find_close_reflections(self, hkl, energy_kev, max_twotheta=2, max_angle=10):
892905 selected = (tth_dif < max_twotheta ) * (all_angles < max_angle )
893906 return all_hkl [selected , :]
894907
895- def reciprocal_space_plane (self , x_axis = [ 1 , 0 , 0 ] , y_axis = [ 0 , 1 , 0 ] , centre = [ 0 , 0 , 0 ] , q_max = 4.0 , cut_width = 0.05 ):
908+ def reciprocal_space_plane (self , x_axis = ( 1 , 0 , 0 ) , y_axis = ( 0 , 1 , 0 ) , centre = ( 0 , 0 , 0 ) , q_max = 4.0 , cut_width = 0.05 ):
896909 """
897910 Returns positions within a reciprocal space plane
898911 x_axis = direction along x, in units of the reciprocal lattice (hkl)
@@ -1481,7 +1494,7 @@ def check(self):
14811494 def fitincell (self ):
14821495 """Adjust all atom positions to fit within unit cell"""
14831496 uvw = fc .fitincell (self .uvw ())
1484-
1497+ self . u , self . v , self . w = uvw . T
14851498
14861499 def uvw (self ):
14871500 """
@@ -2366,7 +2379,7 @@ def __init__(self, Parent, P):
23662379 self .P = np .asarray (P , dtype = float )
23672380 self .Parent = Parent
23682381 newUV = Parent .Cell .calculateR (P )
2369- self .new_cell (fc . UV2latpar (newUV ))
2382+ self .new_cell (fl . basis2latpar (newUV ))
23702383 self .scale = Parent .scale * np .prod (self .P )
23712384
23722385 # Add exta functions
0 commit comments