rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
if numpy.allclose(Tr2, 0.0) or type(Tr2)==complex: | if numpy.allclose(Tr2, 0.0) or type(Tr2)==numpy.complex_: | def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 0.5 * Constants.DEG2RAD2 rdict = {} rdict["T'"] = T0.copy() rdict["L'"] = L0.copy() rdict["S'"] = S0.copy() rdict["rT'"] = T0.copy() rdict["L1_eigen_val"] = 0.0 rdict["L2_eigen_val"] = 0.0 rdict["L3_eigen_val"] = 0.0 rdict["L1_rmsd"] = 0.0 rdict["L2_rmsd"] = 0.0 rdict["L3_rmsd"] = 0.0 rdict["L1_eigen_vec"] = numpy.zeros(3, float) rdict["L2_eigen_vec"] = numpy.zeros(3, float) rdict["L3_eigen_vec"] = numpy.zeros(3, float) rdict["RHO"] = numpy.zeros(3, float) rdict["COR"] = origin rdict["L1_rho"] = numpy.zeros(3, float) rdict["L2_rho"] = numpy.zeros(3, float) rdict["L3_rho"] = numpy.zeros(3, float) rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 rdict["Tr1_eigen_val"] = 0.0 rdict["Tr2_eigen_val"] = 0.0 rdict["Tr3_eigen_val"] = 0.0 rdict["Tr1_rmsd"] = 0.0 rdict["Tr2_rmsd"] = 0.0 rdict["Tr3_rmsd"] = 0.0 ## set the L tensor eigenvalues and eigenvectors (L_evals, RL) = numpy.linalg.eigenvectors(L0) L1, L2, L3 = L_evals good_L_eigens = [] if numpy.allclose(L1, 0.0) or type(L1)==complex: L1 = 0.0 else: good_L_eigens.append(0) if numpy.allclose(L2, 0.0) or type(L2)==complex: L2 = 0.0 else: good_L_eigens.append(1) if numpy.allclose(L3, 0.0) or type(L3)==complex: L3 = 0.0 else: good_L_eigens.append(2) ## no good L eigen values if len(good_L_eigens)==0: return rdict ## one good eigen value -- reconstruct RL about it elif len(good_L_eigens)==1: i = good_L_eigens[0] evec = RL[i] RZt = numpy.transpose(AtomMath.rmatrixz(evec)) xevec = numpy.matrixmultiply(RZt, numpy.array([1.0, 0.0, 0.0], float)) yevec = numpy.matrixmultiply(RZt, numpy.array([0.0, 1.0, 0.0], float)) if i==0: RL[1] = xevec RL[2] = yevec elif i==1: RL[0] = xevec RL[2] = yevec elif i==2: RL[0] = xevec RL[1] = yevec ## two good eigen values -- reconstruct RL about them elif len(good_L_eigens)==2: i = good_L_eigens[0] j = good_L_eigens[1] xevec = AtomMath.normalize(numpy.cross(RL[i], RL[j])) for k in range(3): if k==i: continue if k==j: continue RL[k] = xevec break rdict["L1_eigen_val"] = L1 rdict["L2_eigen_val"] = L2 rdict["L3_eigen_val"] = L3 rdict["L1_rmsd"] = calc_rmsd(L1) rdict["L2_rmsd"] = calc_rmsd(L2) rdict["L3_rmsd"] = calc_rmsd(L3) rdict["L1_eigen_vec"] = RL[0].copy() rdict["L2_eigen_vec"] = RL[1].copy() rdict["L3_eigen_vec"] = RL[2].copy() ## begin tensor transformations which depend upon ## the eigenvectors of L0 being well-determined ## make sure RLt is right-handed if numpy.allclose(numpy.linalg.determinant(RL), -1.0): I = numpy.identity(3, float) I[0,0] = -1.0 RL = numpy.matrixmultiply(I, RL) if not numpy.allclose(numpy.linalg.determinant(RL), 1.0): return rdict RLt = numpy.transpose(RL) ## carrot-L tensor (tensor WRT principal axes of L) cL = numpy.matrixmultiply(numpy.matrixmultiply(RL, L0), RLt) rdict["L^"] = cL.copy() ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) rdict["T^"] = cT.copy() ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) rdict["S^"] = cS.copy() ## ^rho: the origin-shift vector in the coordinate system of L L23 = L2 + L3 L13 = L1 + L3 L12 = L1 + L2 ## shift for L1 if not numpy.allclose(L1, 0.0) and abs(L23)>LSMALL: crho1 = (cS[1,2] - cS[2,1]) / L23 else: crho1 = 0.0 if not numpy.allclose(L2, 0.0) and abs(L13)>LSMALL: crho2 = (cS[2,0] - cS[0,2]) / L13 else: crho2 = 0.0 if not numpy.allclose(L3, 0.0) and abs(L12)>LSMALL: crho3 = (cS[0,1] - cS[1,0]) / L12 else: crho3 = 0.0 crho = numpy.array([crho1, crho2, crho3], float) rdict["RHO^"] = crho.copy() ## rho: the origin-shift vector in orthogonal coordinates rho = numpy.matrixmultiply(RLt, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = numpy.array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = numpy.array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], float) ## calculate tranpose of cPRHO, ans cS cSt = numpy.transpose(cS) cPRHOt = numpy.transpose(cPRHO) rdict["L'^"] = cL.copy() ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp.copy() ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + numpy.matrixmultiply(cPRHO, cS) + numpy.matrixmultiply(cSt, cPRHOt) +\ numpy.matrixmultiply(numpy.matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp.copy() ## transpose of PRHO and S PRHOt = numpy.transpose(PRHO) St = numpy.transpose(S0) ## calculate S' = S + L*PRHOt Sp = S0 + numpy.matrixmultiply(L0, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T0 + numpy.matrixmultiply(PRHO, S0) + numpy.matrixmultiply(St, PRHOt) +\ numpy.matrixmultiply(numpy.matrixmultiply(PRHO, L0), PRHOt) rdict["T'"] = Tp ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if abs(L1)>LSMALL: cL1rho = numpy.array([0.0, -cSp[0,2]/L1, cSp[0,1]/L1], float) else: cL1rho = numpy.zeros(3, float) ## libration axis 2 shift in the L coordinate system if abs(L2)>LSMALL: cL2rho = numpy.array([cSp[1,2]/L2, 0.0, -cSp[1,0]/L2], float) else: cL2rho = numpy.zeros(3, float) ## libration axis 2 shift in the L coordinate system if abs(L3)>LSMALL: cL3rho = numpy.array([-cSp[2,1]/L3, cSp[2,0]/L3, 0.0], float) else: cL3rho = numpy.zeros(3, float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = numpy.matrixmultiply(RLt, cL1rho) rdict["L2_rho"] = numpy.matrixmultiply(RLt, cL2rho) rdict["L3_rho"] = numpy.matrixmultiply(RLt, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if abs(L1)>LSMALL: rdict["L1_pitch"] = cS[0,0]/L1 else: rdict["L1_pitch"] = 0.0 if L2>LSMALL: rdict["L2_pitch"] = cS[1,1]/L2 else: rdict["L2_pitch"] = 0.0 if L3>LSMALL: rdict["L3_pitch"] = cS[2,2]/L3 else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if abs(cL[k,k])>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if abs(cL[k,k])>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tr = numpy.matrixmultiply(numpy.matrixmultiply(RLt, cTred), RL) rdict["rT'"] = Tr Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(Tr) if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex: Tr1 = 0.0 if numpy.allclose(Tr2, 0.0) or type(Tr2)==complex: Tr2 = 0.0 if numpy.allclose(Tr3, 0.0) or type(Tr3)==complex: Tr3 = 0.0 rdict["Tr1_eigen_val"] = Tr1 rdict["Tr2_eigen_val"] = Tr2 rdict["Tr3_eigen_val"] = Tr3 rdict["Tr1_rmsd"] = calc_rmsd(Tr1) rdict["Tr2_rmsd"] = calc_rmsd(Tr2) rdict["Tr3_rmsd"] = calc_rmsd(Tr3) return rdict |
if numpy.allclose(Tr3, 0.0) or type(Tr3)==complex: | if numpy.allclose(Tr3, 0.0) or type(Tr3)==numpy.complex_: | def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 0.5 * Constants.DEG2RAD2 rdict = {} rdict["T'"] = T0.copy() rdict["L'"] = L0.copy() rdict["S'"] = S0.copy() rdict["rT'"] = T0.copy() rdict["L1_eigen_val"] = 0.0 rdict["L2_eigen_val"] = 0.0 rdict["L3_eigen_val"] = 0.0 rdict["L1_rmsd"] = 0.0 rdict["L2_rmsd"] = 0.0 rdict["L3_rmsd"] = 0.0 rdict["L1_eigen_vec"] = numpy.zeros(3, float) rdict["L2_eigen_vec"] = numpy.zeros(3, float) rdict["L3_eigen_vec"] = numpy.zeros(3, float) rdict["RHO"] = numpy.zeros(3, float) rdict["COR"] = origin rdict["L1_rho"] = numpy.zeros(3, float) rdict["L2_rho"] = numpy.zeros(3, float) rdict["L3_rho"] = numpy.zeros(3, float) rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 rdict["Tr1_eigen_val"] = 0.0 rdict["Tr2_eigen_val"] = 0.0 rdict["Tr3_eigen_val"] = 0.0 rdict["Tr1_rmsd"] = 0.0 rdict["Tr2_rmsd"] = 0.0 rdict["Tr3_rmsd"] = 0.0 ## set the L tensor eigenvalues and eigenvectors (L_evals, RL) = numpy.linalg.eigenvectors(L0) L1, L2, L3 = L_evals good_L_eigens = [] if numpy.allclose(L1, 0.0) or type(L1)==complex: L1 = 0.0 else: good_L_eigens.append(0) if numpy.allclose(L2, 0.0) or type(L2)==complex: L2 = 0.0 else: good_L_eigens.append(1) if numpy.allclose(L3, 0.0) or type(L3)==complex: L3 = 0.0 else: good_L_eigens.append(2) ## no good L eigen values if len(good_L_eigens)==0: return rdict ## one good eigen value -- reconstruct RL about it elif len(good_L_eigens)==1: i = good_L_eigens[0] evec = RL[i] RZt = numpy.transpose(AtomMath.rmatrixz(evec)) xevec = numpy.matrixmultiply(RZt, numpy.array([1.0, 0.0, 0.0], float)) yevec = numpy.matrixmultiply(RZt, numpy.array([0.0, 1.0, 0.0], float)) if i==0: RL[1] = xevec RL[2] = yevec elif i==1: RL[0] = xevec RL[2] = yevec elif i==2: RL[0] = xevec RL[1] = yevec ## two good eigen values -- reconstruct RL about them elif len(good_L_eigens)==2: i = good_L_eigens[0] j = good_L_eigens[1] xevec = AtomMath.normalize(numpy.cross(RL[i], RL[j])) for k in range(3): if k==i: continue if k==j: continue RL[k] = xevec break rdict["L1_eigen_val"] = L1 rdict["L2_eigen_val"] = L2 rdict["L3_eigen_val"] = L3 rdict["L1_rmsd"] = calc_rmsd(L1) rdict["L2_rmsd"] = calc_rmsd(L2) rdict["L3_rmsd"] = calc_rmsd(L3) rdict["L1_eigen_vec"] = RL[0].copy() rdict["L2_eigen_vec"] = RL[1].copy() rdict["L3_eigen_vec"] = RL[2].copy() ## begin tensor transformations which depend upon ## the eigenvectors of L0 being well-determined ## make sure RLt is right-handed if numpy.allclose(numpy.linalg.determinant(RL), -1.0): I = numpy.identity(3, float) I[0,0] = -1.0 RL = numpy.matrixmultiply(I, RL) if not numpy.allclose(numpy.linalg.determinant(RL), 1.0): return rdict RLt = numpy.transpose(RL) ## carrot-L tensor (tensor WRT principal axes of L) cL = numpy.matrixmultiply(numpy.matrixmultiply(RL, L0), RLt) rdict["L^"] = cL.copy() ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) rdict["T^"] = cT.copy() ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) rdict["S^"] = cS.copy() ## ^rho: the origin-shift vector in the coordinate system of L L23 = L2 + L3 L13 = L1 + L3 L12 = L1 + L2 ## shift for L1 if not numpy.allclose(L1, 0.0) and abs(L23)>LSMALL: crho1 = (cS[1,2] - cS[2,1]) / L23 else: crho1 = 0.0 if not numpy.allclose(L2, 0.0) and abs(L13)>LSMALL: crho2 = (cS[2,0] - cS[0,2]) / L13 else: crho2 = 0.0 if not numpy.allclose(L3, 0.0) and abs(L12)>LSMALL: crho3 = (cS[0,1] - cS[1,0]) / L12 else: crho3 = 0.0 crho = numpy.array([crho1, crho2, crho3], float) rdict["RHO^"] = crho.copy() ## rho: the origin-shift vector in orthogonal coordinates rho = numpy.matrixmultiply(RLt, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = numpy.array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = numpy.array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], float) ## calculate tranpose of cPRHO, ans cS cSt = numpy.transpose(cS) cPRHOt = numpy.transpose(cPRHO) rdict["L'^"] = cL.copy() ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp.copy() ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + numpy.matrixmultiply(cPRHO, cS) + numpy.matrixmultiply(cSt, cPRHOt) +\ numpy.matrixmultiply(numpy.matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp.copy() ## transpose of PRHO and S PRHOt = numpy.transpose(PRHO) St = numpy.transpose(S0) ## calculate S' = S + L*PRHOt Sp = S0 + numpy.matrixmultiply(L0, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T0 + numpy.matrixmultiply(PRHO, S0) + numpy.matrixmultiply(St, PRHOt) +\ numpy.matrixmultiply(numpy.matrixmultiply(PRHO, L0), PRHOt) rdict["T'"] = Tp ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if abs(L1)>LSMALL: cL1rho = numpy.array([0.0, -cSp[0,2]/L1, cSp[0,1]/L1], float) else: cL1rho = numpy.zeros(3, float) ## libration axis 2 shift in the L coordinate system if abs(L2)>LSMALL: cL2rho = numpy.array([cSp[1,2]/L2, 0.0, -cSp[1,0]/L2], float) else: cL2rho = numpy.zeros(3, float) ## libration axis 2 shift in the L coordinate system if abs(L3)>LSMALL: cL3rho = numpy.array([-cSp[2,1]/L3, cSp[2,0]/L3, 0.0], float) else: cL3rho = numpy.zeros(3, float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = numpy.matrixmultiply(RLt, cL1rho) rdict["L2_rho"] = numpy.matrixmultiply(RLt, cL2rho) rdict["L3_rho"] = numpy.matrixmultiply(RLt, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if abs(L1)>LSMALL: rdict["L1_pitch"] = cS[0,0]/L1 else: rdict["L1_pitch"] = 0.0 if L2>LSMALL: rdict["L2_pitch"] = cS[1,1]/L2 else: rdict["L2_pitch"] = 0.0 if L3>LSMALL: rdict["L3_pitch"] = cS[2,2]/L3 else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if abs(cL[k,k])>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if abs(cL[k,k])>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tr = numpy.matrixmultiply(numpy.matrixmultiply(RLt, cTred), RL) rdict["rT'"] = Tr Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(Tr) if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex: Tr1 = 0.0 if numpy.allclose(Tr2, 0.0) or type(Tr2)==complex: Tr2 = 0.0 if numpy.allclose(Tr3, 0.0) or type(Tr3)==complex: Tr3 = 0.0 rdict["Tr1_eigen_val"] = Tr1 rdict["Tr2_eigen_val"] = Tr2 rdict["Tr3_eigen_val"] = Tr3 rdict["Tr1_rmsd"] = calc_rmsd(Tr1) rdict["Tr2_rmsd"] = calc_rmsd(Tr2) rdict["Tr3_rmsd"] = calc_rmsd(Tr3) return rdict |
tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: | tls_desc_list = tls_file_format.load(open(tlsin, "r")) for tls_desc in tls_desc_list: tls_file.tls_desc_list.append(tls_desc) | def refmac5_prep(xyzin, tlsin_list, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ os.umask(022) ## load structure struct = LoadStructure(fil = xyzin) ## load and construct TLS groups tls_group_list = [] for tlsin in tlsin_list: tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) tls_file.load(open(tlsin, "r")) for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## set the extra Uiso for each atom for tls_group in tls_group_list: ## minimal/maximal amount of Uiso which has to be added ## to the group's atoms to to make Uiso == Uiso_tls min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ## report the percentage of atoms with Uiso within the RMSD ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 ## reduce the TLS group T tensor by min_Uiso so that ## a PDB file can be written out where all atoms ## Uiso == Uiso_tls ## we must rotate the T tensor to its primary axes before ## subtracting min_Uiso magnitude from it (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso ## now take half of the smallest principal component of T and ## move it into the individual atomic temperature factors min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T ## rotate T back to original orientation tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) ## reset the TLS tensor values in the TLSDesc object so they can be saved tls_group.tls_desc.set_tls_group(tls_group) ## set atm.temp_factor for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w")) |
def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): | def calc_TLS_center_of_reaction(T0, L0, S0, origin): | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
(eval_L, evec_L) = eigenvectors(L_orig) | (eval_L, RL) = eigenvectors(L0) if allclose(determinant(RL), -1.0): I = identity(3, Float) I[0,0] = -1.0 RL = matrixmultiply(I, RL) RLt = transpose(RL) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] evec_L = transpose(evec_L) | rdict["L1_eigen_vec"] = RL[0].copy() rdict["L2_eigen_vec"] = RL[1].copy() rdict["L3_eigen_vec"] = RL[2].copy() | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] | cL = matrixmultiply(matrixmultiply(RL, L0), RLt) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) | cT = matrixmultiply(matrixmultiply(RL, T0), RLt) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) det = determinant(evec_L) if int(det) != 1: cS = -cS | cS = matrixmultiply(matrixmultiply(RL, S0), RLt) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rho = matrixmultiply(evec_L, crho) | rho = matrixmultiply(RLt, crho) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rdict["COR"] = origin + rho.copy() | rdict["COR"] = origin + rho | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
St = transpose(S_orig) | St = transpose(S0) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
Sp = S_orig + matrixmultiply(L_orig, PRHOt) | Sp = S0 + matrixmultiply(L0, PRHOt) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ | Tp = T0 + \ matrixmultiply(PRHO, S0) + \ | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) | matrixmultiply(matrixmultiply(PRHO, L0), PRHOt) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rdict["L'"] = L_orig.copy() | rdict["L'"] = L0.copy() | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) | rdict["L1_rho"] = matrixmultiply(RLt, cL1rho) rdict["L2_rho"] = matrixmultiply(RLt, cL2rho) rdict["L3_rho"] = matrixmultiply(RLt, cL3rho) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) | rdict["rT'"] = matrixmultiply(matrixmultiply(RLt, cTred), RL) | def calc_TLS_center_of_reaction(T_orig, L_orig, S_orig, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction T',S',L': T,L,S tensors in origonal coordinate system with the origin shifted to the center of reaction. """ ## LSMALL is the smallest magnitude of L before it is considered 0.0 LSMALL = 1e-6 rdict = {} ## set the L tensor eigenvalues and eigenvectors (eval_L, evec_L) = eigenvectors(L_orig) rdict["L1_eigen_val"] = eval_L[0] rdict["L2_eigen_val"] = eval_L[1] rdict["L3_eigen_val"] = eval_L[2] rdict["L1_eigen_vec"] = evec_L[0] rdict["L2_eigen_vec"] = evec_L[1] rdict["L3_eigen_vec"] = evec_L[2] ## transpose the original the evec_L so it can be used ## to rotate the other tensors evec_L = transpose(evec_L) ## carrot-L tensor (tensor WRT principal axes of L) cL = zeros([3,3], Float) cL[0,0] = eval_L[0] cL[1,1] = eval_L[1] cL[2,2] = eval_L[2] rdict["L^"] = cL ## carrot-T tensor (T tensor WRT principal axes of L) cT = matrixmultiply( matrixmultiply(transpose(evec_L), T_orig), evec_L) rdict["T^"] = cT ## carrot-S tensor (S tensor WRT principal axes of L) cS = matrixmultiply( matrixmultiply(transpose(evec_L), S_orig), evec_L) ## correct for left-handed libration eigenvectors det = determinant(evec_L) if int(det) != 1: cS = -cS rdict["S^"] = cS ## ^rho: the origin-shift vector in the coordinate system of L cL1122 = cL[1,1] + cL[2,2] cL2200 = cL[2,2] + cL[0,0] cL0011 = cL[0,0] + cL[1,1] if cL1122>LSMALL: crho0 = (cS[1,2]-cS[2,1]) / cL1122 else: crho0 = 0.0 if cL2200>LSMALL: crho1 = (cS[2,0]-cS[0,2]) / cL2200 else: crho1 = 0.0 if cL0011>LSMALL: crho2 = (cS[0,1]-cS[1,0]) / cL0011 else: crho2 = 0.0 crho = array([crho0, crho1, crho2], Float) rdict["RHO^"] = crho ## rho: the origin-shift vector in orthogonal coordinates rho = matrixmultiply(evec_L, crho) rdict["RHO"] = rho rdict["COR"] = origin + rho.copy() ## set up the origin shift matrix PRHO WRT orthogonal axes PRHO = array([ [ 0.0, rho[2], -rho[1]], [-rho[2], 0.0, rho[0]], [ rho[1], -rho[0], 0.0] ], Float) ## set up the origin shift matrix cPRHO WRT libration axes cPRHO = array([ [ 0.0, crho[2], -crho[1]], [-crho[2], 0.0, crho[0]], [ crho[1], -crho[0], 0.0] ], Float) ## calculate tranpose of cPRHO, ans cS cSt = transpose(cS) cPRHOt = transpose(cPRHO) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + matrixmultiply(cL, cPRHOt) rdict["S'^"] = cSp ## L'^ = L^ = cL rdict["L'^"] = cL ## calculate T'^ = cT + cPRHO*S^ + cSt*cPRHOt + cPRHO*cL*cPRHOt * cTp = cT + \ matrixmultiply(cPRHO, cS) + \ matrixmultiply(cSt, cPRHOt) + \ matrixmultiply(matrixmultiply(cPRHO, cL), cPRHOt) rdict["T'^"] = cTp ## transpose of PRHO and S PRHOt = transpose(PRHO) St = transpose(S_orig) ## calculate S' = S + L*PRHOt Sp = S_orig + matrixmultiply(L_orig, PRHOt) rdict["S'"] = Sp ## calculate T' = T + PRHO*S + St*PRHOT + PRHO*L*PRHOt Tp = T_orig + \ matrixmultiply(PRHO, S_orig) + \ matrixmultiply(St, PRHOt) + \ matrixmultiply(matrixmultiply(PRHO, L_orig), PRHOt) rdict["T'"] = Tp ## L' is just L rdict["L'"] = L_orig.copy() ## now calculate the TLS motion description using 3 non ## intersecting screw axes, with one ## libration axis 1 shift in the L coordinate system if cL[0,0]>LSMALL: cL1rho = array([0.0, -cSp[0,2]/cL[0,0], cSp[0,1]/cL[0,0]], Float) else: cL1rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[1,1]>LSMALL: cL2rho = array([cSp[1,2]/cL[1,1], 0.0, -cSp[1,0]/cL[1,1]], Float) else: cL2rho = zeros(3, Float) ## libration axis 2 shift in the L coordinate system if cL[2,2]>LSMALL: cL3rho = array([-cSp[2,1]/cL[2,2], cSp[2,0]/cL[2,2], 0.0], Float) else: cL3rho = zeros(3, Float) ## libration axes shifts in the origional orthogonal ## coordinate system rdict["L1_rho"] = matrixmultiply(evec_L, cL1rho) rdict["L2_rho"] = matrixmultiply(evec_L, cL2rho) rdict["L3_rho"] = matrixmultiply(evec_L, cL3rho) ## calculate screw pitches (A*R / R*R) = (A/R) if cL[0,0]>LSMALL: rdict["L1_pitch"] = cS[0,0]/cL[0,0] else: rdict["L1_pitch"] = 0.0 if cL[1,1]>LSMALL: rdict["L2_pitch"] = cS[1,1]/cL[1,1] else: rdict["L2_pitch"] = 0.0 if cL[2,2]>LSMALL: rdict["L3_pitch"] = cS[2,2]/cL[2,2] else: rdict["L3_pitch"] = 0.0 ## now calculate the reduction in T for the screw rotation axes cTred = cT.copy() for i in (0, 1, 2): for k in (0, 1, 2): if i==k: continue if cL[k,k]>LSMALL: cTred[i,i] -= (cS[k,i]**2) / cL[k,k] for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): if j==i: continue if cL[k,k]>LSMALL: cTred[i,j] -= (cS[k,i]*cS[k,j]) / cL[k,k] ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system rdict["rT'"] = matrixmultiply( transpose(evec_L), matrixmultiply(cTred, evec_L)) return rdict |
if not self.default_model: | if self.default_model==None: | def get_chain(self, chain_id): """Returns the Chain object matching the chain_id charactor. """ if not self.default_model: return None if self.default_model.chain_dict.has_key(chain_id): return self.default_model.chain_dict[chain_id] return None |
if not atm1.get_bond(atm2): | if atm1.get_bond(atm2)==None: | def add_bonds_from_covalent_distance(self): """Builds a Structure's bonds by atomic distance distance using the covalent radii in element.cif. A bond is built if the the distance between them is less than or equal to the sum of their covalent radii + 0.54A. """ for model in self.iter_models(): xyzdict = XYZDict(2.0) for atm in model.iter_all_atoms(): if atm.position!=None: xyzdict.add(atm.position, atm) |
if self.chain_dict.has_key(chain.chain_id): | if self.chain_dict.has_key(chain.chain_id)==True: | def add_chain(self, chain, delay_sort=False): """Adds a Chain to the Model. """ assert isinstance(chain, Chain) |
if not frag.is_standard_residue(): | if frag.is_standard_residue()==False: | def iter_non_standard_residues(self): for frag in self.iter_fragments(): if not frag.is_standard_residue(): yield frag |
self.structure.sort() | self.structure.model_list.sort() | def set_model_id(self, model_id): """Sets the model_id of all contained objects. """ assert type(model_id)==IntType |
if not frag.is_standard_residue(): | if frag.is_standard_residue()==False: | def has_non_standard_residues(self): for frag in self.fragment_list: if not frag.is_standard_residue(): return True return False |
if not frag.is_standard_residue(): | if frag.is_standard_residue()==False: | def count_non_standard_residues(self): n = 0 for frag in self.fragment_list: if not frag.is_standard_residue(): n += 1 return n |
if not frag.is_standard_residue(): | if frag.is_standard_residue()==False: | def iter_non_standard_residues(self): for frag in self.fragment_list: if not frag.is_standard_residue(): yield frag |
if library_is_amino_acid(atom.res_name): | if library_is_amino_acid(atom.res_name)==True: | def add_atom(self, atom, delay_sort=False): """Adds a Atom. """ assert isinstance(atom, Atom) assert atom.model_id==self.model_id assert atom.chain_id==self.chain_id |
elif library_is_nucleic_acid(atom.res_name): | elif library_is_nucleic_acid(atom.res_name)==True: | def add_atom(self, atom, delay_sort=False): """Adds a Atom. """ assert isinstance(atom, Atom) assert atom.model_id==self.model_id assert atom.chain_id==self.chain_id |
def set_model_id(self, model_id): """Sets the model_id of all contained objects. """ assert type(model_id)==IntType self.model_id = model_id for frag in self.iter_fragments(): frag.set_model_id(model_id) | def remove_fragment(self, fragment): """Remove the Fragment from the Chain. """ Segment.remove_fragment(self, fragment) fragment.chain = None |
|
self.model.structure.sort() | self.model.chain_list.sort() | def set_chain_id(self, chain_id): """Sets a new ID for the Chain, updating the chain_id for all objects in the Structure hierarchy. """ ## check for conflicting chain_id in the structure if self.model!=None: chk_chain = self.model.get_chain(chain_id) if chk_chain!=None or chk_chain!=self: raise ChainOverwrite() |
name = copy.deepcopy(self.name), alt_loc = copy.deepcopy(self.alt_loc), res_name = copy.deepcopy(self.res_name), fragment_id = copy.deepcopy(self.fragment_id), chain_id = copy.deepcopy(self.chain_id), model_id = copy.deepcopy(self.model_id), element = copy.deepcopy(self.element), | name = self.name, alt_loc = self.alt_loc, res_name = self.res_name, fragment_id = self.fragment_id, chain_id = self.chain_id, model_id = copy.copy(self.model_id), element = self.element, | def __deepcopy__(self, memo): atom_cpy = Atom( name = copy.deepcopy(self.name), alt_loc = copy.deepcopy(self.alt_loc), res_name = copy.deepcopy(self.res_name), fragment_id = copy.deepcopy(self.fragment_id), chain_id = copy.deepcopy(self.chain_id), model_id = copy.deepcopy(self.model_id), element = copy.deepcopy(self.element), position = copy.deepcopy(self.position), sig_position = copy.deepcopy(self.sig_position), temp_factor = copy.deepcopy(self.temp_factor), sig_temp_factor = copy.deepcopy(self.sig_temp_factor), occupancy = copy.deepcopy(self.occupancy), sig_occupancy = copy.deepcopy(self.sig_occupancy), charge = copy.deepcopy(self.charge), U = copy.deepcopy(self.U, memo), sig_U = copy.deepcopy(self.sig_U, memo)) for bond in self.bond_list: bond_cpy = copy.deepcopy(bond, memo) atom_cpy.bond_list.append(bond_cpy) if bond_cpy.atom1 == None: bond_cpy.atom1 = atom_cpy elif bond_cpy.atom2 == None: bond_cpy.atom2 = atom_cpy |
temp_factor = copy.deepcopy(self.temp_factor), sig_temp_factor = copy.deepcopy(self.sig_temp_factor), occupancy = copy.deepcopy(self.occupancy), sig_occupancy = copy.deepcopy(self.sig_occupancy), charge = copy.deepcopy(self.charge), U = copy.deepcopy(self.U, memo), sig_U = copy.deepcopy(self.sig_U, memo)) | temp_factor = copy.copy(self.temp_factor), sig_temp_factor = copy.copy(self.sig_temp_factor), occupancy = copy.copy(self.occupancy), sig_occupancy = copy.copy(self.sig_occupancy), charge = copy.copy(self.charge), U = copy.deepcopy(self.U), sig_U = copy.deepcopy(self.sig_U)) | def __deepcopy__(self, memo): atom_cpy = Atom( name = copy.deepcopy(self.name), alt_loc = copy.deepcopy(self.alt_loc), res_name = copy.deepcopy(self.res_name), fragment_id = copy.deepcopy(self.fragment_id), chain_id = copy.deepcopy(self.chain_id), model_id = copy.deepcopy(self.model_id), element = copy.deepcopy(self.element), position = copy.deepcopy(self.position), sig_position = copy.deepcopy(self.sig_position), temp_factor = copy.deepcopy(self.temp_factor), sig_temp_factor = copy.deepcopy(self.sig_temp_factor), occupancy = copy.deepcopy(self.occupancy), sig_occupancy = copy.deepcopy(self.sig_occupancy), charge = copy.deepcopy(self.charge), U = copy.deepcopy(self.U, memo), sig_U = copy.deepcopy(self.sig_U, memo)) for bond in self.bond_list: bond_cpy = copy.deepcopy(bond, memo) atom_cpy.bond_list.append(bond_cpy) if bond_cpy.atom1 == None: bond_cpy.atom1 = atom_cpy elif bond_cpy.atom2 == None: bond_cpy.atom2 = atom_cpy |
if not self.altloc: | if self.altloc==None: | def __iter__(self): """Iterates over all Altloc representations of this Atom. """ if not self.altloc: yield self |
if self.default_model==None: | if not self.default_model: | def add_model(self, model, delay_sort=True): """Adds a Model to a Structure. Raises the ModelOverwrite exception if the model_id of the Model matches the model_id of a Model already in the Structure. If there are no Models in the Structure, the Model is used as the default Model. """ assert isinstance(model, Model) |
return self.default_model.iter_alpha_helicies() | if self.default_model: return self.default_model.iter_alpha_helicies() | def iter_alpha_helicies(self): """Iterates over all child AlphaHelix objects in the default Model. """ return self.default_model.iter_alpha_helicies() |
assert self.default_model!=None | def add_beta_sheet(self, beta_sheet): """ """ self.default_model.add_beta_sheet(beta_sheet) |
|
return self.default_model.iter_beta_sheets() | if self.default_model: return self.default_model.iter_beta_sheets() | def iter_beta_sheets(self): """Iterate over all beta sheets in the Structure. """ return self.default_model.iter_beta_sheets() |
assert self.default_model!=None | def add_site(self, site): """ """ self.default_model.add_site(site) |
|
return self.default_model.iter_sites() | if self.default_model: return self.default_model.iter_sites() | def iter_sites(self): """Iterate over all active/important sites defined in the Structure. """ return self.default_model.iter_sites() |
self.glv.roty += 360.0 * ((evx - self.beginx) / float(width)) self.glv.rotx += 360.0 * ((evy - self.beginy) / float(height)) | roty = 360.0 * ((evx - self.beginx) / float(width)) rotx += 360.0 * ((evy - self.beginy) / float(height)) | def on_mouse_motion(self, event): if event.Dragging()==False: return |
class AppFrame(wx.Frame): | class ViewerFrame(wx.Frame): | def glv_redraw(self): self.Refresh(False) |
def __init__(self, parent=None, id=-1, title='Title', pos=wx.DefaultPosition, size=(400, 200)): """Create a Frame instance. """ | def __init__( self, parent = None, id = -1, title = 'Title', pos = wx.DefaultPosition, size = (400, 200)): | def __init__(self, parent=None, id=-1, title='Title', pos=wx.DefaultPosition, size=(400, 200)): """Create a Frame instance. """ wx.Frame.__init__(self, parent, id, title, pos, size) |
self.load_structure(sys.argv[1]) | def __init__(self, parent=None, id=-1, title='Title', pos=wx.DefaultPosition, size=(400, 200)): """Create a Frame instance. """ wx.Frame.__init__(self, parent, id, title, pos, size) |
|
class App(wx.App): | class ViewerApp(wx.App): | def add_struct(self, struct): """Adds a structure to this viewer, and returns the GLStructure object so it can be manipulated. """ gl_struct = self.glviewer.glv.glv_add_struct(struct) |
self.frame = AppFrame() | self.frame = ViewerFrame() | def OnInit(self): self.frame = AppFrame() self.frame.Show() self.SetTopWindow(self.frame) return True |
def main(): app = App() | def main(files): app = ViewerApp() for file in files: app.frame.load_structure(file) | def main(): app = App() app.MainLoop() |
main() | main(sys.argv[1:]) | def main(): app = App() app.MainLoop() |
gl_delete_lists(self.name, 1) | self.gl_delete_list() | def gl_compile_list(self, execute = 0): if self.name != None: gl_delete_lists(self.name, 1) self.name = glGenLists(1) |
gl_delete_lists(self.name, 1) | glDeleteLists(self.name, 1) | def gl_delete_list(self): if self.name != None: gl_delete_lists(self.name, 1) self.name = None |
gl_call_list(self.name) | glCallList(self.name) | def gl_call_list(self): #print "gl_call_list = ",self.name |
analysis_url = "http://veritas.yiqiang.net/~yi/pdb/%s/ANALYSIS" % (pdbid) | analysis_url = "http://skuld.bmsc.washington.edu/~tlsmd/pdb/%s/ANALYSIS" % (pdbid) | def redirect_page(self, pdbid): # check to see if this job is still running try: os.chdir(conf.WEBTLSMDD_PDB_DIR + '/' + pdbid) except OSError: title = "This structure is currently being analyzed, please check back later." page = [self.html_head(title), html_title(title), self.html_foot()] return "".join(page) |
def refmac5_prep(pdbin, tlsins, pdbout, tlsout): | def refmac5_prep(xyzin, tlsin, xyzout, tlsout): """Use TLS model + Uiso for each atom. Output xyzout with the residual Uiso only. """ | def refmac5_prep(pdbin, tlsins, pdbout, tlsout): os.umask(022) ## load input structure struct = LoadStructure(fil = pdbin) ## load input TLS description tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) for tlsin in tlsins: fil = open(tlsin, "r") listx = tls_file.file_format.load(fil) tls_file.tls_desc_list += listx ## generate TLS groups from the structure file tls_group_list = [] for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## shift some Uiso displacement from the TLS T tensor to the ## individual atoms for tls_group in tls_group_list: # for atm, U in tls_group.iter_atm_Utls(): # if min(eigenvalues(U)) < 0.0: # raise UInvalid(atm, U) ## leave some B magnitude in the file for refinement (tevals, R) = eigenvectors(tls_group.T) tmin = min(tevals) T = matrixmultiply(R, matrixmultiply(tls_group.T, transpose(R))) T = T - (tmin * identity(3, Float)) tls_group.T = matrixmultiply(transpose(R), matrixmultiply(T, R)) bmin = U2B * tmin for atm, U in tls_group.iter_atm_Utls(): btls = U2B * (trace(U)/3.0) biso = atm.temp_factor bnew = biso - btls - bmin bnew = max(0.0, bnew) atm.temp_factor = bnew atm.U = None ## write TLSOUT file with new tensor values for tls_group in tls_group_list: tls_desc = tls_group.tls_desc tls_desc.set_tls_group(tls_group) fil = open(tlsout, "w") tls_file.save(fil) fil.close() ## write out a PDB file with reduced temperature factors SaveStructure(fil=pdbout, struct=struct) |
struct = LoadStructure(fil = pdbin) | struct = LoadStructure(fil = xyzin) tls_group_list = [] | def refmac5_prep(pdbin, tlsins, pdbout, tlsout): os.umask(022) ## load input structure struct = LoadStructure(fil = pdbin) ## load input TLS description tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) for tlsin in tlsins: fil = open(tlsin, "r") listx = tls_file.file_format.load(fil) tls_file.tls_desc_list += listx ## generate TLS groups from the structure file tls_group_list = [] for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## shift some Uiso displacement from the TLS T tensor to the ## individual atoms for tls_group in tls_group_list: # for atm, U in tls_group.iter_atm_Utls(): # if min(eigenvalues(U)) < 0.0: # raise UInvalid(atm, U) ## leave some B magnitude in the file for refinement (tevals, R) = eigenvectors(tls_group.T) tmin = min(tevals) T = matrixmultiply(R, matrixmultiply(tls_group.T, transpose(R))) T = T - (tmin * identity(3, Float)) tls_group.T = matrixmultiply(transpose(R), matrixmultiply(T, R)) bmin = U2B * tmin for atm, U in tls_group.iter_atm_Utls(): btls = U2B * (trace(U)/3.0) biso = atm.temp_factor bnew = biso - btls - bmin bnew = max(0.0, bnew) atm.temp_factor = bnew atm.U = None ## write TLSOUT file with new tensor values for tls_group in tls_group_list: tls_desc = tls_group.tls_desc tls_desc.set_tls_group(tls_group) fil = open(tlsout, "w") tls_file.save(fil) fil.close() ## write out a PDB file with reduced temperature factors SaveStructure(fil=pdbout, struct=struct) |
for tlsin in tlsins: fil = open(tlsin, "r") listx = tls_file.file_format.load(fil) tls_file.tls_desc_list += listx tls_group_list = [] | tls_file.load(open(tlsin, "r")) | def refmac5_prep(pdbin, tlsins, pdbout, tlsout): os.umask(022) ## load input structure struct = LoadStructure(fil = pdbin) ## load input TLS description tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) for tlsin in tlsins: fil = open(tlsin, "r") listx = tls_file.file_format.load(fil) tls_file.tls_desc_list += listx ## generate TLS groups from the structure file tls_group_list = [] for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## shift some Uiso displacement from the TLS T tensor to the ## individual atoms for tls_group in tls_group_list: # for atm, U in tls_group.iter_atm_Utls(): # if min(eigenvalues(U)) < 0.0: # raise UInvalid(atm, U) ## leave some B magnitude in the file for refinement (tevals, R) = eigenvectors(tls_group.T) tmin = min(tevals) T = matrixmultiply(R, matrixmultiply(tls_group.T, transpose(R))) T = T - (tmin * identity(3, Float)) tls_group.T = matrixmultiply(transpose(R), matrixmultiply(T, R)) bmin = U2B * tmin for atm, U in tls_group.iter_atm_Utls(): btls = U2B * (trace(U)/3.0) biso = atm.temp_factor bnew = biso - btls - bmin bnew = max(0.0, bnew) atm.temp_factor = bnew atm.U = None ## write TLSOUT file with new tensor values for tls_group in tls_group_list: tls_desc = tls_group.tls_desc tls_desc.set_tls_group(tls_group) fil = open(tlsout, "w") tls_file.save(fil) fil.close() ## write out a PDB file with reduced temperature factors SaveStructure(fil=pdbout, struct=struct) |
(tevals, R) = eigenvectors(tls_group.T) tmin = min(tevals) T = matrixmultiply(R, matrixmultiply(tls_group.T, transpose(R))) T = T - (tmin * identity(3, Float)) tls_group.T = matrixmultiply(transpose(R), matrixmultiply(T, R)) bmin = U2B * tmin for atm, U in tls_group.iter_atm_Utls(): btls = U2B * (trace(U)/3.0) biso = atm.temp_factor bnew = biso - btls - bmin bnew = max(0.0, bnew) atm.temp_factor = bnew atm.U = None for tls_group in tls_group_list: tls_desc = tls_group.tls_desc tls_desc.set_tls_group(tls_group) fil = open(tlsout, "w") tls_file.save(fil) fil.close() SaveStructure(fil=pdbout, struct=struct) | min_Uiso = 0.0 max_Uiso = 0.0 n = 0 sum_diff2 = 0.0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 n += 1 sum_diff2 += (tls_tf - ref_tf)**2 if ref_tf>tls_tf: max_Uiso = max(ref_tf - tls_tf, max_Uiso) else: min_Uiso = max(tls_tf - ref_tf, min_Uiso) msd = sum_diff2 / n rmsd = math.sqrt(msd) ntotal = 0 nrmsd = 0 for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 ntotal += 1 deviation = math.sqrt((tls_tf - ref_tf)**2) if deviation<=rmsd: nrmsd += 1 (T_eval, TR) = eigenvectors(tls_group.T) T = matrixmultiply(TR, matrixmultiply(tls_group.T, transpose(TR))) assert allclose(T[0,1], 0.0) assert allclose(T[0,2], 0.0) assert allclose(T[1,2], 0.0) T[0,0] = T[0,0] - min_Uiso T[1,1] = T[1,1] - min_Uiso T[2,2] = T[2,2] - min_Uiso min_T = min(T[0,0], min(T[1,1], T[2,2])) sub_T = min_T * 0.80 add_Uiso = min_T - sub_T T[0,0] = T[0,0] - sub_T T[1,1] = T[1,1] - sub_T T[2,2] = T[2,2] - sub_T tls_group.T = matrixmultiply(transpose(TR), matrixmultiply(T, TR)) tls_group.tls_desc.set_tls_group(tls_group) for atm, Utls in tls_group.iter_atm_Utls(): for aatm in atm.iter_alt_loc(): tls_tf = trace(Utls)/3.0 ref_tf = trace(aatm.get_U())/3.0 if ref_tf>tls_tf: aatm.temp_factor = ((add_Uiso) + ref_tf - tls_tf)*U2B aatm.U = None else: aatm.temp_factor = (add_Uiso) * U2B aatm.U = None SaveStructure(fil=xyzout, struct=struct) tls_file.save(open(tlsout, "w")) | def refmac5_prep(pdbin, tlsins, pdbout, tlsout): os.umask(022) ## load input structure struct = LoadStructure(fil = pdbin) ## load input TLS description tls_file = TLSFile() tls_file.set_file_format(TLSFileFormatTLSOUT()) for tlsin in tlsins: fil = open(tlsin, "r") listx = tls_file.file_format.load(fil) tls_file.tls_desc_list += listx ## generate TLS groups from the structure file tls_group_list = [] for tls_desc in tls_file.tls_desc_list: tls_group = tls_desc.construct_tls_group_with_atoms(struct) tls_group.tls_desc = tls_desc tls_group_list.append(tls_group) ## shift some Uiso displacement from the TLS T tensor to the ## individual atoms for tls_group in tls_group_list: # for atm, U in tls_group.iter_atm_Utls(): # if min(eigenvalues(U)) < 0.0: # raise UInvalid(atm, U) ## leave some B magnitude in the file for refinement (tevals, R) = eigenvectors(tls_group.T) tmin = min(tevals) T = matrixmultiply(R, matrixmultiply(tls_group.T, transpose(R))) T = T - (tmin * identity(3, Float)) tls_group.T = matrixmultiply(transpose(R), matrixmultiply(T, R)) bmin = U2B * tmin for atm, U in tls_group.iter_atm_Utls(): btls = U2B * (trace(U)/3.0) biso = atm.temp_factor bnew = biso - btls - bmin bnew = max(0.0, bnew) atm.temp_factor = bnew atm.U = None ## write TLSOUT file with new tensor values for tls_group in tls_group_list: tls_desc = tls_group.tls_desc tls_desc.set_tls_group(tls_group) fil = open(tlsout, "w") tls_file.save(fil) fil.close() ## write out a PDB file with reduced temperature factors SaveStructure(fil=pdbout, struct=struct) |
'<p style="font-size:xx-small; margin-top:%dpx; line-height:18px">' % (plot.border_width)] | '<p style="font-size:xx-small; margin-top:%dpx; line-height:12.5px">' % (plot.border_width)] | def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition) |
"""Returns the displacment matrix based on rotation about Euler | """Returns the displacement matrix based on rotation about Euler | def dmatrix(alpha, beta, gamma): """Returns the displacment matrix based on rotation about Euler angles alpha, beta, and gamma. """ return rmatrix(alpha, beta, gamma) - identity(3, Float) |
self.zplane = 500.0 self.term_alpha = 1.0 | self.zplane = 5000.0 self.term_alpha = 0.75 | def __init__(self): self.visible = True self.width = 0 self.height = 0 self.zplane = 500.0 |
self.lines = [" | self.prompt = "> " self.lines = [] | def __init__(self): self.visible = True self.width = 0 self.height = 0 self.zplane = 500.0 |
if key=='\r': self.lines.insert(0, " | ascii = ord(key) if ascii==13: self.lines.insert(0, self.prompt) elif ascii==8 or ascii==127: ln = self.lines[0] if len(ln)>len(self.prompt): self.lines[0] = ln[:-1] | def keypress(self, key): if key=='\r': self.lines.insert(0, "# ") else: self.lines[0] += key |
ambient_light = 0.5 diffuse_light = 1.0 specular_light = 1.0 ambient = (ambient_light, ambient_light, ambient_light, 1.0) diffuse = (diffuse_light, diffuse_light, diffuse_light, 1.0) specular = (specular_light, specular_light, specular_light, 1.0) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient) | glClear(GL_DEPTH_BUFFER_BIT) | def opengl_render(self): ## setup perspective matrix |
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse) glLightfv(GL_LIGHT0, GL_SPECULAR, specular) glLightfv(GL_LIGHT0, GL_POSITION, (0.0, 0.0, -1.0, 0.0)) | glLightfv(GL_LIGHT0, GL_AMBIENT, (0.0, 0.0, 0.0, 1.0)) glLightfv(GL_LIGHT0, GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0)) glLightfv(GL_LIGHT0, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0)) glLightfv(GL_LIGHT0, GL_POSITION, (0.0, 0.0, zplane + 10.0, 0.0)) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (0.2, 0.2, 0.2, 1.0)) | def opengl_render(self): ## setup perspective matrix |
self.opengl_set_material_rgba(0.0, 1.0, 0.0, self.term_alpha) | glMaterialfv( GL_FRONT, GL_AMBIENT, (0.0, 0.0, 0.0, self.term_alpha)) glMaterialfv( GL_FRONT, GL_DIFFUSE, (0.1, 0.1, 0.1, self.term_alpha)) glMaterialfv( GL_FRONT, GL_SPECULAR, (0.0, 0.1, 0.0, self.term_alpha)) glMaterialfv( GL_FRONT, GL_EMISSION, (0.0, 0.1, 0.0, self.term_alpha)) glMaterialfv(GL_FRONT, GL_SHININESS, 128.0) | def opengl_render(self): ## setup perspective matrix |
def opengl_set_material_rgba(self, r, g, b, a): """Creates a stock rendering material colored according to the given RGB values. """ glColor3f(r, g, b) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, (r, g, b, a)) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0)) glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (0.0, 0.0, 0.0, 1.0)) if a<1.0: glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 128.0) else: glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 100.0) | def opengl_set_material_rgba(self, r, g, b, a): """Creates a stock rendering material colored according to the given RGB values. """ glColor3f(r, g, b) |
|
self.glv_add_struct(struct) | glstruct = self.glv_add_struct(struct) for glchain in glstruct.glo_iter_children(): glchain.properties.update( ball_stick = True, ellipse = True) | def load_struct(self, path): """Loads the requested structure. """ info("loading: %s" % (path)) try: struct = LoadStructure( fil = path, build_properties = ("library_bonds","distance_bonds")) except IOError: error("file not found: %s" % (path)) return |
l11 = 20 + (segment.index(frag) * 6) | L11 = 20 + (segment.index(frag) * 6) | def calc_CA_pivot_TLS_least_squares_fit(segment, weight_dict=None): """Perform a LSQ-TLS fit on the given Segment object using the TLS model with amino acid side chains which can pivot about the CA atom. This model uses 20 TLS parameters and 6 libration parameters per side chain. """ ## calculate the number of parameters in the model num_atoms = segment.count_atoms() num_frags = segment.count_fragments() params = (6 * num_frags) + 20 ## use label indexing to avoid confusion! T11, T22, T33, T12, T13, T23, L11, L22, L33, L12, L13, L23, \ S1133, S2211, S12, S13, S23, S21, S31, S32 = ( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19) A = zeros((num_atoms * 6, params), Float) b = zeros(num_atoms * 6, Float) i = -1 for atm in segment.iter_atoms(): i += 1 ## set x, y, z as the vector components from the TLS origin x, y, z = atm.position ## is this fit weighted? if weight_dict!=None: w = math.sqrt(weight_dict[atm]) else: w = 1.0 ## indecies of the components of U U11 = i * 6 ## set the b vector U = atm.get_U() set_TLS_b(b, U11, U[0,0], U[1,1], U[2,2], U[0,1], U[0,2], U[1,2], w) ## set the A matrix set_TLS_A(A, U11, 0, x, y, z, w) ## independent side-chain Ls tensor frag = atm.get_fragment() if frag.is_amino_acid(): if atm.name not in ["N", "CA", "C", "O"]: atm_CA = frag.get_atom("CA") if atm_CA!=None: l11 = 20 + (segment.index(frag) * 6) xs, ys, zs = atm.position - atm_CA.position set_L_A(A, u11, l11, xs, ys, zs, w) ## solve by SVD C = solve_TLS_Ab(A, b) ## calculate the lsq residual utlsw = matrixmultiply(A, C) xw = utlsw - b lsq_residual = dot(xw, xw) ## create the T,L,S tensors T = array([ [ C[T11], C[T12], C[T13] ], [ C[T12], C[T22], C[T23] ], [ C[T13], C[T23], C[T33] ] ], Float) L = array([ [ C[L11], C[L12], C[L13] ], [ C[L12], C[L22], C[L23] ], [ C[L13], C[L23], C[L33] ] ], Float) s11, s22, s33 = calc_s11_s22_s33(C[S2211], C[S1133]) S = array([ [ s11, C[S12], C[S13] ], [ C[S21], s22, C[S23] ], [ C[S31], C[S32], s33 ] ], Float) ## caclculate the center of reaction for the group and cor_info = calc_TLS_center_of_reaction(T, L, S, zeros(3, Float)) ret_dict = {} ret_dict["T"] = cor_info["T'"] ret_dict["L"] = cor_info["L'"] ret_dict["S"] = cor_info["S'"] ret_dict["lsq_residual"] = lsq_residual ret_dict["num_atoms"] = num_atoms ret_dict["params"] = params return ret_dict |
set_L_A(A, u11, l11, xs, ys, zs, w) | set_L_A(A, U11, L11, xs, ys, zs, w) | def calc_CA_pivot_TLS_least_squares_fit(segment, weight_dict=None): """Perform a LSQ-TLS fit on the given Segment object using the TLS model with amino acid side chains which can pivot about the CA atom. This model uses 20 TLS parameters and 6 libration parameters per side chain. """ ## calculate the number of parameters in the model num_atoms = segment.count_atoms() num_frags = segment.count_fragments() params = (6 * num_frags) + 20 ## use label indexing to avoid confusion! T11, T22, T33, T12, T13, T23, L11, L22, L33, L12, L13, L23, \ S1133, S2211, S12, S13, S23, S21, S31, S32 = ( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19) A = zeros((num_atoms * 6, params), Float) b = zeros(num_atoms * 6, Float) i = -1 for atm in segment.iter_atoms(): i += 1 ## set x, y, z as the vector components from the TLS origin x, y, z = atm.position ## is this fit weighted? if weight_dict!=None: w = math.sqrt(weight_dict[atm]) else: w = 1.0 ## indecies of the components of U U11 = i * 6 ## set the b vector U = atm.get_U() set_TLS_b(b, U11, U[0,0], U[1,1], U[2,2], U[0,1], U[0,2], U[1,2], w) ## set the A matrix set_TLS_A(A, U11, 0, x, y, z, w) ## independent side-chain Ls tensor frag = atm.get_fragment() if frag.is_amino_acid(): if atm.name not in ["N", "CA", "C", "O"]: atm_CA = frag.get_atom("CA") if atm_CA!=None: l11 = 20 + (segment.index(frag) * 6) xs, ys, zs = atm.position - atm_CA.position set_L_A(A, u11, l11, xs, ys, zs, w) ## solve by SVD C = solve_TLS_Ab(A, b) ## calculate the lsq residual utlsw = matrixmultiply(A, C) xw = utlsw - b lsq_residual = dot(xw, xw) ## create the T,L,S tensors T = array([ [ C[T11], C[T12], C[T13] ], [ C[T12], C[T22], C[T23] ], [ C[T13], C[T23], C[T33] ] ], Float) L = array([ [ C[L11], C[L12], C[L13] ], [ C[L12], C[L22], C[L23] ], [ C[L13], C[L23], C[L33] ] ], Float) s11, s22, s33 = calc_s11_s22_s33(C[S2211], C[S1133]) S = array([ [ s11, C[S12], C[S13] ], [ C[S21], s22, C[S23] ], [ C[S31], C[S32], s33 ] ], Float) ## caclculate the center of reaction for the group and cor_info = calc_TLS_center_of_reaction(T, L, S, zeros(3, Float)) ret_dict = {} ret_dict["T"] = cor_info["T'"] ret_dict["L"] = cor_info["L'"] ret_dict["S"] = cor_info["S'"] ret_dict["lsq_residual"] = lsq_residual ret_dict["num_atoms"] = num_atoms ret_dict["params"] = params return ret_dict |
self.driver.glr_lighting_enable() | def draw_fan(self): """Draws a fan from the TLS group center of reaction to the TLS group backbone atoms. """ COR = self.properties["COR"] r, g, b = self.gldl_property_color_rgbf("tls_color") a = self.properties["fan_opacity"] |
|
self.driver.glr_lighting_disable() | def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {} |
|
arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"] | if arec1.has_key("serial"): arec2["serial"] = arec1["serial"] if arec1.has_key("chainID"): arec2["chainID"] = arec1["chainID"] if arec1.has_key("resName"): arec2["resName"] = arec1["resName"] if arec1.has_key("resSeq"): arec2["resSeq"] = arec1["resSeq"] if arec1.has_key("iCode"): arec2["iCode"] = arec1["iCode"] if arec1.has_key("name"): arec2["name"] = arec1["name"] if arec1.has_key("altLoc"): arec2["altLoc"] = arec1["altLoc"] if arec1.has_key("element"): arec2["element"] = arec1["element"] if arec1.has_key("charge"): arec2["charge"] = arec1["charge"] | def atom_common(arec1, arec2): arec2["serial"] = arec1["serial"] arec2["chainID"] = arec1["chainID"] arec2["resName"] = arec1["resName"] arec2["resSeq"] = arec1["resSeq"] arec2["iCode"] = arec1["iCode"] arec2["name"] = arec1["name"] arec2["altLoc"] = arec1["altLoc"] arec2["element"] = arec1["element"] arec2["charge"] = arec1["charge"] |
("sgroup", 56, 66, "string", "rjust", None), ("z", 67, 70, "integer", "rjust", None)] | ("sgroup", 56, 66, "string", "ljust", None), ("z", 67, 70, "integer", "ljust", None)] | def process(self, recs): """Returns a dictionary with attributes chain_id, num_res, and sequence_list """ seqres = {} |
assert atm.occupancy >= 0.0 and atm.occupancy < 1.0 | assert atm.occupancy >= 0.0 and atm.occupancy <= 1.0 | def calc_atom_weight(atm): """Weight the least-squares fit according to this function. """ |
def __init__(self, form, text=None): | def __init__(self, form, text): | def __init__(self, form, text=None): Page.__init__(self, form) self.text = text |
page = ErrorPage("The Job ID seems to be expired.") | page = ErrorPage(form, "The Job ID seems to be expired.") | def main(): form = cgi.FieldStorage() page = None job_id = check_job_id(form) if job_id==None: page = ErrorPage("The Job ID seems to be expired.") else: page = RefinePrepPage(form) try: print page.html_page() except RefinePrepError, err: text = '<center><p>%s</p></center>' % (err.text) page = ErrorPage(form, text) print page.html_page() except xmlrpclib.Fault, err: page = ErrorPage(form, "xmlrpclib.Fault: " +str(err)) print page.html_page() except socket.error, err: page = ErrorPage(form, "socket.error: " + str(err)) print page.html_page() |
except KeyError: | except IndexError: | def next_chain_id(suggest_chain_id): if suggest_chain_id != "": try: self.struct[suggest_chain_id] except KeyError: return suggest_chain_id for chain_id in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": try: self.struct[chain_id] except KeyError: return chain_id |
u_iso = atm_desc["u_iso"] | def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees |
|
set_TLSiso_b(B_ISOW, i, u_iso, w) | set_TLSiso_b(B_ISOW, i, atm_desc["u_iso"], w) | def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees |
U_ISOW = matrixmultiply(A_ANISOW, X_ANISO) | def lsq_fit_segment(self, frag_id1, frag_id2): """Performs a LSQ fit of TLS parameters for the protein segment starting with fragment index ifrag_start to (and including) the fragment ifrag_end. """ ## all return values here fit_info = {} ## calculate the start/end indexes of the start fragment ## and end fragment so the A matrix and b vector can be sliced ## in the correct placees |
|
return TLSGraphChainFastHybrid() | if USE_TLSMDMODULE==True: return TLSGraphChainFastHybrid() else: return TLSGraphChainHybrid() | def NewTLSGraphChain0(tls_model): """Generate and return the proper TLSGraphChain subclass for the requested TLS model. """ if tls_model=="HYBRID": return TLSGraphChainFastHybrid() if tls_model=="ANISO": return TLSGraphChainAnisotropic() if tls_model=="PLUGIN": return TLSGraphChainPlugin() raise Exception() |
'<p style="font-size:xx-small; margin-top:%dpx; line-height:12.5px">' % (plot.border_width)] | '<p style="font-size:xx-small; margin-top:%dpx">' % (plot.border_width)] l.append('<ul style="list-style-type:none;margin:0px;padding:0px">') | def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition) |
l.append('<a href=" | l.append('<li style="line-height:20px"><a href=" l.append('</ul>') | def html_chain_alignment_plot(self, chain): """generate a plot comparing all segmentations """ plot = sequence_plot.TLSSegmentAlignmentPlot() for ntls, cpartition in chain.partition_collection.iter_ntls_chain_partitions(): plot.add_tls_segmentation(cpartition) |
self.driver.glr_translate(-rho) | self.driver.glr_translate(rho) | def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ): |
self.driver.glr_translate(rho + screw) | self.driver.glr_translate(-rho + screw) | def gldl_iter_multidraw_animate(self): """ """ ## optimization: if a rotation of 0.0 degrees was already ## drawn, then there is no need to draw it again zero_rot = False for Lx_axis, Lx_rho, Lx_pitch, Lx_rot, Lx_scale in ( ("L1_eigen_vec", "L1_rho", "L1_pitch", "L1_rot", "L1_scale"), ("L2_eigen_vec", "L2_rho", "L2_pitch", "L2_rot", "L2_scale"), ("L3_eigen_vec", "L3_rho", "L3_pitch", "L3_rot", "L3_scale") ): |
gam = 0.5 | gam = 0.50 | def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {} |
step1 = rot_step * float(step) step2 = step1 + rot_step | rot_start = rot_step * float(step) rot_end = rot_step * float(step + 1) | def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {} |
rot1 = step1 * sign rot2 = step2 * sign | rot1 = rot_start * sign rot2 = rot_end * sign | def draw_tls_surface(self, Lx_eigen_vec, Lx_eigen_val, Lx_rho, Lx_pitch): """Draws the TLS probability surface for a single non-intersecting screw axis. Lx_eigen_val is the vaiance (mean square deviation MSD) of the rotation about the Lx_eigen_vec axis. """ ## create a unique list of bonds which will be used to ## render the TLS surface; this list may be passed in a argument ## to avoid multiple calculations for each screw-rotation axis bond_list = [] in_dict = {} |
self.write(self.form_string(mstring)) | self.write(self.form_mstring(mstring)) | def write_mstring(self, mstring): self.write(self.form_string(mstring)) |
sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) | sys.stderr.write("mail client not found: %s" % (conf.MSMTP)) | def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) pobj.stdin.write("\n".join(mlist)) pobj.wait() |
pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) | try: pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) except OSError: sys.stderr.write("[ERROR] mail client failed to execute: %s" % (conf.MSMTP)) return | def SendEmail(address, subject, body): if not os.path.isfile(conf.MSMTP): sys.stderr.write("Mail Client %s Not Found" % (conf.MSMTP)) return mlist = ["To: %s" % (address), "Subject: %s" % (subject), "", body] ## send mail using msmtp pobj = subprocess.Popen([conf.MSMTP, address], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 8192) pobj.stdin.write("\n".join(mlist)) pobj.wait() |
if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) | stats = {} stats["time"] = sec | def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text |
if rec["RECORD"] == "REMARK": | rec_type = rec["RECORD"] if rec_type == "REMARK": | def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text |
pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text | continue if text.find("RESOLUTION RANGE HIGH") == 1: try: stats["res"] = float(text[33:]) except ValueError: pass elif rec_type == "ATOM " or rec_type == "HETATM": try: stats["atoms"] += 1 except KeyError: stats["atoms"] = 1 elif rec_type == "ANISOU": try: stats["anisou"] += 1 except KeyError: stats["anisou"] = 1 return stats | def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text |
print str(i)+": ", read_pdb(pathx) | stats = read_pdb(pathx) print "%d:%s:%s" % (i, pathx, stats) | def read_pdb(path): sec = time.time() records = pdbmodule.read(path) sec = time.time() - sec if records != None: print "%s: %d records in %.2f seconds" % ( path, len(records), sec) else: print "%s: NO RECORDS" % (path) for rec in records: if rec["RECORD"] == "REMARK": try: text = rec["text"] except KeyError: pass else: if text.find("RESOLUTION RANGE HIGH") == 1: print text |
"[Status: %s] " % (jdict.get('status', 'None'))] | "[State: %s] " % (jdict.get('state', 'None'))] | def log_job_end(jdict): ln = "" ln += "[%s]: " % (time.asctime(time.localtime(time.time()))) ln += "Finished Job %s" % (jdict["job_id"]) log_write(ln) ## write to a special log file if jdict.get("private_job", True): private_text = "private" else: private_text = "public" submit_time = jdict.get('submit_time', 0.0) run_time_begin = jdict.get('run_time_begin', 0.0) run_time_end = jdict.get('run_time_end', 0.0) processing_time = timediff(run_time_begin, run_time_end) l = ["[Submit time: %s]" % (timestring(submit_time)), "[Start time: %s] " % (timestring(run_time_begin)), "[End time: %s] " % (timestring(run_time_end)), "[Processing time: %s] " % (processing_time), "[IP : %s] " % (jdict.get("ip_addr", "000.000.000.000")), "[Email: %s] " % (jdict.get("email", "[email protected]")), "[Privacy: %s] " % (private_text), "[Job ID: %s] " % (jdict.get("job_id", "EEK!!")), "[Structure ID: %s] " % (jdict.get("structure_id", "----")), "[Chain sizes: %s] " % (chain_size_string(jdict)), "[TLS Model: %s] " % (jdict.get('tls_model', 'None')), "[Weight: %s] " % (jdict.get('weight', 'None')), "[Atoms: %s] " % (jdict.get('include_atoms', 'None')), "[Status: %s] " % (jdict.get('status', 'None'))] try: open(conf.LOG_PATH, "a").write(" ".join(l) + "\n") except IOError: log_write("ERROR: cannot open logfile %s" % (conf.LOG_PATH)) |
if atmx.name=="CA": yield atmx | if atmx.name in ["N","CA","C","O","CB"]: yield atmx | def iter_protein_atoms(sobjx): for fragx in sobjx.iter_amino_acids(): for atmx in fragx.iter_atoms(): if atmx.name=="CA": yield atmx |
"""Iterates over all Atom objects. The iteration is preformed in order according to the Chain and Fragment ordering rules the Atom object is a part of. | """Iterates over all Atom objects according to the Structure defaults. | def iter_atoms(self): """Iterates over all Atom objects. The iteration is preformed in order according to the Chain and Fragment ordering rules the Atom object is a part of. """ for chain in self.iter_chains(): for atm in chain.iter_atoms(): yield atm |
"""Counts all Atom objects in the Structure's default alt_loc. | """Counts all Atom objects in according to the Structure defaults. | def count_atoms(self): """Counts all Atom objects in the Structure's default alt_loc. """ n = 0 for atm in self.iter_atoms(): n += 1 return n |
""" | """Iterates over all Atom objects including all atoms in multiple conformations. | def iter_all_atoms(self): """ """ for chain in self.iter_chains(): for atm in chain.iter_all_atoms(): yield atm |
"""Counts all Atom objects. | """Counts all Atom objects including all atoms in multiple conformations. | def count_all_atoms(self): """Counts all Atom objects. """ n = 0 for atm in self.iter_all_atoms(): n += 1 return n |
"Ethan Merrit") | "Ethan Merritt") | def __init__(self): gtk.Dialog.__init__(self, "About mmCIF Editor", None, 0) self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.connect("delete-event", self.delete_event_cb) self.connect("response", self.delete_event_cb) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.