rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
file.write('\n')
file.write('\n')
def writearray(filename,a): file = open(filename, 'w') if len(a.shape) == 1: a = a[:, Numeric.NewAxis] for line in a: for element in line: file.write('%le ' % element) file.write('\n') file.close()
8504f95eac9730f7cbb052e152f2de2bcd4c9e76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/8504f95eac9730f7cbb052e152f2de2bcd4c9e76/lisautils.py
lambda x: ( str(2.0*math.pi - float(x)), 'Radian' ) )
lambda x: ( float(x) != 0 and str(2.0*math.pi - float(x)) or '0', 'Radian' ) )
def convertUnit(param,unitin,unitout,paramname=''): if unitout == unitin: return (param,unitin) if unitout == "Radian": if unitin == "Degree": return ((math.pi/180.0) * float(param),'Radian') elif unitin == "DMS": # space separated dms = map(float, param.split()) return ((math.pi/180.0) * (dms[0] + dms[1]/60.0 + dms[2]/3600.0),'Radian') elif unitin == "HMS": # space separated hms = map(float, param.split()) return ((15.0*math.pi/180.0) * (hms[0] + hms[1]/60.0 + hms[2]/3600.0),'Radian') if unitout == 'String': if paramname == 'SpectralType': if unitin == '1': if float(param) == 0.0: return ('WhiteFrequency','String') elif float(param) == 2.0: return ('WhitePhase','String') elif float(param) == -2.0: return ('WhiteAcceleration','String') if unitout == '1': if paramname == 'SpectralType': if unitin == 'String': if param == 'WhiteFrequency': return ('0.0','1') elif param == 'WhitePhase': return ('2.0','1') elif param == 'WhiteAcceleration': return ('-2.0','1') raise NotImplementedError, "convertUnit(): cannot convert %s from %s to %s (parameter %s)" % (param,unitin,unitout,paramname)
0183345b8461f49c3e04b900e8a00fbc6456395c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/0183345b8461f49c3e04b900e8a00fbc6456395c/convertunit.py
lambda x: ( str(2.0*math.pi - float(x)), 'Radian' ) )
lambda x: ( float(x) != 0 and str(2.0*math.pi - float(x)) or '0', 'Radian' ) ) conversionRules['Inclination'] = ( [('SLInclination','Radian')], lambda x: ( str(float(x) < math.pi and math.pi - float(x) or 3.0*math.pi - float(x)), 'Radian' ) ) conversionRules['SLInclination'] = ( [('Inclination','Radian')], lambda x: ( str(float(x) < math.pi and math.pi - float(x) or 3.0*math.pi - float(x)), 'Radian' ) )
def convertUnit(param,unitin,unitout,paramname=''): if unitout == unitin: return (param,unitin) if unitout == "Radian": if unitin == "Degree": return ((math.pi/180.0) * float(param),'Radian') elif unitin == "DMS": # space separated dms = map(float, param.split()) return ((math.pi/180.0) * (dms[0] + dms[1]/60.0 + dms[2]/3600.0),'Radian') elif unitin == "HMS": # space separated hms = map(float, param.split()) return ((15.0*math.pi/180.0) * (hms[0] + hms[1]/60.0 + hms[2]/3600.0),'Radian') if unitout == 'String': if paramname == 'SpectralType': if unitin == '1': if float(param) == 0.0: return ('WhiteFrequency','String') elif float(param) == 2.0: return ('WhitePhase','String') elif float(param) == -2.0: return ('WhiteAcceleration','String') if unitout == '1': if paramname == 'SpectralType': if unitin == 'String': if param == 'WhiteFrequency': return ('0.0','1') elif param == 'WhitePhase': return ('2.0','1') elif param == 'WhiteAcceleration': return ('-2.0','1') raise NotImplementedError, "convertUnit(): cannot convert %s from %s to %s (parameter %s)" % (param,unitin,unitout,paramname)
0183345b8461f49c3e04b900e8a00fbc6456395c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/0183345b8461f49c3e04b900e8a00fbc6456395c/convertunit.py
conversionRules['InitialPosition'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('Armswitch','1')],
conversionRules['InitialPosition'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('ArmSwitch','1')],
def ex2ipr(e,x,s): eta = float(e) xi = float(x) sw = float(s) if sw > 0: raise NotImplementedError, "convertParameters(): LISA eta/xi configuration with sw > 0 not compatible with PseudoLISA" initpos = eta initrot = xi + initpos - 1.5*math.pi return ( (str(initpos),'Radian'), (str(initrot),'Radian') )
0183345b8461f49c3e04b900e8a00fbc6456395c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/0183345b8461f49c3e04b900e8a00fbc6456395c/convertunit.py
conversionRules['InitialRotation'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('Armswitch','1')],
conversionRules['InitialRotation'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('ArmSwitch','1')],
def ex2ipr(e,x,s): eta = float(e) xi = float(x) sw = float(s) if sw > 0: raise NotImplementedError, "convertParameters(): LISA eta/xi configuration with sw > 0 not compatible with PseudoLISA" initpos = eta initrot = xi + initpos - 1.5*math.pi return ( (str(initpos),'Radian'), (str(initrot),'Radian') )
0183345b8461f49c3e04b900e8a00fbc6456395c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/0183345b8461f49c3e04b900e8a00fbc6456395c/convertunit.py
XMLToObject['EMRI'] = ('EMRI',lisawp_emri.EMRI)
XMLToObject['ExtremeMassRatioInspiral'] = ('EMRI',lisawp_emri.EMRI)
def makeoptional(parlist): return map(lambda p: lambda s: p[0] in s or p,parlist)
01e037cebbac5678af7cf64fc66f55054bc432ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/01e037cebbac5678af7cf64fc66f55054bc432ab/lisaxml.py
self.coupletag('Param',{'Name': 'TimeOffset','Type': 's'},
self.coupletag('Param',{'Name': 'TimeOffset','Type': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
01e037cebbac5678af7cf64fc66f55054bc432ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/01e037cebbac5678af7cf64fc66f55054bc432ab/lisaxml.py
self.coupletag('Param',{'Name': 'Cadence','Unit': 's'},
self.coupletag('Param',{'Name': 'Cadence','Unit': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
01e037cebbac5678af7cf64fc66f55054bc432ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/01e037cebbac5678af7cf64fc66f55054bc432ab/lisaxml.py
self.coupletag('Param',{'Name': 'Duration','Unit': 's'},
self.coupletag('Param',{'Name': 'Duration','Unit': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
01e037cebbac5678af7cf64fc66f55054bc432ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/01e037cebbac5678af7cf64fc66f55054bc432ab/lisaxml.py
tree = p(f.read())
lines = f.read()
def __init__(self,filename): p = pyRXP.Parser()
01e037cebbac5678af7cf64fc66f55054bc432ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/01e037cebbac5678af7cf64fc66f55054bc432ab/lisaxml.py
import numpy.dft as FFT
import numpy.fft as FFT
def sn(signal,noise,stime,npatches): """Compute the optimal S/N for signal, sampled at intervals of stime, and for the total duration represented in the array, against noise represented by the time series noise; npatches overlapping periods are used to estimate the PSD of the noise.""" # compute signal spectrum without windowing or averaging sspec = spect(signal,stime,0) # compute the noise spectrum, using segment averaging nspec = spect(noise,stime,npatches) # interpolate the noise to be defined on the same frequencies # of the signal's spectrum ispec = Numeric.zeros(Numeric.shape(sspec),dtype='d') ispec[:,0] = sspec[:,0] # ispec[:,1] = arrayfns.interp(nspec[:,1],nspec[:,0],ispec[:,0]) ispec[:,1] = linearinterpolate(nspec[:,1],nspec[:,0],ispec[:,0]) # the (S/N)^2 is given by 2T times the integrated ratio # of the spectral densities (the factor of 2 because the spectral # density is one-sided); notice however that the df is 1/T, # so we need only to sum up the array containing the ratio, # and multiply by two sratio = Numeric.zeros(Numeric.shape(sspec)[0],dtype='d') sratio[1:] = sspec[1:,1] / ispec[1:,1] sn2 = 2.0 * sum(sratio[1:]) return math.sqrt(sn2)
96faa2234a8d3bf3520570203e0f9f598d917af6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/96faa2234a8d3bf3520570203e0f9f598d917af6/lisautils.py
""" % (pythonpath, pythonpath)
SYNTHLISABASE="%s"; export SYNTHLISABASE """ % (pythonpath, pythonpath, installpath)
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
20be3f400916b09f4354dd8b44f7b7ba03381033 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/20be3f400916b09f4354dd8b44f7b7ba03381033/setup.py
""" % (pythonpath, pythonpath)
setenv SYNTHLISABASE %s """ % (pythonpath, pythonpath, installpath)
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
20be3f400916b09f4354dd8b44f7b7ba03381033 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/20be3f400916b09f4354dd8b44f7b7ba03381033/setup.py
version = '1.2.4',
version = '1.2.6',
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
20be3f400916b09f4354dd8b44f7b7ba03381033 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/11274/20be3f400916b09f4354dd8b44f7b7ba03381033/setup.py
db = CountryByIP(db_file)
try: db = CountryByIP(db_file) except IOError, exc: import errno if exc.errno==errno.ENOENT: sys.exit('Database not found. Run update.py to create it.') else: sys.exit('Cannot open database: %s' % exc)
def __getitem__(self, ip): offset = 0 fp = self.fp for part in ip.split('.'): start = offset+int(part)*4 fp.seek(start) value = fp.read(4) assert len(value)==4 if value[:2]=='\xFF\xFF': if value[2:]=='\x00\x00': raise KeyError(ip) else: return value[2:] offset = struct.unpack('!I', value)[0] raise RuntimeError('ip2cc database is briken') # must never reach here
18140e6a4947032385dc45bb7a75517d092918b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8235/18140e6a4947032385dc45bb7a75517d092918b1/ip2cc.py
try: ln = pobj.stdout.readline() except IOError:
ln = pobj.stdout.readline() if alarm_triggered:
def run_tlsmd(webtlsmdd, jdict): job_id = jdict["job_id"] tlsmd = jdict["tlsmd"] ## write the tlsmd execution command out to a file open("tlsmdcmd.txt", "w").write(" ".join(tlsmd) + '\n') pobj = subprocess.Popen(tlsmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, bufsize = 0) logfil = open("log.txt", "w") chain_time_dict = {} time_chain_id = None time_begin = None signal.signal(signal.SIGALRM, sigalrm_handler) while True: signal.alarm(TIMEOUT_SECS) try: ln = pobj.stdout.readline() except IOError: os.kill(pobj.pid, signal.SIGTERM) break if len(ln) == 0: break signal.alarm(0) logfil.write(ln) logfil.flush() pobj.wait() logfil.close()
4564248791c2c46ecb11d6918a77dded1c2e117d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4564248791c2c46ecb11d6918a77dded1c2e117d/webtlsmdrund.py
if self.struct.title:
if self.struct.header:
def html_globals(self): """Output a HTML table displaying global TLSMD settings. """ if conf.globalconf.tls_model in ["ISOT", "NLISOT"]: tls_model = "Isotropic" elif conf.globalconf.tls_model in ["ANISO", "NLANISO"]: tls_model = "Anisotropic"
a0d47a7522045a3ce24a8c43b715b00567986cf4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/a0d47a7522045a3ce24a8c43b715b00567986cf4/html.py
if numpy.allclose(L1, 0.0) or type(L1)==complex:
if numpy.allclose(L1, 0.0) or type(L1)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(L2, 0.0) or type(L2)==complex:
if numpy.allclose(L2, 0.0) or type(L2)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(L3, 0.0) or type(L3)==complex:
if numpy.allclose(L3, 0.0) or type(L3)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex:
if numpy.allclose(Tr1, 0.0) or type(Tr1)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(Tr2, 0.0) or type(Tr2)==complex:
if numpy.allclose(Tr2, 0.0) or type(Tr2)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(Tr3, 0.0) or type(Tr3)==complex:
if numpy.allclose(Tr3, 0.0) or type(Tr3)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, iS[2], 0.0] ], float) ## 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: Tr1, Tr2, Tr3 = numpy.linalg.eigenvalues(T0) 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 ## 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) ## carrot-T tensor (T tensor WRT principal axes of L) cT = numpy.matrixmultiply(numpy.matrixmultiply(RL, T0), RLt) ## carrot-S tensor (S tensor WRT principal axes of L) cS = numpy.matrixmultiply(numpy.matrixmultiply(RL, S0), RLt) ## ^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) ## 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) ## calculate S'^ = S^ + L^*pRHOt cSp = cS + numpy.matrixmultiply(cL, cPRHOt) ## 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) ## 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 ## you cannot determine axis shifts from the isotropic TLS parameters cL1rho = numpy.zeros(3, float) cL2rho = numpy.zeros(3, float) 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) ## no screw pitches either rdict["L1_pitch"] = 0.0 rdict["L2_pitch"] = 0.0 rdict["L3_pitch"] = 0.0 ## rotate the newly calculated reduced-T tensor from the carrot ## coordinate system (coordinate system of L) back to the structure ## coordinate system Tiso = numpy.trace(Tp) / 3.0 rdict["rT'"] = Tiso * numpy.identity(3, float) rdict["Tr1_eigen_val"] = Tiso rdict["Tr2_eigen_val"] = Tiso rdict["Tr3_eigen_val"] = Tiso rdict["Tr1_rmsd"] = calc_rmsd(Tiso) rdict["Tr2_rmsd"] = calc_rmsd(Tiso) rdict["Tr3_rmsd"] = calc_rmsd(Tiso) return rdict
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(L1, 0.0) or type(L1)==complex:
if numpy.allclose(L1, 0.0) or type(L1)==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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(L2, 0.0) or type(L2)==complex:
if numpy.allclose(L2, 0.0) or type(L2)==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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(L3, 0.0) or type(L3)==complex:
if numpy.allclose(L3, 0.0) or type(L3)==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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex:
if numpy.allclose(Tr1, 0.0) or type(Tr1)==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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
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
56f30da138626c8c6f397e7d28b00e0126c279a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/56f30da138626c8c6f397e7d28b00e0126c279a7/TLS.py
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"))
4379681d356c5fb9927aca5146e2ef9bbeadf005 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4379681d356c5fb9927aca5146e2ef9bbeadf005/refineprep.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
(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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
742140185bc8b6b74df991525abcac33bdc82b5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/742140185bc8b6b74df991525abcac33bdc82b5f/TLS.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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)
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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)
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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()
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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
98cad825ba0fabe8950b29dee5164e5a7571a5e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/98cad825ba0fabe8950b29dee5164e5a7571a5e1/Structure.py
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)
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
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()
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
""" """
"""Adds a BetaSheet to the default Model object. """ assert self.default_model!=None
def add_beta_sheet(self, beta_sheet): """ """ self.default_model.add_beta_sheet(beta_sheet)
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
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()
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
""" """
"""Adds a Site object to the default Model. """ assert self.default_model!=None
def add_site(self, site): """ """ self.default_model.add_site(site)
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
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()
84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/84b0a6ed8a31fcf58d51b7ad2660eeb7ebbb9c43/Structure.py
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
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
class AppFrame(wx.Frame):
class ViewerFrame(wx.Frame):
def glv_redraw(self): self.Refresh(False)
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
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)
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
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)
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
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)
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
self.frame = AppFrame()
self.frame = ViewerFrame()
def OnInit(self): self.frame = AppFrame() self.frame.Show() self.SetTopWindow(self.frame) return True
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
def main(): app = App()
def main(files): app = ViewerApp() for file in files: app.frame.load_structure(file)
def main(): app = App() app.MainLoop()
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
main()
main(sys.argv[1:])
def main(): app = App() app.MainLoop()
de61a32ba86556190e884def657cad76bf6b59d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/de61a32ba86556190e884def657cad76bf6b59d7/wxviewer.py
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)
4db0b38d0e489382932399280884aade18cbc4c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4db0b38d0e489382932399280884aade18cbc4c0/GLViewer.py
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
4db0b38d0e489382932399280884aade18cbc4c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4db0b38d0e489382932399280884aade18cbc4c0/GLViewer.py
gl_call_list(self.name)
glCallList(self.name)
def gl_call_list(self): #print "gl_call_list = ",self.name
4db0b38d0e489382932399280884aade18cbc4c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4db0b38d0e489382932399280884aade18cbc4c0/GLViewer.py
def set_origin(self, origin): """Reset the origin of the draw list. """ self.origin = origin
4db0b38d0e489382932399280884aade18cbc4c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/4db0b38d0e489382932399280884aade18cbc4c0/GLViewer.py
if pixel_width>pixel_height:
if pixel_width > pixel_height:
def glr_construct_header(self): """Creates the header for the render program. """ tsz_width = 16 tsz_height = 16 xtiles = int(round(self.width / float(tsz_width))) ytiles = int(round(self.height / float(tsz_height)))
333b2e69b52eae1911432cd9bd3889427c3a3d97 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/333b2e69b52eae1911432cd9bd3889427c3a3d97/R3DDriver.py
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)
baa591abc91d0ad43d45719554da1e6ed072356b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/baa591abc91d0ad43d45719554da1e6ed072356b/webtlsmd.py
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)
0833e50284e4326c9e648fdbd4ff3ecf927e310b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0833e50284e4326c9e648fdbd4ff3ecf927e310b/refineprep.py
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)
0833e50284e4326c9e648fdbd4ff3ecf927e310b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0833e50284e4326c9e648fdbd4ff3ecf927e310b/refineprep.py
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)
0833e50284e4326c9e648fdbd4ff3ecf927e310b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0833e50284e4326c9e648fdbd4ff3ecf927e310b/refineprep.py
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)
0833e50284e4326c9e648fdbd4ff3ecf927e310b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0833e50284e4326c9e648fdbd4ff3ecf927e310b/refineprep.py
(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)
0833e50284e4326c9e648fdbd4ff3ecf927e310b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0833e50284e4326c9e648fdbd4ff3ecf927e310b/refineprep.py
'<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)
cb5706ec3ac3b007f4d2780717fcb6c7e7ebeab6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/cb5706ec3ac3b007f4d2780717fcb6c7e7ebeab6/html.py
"""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)
cac2639bc762b0d5b95beca937599b3632850311 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/cac2639bc762b0d5b95beca937599b3632850311/AtomMath.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
self.lines = ["
self.prompt = "> " self.lines = []
def __init__(self): self.visible = True self.width = 0 self.height = 0 self.zplane = 500.0
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
def opengl_render(self): ## setup perspective matrix
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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)
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
878842438ad5dcf87f49337f7c582fe163496f4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/878842438ad5dcf87f49337f7c582fe163496f4b/glutviewer.py
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
0779a1d6628e6acba115b7ba9004fcb5efdcc8b7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0779a1d6628e6acba115b7ba9004fcb5efdcc8b7/TLS.py
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
0779a1d6628e6acba115b7ba9004fcb5efdcc8b7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0779a1d6628e6acba115b7ba9004fcb5efdcc8b7/TLS.py
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"]
0779a1d6628e6acba115b7ba9004fcb5efdcc8b7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10674/0779a1d6628e6acba115b7ba9004fcb5efdcc8b7/TLS.py