forked from armando-2011/pyStokes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirac.py
47 lines (40 loc) · 1.38 KB
/
dirac.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# ------------------------------------------------------------------
# Funcion Delta dirac n=2,3,4 Agosto 24 - 2010
# Universidad de Los Andes arXiv:1004.2416v1
# Autor: Oscar Castillo O. ol.castillo28@uniandes.edu.co
# ------------------------------------------------------------------
from numpy import *
def phi_2(r):
if (0 <= abs(r) <= 1):
return (1.0-abs(r))
if ( 1 <= abs(r)):
return 0.0
def phi_3(r):
if(0 <= abs(r) <= (1./2.)):
return ((1./3.)*(1+sqrt(1-3*r**2)))
if((1./2.) <= abs(r) <= (3./2.)):
return ((1./6.)*(5-3+abs(r)-sqrt(-2+6*abs(r)-3*r**2)))
if((3./2.) <= abs(r)):
return 0.0
def phi_4(r):
if(0 <= abs(r) <= 1):
return ((1./8.)*(3-2*abs(r)+sqrt(1+4*abs(r)-4*r**2)))
if(1 <= abs(r) <= 2):
return ((1./8.)*(5-2*abs(r)-sqrt(-7+12*abs(r)-4*r**2)))
if(2 <= abs(r)):
return 0.0
def main():
# Crear una grafica de cada funcion de impulso con diferente soporte
x = arange(-2.0,2.0,0.05)
y_2 = arange(2,-2,1)
y_3 = arange(2,-2,1)
y_4 = arange(2,-2,1)
for i in range(0,x.shape[0]):
y_2 = append(y_2,phi_2(x[i]))
y_3 = append(y_3,phi_3(x[i]))
y_4 = append(y_4,phi_4(x[i]))
plot(x, y_2, 'bo-')
plot(x, y_3, 'r+-')
plot(x, y_4, 'yx-')
if __name__ == '__main__':
main()