-
Notifications
You must be signed in to change notification settings - Fork 6
Xtalcalcs
- modules/xtal
-
Create a lattice object using a set of cell parameters (the arguments are a,b,c,alpha,beta,gamma)
p>>from xtal import Lattice p>>cell = Lattice(5.6,5.6,13,90,90,120)
-
Show lattice parameters and real and recip lattice cell volumes
>>print cell >>print cell.vol() >>print cell.vol(recip=True)
-
Compute the dspace and 2Theta angle for the hkl = [0,0,1] reflection (with 1 angstrom radiation)
>>print cell.d([0,0,1]) >>print cell.tth([0,0,1],lam=1.)
-
Create a real space vector perpendicular to hkl = [0,0,1], with magnitude = dspace(001)
>>dv = cell.dvec([0,0,1]) >>print dv >>print cell.mag(dv)
-
Compute the angle between the recip lattice [1,0,0] and [0,1,0] vectors
>>print cell.angle([1,0,0],[0,1,0],recip=True)
-
Compute the angle between the recip lattice [1,0,0] and [0,0,1]
>>print cell.angle([1,0,0],[0,0,1],recip=True)
-
Compute the angle between the real lattice [1,0,0] and [0,1,0]
>>print cell.angle([1,0,0],[0,1,0])
-
Compute the angle between the real lattice [0,0,1] and [1,1,1]
>>print cell.angle([0,0,1],[1,1,1])
-
Compute the angle between the real [0,0,1] and recip [0,0,1]
>>print cell.angle_rr([0,0,1],[0,0,1])
-
Compute the angle between the real dv and recip [0,0,1]
>>print cell.angle_rr(dv,[0,0,1])
-
Test lattice transform operations
>>from xtal import Lattice, LatticeTransform
-
Create a new hexagonal lattice instance.
>>cell = Lattice(5.6,5.6,13,90,90,120)
-
The below set of vectors defines rhombohedral basis vectors in terms of the heaxagonal basis vectors. The rhombohedral system will be our primed lattice.
>>Va_rhom = [0.6667, 0.3333, 0.3333] >>Vb_rhom = [-0.3333, 0.3333, 0.3333] >>Vc_rhom = [-0.3333, -0.6667, 0.3333]
-
Create the transform
>>t = LatticeTransform(cell,Va=Va_rhom,Vb=Vb_rhom,Vc=Vc_rhom)
-
This returns a Lattice object with the primed (rhombohedral) coordinate system cell params
>>r = t.plat() >>print r
-
Given hkl = [001] in the hexagonal setting, calculate hkl in the rhombohedral (primed) setting
>>print t.hp([0,0,1])
-
Given hkl = [111] in rhombohedral (primed) setting calculate hkl in the hexagonal setting
>>print t.h([1,1,1])
-
Now create a cartesian transform of the hexagonal lattice (note this blows away the definitions of Va,Vb,Vc we used for the rhombohedral transform and replaces them with the vectors used for the cartesian transform).
>>t.cartesian() >>cart = t.plat() >>print cart
-
Convert a [1,1,0] lattice vector in the hexagonal lattice to the cartesian (primed) setting
>>vc = t.xp([1,1,0]) >>print vc
-
Check that the vector is the same length
>>print cell.mag([1,1,0]) >>print cart.mag(vc)
-
Test PositionGenerator for C2/m space group
>>from xtal import PositionGenerator >>p = PositionGenerator()
-
Add the symmetry operations and shift vectors
>>sym1 = "x,y,z" >>sym2 = "-x,y,-z" >>sym3 = "-x,-y,-z" >>sym4 = "x,-y,z" >>shift0 = "0,0,0" >>shift1 = "1/2, 1/2, 0" >> >>p.add_op(sym=sym1,shift=shift0) >>p.add_op(sym=sym2,shift=shift0) >>p.add_op(sym=sym3,shift=shift0) >>p.add_op(sym=sym4,shift=shift0) >>p.add_op(sym=sym1,shift=shift1) >>p.add_op(sym=sym2,shift=shift1) >>p.add_op(sym=sym3,shift=shift1) >>p.add_op(sym=sym4,shift=shift1)
-
Given a vector [0.15,0.0,0.33] create all symmetry copies
>>vecs = p.copy(0.15,0.0,0.33) >>for v in vecs: print v
-
Given a vector [0.5,0.11,0.5] create all symmetry copies
>>vecs = p.copy(0.5,0.11,0.5) >>for v in vecs: print v
-
Given a vector [0.25,0.25,0.25] create all symmetry copies
vecs = p.copy(0.25,0.25,0.25) for v in vecs: print v