-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsplit-step-fourier-method.py
executable file
·131 lines (109 loc) · 3.35 KB
/
split-step-fourier-method.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'''
Created in: 31 Oct 2016
Python Version: 3
License: GPLv3
Author: Jeova Pereira
Github: @jeovazero
Email: contato@jeova.ninja
'''
import numpy as np
from scipy.stats import multivariate_normal
from plotly.offline import plot
from plotly.graph_objs import Scatter, Box
import plotly.graph_objs as go
from plotly import tools
ln = 0
Po = .00064
alpha = 0
alph = alpha/(4.343)
gamma = 0.003
to = 125e-12
C = -2
b2 = -20e-27
Ld = (to**2)/np.absolute(b2)
pi = 3.1415926535
Ao = np.sqrt(Po)
tau = np.arange(-4096e-12, 4095e-12, 1e-12)
dt = 1e-12
rel_error = 1e-5
h = 1000
op_pulse = [[0 for y in tau] for x in np.arange(0.1, 1.51, 0.1)]
pbratio = [0 for x in np.arange(0.1, 1.51, 0.1)]
phadisp = [0 for x in np.arange(0.1, 1.51, 0.1)]
uaux = Ao*np.exp(-((1+1j*(-C))/2.0)*(tau/to)**2)
for ii in np.arange(0.1, 1.51, 0.1):
z = ii * Ld
u = uaux[:]
l = np.max(u.shape)
fwhml = np.nonzero(np.absolute(u) > np.absolute(np.max(np.real(u))/2.0))
fwhml = len(fwhml[0])
dw = 1.0/float(l)/dt*2.0*pi
w = dw*np.arange(-1*l/2.0, l/2.0, 1)
w = np.asarray(w)
w = np.fft.fftshift(w)
u = np.asarray(u)
u = np.fft.fftshift(u)
spectrum = np.fft.fft(np.fft.fftshift(u))
for jj in np.arange(h, z+1, h):
spectrum = spectrum*np.exp(-alph*(h/2.0)+1j*b2/2.0*(np.power(w, 2))*(h/2.0))
f = np.fft.ifft(spectrum)
f = f*np.exp(1j*gamma*np.power(np.absolute(f), 2)*(h))
spectrum = np.fft.fft(f)
spectrum = spectrum*np.exp(-alph*(h/2.0)+1j*b2/2.0*(np.power(w, 2)*(h/2.0)))
f = np.fft.ifft(spectrum)
op_pulse[ln] = np.absolute(f)
fwhm = np.nonzero(np.absolute(f) > np.absolute(np.max(np.real(f))/2.0))
fwhm = len(fwhm[0])
ratio = float(fwhm)/fwhml
pbratio[ln] = ratio
im = np.absolute(np.imag(f))
re = np.absolute(np.real(f))
div = np.dot(im, np.linalg.pinv([re]))
dd = np.degrees(np.arctan(div))
phadisp[ln] = dd[0]
print("> %d / 14 " % ln)
ln = ln + 1
# Plots
print("\n\n> Plotting...")
trace_pulse_evolution = go.Surface(z=op_pulse, colorscale='Jet')
trace_pulse_broad = go.Scatter(y=pbratio[0:ln], x=np.arange(1,ln+1,1))
trace_phase_change = go.Scatter(y=phadisp[0:ln], x=np.arange(1,ln+1,1))
layout_input_pulse = go.Layout(
autosize = False,
width=500,
height=400,
title='Input Pulse',
xaxis=dict(
title='Time',
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
),
yaxis=dict(
title='Amplitude',
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
)
)
layout_pulse_evolution = go.Layout(
autosize = False,
width=800,
height=800,
title='Pulse Evolution',
scene=go.Scene(
xaxis=go.XAxis(title='Time'),
yaxis=go.YAxis(title='Distance'),
zaxis=go.ZAxis(title='Amplitude'))
)
trace_input_pulse = go.Scatter(y=np.absolute(uaux))
pulse_evolution = go.Figure(data=[trace_pulse_evolution], layout=layout_pulse_evolution)
input_pulse = go.Figure(data=[trace_input_pulse], layout=layout_input_pulse)
plot([trace_phase_change], filename='./phase_change.html')
plot([trace_pulse_broad], filename='./pulse_broadening.html')
plot(pulse_evolution, filename='./pulse_evolution.html')
plot(input_pulse, filename='./input_pulse.html')