All Samples(1983) | Call(1850) | Derive(0) | Import(133)
pow(x, y) Return x**y (x to the power of y).
src/l/a/Langtangen-HEAD/src/py/examples/efficiency/pyefficiency.py Langtangen(Download)
def py_loop1_sincos_x2(x):
from math import sin, cos, pow # scalar sin
for i in xrange(len(x)):
x[i] = sin(x[i])*cos(x[i]) + x[i]**2
return x
def py_loop2_sincos_x2(x):
src/h/e/heatsource-HEAD/src/Stream/PyHeatsource.py heatsource(Download)
from __future__ import division from math import pow, sqrt, sin, log, atan, sin, cos, pi, tan, acos, exp,radians, degrees, log10 from random import randint from bisect import bisect class HeatSourceError(Exception): pass
Dummy1 = sin(toRadians*Obliquity) * sin(toRadians*SunApparentLong)
Declination = toDegrees*(atan(Dummy1 / sqrt(-Dummy1 * Dummy1 + 1)))
SunRadVector = (1.000001018 * (1 - pow(Eccentricity,2))) / (1 + Eccentricity * cos(toRadians*(GeoMeanAnomalySun + SunEqofCenter)))
#======================================================
#Equation of time (minutes)
Dummy = pow((tan(Obliquity * pi / 360)),2)
Dummy1 = sin(toRadians*(2 * GeoMeanLongSun))
Dummy2 = sin(toRadians*(GeoMeanAnomalySun))
Dummy3 = cos(toRadians*(2 * GeoMeanLongSun))
Dummy4 = sin(toRadians*(4 * GeoMeanLongSun))
Dummy5 = sin(toRadians*(2 * GeoMeanAnomalySun))
Et = toDegrees*(4 * (Dummy * Dummy1 - 2 * Eccentricity * Dummy2 + 4 * Eccentricity * Dummy * Dummy2 * Dummy3 - 0.5 * pow(Dummy,2) * Dummy4 - 1.25 * pow(Eccentricity,2) * Dummy5))
else:
Dummy = tan(toRadians*(AtmElevation))
if AtmElevation > 5:
RefractionCorrection = 58.1 / Dummy - 0.07 / pow(Dummy,3) + 0.000086 / pow(Dummy,5)
elif AtmElevation > -0.575:
RefractionCorrection = 1735 + AtmElevation * (-518.2 + AtmElevation * (103.4 + AtmElevation * (-12.79 + AtmElevation * 0.711)))
else:
# then adds a slight change to the depth and solves it again. It should iterate for a solution to depth
# within about 5-6 solutions.
while Converge > 1e-7:
Fy = (D_est * (W_b + z * D_est)) * pow(((D_est * (W_b + z * D_est)) / (W_b + 2 * D_est * sqrt(1+ pow(z,2)))),power) - ((n * Q_est) / sqrt(S))
thed = D_est + dy
Fyy = (thed * (W_b + z * thed)) * pow((thed * (W_b + z * thed))/ (W_b + 2 * thed * sqrt(1+ pow(z,2))),power) - (n * Q_est) / sqrt(S)
dFy = (Fyy - Fy) / dy
count += 1
# Use the calculated wetted depth to calculate new channel characteristics
A = (D_est * (W_b + z * D_est))
Pw = (W_b + 2 * D_est * sqrt(1+ pow(z,2)))
Rh = A/Pw
Ww = W_b + 2 * z * D_est
U = Q_est / A
# THis is a sheer velocity estimate, followed by an estimate of numerical dispersion
if S == 0.0:
Shear_Velocity = U
else:
Shear_Velocity = sqrt(9.8 * D_est * S)
Dispersion = (0.011 * pow(U,2.0) * pow(Ww,2.0)) / (D_est * Shear_Velocity)
else:
Shear_Velocity = sqrt(9.8 * D_est * S)
Dispersion = (0.011 * pow(U,2.0) * pow(Ww,2.0)) / (D_est * Shear_Velocity)
if (Dispersion * dt / pow(dx,2.0)) > 0.5:
Dispersion = (0.45 * pow(dx,2)) / dt
#Dispersion = 50
return D_est, A, Pw, Rh, Ww, U, Dispersion
src/a/n/analyticgeom-HEAD/trunk/modulos/Cuadricas.py analyticgeom(Download)
from pivy.coin import * from PyQt4 import QtGui, QtCore, uic from modulos.util import main, lee, conecta from math import sqrt, cos, sin, asin, pi, pow from MallaBase2 import MallaBase, ParametricPlot3D, creaVars, Eq, creaVarParam, creaOpParam from Visor import Visor #import psyco
def rangox(self,w=0):
a = sqrt(16 - 16*w + pow(w,2))
return (
(2*sqrt(pow(-2 + w,2)))/a,
(2*sqrt(40 - 40*w + pow(w,2)))/a, 40)
def rangox2(self,w=0):
a = sqrt(16 - 16*w + pow(w,2))
return ((2*sqrt(pow(-2 + w,2)))/a,3, 40)
def func1(w, r, t):
a = 16 -16*w +w**2
b = -1 + w
return (
.25*r*sqrt(a/(1 - w))*cos(t),
.25*sqrt(abs(((-a)*pow(r,2) + 4*pow(-2 + w,2))/b)),
(2*w + sqrt(a/pow(b,2))*b*r*sin(t))/(4*b))
def func2(w, r, t):
a = 16 -16*w +w**2
b = -1 + w
return (
.25*r*sqrt(a/(1 - w))*cos(t),
-.25*sqrt(abs(((-a)*pow(r,2) + 4*pow(-2 + w,2))/b)),
(2*w + sqrt(a/pow(b,2))*b*r*sin(t))/(4*b))
src/a/n/analyticgeom-HEAD/modulos/Cuadricas.py analyticgeom(Download)
from pivy.coin import * from PyQt4 import QtGui, QtCore, uic from modulos.util import main, lee, conecta from math import sqrt, cos, sin, asin, pi, pow from MallaBase2 import MallaBase, ParametricPlot3D, creaVars, Eq, creaVarParam, creaOpParam from Visor import Visor #import psyco
def rangox(self,w=0):
a = sqrt(16 - 16*w + pow(w,2))
return (
(2*sqrt(pow(-2 + w,2)))/a,
(2*sqrt(40 - 40*w + pow(w,2)))/a, 40)
def rangox2(self,w=0):
a = sqrt(16 - 16*w + pow(w,2))
return ((2*sqrt(pow(-2 + w,2)))/a,3, 40)
def func1(w, r, t):
a = 16 -16*w +w**2
b = -1 + w
return (
.25*r*sqrt(a/(1 - w))*cos(t),
.25*sqrt(abs(((-a)*pow(r,2) + 4*pow(-2 + w,2))/b)),
(2*w + sqrt(a/pow(b,2))*b*r*sin(t))/(4*b))
def func2(w, r, t):
a = 16 -16*w +w**2
b = -1 + w
return (
.25*r*sqrt(a/(1 - w))*cos(t),
-.25*sqrt(abs(((-a)*pow(r,2) + 4*pow(-2 + w,2))/b)),
(2*w + sqrt(a/pow(b,2))*b*r*sin(t))/(4*b))
src/p/y/pyquante-HEAD/trunk/PyQuante/MINDO3.py pyquante(Download)
import Defaults from Constants import bohr2ang,e2,ev2kcal from MINDO3_Parameters import axy,Bxy from math import sqrt,exp,pow from NumWrap import zeros,eigh,dot,array from LA2 import mkdens,trace2 from PyQuante.Convergence import SimpleAverager
def get_gamma(atomi,atomj):
"Coulomb repulsion that goes to the proper limit at R=0"
R2 = atomi.dist2(atomj)*bohr2ang**2
return e2/sqrt(R2+0.25*pow(atomi.rho+atomj.rho,2))
def get_g(bfi,bfj):
"Coulomb-like term for orbitals on the same atom"
beta = get_beta0(atomi.atno,atomj.atno)
R2 = atomi.dist2(atomj)*bohr2ang**2
R = sqrt(R2)
c2 = 0.25*pow(atomi.rho+atomj.rho,2)
for dir in xrange(3):
Fij = 0 # Force between atoms iat and jat in direction dir
# initialize some constants
delta = atomi.r[dir]-atomj.r[dir]
c1 = delta*atomi.Z*atomj.Z*e2/R
dr1 = e2*delta*pow(R2+c2,-1.5)
or (atomj.atno == 1
and (atomi.atno == 7 or atomi.atno == 8))):
# Special case of NH or OH bonds
Fij += -c1*alpha*(1/R2 - R*pow(R2+c2,-1.5)
+ 1/R - 1/sqrt(R2+c2))*exp(-R) \
- c1*R*pow(R2+c2,-1.5)
else:
Fij += -c1*(1/R2 - R*pow(R2+c2,-1.5) + alpha/R
- alpha/sqrt(R2+c2))*exp(-alpha*R) \
- c1*R*pow(R2+c2,-1.5)
Dij = D[bfi.index,bfj.index]
# exchange is the first term, coulomb is second:
Fij += 0.5*dr1*pow(Dij,2)-dr1*Dii*Djj
# Now sum total forces and convert to kcal/mol
Forces[iat][dir] += ev2kcal*Fij
def mopac_overlap(bfi,bfj): # from the routine gover.f
cgbfi,cgbfj = bfi.cgbf,bfj.cgbf
ri = cgbfi.origin # distance in bohr
rj = cgbfj.origin
RR = pow(ri[0]-rj[0],2)+pow(ri[1]-rj[1],2)+pow(ri[2]-rj[2],2)
itype = bfi.type
jtype = bfj.type
if adb*RR < 90:
Sij += primi.coef*primj.coef*\
pow(2*sqrt(apb)/amb,1.5)*exp(-adb*RR)*abn
return Sij
def mopac_doverlap(bfi,bfj,direction): # from the routine dcart.f
cgbfi,cgbfj = bfi.cgbf,bfj.cgbf
ri = cgbfi.origin # distance in bohr
rj = cgbfj.origin
RR = pow(ri[0]-rj[0],2)+pow(ri[1]-rj[1],2)+pow(ri[2]-rj[2],2)
else:
#is = 8 (p'|p')
del2 = ri[jtype-1]-rj[jtype-1]
abn=-8*pow(adb,2)*del1/sqrt(apb)*(0.5-adb*del2*del2)/A0
elif (direction != itype-1) and (direction != jtype-1):
#is = 7(p'|p")
del2 = ri[itype-1] - rj[itype-1]
del3 = ri[jtype-1] - rj[jtype-1]
abn=8*pow(adb,3)*del1*del2*del3/sqrt(apb)/A0
else:
#is = 6 (p|p') or (p'|p)
del2 = ri[itype+jtype-direction-2]-rj[itype+jtype-direction-2]
abn=-4*adb*adb*del2/sqrt(apb)*(1-2*adb*del1*del1)/A0
SS = pow(2*sqrt(apb)/amb,1.5)*exp(-adr)*abn
src/p/y/pyquante-HEAD/PyQuante/MINDO3.py pyquante(Download)
from Constants import bohr2ang,e2,ev2kcal from MINDO3_Parameters import axy,Bxy from math import sqrt,exp,pow from NumWrap import zeros,eigh,dot,array from LA2 import mkdens,trace2 from PyQuante.Convergence import SimpleAverager
def get_gamma(atomi,atomj):
"Coulomb repulsion that goes to the proper limit at R=0"
R2 = atomi.dist2(atomj)*bohr2ang**2
return e2/sqrt(R2+0.25*pow(atomi.rho+atomj.rho,2))
def get_g(bfi,bfj):
"Coulomb-like term for orbitals on the same atom"
beta = get_beta0(atomi.atno,atomj.atno)
R2 = atomi.dist2(atomj)*bohr2ang**2
R = sqrt(R2)
c2 = 0.25*pow(atomi.rho+atomj.rho,2)
for dir in xrange(3):
Fij = 0 # Force between atoms iat and jat in direction dir
# initialize some constants
delta = atomi.r[dir]-atomj.r[dir]
c1 = delta*atomi.Z*atomj.Z*e2/R
dr1 = e2*delta*pow(R2+c2,-1.5)
or (atomj.atno == 1
and (atomi.atno == 7 or atomi.atno == 8))):
# Special case of NH or OH bonds
Fij += -c1*alpha*(1/R2 - R*pow(R2+c2,-1.5)
+ 1/R - 1/sqrt(R2+c2))*exp(-R) \
- c1*R*pow(R2+c2,-1.5)
else:
Fij += -c1*(1/R2 - R*pow(R2+c2,-1.5) + alpha/R
- alpha/sqrt(R2+c2))*exp(-alpha*R) \
- c1*R*pow(R2+c2,-1.5)
Dij = D[bfi.index,bfj.index]
# exchange is the first term, coulomb is second:
Fij += 0.5*dr1*pow(Dij,2)-dr1*Dii*Djj
# Now sum total forces and convert to kcal/mol
Forces[iat][dir] += ev2kcal*Fij
def mopac_overlap(bfi,bfj): # from the routine gover.f
cgbfi,cgbfj = bfi.cgbf,bfj.cgbf
ri = cgbfi.origin # distance in bohr
rj = cgbfj.origin
RR = pow(ri[0]-rj[0],2)+pow(ri[1]-rj[1],2)+pow(ri[2]-rj[2],2)
itype = bfi.type
jtype = bfj.type
if adb*RR < 90:
Sij += primi.coef*primj.coef*\
pow(2*sqrt(apb)/amb,1.5)*exp(-adb*RR)*abn
return Sij
def mopac_doverlap(bfi,bfj,direction): # from the routine dcart.f
cgbfi,cgbfj = bfi.cgbf,bfj.cgbf
ri = cgbfi.origin # distance in bohr
rj = cgbfj.origin
RR = pow(ri[0]-rj[0],2)+pow(ri[1]-rj[1],2)+pow(ri[2]-rj[2],2)
else:
#is = 8 (p'|p')
del2 = ri[jtype-1]-rj[jtype-1]
abn=-8*pow(adb,2)*del1/sqrt(apb)*(0.5-adb*del2*del2)/A0
elif (direction != itype-1) and (direction != jtype-1):
#is = 7(p'|p")
del2 = ri[itype-1] - rj[itype-1]
del3 = ri[jtype-1] - rj[jtype-1]
abn=8*pow(adb,3)*del1*del2*del3/sqrt(apb)/A0
else:
#is = 6 (p|p') or (p'|p)
del2 = ri[itype+jtype-direction-2]-rj[itype+jtype-direction-2]
abn=-4*adb*adb*del2/sqrt(apb)*(1-2*adb*del1*del1)/A0
SS = pow(2*sqrt(apb)/amb,1.5)*exp(-adr)*abn
src/p/y/pyquante-HEAD/trunk/PyQuante/PGBF.py pyquante(Download)
distribution. """ from math import sqrt,pi,pow,exp from NumWrap import array from PyQuante.cints import kinetic,overlap,nuclear_attraction,fact2,dist2
def amp(self,x,y,z):
"Compute the amplitude of the PGBF at point x,y,z"
i,j,k = self.powers
x0,y0,z0 = self.origin
return self.norm*self.coef*\
pow(x-x0,i)*pow(y-y0,j)*pow(z-z0,k)*\
exp(-self.exp*dist2((x,y,z),(x0,y0,z0)))
def normalize(self):
"Normalize basis function. From THO eq. 2.2"
l,m,n = self.powers
alpha = self.exp
self.norm = sqrt(pow(2,2*(l+m+n)+1.5)*
pow(alpha,l+m+n+1.5)/
fact2(2*l-1)/fact2(2*m-1)/
fact2(2*n-1)/pow(pi,1.5))
def grad(self,x,y,z):
alpha = self.exp
I,J,K = self.powers
C = self.norm*self.coef
x0,y0,z0 = self.origin
fx = pow(x-x0,I)*exp(-alpha*pow(x-x0,2))
fy = pow(y-y0,J)*exp(-alpha*pow(y-y0,2))
fz = pow(z-z0,K)*exp(-alpha*pow(z-z0,2))
gx = -2*alpha*(x-x0)*fx
gy = -2*alpha*(y-y0)*fy
gz = -2*alpha*(z-z0)*fz
if I > 0: gx += pow(x-x0,I-1)*exp(-alpha*pow(x-x0,2))
if J > 0: gy += pow(y-y0,J-1)*exp(-alpha*pow(y-y0,2))
if K > 0: gz += pow(z-z0,K-1)*exp(-alpha*pow(z-z0,2))
src/p/y/pyquante-HEAD/PyQuante/PGBF.py pyquante(Download)
distribution. """ from math import sqrt,pi,pow,exp from NumWrap import array from PyQuante.cints import kinetic,overlap,nuclear_attraction,fact2,dist2
def amp(self,x,y,z):
"Compute the amplitude of the PGBF at point x,y,z"
i,j,k = self.powers
x0,y0,z0 = self.origin
return self.norm*self.coef*\
pow(x-x0,i)*pow(y-y0,j)*pow(z-z0,k)*\
exp(-self.exp*dist2((x,y,z),(x0,y0,z0)))
def normalize(self):
"Normalize basis function. From THO eq. 2.2"
l,m,n = self.powers
alpha = self.exp
self.norm = sqrt(pow(2,2*(l+m+n)+1.5)*
pow(alpha,l+m+n+1.5)/
fact2(2*l-1)/fact2(2*m-1)/
fact2(2*n-1)/pow(pi,1.5))
def grad(self,x,y,z):
alpha = self.exp
I,J,K = self.powers
C = self.norm*self.coef
x0,y0,z0 = self.origin
fx = pow(x-x0,I)*exp(-alpha*pow(x-x0,2))
fy = pow(y-y0,J)*exp(-alpha*pow(y-y0,2))
fz = pow(z-z0,K)*exp(-alpha*pow(z-z0,2))
gx = -2*alpha*(x-x0)*fx
gy = -2*alpha*(y-y0)*fy
gz = -2*alpha*(z-z0)*fz
if I > 0: gx += pow(x-x0,I-1)*exp(-alpha*pow(x-x0,2))
if J > 0: gy += pow(y-y0,J-1)*exp(-alpha*pow(y-y0,2))
if K > 0: gz += pow(z-z0,K-1)*exp(-alpha*pow(z-z0,2))
src/w/u/wu-ros-pkg-HEAD/stacks/ride/trunk/ride_core/src/ui/core/SphereCam.py wu-ros-pkg(Download)
from math import sin,cos,tan,pi,sqrt,pow from direct.task import Task ''' Created on Jul 20, 2009 @author: pbd1
def _zoom(self,direction,speed):
z = base.camera.getZ()
dist = tan((90+base.camera.getP())*pi/180)*z
radius = sqrt(pow(dist,2)+pow(z,2))
#restrict zooming to the radius of the SphereCam
if (radius > self._minRadius and direction == self._up) or (radius < self._maxRadius and direction == self._down):
dx = -dist*sin(base.camera.getH()*pi/180)
dx /= dist; dy /= dist
#adjust scroll speed to the current zoom level if desired
if adjustSpeed:
speed = speed*sqrt(pow(dist,2)+pow(base.camera.getZ(),2))/self._maxRadius
#compute new camera location
x = base.camera.getX(); y = base.camera.getY()
if direction == self._right:
#travel down towards floor
elif direction == self._down and base.camera.getP()+speed < -2.5:
base.camera.setP(base.camera.getP()+speed/2.0)
base.camera.setZ(sqrt(pow(dist,2)+pow(base.camera.getZ(),2))*sin(-base.camera.getP()*pi/180))
dist = tan((90+base.camera.getP())*pi/180)*base.camera.getZ()
#travel counterclockwise
elif direction == self._right:
src/w/u/wu-ros-pkg-HEAD/externals/wu-ros-pkg/ride/ride_core/src/ui/core/SphereCam.py wu-ros-pkg(Download)
from math import sin,cos,tan,pi,sqrt,pow from direct.task import Task ''' Created on Jul 20, 2009 @author: pbd1
def _zoom(self,direction,speed):
z = base.camera.getZ()
dist = tan((90+base.camera.getP())*pi/180)*z
radius = sqrt(pow(dist,2)+pow(z,2))
#restrict zooming to the radius of the SphereCam
if (radius > self._minRadius and direction == self._up) or (radius < self._maxRadius and direction == self._down):
dx = -dist*sin(base.camera.getH()*pi/180)
dx /= dist; dy /= dist
#adjust scroll speed to the current zoom level if desired
if adjustSpeed:
speed = speed*sqrt(pow(dist,2)+pow(base.camera.getZ(),2))/self._maxRadius
#compute new camera location
x = base.camera.getX(); y = base.camera.getY()
if direction == self._right:
#travel down towards floor
elif direction == self._down and base.camera.getP()+speed < -2.5:
base.camera.setP(base.camera.getP()+speed/2.0)
base.camera.setZ(sqrt(pow(dist,2)+pow(base.camera.getZ(),2))*sin(-base.camera.getP()*pi/180))
dist = tan((90+base.camera.getP())*pi/180)*base.camera.getZ()
#travel counterclockwise
elif direction == self._right:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next