from __future__ import division,print_function import numpy as np from numpy import sin,cos class Triclinic(object): def __init__(self,a=1,b=1,c=1,alpha=90,beta=90,gamma=90): self.a = a self.b = b self.c = c alpha = alpha*np.pi/180 beta = beta*np.pi/180 gamma = gamma*np.pi/180 self.alpha = alpha self.beta = beta self.gamma = gamma self._s11 = b**2 * c**2 * sin(alpha)**2 self._s22 = a**2 * c**2 * sin(beta)**2 self._s33 = a**2 * b**2 * sin(gamma)**2 self._s12 = a*b*c**2*(cos(alpha) * cos(beta) - cos(gamma)) self._s23 = a**2*b*c*(cos(beta) * cos(gamma) - cos(alpha)) self._s13 = a*b**2*c*(cos(gamma) * cos(alpha) - cos(beta)) self.V = (a*b*c)*np.sqrt(1-cos(alpha)**2 - cos(beta)**2 - cos(gamma)**2 + 2*cos(alpha)*cos(beta)*cos(gamma)) def __call__(self,h,k,l): return self.q(h,k,l) def d(self,h,k,l): temp = self._s11*h**2 + \ self._s22*k**2 + \ self._s33*l**2 + \ 2*self._s12*h*k+ \ 2*self._s23*k*l+ \ 2*self._s13*h*l d = self.V/np.sqrt(temp) return d def q(self,h,k,l): return 2*np.pi/self.d(h,k,l) class Orthorombic(Triclinic): def __init__(self,a=1,b=1,c=1): Triclinic.__init__(self,a=a,b=b,c=c,alpha=90,beta=90,gamma=90) class Monoclinic(object): def __init__(self,a=1,b=1,c=1,beta=90.): self.a = a self.b = b self.c = c beta = beta/np.pi*180 self.beta = beta self.V = (a*b*c) def __call__(self,h,k,l): return self.Q(h,k,l) def Q(self,h,k,l): temp = h**2/self.a**2 + (k*sin(self.beta))**2/self.b**2+l**2/self.c**2+2*h*l*cos(self.beta)/self.a/self.c d = 1/np.sqrt(temp) print(d) return 2*np.pi/d ti3o5_lambda = Triclinic(a = 9.83776, b = 3.78674, c = 9.97069, beta = 91.2567) ti3o5_beta = Triclinic(a = 9.7382 , b = 3.8005 , c = 9.4333 , beta = 91.496) #ti3o5_beta = Monoclinic(a = 9.7382 , b = 3.8005 , c = 9.4333 , beta = 91.496) ti3o5_alpha = Triclinic(a = 9.8372, b = 3.7921, c = 9.9717) #ti3o5_alpha1 = Orthorombic(a = 9.8372, b = 3.7921, c = 9.9717)