Commit d3a83113 authored by Arne Striegler's avatar Arne Striegler 😁

Version 3: Init

parent 331918a2
# Default ignored files
/workspace.xml
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (pypho)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pypho.iml" filepath="$PROJECT_DIR$/.idea/pypho.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -5,19 +5,19 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_oamp import pypho_oamp
from pypho_osnr import pypho_osnr
from pypho_functions import *
import numpy as np
import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 128, sps = 128, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random')
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'random')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.85)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0.25*np.pi)
SSMF = pypho_fiber(glova = gp, l = 8.0e3, D = 17, S = 0, alpha = 2.0, gamma = 1.0e-12, phi_max = 10.0) # High loss fiber, to speed up the simulation
......@@ -32,11 +32,11 @@ E = osnr( E = E, OSNR = 58.0 ) # Set initial OSNR to 58 dB
P = 3.0 # Signal power
plt.figure(1); plt.plot(0, osnr( E = E ), 'r*')
plt.figure(1); plt.plot(0, osnr(E = E ), 'r*')
for t in range(10): # Loop through 10 spans
E = SSMF(E = E)
E = amp( E = E, Pmean = P) # Set mean power to 3 dBm
plt.plot(t+1, osnr( E = E ), 'r*')
plt.title("OSNR as function of number of spans", loc='left');plt.ylabel('OSNR [dB]');plt.xlabel('Span number'); plt.grid(True)
\ No newline at end of file
plt.title("OSNR as function of number of spans", loc='left');plt.ylabel('OSNR [dB]');plt.xlabel('Span number'); plt.grid(True); plt.show()
\ No newline at end of file
......@@ -5,7 +5,7 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
......@@ -13,9 +13,7 @@ from pypho_fiber_birefringence import pypho_fiber_birefringence
from pypho_arbmod import pypho_arbmod
from pypho_oamp import pypho_oamp
from pypho_osnr import pypho_osnr
from pypho_sample import pypho_sample
from pypho_optfi import pypho_optfi
from pypho_cwlaser import pypho_cwlaser
from pypho_functions import *
import numpy as np
......@@ -28,8 +26,8 @@ colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
plt.close('all')
# Define network elements
gp = pypho_setup(nos = 512, sps = 128, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'ones')
gp = pypho_setup(nos = 128, sps = 128, symbolrate = 10e9)
symsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'ones')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.25)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = np.pi/4.0)
SSMF = pypho_fiber(glova = gp, l = 80.0e3, D = 17.0, S = 0, alpha = 0.3, gamma = 1.14, phi_max = 0.4)
......@@ -37,41 +35,32 @@ DCF = pypho_fiber(glova = gp, l = 1.0e3, D = -SSMF.D*SSMF.l, S = 0, a
amp = pypho_oamp(glova = gp, Pmean = 3.0, NF = 5)
osnr = pypho_osnr(glova = gp)
modulator = pypho_arbmod(glova = gp)
sigsampler = pypho_sample(glova = gp)
cw_src = pypho_cwlaser(glova = gp, power = 3 , Df = 0, teta = np.pi/4.0)
filter_f0 = pypho_optfi(glova = gp, Df = 0, B = 50)
# Simulation
# Create bitpattern
bits_x = np.append(bitsrc(pattern = 'random'), [bitsrc(pattern = 'random'), bitsrc(pattern = 'random'), bitsrc(pattern = 'random')])
bits_y = np.append(bitsrc(pattern = 'random'), [bitsrc(pattern = 'random'), bitsrc(pattern = 'random'), bitsrc(pattern = 'random')])
# Create symbol pattern
symbols_x = symsrc(pattern = 'random', p1 = 4)
symbols_y = symsrc(pattern = 'random', p1 = 4)
# Create pulsetrain
onebits = bitsrc(pattern = 'ones')
esig = esigsrc(bitsequence = onebits)
E_Tx = sig_1550(esig = esig)
# Define constellation points: 16-QAM
alpha = np.arctan(np.sqrt(1.0)/3.0)
constpts_x = [( [np.sqrt(3.0**2 + 1.0)]*8 + [np.sqrt(2.0)]*4 + [np.sqrt(2*3.0**2)]*4),
( [2.0*np.pi*x/4.0+alpha for x in range(0,4)] + [2.0*np.pi*x/4.0+np.pi-alpha for x in range(0,4)] + [2.0*np.pi*x/4.0+np.pi/4 for x in range(0,8)] ),
( [colors.values()[x] for x in range(0,16)]),
( [x for x in range(0,16)]),
([(0),(0),(0),(0)], [(0),(0),(0),(1)], [(0),(0),(1),(0)], [(0),(0),(1),(1)], [(0),(1),(0),(0)], [(0),(1),(0),(1)], [(0),(1),(1),(0)], [(0),(1),(1),(1)],
[(1),(1),(1),(1)], [(1),(1),(1),(0)], [(1),(1),(0),(1)], [(1),(1),(0),(0)], [(1),(0),(1),(1)], [(1),(0),(1),(0)], [(1),(0),(0),(1)], [(1),(0),(0),(0)]
)] # codes not optimized!
onebits = symsrc(pattern = 'ones')
esig = esigsrc(bitsequence = onebits)
E_Tx = sig_1550(esig = esig)
# Define constellation points: 4-QAM
constpts_x = [( [ 1.0*np.exp(2.0j*np.pi*x/4.0+np.pi/4) for x in range(0, 4) ] ),
( [ (0),(0)], [(0),(1)], [(1),(1)], [(1),(0)] )]
constpts_y = constpts_x # Constellation
E = modulator( E = E_Tx, constpoints = [constpts_x, constpts_y], bits = [bits_x, bits_y]) # Modulate
E = modulator( E = E_Tx, constpoints = [constpts_x, constpts_y], symbols = [symbols_x, symbols_y]) # Modulate
P0 = 0.0
E = amp(E = E, Pmean = 0)
LO = cw_src(power = 10.0*np.log10(1e5*np.mean( np.abs( E[0]['E'][0])**2 ) )) # Local oscillator
E = amp(E = E, Pmean = P0)
E = osnr( E = E, OSNR = 15.0 ) # Set initial OSNR to bad 20 dB
E = osnr( E = E, OSNR = 10.0 ) # Set initial OSNR
for c in range(0, 0):
......@@ -92,16 +81,17 @@ E = amp(E = E, Pmean = 0)
#Ein = copy.deepcopy(E)
plt.figure(1)
# Get decision matrix
Dec_x, Esx_re_ax, Esx_im_ax, Dec_y, Esy_re_ax, Esy_im_ax = get_decision_matrix(gp, E, [constpts_x, constpts_y], [bits_x, bits_y], LO, filter_f0, sigsampler)
Dec_x, Esx_re_ax, Esx_im_ax, Dec_y, Esy_re_ax, Esy_im_ax = get_decision_matrix(gp, E, [constpts_x, constpts_y], [symbols_x, symbols_y], filter_f0)
# Plot decision matrix
plt.figure(1)
plt.subplot(2, 1, 1); h = plt.contourf(Esx_re_ax, Esx_im_ax, Dec_x, 32, cmap=plt.cm.bone )
plt.subplot(2, 1, 2); h = plt.contourf(Esy_re_ax, Esy_im_ax, Dec_y, 32, cmap=plt.cm.bone )
plt.subplot(2, 1, 1); h = plt.contourf(Esx_re_ax/1000, Esx_im_ax/1000, Dec_x, 32, cmap=plt.cm.bone )
plt.plot(np.real(E[0]['E'][0][int(gp.sps/2)::gp.sps]), np.imag(E[0]['E'][0][int(gp.sps/2)::gp.sps]), '.')
plt.subplot(2, 1, 2); h = plt.contourf(Esy_re_ax, Esy_im_ax, Dec_y, 32, cmap=plt.cm.bone )
plt.plot(np.real(E[0]['E'][1][int(gp.sps/2)::gp.sps]), np.imag(E[0]['E'][1][int(gp.sps/2)::gp.sps]), '.')
############################
# Calculate BER
############################
BER = calc_BER (gp, E, [constpts_x, constpts_y], osnr( E = E), Dec_x, Dec_y, Esx_re_ax, Esx_im_ax, Esy_re_ax, Esy_im_ax, 10, LO, filter_f0, sigsampler,[bits_x, bits_y])
print(BER)
\ No newline at end of file
#BER = calc_BER (gp, E, [constpts_x, constpts_y], osnr( E = E), Dec_x, Dec_y, Esx_re_ax, Esx_im_ax, Esy_re_ax, Esy_im_ax, 1, filter_f0, [symbols_x, symbols_y])
#print(BER)
plt.show()
\ No newline at end of file
......@@ -5,10 +5,10 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_cfiber import pypho_fiber
from pypho_cwlaser import pypho_cwlaser
from pypho_optfi import pypho_optfi
from pypho_functions import *
......@@ -21,7 +21,7 @@ import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 8, sps = 256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse') # Set pattern = "singlepulse"
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'singlepulse') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig_f0 = pypho_cwlaser(glova = gp, power = -20, Df = 0, teta =1*np.pi/4.0)
sig_f1 = pypho_lasmod(glova = gp, power = -10, Df = 500, teta = 0*np.pi/1.0)
......@@ -47,8 +47,8 @@ E_Tx = copy.deepcopy(E)
# Plot Spectrum Input signals
plt.figure(1)
plt.subplot(2, 1, 1)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r', label='X-Pol')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g', label='Y-Pol')
plt.plot((gp.freqax()-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r', label='X-Pol')
plt.plot((gp.freqax()-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g', label='Y-Pol')
plt.title("Input spectrum", loc='left')
plt.ylabel('Spec. density');
plt.grid(True)
......@@ -59,8 +59,8 @@ E = SSMF(E = E)
# Plot Spectrum Output signals
plt.subplot(2, 1, 2)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r', label='X-Pol')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g', label='Y-Pol')
plt.plot((gp.freqax()-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r', label='X-Pol')
plt.plot((gp.freqax()-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g', label='Y-Pol')
plt.title("Output spectrum", loc='left')
plt.ylabel('Spec. density'); plt.xlabel('Frequency deviation [GHz]');
plt.grid(True)
......@@ -74,13 +74,13 @@ phi_XPM_y_max = - 2*(np.max(np.abs(E_f1[0]['E'][1])**2) + 2.0/3.0* np.max(np.abs
phi_SPM_x_max = - (np.max(np.abs(E_f0[0]['E'][0])**2) + 2.0/3.0* np.max(np.abs(E_f0[0]['E'][1])**2))* L_eff * SSMF.gamma *1e-3
phi_SPM_y_max = - (np.max(np.abs(E_f0[0]['E'][1])**2) + 2.0/3.0* np.max(np.abs(E_f0[0]['E'][0])**2))* L_eff * SSMF.gamma *1e-3
print 'L_eff = ', L_eff
print 'phi_XPM_x_max = ', phi_XPM_x_max
print 'phi_XPM_y_max = ', phi_XPM_y_max
print 'phi_SPM_x_max = ', phi_SPM_x_max
print 'phi_SPM_y_max = ', phi_SPM_y_max
print 'phi_x_max = phi_XPM_x_max + phi_SPM_x_max', phi_XPM_x_max + phi_SPM_x_max
print 'phi_y_max = phi_XPM_y_max + phi_SPM_y_max', phi_XPM_y_max + phi_SPM_y_max
print ('L_eff = ', L_eff)
print ('phi_XPM_x_max = ', phi_XPM_x_max)
print ('phi_XPM_y_max = ', phi_XPM_y_max)
print ('phi_SPM_x_max = ', phi_SPM_x_max)
print ('phi_SPM_y_max = ', phi_SPM_y_max)
print ('phi_x_max = phi_XPM_x_max + phi_SPM_x_max', phi_XPM_x_max + phi_SPM_x_max)
print ('phi_y_max = phi_XPM_y_max + phi_SPM_y_max', phi_XPM_y_max + phi_SPM_y_max)
# Plot power of both pol axis as function of transmission distance
......@@ -90,16 +90,16 @@ plt.figure(2)
plt.subplot(2, 1, 1)
plt.ylabel('$|E|^2$'); plt.xlabel('Transmission distance [m]');
plt.plot(gp.timeax*1.0e12, np.abs(E_f1[0]['E'][0])**2, 'r', label='$Pulse: E_x $')
plt.plot(gp.timeax*1.0e12, np.abs(E_f1[0]['E'][1])**2, 'g', label='$Pulse: E_y Pulse$')
plt.plot(gp.timeax*1.0e12, np.abs(E_f0[0]['E'][0])**2, 'r:', label='$cw@1550nm: E_x $')
plt.plot(gp.timeax*1.0e12, np.abs(E_f0[0]['E'][1])**2, 'g:', label='$cw@1550nm: E_y$')
plt.plot(gp.timeax()*1.0e12, np.abs(E_f1[0]['E'][0])**2, 'r', label='$Pulse: E_x $')
plt.plot(gp.timeax()*1.0e12, np.abs(E_f1[0]['E'][1])**2, 'g', label='$Pulse: E_y Pulse$')
plt.plot(gp.timeax()*1.0e12, np.abs(E_f0[0]['E'][0])**2, 'r:', label='$cw@1550nm: E_x $')
plt.plot(gp.timeax()*1.0e12, np.abs(E_f0[0]['E'][1])**2, 'g:', label='$cw@1550nm: E_y$')
legend = plt.legend(loc='upper right')
plt.grid(True)
plt.subplot(2, 1, 2)
plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][0]), 'r', label='$cw@1550nm: E_x$')
plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][1]), 'g', label='$cw@1550nm: E_y$')
plt.plot(gp.timeax()*1.0e12, np.angle(E[0]['E'][0]), 'r', label='$cw@1550nm: E_x$')
plt.plot(gp.timeax()*1.0e12, np.angle(E[0]['E'][1]), 'g', label='$cw@1550nm: E_y$')
plt.ylabel('$phase(E_x)$');
plt.grid(True)
legend = plt.legend(loc='upper right')
......
......@@ -2,10 +2,11 @@
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
......@@ -16,18 +17,22 @@ import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
# Define network elements
gp = pypho_setup(nos = 16, sps = 256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.85)
gp = pypho_setup(nos =2**4, sps = 256, symbolrate = 10.0e9)
symbolsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'debruijn')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'rect' , fwhm = 0.85)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
SSMF = pypho_fiber(glova = gp, l = 80.0e3, D = 17, S = 0, alpha = 0.2e-12, gamma = 0, phi_max=10.0)
SSMF = pypho_fiber(glova = gp, l = 60.0e3, D = 17.0, S = 0, alpha = 0.2e-12, gamma = 1.4e-12, phi_max = 10.0)
# Simulation
bits = bitsrc()
bits = symbolsrc()
esig = esigsrc(bitsequence = bits)
E_Tx = sig_1550(esig = esig)
# Define your parameters here
T_0 = 25.0e-12
z = SSMF.l
......@@ -36,20 +41,23 @@ beta_2, beta_3 = DS2beta(17.0, 0, gp.lambda0)
# Create a single pulse with gaussian shape (not power!)
E_Tx[0]['E'][0] = E_Tx[0]['E'][0]*0 + np.exp(-(gp.timeax-gp.timeax[-1]/2)**2 / (2.0*T_0**2) )
E_Tx[0]['E'][0] = E_Tx[0]['E'][0]*0 + np.exp(-(gp.timeax()-gp.timeax()[-1]/2)**2 / (2.0*T_0**2) )
E = copy.deepcopy(E_Tx)
# Fiber trannsmission
# Fiber transmission
E = SSMF(E = E, D = D, l = z)
#sys.exit()
# Plot Input and Output signal
plt.figure(1)
plt.plot(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0]), 'r', label='$E(0, t)$')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0]), 'g', label= '$E(z='+ str(SSMF.l/1e3)+ 'km, t)')
plt.plot(gp.timeax()*1.0e12, np.abs(E_Tx[0]['E'][0]), 'r', label='$E(0, t)$')
plt.plot(gp.timeax()*1.0e12, np.abs(E[0]['E'][0]), 'g', label= '$E(z='+ str(SSMF.l/1e3)+ 'km, t)')
# Get FWHM of the input signal E_Tx
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0])-1*np.max(np.abs(E_Tx[0]['E'][0]))/2, s=0)
spline = UnivariateSpline(gp.timeax()*1.0e12, np.abs(E_Tx[0]['E'][0])-1*np.max(np.abs(E_Tx[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E_Tx[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E_Tx[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, 0.01 +np.max(np.abs(E_Tx[0]['E'][0]))/2, '$T_{FWHM,0}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
......@@ -58,7 +66,7 @@ T_0_plot = T_FWHM_0 / 2.35482
# Get FWHM of the output signal E
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E[0]['E'][0])-1*np.max(np.abs(E[0]['E'][0]))/2, s=0)
spline = UnivariateSpline(gp.timeax()*1.0e12, np.abs(E[0]['E'][0])-1*np.max(np.abs(E[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, 0.01 + np.max(np.abs(E[0]['E'][0]))/2, '$T_{FWHM,1}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
......
......@@ -5,7 +5,7 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
......@@ -26,7 +26,7 @@ T_FWHM_norm_max = 0.75 # Maximum FWHM pulseiwdth of the
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = T_FWHM*gp.symbolrate)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
SSMF = pypho_fiber(glova = gp, l = z, D = D, S = 0, alpha = 0.2e-12, gamma = 0, phi_max = 10.0)
......@@ -56,6 +56,6 @@ red_patch = mpatches.Patch(color='red', label='Input signal')
green_patch = mpatches.Patch(color='green', label='Output signal')
plt.legend(handles=[red_patch, green_patch], loc=1); plt.show()
print 'Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps'
print ('Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps')
T_FWHM_norm_0 = T_FWHM*1e12 / 100.0
print ( 'Calculated max reach : ' , 100e-12**2 *(1/1.665095)**2 * 2.0*np.pi * 299792458 * T_FWHM_norm_0*np.sqrt( T_FWHM_norm_max**2 - T_FWHM_norm_0**2) / (16.8e-6 * 1550e-9**2 ) *1e-3 )
\ No newline at end of file
......@@ -5,7 +5,7 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
......@@ -19,7 +19,7 @@ import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*256, symbolrate = 40e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
sig_1546 = pypho_lasmod(glova = gp, power = 0, Df = +500, teta = 0)
......
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_oamp import pypho_oamp
from pypho_osnr import pypho_osnr
from pypho_functions import *
from pypho_optfi import *
import numpy as np
import copy
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
# Define network elements
gp = pypho_setup(nos = 1*128, sps = 1*128, symbolrate = 10e9)
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'random')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.85)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0.25*np.pi)
osnr = pypho_osnr(glova = gp)
opfilter = pypho_optfi(glova = gp, Df = 0, B = 50, filtype = 'cosrolloff', alpha = 0.8, loss = 0.0)
amp = pypho_oamp(glova = gp, NF = 6)
# Simulation
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E = sig_1550(esig = esig)
E = amp( E = E, Pmean = 0) # Set mean power to 0 dBm
E = osnr( E = E, OSNR = 30.0 ) # Set initial OSNR to 30 dB
E_Tx = copy.deepcopy(E)
plt.figure(1)
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'r', label='White gaussian noise')
E = copy.deepcopy(E_Tx)
E = opfilter(E = E, filtype = 'cosrolloff' )
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'g', label='cosrolloff')
E = copy.deepcopy(E_Tx)
E = opfilter(E = E, filtype = 'gauss' )
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'b', label='gauss')
E = copy.deepcopy(E_Tx)
E = opfilter(E = E, filtype = 'rect' )
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'k', label='rect')
E = copy.deepcopy(E_Tx)
E = opfilter(E = E, filtype = 'gaussrolloff' )
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'm', label='gaussrolloff')
E = copy.deepcopy(E_Tx)
E = opfilter(E = E, filtype = 'gauss_nth', alpha = 4 )
plt.plot((gp.freqax()-gp.f0)*1.0e-9, 10.0*np.log10(E[0]['noise']*1e3), 'c', label='gauss_nth')
plt.ylabel("Spectral power density [dBm/( " + str(gp.fres*1.0e-9) + " GHz)]"); plt.xlabel('Frequency deviation in GHz');
plt.grid(True)
plt.legend()
plt.show()
\ No newline at end of file
......@@ -5,20 +5,19 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_fiber import pypho_fiber
from pypho_cfiber import pypho_fiber
from pypho_cwlaser import pypho_cwlaser
from pypho_optfi import pypho_optfi
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import time
# Define some paramaters
delta_f = 25 # Frequency difference of the two cw-signals
L = 20e3 # Fiber length in m
l = 0.1e3 # Step fiber length in m
L = 80e3 # Fiber length in m
l = 0.2e3 # Step fiber length in m
k = 7 # Defines how man channels left and right will be analyzed
chut = np.arange(-k*delta_f, k*delta_f+delta_f, delta_f) # Channels under test
......@@ -27,11 +26,11 @@ P_FWM_x = np.zeros((chut.size, int(L/l)))
P_FWM_y = np.zeros((chut.size, int(L/l)))
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*128, symbolrate = 10e9)
gp = pypho_setup(nos = 2**5, sps = 128, symbolrate = 10e9)
sig_f0 = pypho_cwlaser(glova = gp, power = 3, Df = 0, teta = 1*np.pi/4.0)
sig_f = pypho_cwlaser(glova = gp, power = 3, Df = delta_f, teta = 1*np.pi/2.0)
filter_df = pypho_optfi(glova = gp, Df = 0, B = 10)
SSMF = pypho_fiber(glova = gp, l = l, D = 5.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .1)
SSMF = pypho_fiber(glova = gp, l = l, D = 5.0, S = 0.0, alpha = 0.2e-12, gamma = 1.4, phi_max = .1)
# Simulation
......@@ -51,30 +50,34 @@ E_Tx = copy.deepcopy(E)
# Plot Spectrum Input signals
plt.figure(1)
plt.subplot(2, 1, 1)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.semilogy((gp.freqax()-gp.f0)*1e-9, abs(fftshift(fft(E[0]['E'][0] )))**2, 'r')
plt.semilogy((gp.freqax()-gp.f0)*1e-9, abs(fftshift(fft(E[0]['E'][1] )))**2, 'g:')
plt.title("Input spectrum", loc='left')
plt.ylabel('Spec. density');
plt.grid(True)
plt.show()
# Fiber transmission
c1 = 0
t=time.time()
for z in np.arange(0,L,l):
print(z)
c2 = 0
for ch in chut: # Loop through wavelengths and save mean power value of both pol axis
E_filtered = filter_df(copy.deepcopy(E), Df = ch)
E_in = copy.deepcopy(E)
E_filtered = filter_df(E_in, Df = ch)
P_FWM_x[c2][c1] = np.mean( np.abs(E_filtered[0]['E'][0])**2 )
P_FWM_y[c2][c1] = np.mean( np.abs(E_filtered[0]['E'][1])**2 )
c2 = c2 + 1
c1 = c1 + 1
E = SSMF(E = E)
print('Time='+str(time.time()-t))
# Plot Spectrum Output signals
plt.subplot(2, 1, 2)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.semilogy((gp.freqax()-gp.f0)*1e-9, abs(fftshift(fft(E[0]['E'][0] )))**2, 'r')
plt.semilogy((gp.freqax()-gp.f0)*1e-9, abs(fftshift(fft(E[0]['E'][1] )))**2, 'g:')
plt.title("Output spectrum", loc='left')
plt.ylabel('Spec. density'); plt.xlabel('Frequency deviation [GHz]');
plt.grid(True)
......@@ -83,17 +86,15 @@ plt.grid(True)
plt.figure(2)
for i in np.arange(0,chut.size):
plt.subplot(2, 1, 1)
plt.plot(np.arange(0,L,l), 10*np.log10(P_FWM_x[i]*1e3), label=str(chut[i]) + ' GHz')
plt.semilogy(np.arange(0,L,l), P_FWM_x[i]*1e3, label=str(chut[i]) + ' GHz')
plt.subplot(2, 1, 2)
plt.plot(np.arange(0,L,l), 10*np.log10(P_FWM_y[i]*1e3))
plt.semilogy(np.arange(0,L,l), P_FWM_y[i]*1e3)
plt.subplot(2, 1, 2)
plt.ylabel('$10log |E_y|^2$'); plt.xlabel('Transmission distance [m]');
plt.ylim((-120, 10))
plt.grid(True)
plt.subplot(2, 1, 1)
plt.ylabel('$10log |E_y|^2$');
plt.ylim((-120, 10))
plt.grid(True)
plt.legend()
plt.show()
\ No newline at end of file
This diff is collapsed.
......@@ -5,22 +5,20 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_symbols import pypho_symbols
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_fiber_birefringence import pypho_fiber_birefringence
from pypho_cwlaser import pypho_cwlaser
from pypho_optfi import pypho_optfi
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 16, sps = 1*128, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse') # Set pattern = "singlepulse"
bitsrc = pypho_symbols(glova = gp, nos = gp.nos, pattern = 'singlepulse') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 1*np.pi/8.0)
SSMF = pypho_fiber(glova = gp, l = 80e3, D = 0.0, S = 0.0, alpha = 1.0e-12, gamma = 1.4, phi_max = 0.9)
......@@ -45,8 +43,8 @@ E = SSMF(E = E, birefarray = fibres)
# Plot power of both pol axis as function of transmission distance
plt.figure(2)
plt.ylabel('$|E|^2$'); plt.xlabel('Time [ps]');
plt.plot(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0])**2, 'r', alpha=0.4, label='$E_x$ input')
plt.plot(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][1])**2, 'g', alpha=0.4, label='$E_y$ input')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0])**2, 'r', label='$E_x$ output')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][1])**2, 'g', label='$E_y$ output')
plt.plot(gp.timeax()*1.0e12, np.abs(E_Tx[0]['E'][0])**2, 'r', alpha=0.4, label='$E_x$ input')
plt.plot(gp.timeax()*1.0e12, np.abs(E_Tx[0]['E'][1])**2, 'g', alpha=0.4, label='$E_y$ input')
plt.plot(gp.timeax()*1.0e12, np.abs(E[0]['E'][0])**2, 'r', label='$E_x$ output')
plt.plot(gp.timeax()*1.0e12, np.abs(E[0]['E'][1])**2, 'g', label='$E_y$ output')
plt.grid(True); legend = plt.legend(loc='upper right'); plt.show()
\ No newline at end of file
......@@ -5,20 +5,19 @@
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pyph