def JlInverse(x): phi = np.linalg.norm(x) multiplier = phi / (2 * np.pi) if phi > SO3._EPSILON and abs(multiplier - np.round(multiplier)) > SO3._EPSILON: a = x / phi c1 = phi / 2 * np.cot(phi / 2) c2 = 1.0 - c1 c3 = -phi / 2 return c1 * np.eye(3) + c2 * np.outer(a, a) + c3 * SO3.hat(a) else: X = SO3.hat(x) X2 = X @ X X4 = X2 @ X2 return np.eye(3) - X / 2 + X2 / 12 - X4 / 720
def resolution_volume_correction(data): # Requires constant-Q scan with fixed incident energy, Ei pass #TODO - CHECK - taken from the IDL # resCor = Norm/(cot(A6/2)*Ef^1.5) # where Norm = Ei^1.5 * cot(asin(!pi/(0.69472*dA*sqrt(Ei)))) '' for i in len(data.get(Ei)) thetaA = N.radians(data.get(a6)[i]/2.0) arg = asin(N.pi/(0.69472*dA*sqrt(double(data.get(Ei)[i])))) norm = (Ei^1.5) / tan(arg) cotThetaA = 1/tan(thetaA) resCor = norm/(cotThetaA * (Ef^1.5)) N.exp((ki/kf) ** 3) * (1/N.tan(thetaM)) / (1/N.cot(thetaA)) ''
def getBrownianDamping2(t, lmbda, Lambda, T=298.0, cutoff=1e-6): """Calculate pure electronic dephasing due to interaction with solvent using frictionally overdamped Brownian oscillator model. The real part of g(t) leads to a Gaussian broadening of the spectra, while the imaginary part leads to a solvent induced Stokes shift. :param array t: Time axis in fs. :param float lmbda: Solvent contribution to reorganization energy (cm-1). :param float Lambda: Inverse of characteristic time scale for solvent fluctuations (fs-1). :param float T: Temperature (K, default = 298 K). :param float cutoff: Cutoff value for summation over brownian oscillators (default 1e-6). :returns: Damping term in the time domain, :math:`e^{-g(t)}`. .. seealso:: This implementation is taken from Kulinowksi, *J Phys Chem* **99**, 9017 (1995), Eqs. (10a) to (10d). """ beta = 1.0 / (kB * np.absolute(T)) lmb = lmbda / hbar # convert to fs-1 # calculate real part as sum over oscillators gR = 0.0 i = 1.0 while 1: nun = 2.0 * np.pi / (hbar * beta) * i # frequency of ith oscillator dg = (np.exp(-nun * t) + nun * t - 1.0) / (nun * (nun ** 2 - Lambda ** 2)) gR = gR + dg i = i + 1.0 if np.sum(np.absolute(np.dg)) / np.sum(np.absolute(gR)) < cutoff: break gR = gR * 4.0 * lmb * Lambda / (hbar * beta) gR = gR + (lmb / Lambda) * np.cot(hbar * beta * Lambda / 2.0) * (np.exp(-Lambda * t) + Lambda * t - 1.0) # calculate imaginary part = Stokes shift gI = -(lmb / Lambda) * (np.exp(-Lambda * t) - 1.0) # assemble g = gR + 1j * gI # dimensionless return np.exp(-g)
def ejecutar_trigo(self, funcion): if funcion.funcion == 'acos': try: return np.acos(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en acos ') return 0 elif funcion.funcion == 'acosd': try: return np.acosd(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en acosd ') return 0 elif funcion.funcion == 'asin': try: return np.asin(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en asin ') return 0 elif funcion.funcion == 'asind': try: return np.asind(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en asind ') return 0 elif funcion.funcion == 'atan': try: return np.atan(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores ') return 0 elif funcion.funcion == 'atand': try: return np.atand(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores atand ') return 0 elif funcion.funcion == 'atan2': try: return np.atan2(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en atan2 ') return 0 elif funcion.funcion == 'cos': try: return np.cos(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en cos ') return 0 elif funcion.funcion == 'cosd': try: return np.cosd(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores cosd cosd') return 0 elif funcion.funcion == 'cot': try: return np.cot(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores cot') return 0 elif funcion.funcion == 'cotd': try: return np.cotd(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en cotd ') return 0 elif funcion.funcion == 'sin': try: return np.sin(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en sin ') return 0 elif funcion.funcion == 'sind': try: return np.sind(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en sind ') return 0 elif funcion.funcion == 'tan': try: return np.tan(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en tan ') return 0 elif funcion.funcion == 'tand': try: return np.tand(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en tand') return 0 elif funcion.funcion == 'sinh': try: return np.sinh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en sinh') return 0 elif funcion.funcion == 'cosh': try: return np.cosh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en cosh ') return 0 elif funcion.funcion == 'tanh': try: return np.tanh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en tanh ') return 0 elif funcion.funcion == 'asinh': try: return np.asinh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en asinh') return 0 elif funcion.funcion == 'acosh': try: return np.acosh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en acosh ') return 0 elif funcion.funcion == 'atanh': try: return np.atanh(self.aritexc.ejecutar_operacion(funcion.op1)) except: errorsem.append('error al convertir valores en atanh ') return 0
[ 0.75390225, -0.14550003, -0.91113026]]) >>> np.sec(arr) Traceback (most recent call last): File "<pyshell#92>", line 1, in <module> np.sec(arr) AttributeError: module 'numpy' has no attribute 'sec' >>> np.tan(arr) array([[ 0.75959514, 2.42014405, 0.63058335], [ 8.75545783, 5.58260044, -1.44723779], [ 0.858882 , -0.58088694, -0.49696815]]) >>> np.cosec(arr2) Traceback (most recent call last): File "<pyshell#94>", line 1, in <module> np.cosec(arr2) AttributeError: module 'numpy' has no attribute 'cosec' >>> np.cot(arr) Traceback (most recent call last): File "<pyshell#95>", line 1, in <module> np.cot(arr) AttributeError: module 'numpy' has no attribute 'cot' >>> np.log(arr) array([[-0.4313773 , 0.16463603, 1.9236338 ], [ 0.37643076, 1.51185613, 2.13518633], [ 1.34839014, 1.75040575, 2.19316733]]) >>> np.abs(arr2) array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> np.abs(arr) array([[0.64961377, 1.17896393, 6.84578954], [1.45707464, 4.53514081, 8.45862244],
def christoffel(radial, theta, a, i, j, k): if i == 0: # 0?? ################################ if j == 0: # 00? ------------------------------- if k == 0: # 000 return 0 elif k == 1: # 001 return ( -2.0 * (a ** (2) + radial ** (2)) * (a ** (2) - 2.0 * radial ** (2) + a ** (2) * np.cos(2.0 * theta)) ) / ( (a ** (2) + (-2.0 + radial) * radial) * np.power(a ** (2) + 2.0 * radial ** (2) + a ** (2) * np.cos(2.0 * theta), 2) ) elif k == 2: # 002 return 0 elif k == 3: # 003 return 0 else: print("ERROR: 00?") return 0 elif j == 1: # 01? ------------------------------- if k == 0: # 010 return 1.0 / ((-2.0 + radial) * radial) elif k == 1: # 011 return 0 elif k == 2: # 012 return 0 elif k == 3: # 013 return 0 else: print("ERROR: 01?") return 0 elif j == 2: # 02? ------------------------------- if k == 0: # 020 return 0 elif k == 1: # 021 return 0 elif k == 2: # 022 return 0 elif k == 3: # 023 return 0 else: print("ERROR: 02?") return 0 elif j == 3: # 03? ------------------------------- if k == 0: # 030 return 0 elif k == 1: # 031 return 0 elif k == 2: # 032 return 0 elif k == 3: # 033 return 0 else: print("ERROR: 03?") return 0 else: print("ERROR: 0??") return 0 elif i == 1: # 1?? ################################ if j == 0: # 10? ------------------------------- if k == 0: # 100 return (-2.0 + radial) / (np.power(radial, 3.0)) elif k == 1: # 101 return 0 elif k == 2: # 102 return 0 elif k == 3: # 103 return 0 else: print("ERROR: 10?") return 0 elif j == 1: # 11? ------------------------------- if k == 0: # 110 return 0 elif k == 1: # 111 return 1.0 / (2.0 * radial - np.power(radial, 2.0)) elif k == 2: # 112 return 0 elif k == 3: # 113 return 0 else: print("ERROR: 11?") return 0 elif j == 2: # 12? ------------------------------- if k == 0: # 120 return 0 elif k == 1: # 121 return 0 elif k == 2: # 122 return 2.0 - radial elif k == 3: # 123 return 0 else: print("ERROR: 12?") return 0 elif j == 3: # 13? ------------------------------- if k == 0: # 130 return 0 elif k == 1: # 131 return 0 elif k == 2: # 132 return 0 elif k == 3: # 133 return -((-2.0 + radial) * (np.power(np.sin(theta), 2.0))) else: print("ERROR: 13?") return 0 else: print("ERROR: 1??") return 0 elif i == 2: # 2?? ################################ if j == 0: # 20? ------------------------------- if k == 0: # 200 return 0 elif k == 1: # 201 return 0 elif k == 2: # 202 return 0 elif k == 3: # 203 return 0 else: print("ERROR: 20?") return 0 elif j == 1: # 21? ------------------------------- if k == 0: # 210 return 0 elif k == 1: # 211 return 0 elif k == 2: # 212 return 1.0 / radial elif k == 3: # 213 return 0 else: print("ERROR: 21?") return 0 elif j == 2: # 22? ------------------------------- if k == 0: # 220 return 0 elif k == 1: # 221 return 1.0 / radial elif k == 2: # 222 return 0 elif k == 3: # 223 return 0 else: print("ERROR: 22?") return 0 elif j == 3: # 23? ------------------------------- if k == 0: # 230 return 0 elif k == 1: # 231 return 0 elif k == 2: # 232 return 0 elif k == 3: # 233 return -(np.cos(theta) * np.sin(theta)) else: print("ERROR: 23?") return 0 else: print("ERROR: 2??") return 0 elif i == 3: # 3?? ################################ if j == 0: # 30? ------------------------------- if k == 0: # 300 return 0 elif k == 1: # 301 return 0 elif k == 2: # 302 return 0 elif k == 3: # 303 return 0 else: print("ERROR: 30?") return 0 elif j == 1: # 31? ------------------------------- if k == 0: # 310 return 0 elif k == 1: # 311 return 0 elif k == 2: # 312 return 0 elif k == 3: # 313 return 1.0 / radial else: print("ERROR: 31?") return 0 elif j == 2: # 32? ------------------------------- if k == 0: # 320 return 0 elif k == 1: # 321 return 0 elif k == 2: # 322 return 0 elif k == 3: # 323 return np.cot(theta) else: print("ERROR: 32?") return 0 elif j == 3: # 33? ------------------------------- if k == 0: # 330 return 0 elif k == 1: # 331 return 1.0 / radial elif k == 2: # 332 return np.cot(theta) elif k == 3: # 333 return 0 else: print("ERROR: 33?") return 0 else: print("ERROR: 3??") return 0 else: print("ERROR: This should not happen... If you see this, go home for the day") return 0
def theta_motion(theta): return q_const + (a * np.cos(theta)) ** 2 - (lambda_const * np.cot(theta)) ** 2
''' Numerically solves the equation l = -cot l. Produces a plot of l versus -cot l and produces a text file of n zeroes of f(l) = l + cot l. Usage: eigenvaluePlot.py filename ''' import matplotlib.pyplot as plt import numpy as np import sys filename = sys.argv[2] # initial conditions n = 500 l = np.arange(0, n, 1) # plotting and saving plot plt.figure(1) plt.plot(l, l, 'r',l, np.cot(l), 'b') plt.savefig(filename) # generating zeroes
def AccMonoMosaWav(DeltaLambda, Lambda, SigmaYp, eta, ThetaB): return sqrt(6/pi) * exp( - (DeltaLambda/Lambda)**2 / 2 /((SigmaYp**2+eta**2)*np.cot(ThetaB))) #Sigma Yp ???
def AccMonoPlanWav(DeltaLambda, Lambda, SigmaYp, ThetaB): return sqrt(6/pi) * exp( - (DeltaLambda/Lambda)**2 / (2*(SigmaYp**2+Wd**2/12)*np.cot(ThetaB)**2) )
x = np.arange(0, c * (np.pi), 0.1) y = np.csc(x) plt.plot(x, y) plt.show() elif b == "sec": import matplotlib.pyplot as plt import numpy as np x = np.arange(0, c * (np.pi), 0.1) y = np.sec(x) plt.plot(x, y) plt.show() elif b == "cot": import matplotlib.pyplot as plt import numpy as np x = np.arange(0, c * (np.pi), 0.1) y = np.cot(x) plt.plot(x, y) plt.show() else: print("INVALID INPUT") elif d == "EXPONENTIAL": f = int(input("ENTER THE FIRST VALUE OF RANGE:")) g = int(input("ENTER THE LAST VALUE OF RANGE:")) e = 2.718281828 import matplotlib.pyplot as plt import numpy as np x = np.arange(f, g, 0.1) y = np.e**x plt.plot(x, y) plt.show() elif d == "LOGARITHMIC":
def calculateONP(self, eq): stack = [] for c in eq: t = self.getType(c) if t == 1: # if it is a number stack.append(c) elif t == -1: # if it is an operation if len(stack) < 2: raise CalculationError(eq, 'STACK IS EMPTY') v2 = float(stack.pop()) v1 = float(stack.pop()) if c == '+': v1 += v2 elif c == '-': v1 -= v2 elif c == '*': v1 *= v2 elif c == '/': v1 /= v2 elif c == '^': v1 = np.pow(v1, v2) if isinstance(v1, complex): raise CalculationError(eq, 'COMPLEX SOLUTION') stack.append(v1) elif t == -3: if len(stack) < 1: raise CalculationError(eq, 'STACK IS EMPTY') v = float(stack.pop()) ang = v if c[-1] == 'r' else np.radians(v) if c == 'abs': v = np.abs(v) if c == 'exp': v = np.exp(v) elif c == 'ln': v = np.log(v) elif c == 'log2': v = np.log2(v) elif c == 'log10': c = np.log10(v) elif c == 'sin' or 'sinr': v = np.sin(ang) elif c == 'cos' or 'cosr': v = np.cos(ang) elif c == 'tg' or 'tgr': v = np.tan(ang) elif c == 'ctg' or 'ctgr': v = np.cot(ang) elif c == 'sinh' or 'sinhr': v = np.sinh(ang) elif c == 'cosh' or 'coshr': v = np.cosh(ang) elif c == 'tgh' or 'tghr': v = np.tanh(ang) elif c == 'ctgh' or 'ctghr': v = np.coth(ang) if np.isnan(v): raise CalculationError(c, 'UNEXPECTED NAN VALUE') stack.append(v) return stack[0]
def evaluate(self): return np.cot(self.operand[0].evaluate())