From 8f28018c501413ccab3fc2edf6fc1cb7e6c334b6 Mon Sep 17 00:00:00 2001 From: hm-striegle Date: Fri, 5 Oct 2018 21:27:17 +0200 Subject: [PATCH] v1.0.0 --- examples/example_amplifier_osnr_8.py | 42 +++ examples/example_ber_estimation_10.py | 107 ++++++++ examples/example_dispersion_1.py | 16 +- examples/example_dispersion_3.py | 2 +- examples/example_filter_9.py | 59 ++++ examples/example_generic_modulator_9.py | 133 +++++++++ examples/example_selfphasemodulation_5.py | 4 +- pyclo_functions.py | 90 +++++++ pypho_arbmod.py | 87 ++++++ pypho_bits.pyc | Bin 2433 -> 0 bytes pypho_cfiber.py | 195 ++++++++++++++ pypho_constants.py | 7 +- pypho_constants.pyc | Bin 538 -> 0 bytes pypho_cwlaser.py | 6 +- pypho_cwlaser.pyc | Bin 2622 -> 0 bytes pypho_eye.py | 3 +- pypho_eye.pyc | Bin 2864 -> 0 bytes pypho_fiber.py | 19 +- pypho_fiber.pyc | Bin 9506 -> 0 bytes pypho_fiber_birefringence.py | 3 + pypho_fiber_birefringence.pyc | Bin 1223 -> 0 bytes pypho_functions.py | 225 ---------------- pypho_functions.pyc | Bin 6694 -> 0 bytes pypho_lasmod.py | 2 +- pypho_lasmod.pyc | Bin 2809 -> 0 bytes pypho_meanpow.py | 130 --------- pypho_meanpow.pyc | Bin 3265 -> 0 bytes pypho_oamp.py | 106 ++++++++ pypho_optfi.py | 159 ++++++++--- pypho_optfi.pyc | Bin 2755 -> 0 bytes pypho_osnr.py | 93 +++++++ pypho_poincare.pyc | Bin 5313 -> 0 bytes pypho_sample.py | 133 +++++++++ pypho_setup.py | 4 +- pypho_setup.pyc | Bin 2958 -> 0 bytes pypho_signalsrc.pyc | Bin 4834 -> 0 bytes speedfiber.pyx | 313 ++++++++++++++++++++++ speedup.py | 49 ++++ 38 files changed, 1564 insertions(+), 423 deletions(-) create mode 100644 examples/example_amplifier_osnr_8.py create mode 100644 examples/example_ber_estimation_10.py create mode 100644 examples/example_filter_9.py create mode 100644 examples/example_generic_modulator_9.py create mode 100644 pyclo_functions.py create mode 100644 pypho_arbmod.py delete mode 100644 pypho_bits.pyc create mode 100644 pypho_cfiber.py delete mode 100644 pypho_constants.pyc delete mode 100644 pypho_cwlaser.pyc delete mode 100644 pypho_eye.pyc delete mode 100644 pypho_fiber.pyc delete mode 100644 pypho_fiber_birefringence.pyc delete mode 100644 pypho_functions.py delete mode 100644 pypho_functions.pyc delete mode 100644 pypho_lasmod.pyc delete mode 100644 pypho_meanpow.py delete mode 100644 pypho_meanpow.pyc create mode 100644 pypho_oamp.py delete mode 100644 pypho_optfi.pyc create mode 100644 pypho_osnr.py delete mode 100644 pypho_poincare.pyc create mode 100644 pypho_sample.py delete mode 100644 pypho_setup.pyc delete mode 100644 pypho_signalsrc.pyc create mode 100644 speedfiber.pyx create mode 100644 speedup.py diff --git a/examples/example_amplifier_osnr_8.py b/examples/example_amplifier_osnr_8.py new file mode 100644 index 0000000..08288a5 --- /dev/null +++ b/examples/example_amplifier_osnr_8.py @@ -0,0 +1,42 @@ +##!/usr/bin/env python2 +# -*- 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_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') +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 +amp = pypho_oamp(glova = gp, NF = 6) +osnr = pypho_osnr(glova = gp) + +# Simulation +bits = bitsrc() +esig = esigsrc(bitsequence = bits) +E = sig_1550(esig = esig) +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*') + +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 diff --git a/examples/example_ber_estimation_10.py b/examples/example_ber_estimation_10.py new file mode 100644 index 0000000..f8465a5 --- /dev/null +++ b/examples/example_ber_estimation_10.py @@ -0,0 +1,107 @@ +##!/usr/bin/env python2 +# -*- 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_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_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 +import copy +import matplotlib.pyplot as plt + +from matplotlib import colors as mcolors +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') +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) +DCF = pypho_fiber(glova = gp, l = 1.0e3, D = -SSMF.D*SSMF.l, S = 0, alpha = 0.2e-12, gamma = 1.0e-12, phi_max = 10.0) +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 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! + +constpts_y = constpts_x # Constellation + +E = modulator( E = E_Tx, constpoints = [constpts_x, constpts_y], bits = [bits_x, bits_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 + + +for c in range(0, 10): + print('Span: ', c) + fibres = pypho_fiber_birefringence.create_pmd_fibre(SSMF.l, 1e3, 0.00) + E = SSMF(E = E, birefarray = fibres) + E = DCF(E = E, l = 1.0) + E = amp(E = E, Pmean = P0) + print('OSNR = ', osnr( E = E)) + + +############################ +# Calculate decision matrix +############################ + +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) + +# 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 ) + +############################ +# 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, 5, LO, filter_f0, sigsampler) +print(BER) \ No newline at end of file diff --git a/examples/example_dispersion_1.py b/examples/example_dispersion_1.py index 971dc5c..f7c4df3 100644 --- a/examples/example_dispersion_1.py +++ b/examples/example_dispersion_1.py @@ -30,7 +30,7 @@ E_Tx = sig_1550(esig = esig) # Define your parameters here T_0 = 25.0e-12 -z = 100.0e3 +z = SSMF.l D = 17.0 beta_2, beta_3 = DS2beta(17.0, 0, gp.lambda0) @@ -45,7 +45,7 @@ E = SSMF(E = E, D = D, l = z) # 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=100$km$, t)$') +plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0]), 'g', label= '$E(z='+ SSMF.l/1e3+ 'km, t)') # Get FWHM of the input signal E_Tx @@ -64,11 +64,11 @@ plt.annotate(s='', xy=(r1,np.max(np.abs(E[0]['E'][0]))/2), xytext=(r2,np.max(np. 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') T_FWHM_1 = (r2-r1) * 1e-12 plt.ylabel('$|E|$ a.u.'); plt.xlabel('Time $t$ [ps]'); legend = plt.legend(loc='upper right') - +plt.show() L_D = (T_0_plot)**2 / np.abs(beta_2) # Print the results -print 'Input signal 1/e-pulse width by definition : T_0 = ' , T_0*1e12, ' ps' -print 'Input signal 1/e-pulse width from plot : T_0 = ' , T_0_plot*1e12, ' ps' -print 'Input signal FWHM-pulse width from plot : T_FWHM,0 = ' , T_FWHM_0*1e12, ' ps' -print 'Output signal FWHM-pulse width from plot : T_FWHM,1 = ' , T_FWHM_1*1e12, ' ps' -print 'Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM_0 * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps' \ No newline at end of file +print ('Input signal 1/e-pulse width by definition : T_0 = ' , T_0*1e12, ' ps') +print ('Input signal 1/e-pulse width from plot : T_0 = ' , T_0_plot*1e12, ' ps') +print ('Input signal FWHM-pulse width from plot : T_FWHM,0 = ' , T_FWHM_0*1e12, ' ps') +print ('Output signal FWHM-pulse width from plot : T_FWHM,1 = ' , T_FWHM_1*1e12, ' ps') +print( 'Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM_0 * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps') \ No newline at end of file diff --git a/examples/example_dispersion_3.py b/examples/example_dispersion_3.py index 20677a2..54653e7 100644 --- a/examples/example_dispersion_3.py +++ b/examples/example_dispersion_3.py @@ -60,7 +60,7 @@ E = copy.deepcopy(E_Tx) # Fiber transmission E = SSMF(E = E,l = 100e3, D = 16.8, S = 0.058) -E = DCF(E = E,l = 16.8e3, D = -100, S = -0.058/16.8 * 100) # For full dispersion compenstion set S = -0.058/16.8 * 100 +E = DCF(E = E,l = 16.8e3, D = -100, S = -0.058/16.8 * 100) # For full dispersion compensation set S = -0.058/16.8 * 100 # Filter out the channels diff --git a/examples/example_filter_9.py b/examples/example_filter_9.py new file mode 100644 index 0000000..c625845 --- /dev/null +++ b/examples/example_filter_9.py @@ -0,0 +1,59 @@ +##!/usr/bin/env python2 +# -*- 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_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 = 128, sps = 128, symbolrate = 10e9) +bitsrc = pypho_bits(glova = gp, nob = 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') + +plt.ylabel("Spectral power density [dBm/( " + str(gp.fres*1.0e-9) + " GHz)]"); plt.xlabel('Frequency deviation in GHz'); +plt.grid(True) +plt.legend() \ No newline at end of file diff --git a/examples/example_generic_modulator_9.py b/examples/example_generic_modulator_9.py new file mode 100644 index 0000000..ac46273 --- /dev/null +++ b/examples/example_generic_modulator_9.py @@ -0,0 +1,133 @@ +##!/usr/bin/env python2 +# -*- 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_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_arbmod import pypho_arbmod +from pypho_oamp import pypho_oamp +from pypho_osnr import pypho_osnr +from pypho_sample import pypho_sample +from pypho_functions import * +import numpy as np +import copy +import matplotlib.pyplot as plt +from matplotlib import colors as mcolors +colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS) + +plt.close('all') + +# Define network elements +gp = pypho_setup(nos = 4*128, sps = 128, symbolrate = 10e9) +bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'ones') +esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33) +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.2, gamma = 1.14, phi_max = 0.01) +DCF = pypho_fiber(glova = gp, l = 1.0e3, D = -SSMF.D*SSMF.l*1.0e-3, S = 0, alpha = 0.2e-12, gamma = 1.0e-9, phi_max = 10.0) +amp = pypho_oamp(glova = gp, Pmean = 3.0, NF = 5) +osnr = pypho_osnr(glova = gp) +modulator= pypho_arbmod(glova = gp) +cstdgr = pypho_sample(glova = gp) +# Simulation + +# Create bitpattern (enough up to 4 bits per symbol) +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 pulsetrain +onebits = bitsrc(pattern = 'ones') +esig = esigsrc(bitsequence = onebits) +E_Tx = sig_1550(esig = esig) + + + +# OOK +constpts_ook = [( [0.001, 1.0]), + ( [0.0, 0.0] ), + ( [colors.values()[x] for x in range(0,2)]), + ( [x for x in range(0,2)]), + ( [(0)], [(1)] )] + + +# 8-PSK +constpts_8psk = [( [1.0]*8), + ( [ 2.0*np.pi*x/8.0 for x in range(0,8)] ), + ( [colors.values()[x] for x in range(0,8)]), + ( [x for x in range(0,8)]), + ([(0),(0),(0)], [(0),(0),(1)], [(0),(1),(0)], [(0),(1),(1)], [(1),(1),(1)], [(1),(1),(0)], [(1),(0),(1)], [(1),(0),(0)], + )] + +# 16-PSK +constpts_16psk = [( [1.0]*16), + ( [ 2.0*np.pi*x/16.0 for x in range(0,16)] ), + ( [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)] + )] + +# 4-QAM +constpts_4qam = [( [1.0]*4), + ( [ 2.0*np.pi*x/4.0+np.pi/4 for x in range(0,4)] ), + ( [colors.values()[x] for x in range(0,4)]), + ( [x for x in range(0,4)]), + ( [(0),(0)], [(0),(1)], [(1),(1)], [(1),(0)] )] + + +# 16-QAM +alpha = np.arctan(np.sqrt(1.0)/3.0) +constpts_16qam = [( [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! + +constpts = constpts_4qam + +E = modulator( E = E_Tx, constpoints = [constpts, constpts], bits = [bits_x, bits_y]) # Modulate + +P0 = 4 +E = amp(E = E, Pmean = P0) +E = osnr( E = E, OSNR = 58.0 ) # Set initial OSNR to 58 dB + +plt.figure(1) +cstdgr(E = E, constpoints = [constpts, constpts], bits = [bits_x, bits_y], style = 'o,o') # Plot constallation diagramme + +E_Tx = copy.deepcopy(E) +n_span = 10 + +E = amp(E = E, Pmean = P0) + +for c in range(0, n_span): # Transmission fiber + print('Span: ', c) + fibres = pypho_fiber_birefringence.create_pmd_fibre(SSMF.l, 1.0e3, 0.00) + E = SSMF(E = E, birefarray = fibres) + E = amp(E = E, Pmean = P0) + +for c in range(0, n_span): # Dispersion compensation + E = DCF(E = E) + +plt.figure(2) +cstdgr(E = E, sampletime = gp.sps/2, constpoints = [constpts, constpts], bits = [bits_x, bits_y], style = 'o,o') # Plot constallation diagramme +plt.subplot(2, 1, 1); plt.grid(True); plt.title("Output signal", loc='left'); plt.subplot(2, 1, 2); plt.grid(True); plt.show() + +# Plot power and phase of the signal +plt.figure(3) +plt.subplot(2, 1, 1) +plt.title("Input signal", loc='left') +plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0])**2, 'r', label='$E_x(0, t)$') +plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][1])**2, 'g', label='$E_y(0, t)$') +plt.ylabel('$10log |E_{x,y}|^2$'); plt.xlabel('Time [ps]'); plt.grid(True) + +plt.subplot(2, 1, 2) +plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][0]), 'r') +plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][1]), 'g') +plt.ylabel('$ \phi_{x,y} $'); plt.xlabel('Time [ps]');plt.grid(True); plt.legend(); plt.show() \ No newline at end of file diff --git a/examples/example_selfphasemodulation_5.py b/examples/example_selfphasemodulation_5.py index 495b85e..cfd253f 100644 --- a/examples/example_selfphasemodulation_5.py +++ b/examples/example_selfphasemodulation_5.py @@ -20,8 +20,8 @@ import matplotlib.pyplot as plt gp = pypho_setup(nos = 16, sps = 1*128, symbolrate = 10e9) bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'ones') esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33) -sig = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = np.pi/8) -SSMF = pypho_fiber(glova = gp, l = 80e3, D = 0.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .1) +sig = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = np.pi/8) +SSMF = pypho_fiber(glova = gp, l = 80e3, D = 0.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .01) # Simulation diff --git a/pyclo_functions.py b/pyclo_functions.py new file mode 100644 index 0000000..01b25e4 --- /dev/null +++ b/pyclo_functions.py @@ -0,0 +1,90 @@ +#!/usr/bin/env pytsftp://104.199.77.123/var/www/html/ul/upload.php +# -*- coding: utf-8 -*- +""" +Created on Thu Nov 2 21:26:04 2017 + +@author: arne +""" + +import MySQLdb +import numpy as np +import pycurl +from StringIO import StringIO + +######################################################################## +def mysql_get(sql): + "Read data from DB" + db = MySQLdb.connect(host="130.211.56.253", user="root", passwd="pyphodb", db="pypho") + + cur = db.cursor() + cur.execute( sql ) + + + db.close() + return cur.fetchall() + + +######################################################################## +def mysql_set(sql): + "Write data to DB" + db = MySQLdb.connect(host="130.211.56.253", user="root", passwd="pyphodb", db="pypho") + + cur = db.cursor() + number_of_rows = cur.execute(sql) + db.commit( ) + + + db.close() + return number_of_rows + + +######################################################################## +def cloud_LoadFiles(): + "Save, zip and send all files for cloude computing" + import json + Etmp = np.loadtxt('E.txt').view(complex) + + with open('glova.json') as json_data: + glova = json.load(json_data) + + with open('link.json') as json_data: + link = json.load(json_data) + + return Etmp, glova, link + + +######################################################################## +def local_SaveFiles(filename, E): + np.savetxt(filename + '.txt', E[0]['E'].view(float) ) + + try: + import zlib + import zipfile + compression = zipfile.ZIP_DEFLATED + except: + compression = zipfile.ZIP_STORED + + zf = zipfile.ZipFile(filename +".zip", mode='w') + try: + zf.write(filename + '.txt', compress_type=compression) + finally: + zf.close() + + +######################################################################## +def cloud_SaveFiles(cid, filename): + # Send files to cloud + print ('Sending files to master!') + c = pycurl.Curl() + buffer1 = StringIO() + c.setopt(c.URL, 'https://optical-fiber-transmission-simulation.com/ul/upload.php') + c.setopt(c.POST, 1) + c.setopt(c.HTTPPOST, [("sim_ticket", cid), ("filecontents", (c.FORM_FILE, filename))]) + + c.setopt(c.WRITEDATA, buffer1) + c.perform() + c.close() + body1 = buffer1.getvalue() + + return body1[0:74] + \ No newline at end of file diff --git a/pypho_arbmod.py b/pypho_arbmod.py new file mode 100644 index 0000000..11ce798 --- /dev/null +++ b/pypho_arbmod.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# pypho_arbmod.py +# +# Copyright 2018 Arne Striegler (arne.striegler@hm.edu) +# +# +# +# Modulates in arbitray constellation points +# +# +######################################################################## + +import numpy as np +import sys +from pypho_functions import * + +######################################################################## + +class pypho_arbmod(object): + + def __init__(self, glova = None): + + if glova == None: + print ("ERROR: pypho_armod: You must define the global variables") + sys.exit("PyPho stopped!") + + self.glova = glova + + +######################################################################## + + def __call__(self, glova = None, E = None, constpoints = None, bits = None): + + + if E == None: + print ("ERROR: pypho_armod: You must define an optical signal E") + sys.exit("PyPho stopped!") + + self.set(E, constpoints, bits) + + return self.out(E) + + +######################################################################## + + def out(self, E = []): + + const_dec = []; + for const_bin in np.asarray( self.constpoints[0][4] ) : + const_dec.append( const_bin.dot(2**np.arange(const_bin.size)[::-1]) ) + + for symbol in range(0, self.glova.nos): + b = self.bits[0][symbol*self.M : symbol*self.M + self.M] + const_num = b.dot(2**np.arange(b.size)[::-1]) + E[0]['E'][0][symbol*self.glova.sps:(symbol+1)*self.glova.sps] *= self.constpoints[0][0][const_dec.index(const_num)]*np.exp(1.0j*self.constpoints[0][1][const_dec.index(const_num)]) + + b = self.bits[1][symbol*self.M : symbol*self.M + self.M] + const_num = b.dot(2**np.arange(b.size)[::-1]) + E[0]['E'][1][symbol*self.glova.sps:(symbol+1)*self.glova.sps] *= self.constpoints[1][0][const_dec.index(const_num)]*np.exp(1.0j*self.constpoints[1][1][const_dec.index(const_num)]) + + return E + +######################################################################## + + def set(self, E = [], constpoints = None, bits = None): + + + if constpoints == None and self.constpoints == None: + print ("ERROR: pypho_armod: No constellation points definded") + sys.exit("PyPho stopped!") + elif constpoints != None: + self.constpoints = constpoints + self.M = int(np.floor( np.log2(len(constpoints[0][0])) )) + + if bits == None and self.bits == None: + print ("ERROR: pypho_armod: No bit sequences definded") + sys.exit("PyPho stopped!") + elif bits != None: + if len(bits) == 1: + bits = [bits, bits] + + self.bits = bits + + +######################################################################## diff --git a/pypho_bits.pyc b/pypho_bits.pyc deleted file mode 100644 index 3bae4ee9ff0a16b1b2a0e1c19716f088753a3921..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2433 zcmb7GO>Z1U5Urls53gCXjul6UNN5Za+63erfJj=EY^r)50Jtht2H!SFXICPt;*=J4bGh%Vf=uB+$*h&t`8C*3Xq3J_p--EYw- zI$3MYx?(n<=xE%>9#h_t3m^U&iaA7eCTD)_QN6>5*gpX3InM6Uxgu4F!5L93A>am3 zU=WQi*Yh5od35H}xkm~UM`QLLn$J*w8$~ao$HB{T87!8@2C1H9g%0eg4qoNuB*}v} zNu4E=TpRN~>6%cJ_w0dh9G(y}IBHhB z%5}BOjTUyKc2((&MVNW0ga)9Ju^h}gDbjLbK1Q?QX;^}fd6otZhXPaSX*SEi#hd84 zft8Xs;SvHxR8+F>TV0n%GA1d_3M*T)`h|fFVNEo`8kwq#bP-9iIXNPs+oe6?^FKr} zOjJ(yNPVO}M7@Ku<#pADKjlbpxgAl)=T7pVFRq3r z`C`0xxc~&%W0#H-V#zN1l2X69Bf|_EyQH}E@SQnk4Mcai;<&i@@!g4}EOm?!6%or+ zWNuEEvsv!aoYZx)itb`c6eWTCA8AJ%rKc#3q_@>wwW&7n-S#fS#Gw+MFbHOwM9Rt5 zY+-C)+n`u3Cb|yFS-|NXGYbTYq}60^^}A!*#@ZJshMkaqd9`p?aQun}U)LQ`$rHhJ zt=r^46g%@E7slM`H&#@9(608W{+`>M8H~d#a_qeRBwiu*whPtoAGloO>SrI$7CwHF zs~@2(HpBh?CB}}wj>6~R{^KCL9<-n+?UmF%4@?<650XW& zWH|@stLqC}W&Y<9r|dw;63Uw#Nm}Fzl^1{`?Op)U+^sHHk^C_n7-k&#_thP>rG{$g z-N(CtUlop-FwN^xBnutK@;^WvFUoY8qwDanRW#&^#VeGQMNQOJk-%hCT(MbNH@;R8 z)0I~kcG*)~8>9Z{-e5FZa}OyW9AvFlPGWL!krQXjy?e7|F|}D)xC^qJ%=OfY+jrSt Upzpa8KH=BgFmjH^P_1|V0he5&?*IS* diff --git a/pypho_cfiber.py b/pypho_cfiber.py new file mode 100644 index 0000000..d7e33e2 --- /dev/null +++ b/pypho_cfiber.py @@ -0,0 +1,195 @@ +#!/usr/bin/env python +# +# Copyright 2018 Arne Striegler (arne.striegler@hm.edu) +# +# +# +# Simulates a fiber ...fast! +# +# +######################################################################## + +import numpy as np +import sys +from pypho_functions import * +from pypho_fiber_birefringence import pypho_fiber_birefringence +import time + +import copy +from speedfiber import * +#from speedtest import * + +######################################################################## + +class pypho_cfiber(object): + def __init__(self, glova = None, fibertype = None, D = None, S = None, gamma = None, alpha = None, l = None, birefarray = None, phi_max = None): + + if glova == None: + print ("ERROR: You must define the global variables") + sys.exit("PyPho stopped!") + + self.glova = glova + self.D = None + self.S = None + self.l = None + self.gamma = None + self.alpha = None + self.birefarray = None + self.nos = None + self.phi_max = None + + self.set(fibertype, D, S, gamma, alpha, l, birefarray, phi_max) + + +######################################################################## + + def __call__(self, E = None, fibertype = None, D = None, S = None, gamma = None, alpha = None, l = None, birefarray = None, phi_max = None): + + self.set(fibertype, D, S, gamma, alpha, l, birefarray, phi_max) + + if self.glova.cloud : + E.append(self.get_parameters()) + return E + else : + return self.transmit(E, fibertype, D, S, gamma, alpha, l, phi_max) + +######################################################################## + + def transmit(self, E = None, fibertype = None, D = None, S = None, gamma = None, alpha = None, l = None, phi_max = None): + """Transmit the signal""" + + if E == None: + print ("ERROR: You must define an optical signal") + sys.exit("PyPho stopped!") + + if type(E) != list: + E = [E] + + self.set(fibertype, D, S, gamma, alpha, l, phi_max) + + self.E = E + + self.gamma_intern = self.gamma * 1e-3 + self.max_step = 200 + + z = 0 + + #for Ei in E: + self.fibtrans(z) + #z += 1 + + return self.E + + + ######################################################################## + + def fibtrans(self, zsep): + """Calculate step""" + + print('Start!') + + tic0 = time.time() + n = self.glova.sps*self.glova.nos + #Ef_out = np.zeros((1,n)) + 1j*np.ones((1,n)) + Ex_out = np.zeros(n) + 1j*np.ones(n) + Ey_out = np.zeros(n) + 1j*np.ones(n) + birefarraydoubles = np.zeros((len(self.birefarray), 3)) + for i in range (0, len(self.birefarray)): + birefarraydoubles[i,0] = self.birefarray[i].angle + birefarraydoubles[i,1] = self.birefarray[i].z_point + birefarraydoubles[i,2] = self.birefarray[i].delta_beta + + cyfiber(self.glova.sps*self.glova.nos, self.l, np.asarray(self.E[zsep]['E'][0]), np.asarray(self.E[zsep]['E'][1]), + self.alpha, self.gamma_intern, self.phi_max, birefarraydoubles, len(self.birefarray), self.max_step, self.beta_fac, + np.asarray(1j * scipy.fftpack.fftshift( self.Domega )), Ex_out, Ey_out) + + self.E[zsep]['E'][0] = Ex_out + self.E[zsep]['E'][1] = Ey_out + + print ('Fertig: ', time.time() - tic0 ) + + +######################################################################## + def get_parameters(self): + """Get all fiber parameters set by the user""" + biref_angle = [] + biref_zpoint = [] + biref_delta_beta = [] + for x in self.birefarray: + biref_angle.append(x.angle) + biref_zpoint.append(x.z_point) + biref_delta_beta.append(x.delta_beta) + + params = {'type' : 'fiber', 'D': self.D, 'S' : self.S,'l' : self.l, 'gamma' : self.gamma, 'alpha' : 4.343e3*self.alpha, 'biref_delta_beta' : biref_delta_beta, 'biref_zpoint' : biref_zpoint, 'biref_angle' : biref_angle, 'useYPol' : True} + return params + +######################################################################## + def set(self, fibertype = None, D = None, S = None, gamma = None, alpha = None, l = None, birefarray = None, phi_max = None): + """Set fibre properties""" + + + if fibertype == 'SSMF': + self.D = 17.0 # [ps/(nm km)] + self.S = 0.0 # [ps/(nm2 km)] + self.gamma = 1.14 # [1/(W m)] + self.alpha = db2neper(0.20) / 1.0e3 # [1/m] + + + if fibertype == 'DCF': + self.D = -100.0 # [ps/(nm km)] + self.S = 0.0 # [ps/(nm2 km)] + self.gamma = 1.7 # [1/(W m)] + self.alpha = db2neper(0.20) / 1.0e3 # [1/m] + + + if D == None and fibertype == None and self.D == None: + print ("Warning: D and fibertype not specified, so I set D = 16.8 ps/nm/km") + self.D = 17.0 + elif D != None: + self.D = D + + if S == None and fibertype == None and self.S == None: + print ("Warning: S and fibertype not specified, so I set S = 0.68 ps/nm**2/km") + self.S = 0.68 + elif S != None: + self.S = S + + if gamma == None and fibertype == None and self.gamma == None: + print ("Warning: gamma and fibertype not specified, so I set gamma = 1.14 1/W/km") + self.gamma = 1.14 + elif gamma != None: + self.gamma = gamma + + if alpha == None and fibertype == None and self.alpha == None: + print ("Warning: alpha and fibertype not specified, so I set alpha = 0.25 dB/km") + self.alpha = db2neper(0.25) / 1.0e3 + elif alpha != None: + self.alpha = db2neper(alpha) / 1.0e3 + + if l == None and fibertype == None and self.l == None: + print ("Warning: L and fibertype not specified, so I set L = 80 km") + self.l = 80e3 + elif l != None: + self.l = l + + if phi_max == None and self.phi_max == None: + print ("Warning: phi_max not specified, so I set phi_max = 1e-3") + self.phi_max = 1e-3 + elif phi_max != None: + self.phi_max = phi_max + + if birefarray == None and self.birefarray == None: + nosiref = pypho_fiber_birefringence (0.0, 0.0, 0.0) + self.birefarray = [nosiref] + elif birefarray != None: + self.birefarray = birefarray + + (self.beta_2, self.beta_3) = DS2beta(self.D, self.S, self.glova.lambda0) + + self.Domega = 2.0 * np.pi * (self.glova.freqax - 1*self.glova.f0) / 1.0e12 + self.beta_fac = -1j * fftshift ( self.beta_2*0.5e24 * self.Domega**2.0 + self.beta_3*1.0e36 / 6.0 * self.Domega**3.0) + + +######################################################################## + + diff --git a/pypho_constants.py b/pypho_constants.py index 5b627e8..3c15c11 100644 --- a/pypho_constants.py +++ b/pypho_constants.py @@ -16,6 +16,7 @@ ######################################################################## class pypho_constants(object): - def __init__(self): - - self.lightspeed = 299792458 + def __init__(self): + + self.lightspeed = 299792458 + self.pwquant = 6.62607004e-34 \ No newline at end of file diff --git a/pypho_constants.pyc b/pypho_constants.pyc deleted file mode 100644 index ad44b0302a45c615e21cb7063222504caa3450b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 538 zcmb_Y!AiqG5S^q_q)?;^9{hrwObi}8h=|@i^pKp|%M!C&6G=9~oq`2#`kjS-gFoP# zO{pKC3-9gD&d$6yJNlkZ&UbxY(teGw-vjOfq=^jCDj*%u7ttrtVu>K6Jd$^O0_rz? z)v2I`Qm1}Gfn9g?x`jW@l&K`@NaB^Rb0L z&dwaXS^l^|!>fS%I)+{aiSTzQA=-9Eyi41z@Gd0<`YIpTOi8rS!CSdpXgqZwhN<2$Q`;@ zpzY%cU|f;FfMa1nBqj2#K@Hx8M-k&)4E+hnK-}ANsk_9e*KfesHr#aS$RQ_{2?L@4 zn}Y`fc*|fb%amB&o}__Gg8~hTbW|V*x~&?YXkD*>Ui1AA{1xvJ_gB1IS&v{ajd$P^hoOO@eWbYF`=9mK}4 zlYrR|h0C+Msw+yPOlVvvH=1^lGV-cKsa4YSd8J=sGRcJZsbN^67r-qqzw(F^%X#1M zv>=Gn*aX2Mcs&O~?yNK6%(>IPB=g%oIGL*DL z6}W@|YS}0$(!o{n&83aoZ#joWiir**lHmis^+A1zRI=+OoEH%n%b+84o9sah4V zIa=ijMQT682ZS}wotyNLm2K57;N{dMKykkI8Zr;p`Xhs_syj zXGu3RQWIn~HcEwQb^*i3(bzY9VoBWEH9A)+60i{EDvfHB(2UDcF<_$^3)D5!$)!<* z|6OtXSs=cKp`Qmq(iW;t8I@+vDLFIly8DK+>@K-C-O5STVIw7(AAmV2`j;g{5syUN z11{ShfJ{W31rDVbM{|+f8&Z_492n9Ic~LGHryh~T*KZ6lPy&EqmB9E+3LP+{G@xA! zH~v;IPCcTH9b*&(!zzLCle8INKrW5i_P4rz53Y@GH1*8mcjieiKyOKU%EN1F#LZYm zmpz?%?|VJ1yiMU?>+ z{9;W~UTROTllT2HL-Ut_IS*o6bhDQ>_)u+TXFF}xFoO1!JBwGV){iUP(=~6(Coxm} E2TYsjrvLx| diff --git a/pypho_eye.py b/pypho_eye.py index 4a31676..2c19c78 100644 --- a/pypho_eye.py +++ b/pypho_eye.py @@ -3,7 +3,7 @@ # # pypho.py # -# Copyright 2014 Arne Striegler (arne.striegler@hm.edu) +# Copyright 2018 Arne Striegler (arne.striegler@hm.edu) # # # @@ -54,7 +54,6 @@ class pypho_eye(object): def out(self, E = []): styles = self.style.split(',') - print (styles[0]) if len(styles) == 1: styles.append(styles[0]) diff --git a/pypho_eye.pyc b/pypho_eye.pyc deleted file mode 100644 index 383396378bc2a436366aca065e547ad791403762..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2864 zcmcImQEwYX5T3m|JBec_sT*iZ5x59Zi>4JqqM!;vDXoflNUKXBs;lTY`_A^c=ew(S z-P$POffVtGkPttB|G^vo2#F^o_-5|TiQ1wn57@r-?C#9$>^HODp8aQ|_WQSgcY0KO zZ2VuxqaUCN@KY2MbyO)^)UiaiD7NVyYuFS!G9jSTYSRkBew2hQGYngUIPLmz>#;wH{B9g-y$0jE^Si^e zrA?Y;VQ`_%FdE*}cAA8S*U)n<1K}((hW8COk9|qUEmKE7OJjJ{zKPPraMt?KU^)p! zSDSfUxCu?0{faLg#(kGn-DPfSXxe!4MvGHPFH(6Wn;Ta0yeNr`=beMBo2+crRYh&6 zmGWynpOD*7GXgolM>ZbXG`YyRSfmAj7HI*}HfQe$W(FUyD^}T&;I|`-m*-du(4WQG zPg=-8)C0~%ZN30xMp3Yh!^CA!Tpn>(%i(mIW92du?h-dAzzJ)|p2sn22A1q5<7Az- zdK^4E;$bOR2MOj~;wSiEqX(!mDc5trNMwf2Ca&nuc#2WV6^2J0*m;d?J zOy=`;o)dv6Tq+bU&A{mRT>t4h3%~vH+W3Z?z`N;_aMF4(-rdtoulJ&H*m{uZJ@MB? zLW!OXqux-Yu|G;DBK6WZooJ?q_pV(1KrXl#R4$aN`6yq$+}^~W(5G1FERKxJgd;rc zgVK{gr~@aND9MC${H`|4DU(nS{VWt7mWd?QIpb$Kx1adQAZPC^HbUH4oEpRQq5W|N zX2(_}FauScr8*SDdF*$?Sj1T_@-7CGC=e(2CeyGjgtp)}(am>;Wa3W2I!}hai6d&Qj- j0=wjX+8u>GBMZMQI@$8a`6fT%rR9V(G&Q`7tULb#U3B(& diff --git a/pypho_fiber.py b/pypho_fiber.py index 209360c..4e4b83d 100644 --- a/pypho_fiber.py +++ b/pypho_fiber.py @@ -26,7 +26,6 @@ import mpl_toolkits.mplot3d.axes3d as p3 ######################################################################## -##modiefied by Florian Lechner class pypho_fiber(object): def __init__(self, glova = None, fibertype = None, D = None, S = None, gamma = None, alpha = None, l = None, useYPol = True, birefarray = None, phi_max=None): @@ -73,8 +72,8 @@ class pypho_fiber(object): self.output_array_fx = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) self.input_array_bx = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) self.output_array_bx = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) - self.fft_fwdx = fftw3.Plan(self.input_array_fx, self.output_array_fx, direction='forward', flags=['estimate'], nthreads=16) - self.fft_bwdx = fftw3.Plan(self.input_array_bx, self.output_array_bx, direction='backward', flags=['estimate'], nthreads=16) + self.fft_fwdx = fftw3.Plan(self.input_array_fx, self.output_array_fx, direction='forward', flags=['estimate'], nthreads=4) + self.fft_bwdx = fftw3.Plan(self.input_array_bx, self.output_array_bx, direction='backward', flags=['estimate'], nthreads=4) if self.useYPol: @@ -82,8 +81,8 @@ class pypho_fiber(object): self.output_array_fy = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) self.input_array_by = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) self.output_array_by = np.zeros(self.glova.sps*self.glova.nos, dtype=np.complex128) - self.fft_fwdy = fftw3.Plan(self.input_array_fy, self.output_array_fy, direction='forward', flags=['estimate'], nthreads=16) - self.fft_bwdy = fftw3.Plan(self.input_array_by, self.output_array_by, direction='backward', flags=['estimate'], nthreads=16) + self.fft_fwdy = fftw3.Plan(self.input_array_fy, self.output_array_fy, direction='forward', flags=['estimate'], nthreads=4) + self.fft_bwdy = fftw3.Plan(self.input_array_by, self.output_array_by, direction='backward', flags=['estimate'], nthreads=4) self.set(fibertype, D, S, gamma, alpha, l, self.useYPol) @@ -123,6 +122,7 @@ class pypho_fiber(object): tic = time.time() + self.E[zsep]['noise'] *= np.exp(-self.l * self.alpha) while lc < self.l: @@ -159,7 +159,10 @@ class pypho_fiber(object): next_leff = (1-np.exp(-self.alpha*next_l)) / self.alpha doCoordRot = True - + # linear & nonlinear calculation + #next_l = 100 + #next_leff = next_l + #self.E[zsep]['E'][0], self.E[zsep]['E'][1] = self.timestep(self.E[zsep]['E'][0], self.E[zsep]['E'][1], power_x, power_y, next_leff) self.E[zsep]['E'][0], self.E[zsep]['E'][1] = (self.E[zsep]['E'][0] * np.exp(-1j*next_leff*self.gamma_intern*(power_x + 0.6666666666666666 * power_y)), self.E[zsep]['E'][1] * np.exp(-1j*next_leff*self.gamma_intern*(power_y + 0.6666666666666666 * power_x))) @@ -176,7 +179,7 @@ class pypho_fiber(object): lcd += next_l # print (lc, next_l, next_leff) if lcd > 1000 : - print lc + print (lc) lcd = 0 if self.useYPol: @@ -188,7 +191,7 @@ class pypho_fiber(object): print (time.time() - tic ) - print 'OFF', lc + print ('OFF', lc) ######################################################################## diff --git a/pypho_fiber.pyc b/pypho_fiber.pyc deleted file mode 100644 index 3d02d3d2a650a1646f0760088c2cadccf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qS zqwp`^ZQb~f)%v%-$aMk~tVx8meyca={lBbVk4%Yf-s_%U5OyiB-nTk`!2bq;W{r10hZ*_jSUjMgJ_aA;ay>&Ys zxzH1(+?vj_3^+47QaKuVm6gbcENZ7le==~5E13{FSbd?(_(USl^^FxCxAd*RFrcB^ zsCe!rad>hNTiLH((V;Hmzg8gN8d55_fF`7N$^H;O_6IDOi_lJ40^ld-wCNf3v^YVT z7VaeY&lgXPy?Cc{hTe4x6_r7nL%ws!cK2#8;r@A)U-P8e9D3&ldY4lCCD53XkxRxj z4lbl|-hA1(Q|4ue@Z51Cgg=fW=^e*u;6Fh^H1)NN@O%!a_96@B}-R9xxc|0*+k~LnMeJOYLwfvp@r}DXcAIa7X*R?AK@u;c(M+y*Ha8vCmkGOs zpfIT5-vC(C(UPt*0&azgB*p^7i6j%-gxa*1I(60!-HIG1Tgeg$9`m|om;ZL-iFBkh ykk_POk;y9pX;!vz11HQm6&qzEuj{S*EW^#1nM{gI0YRD;ok?u}9I|55+5ZR8OR%c| diff --git a/pypho_fiber_birefringence.py b/pypho_fiber_birefringence.py index 96ecae5..440bcf5 100644 --- a/pypho_fiber_birefringence.py +++ b/pypho_fiber_birefringence.py @@ -19,14 +19,17 @@ and the delta beta for the birefringence. class pypho_fiber_birefringence(object): def __init__(self, z_point = None, angle = None, delta_beta = None): + if z_point == None: self.z_point = 0.0 else: self.z_point = z_point + if angle == None: self.angle = 0.0 else: self.angle = angle + if delta_beta == None: self.delta_beta = 0.0 else: diff --git a/pypho_fiber_birefringence.pyc b/pypho_fiber_birefringence.pyc deleted file mode 100644 index c74fd019d2b9556e09bfc75602b819c90f6d6917..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1223 zcmb_b&2G~`5T3P@KubzO6(o27P`Hqg3qL{?DjZP`4iaiEE61KBPVKeXok$HzPwmrk z_!o6A64*TFQZQ{oH0euiiTDZyOrM$Dg4veK0=NvoJ`<-cfL36RL|@BWA6N|D?+pTP5O@RT z+)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ypho_lasmod.py +++ b/pypho_lasmod.py @@ -68,7 +68,7 @@ class pypho_lasmod(object): Etmp['E'] = polrot(a*self.omega, self.teta) + 0j - Etmp['noise'] = np.zeros(self.glova.nos * self.glova.sps) + np.mean(a) / 10**(5.0) * self.glova.fres / (0.1 * cv.lightspeed/(1550**2 *1e-9) ) + Etmp['noise'] = np.zeros(self.glova.nos * self.glova.sps) + dbm2w( self.power ) / 10.0**(5.8) / 12.5e9 * self.glova.fres self.E.append( Etmp ) diff --git a/pypho_lasmod.pyc b/pypho_lasmod.pyc deleted file mode 100644 index e12b080dd450f82d2ab9e4c5641308ccdd9e31af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2809 zcmbVO&2Jl35TD((o#y+ac0Z_uHUfc5s|fYLAqs6;5~V%hR-2-#sVZx;es4ATM1N;S?xFT*naP1Xw;1A%4#DyFDW}fY~Q3{An-t%~N-pst;eA)YBc53>P z_b8&_MyR_p9?NZ{=eU|VjDN(OPJ0)^diH;#&rdEkmh1xh* zrsu@WhdUFjZM$B9=J+o>jk*KU@b-}<=RxL!d@pN8S*lH#8f|9Ayd>1UtTlGEj2E}C z^h0dQI$2`F!+)aZaLS_&d>k_!VV2%xy22EvhmsyW_h_d=!FHX^M7;4TVSR?BVULak zm3^0rWxmA7*{O*Vo2xsdk(y-|Q*BlVrPL;va-X9PTDc>p95Z8{FH=d~LEk zSFPpxBv^(o(8y9{SgjstVW`8{7``6V9E3vU*;7^6mpbkk7cV#3^4%yC+SAGiIKtH` zX$KtHV1hTc6-;5PW7$o=3a$<0N0A;H+;>qA5~b z5mxknU=0V8X7e&sXx2mSlEvCRYf)wwIF5qyBh)6N3}hUJ6M3-jG0>LNvB)}vTt}6G ziCjNicI?}Y$LE}9Wdd~104q>NvOBbfbOGdMgfz4wKvm`<`^8EPyk`@ft6fCT5>sMw znz}P1VwS3qYfG^WrRS(MC&%Wg3WHS?bCrF;u?3N44;RTSu~vSuXy2cuW0Y-~&a;aZ z>*Cnp?8xAZs2Dmr!Em(ZsW#MKg|$gCHR_%NwMey^D4V4<7VxNhp6`z{&XZMoV0qhh z&h~~B%K+4C&+j*Yr#$OIsFyEqo)8&!&dr$1Y$#n_?|l0WKR@1x=Mcr1>$dat&ma6Y zy|Q>+3OmhWtxl@4MyUJedi>LO?^9=O|A)tW-$ys<7jPao#x}^6I4a+gSesyx*=!)q zg{hwuwu`iOd)J;y<_f>3(8oEY4$#q~eevQ;Rb*QFg>5Cdmd`Y^pXx9d&3P;bO$;4} zaxm+uPAJSgONz`$lMyrRLTNb^9TDy@!P4Bo$gMd`?xefmRGca2va{k|ahKiC-KrZgjJy~!sjgo^@C+$S z_qr;1_S#n&Dd=cOmL^KgVR!1&6B$v4%<~*FYZVz?1qQlBU$5%3F zpc{PX7$15eI>str@bE-am8yj%)I747ZF{26o`b$$q_bK+CT#DCa|Bm0+%D?A->VMq2)w7-X z&Oa(ds$ekc(8O8lhiNA{T_sO8)+)b!PPi96MXy(A{Al$uWkpxJ$a;RHQlknV`S+x+ z(r9q1yBlrR+z?0tZv3{hbE4W|Spy{*9u`G7kf{?$o=%KK{(YXx?6`{q`dw_~T|#f4 z;lC5q1@Ibm);yfRY1mWErqoTdi62@01YfP6vyciFc;iGD3$F@7sM98Uz*&9~OLN6l zoZ5VCwsuj<&$gj{FCPSaX&Ha!)sKUAKaCh%9q1`3(jQeZ;M?9Hvj+t diff --git a/pypho_meanpow.py b/pypho_meanpow.py deleted file mode 100644 index 90dec37..0000000 --- a/pypho_meanpow.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# pypho.py -# -# Copyright 2014 Arne Striegler (arne.striegler@hm.edu) -# -# -# -# Amplifies the optical signal to a mean value -# -# -######################################################################## - -import numpy as np -import sys -from pypho_functions import * - -######################################################################## - -class pypho_meanpow(object): - def __init__(self, glova = None, power = None, unit = None): - - if glova == None: - print ("ERROR: pypho_meanpow: You must define the global variables") - sys.exit("PyPho stopped!") - else: - self.glova = glova - - self.power = None - self.unit = None - self.E = None - - self.set(power, unit) - - - -######################################################################## - def __call__(self, E = None, power = None, unit = None): - - self.set(power, unit) - - if self.glova.cloud : - E.append(self.get_parameters()) - return E - else: - return self.out(E, power, unit) - -######################################################################## - def out(self, E= None, power = None, unit = None): - - if E == None: - print ("ERROR: pypho_meanpow: You must define an optical signal") - sys.exit("PyPho stopped!") - - if type(E) != list: - E = [E] - - self.set(power, unit) - - z = 0 - - for Ei in E: - (P1, P2) = getpower_W(E[z]['E']) - - G = np.sqrt( self.power / np.mean(P1+P2) ) - - E[z]['E'] = E[z]['E'] * G - E[z]['noise'] = E[z]['noise'] * G**2 - - z += 1 - - self.E = E - return E - - -######################################################################## -# power : mean power - @property - def pow(self): - """Get mean power""" - return self.power - - @pow.setter - def pow(self, value): - """Set mean power""" - if self.unit == 'dBm': - self.power = dbm2w(value) - else: - self.power = value - - - ######################################################################## - def get_parameters(self): - """Get all fiber parameters set by the user""" - - params = {'type' : 'meanpow', 'power' : self.power, 'unit' : self.unit} - return params - - -######################################################################## - def set(self, power = None, unit = None): - """Set amplifer parameter""" - - if power == None and self.power != None: - power = self.power - - if power == None and self.power == None: - print ("ERROR: pypho_meanpow: No mean power value specified!") - sys.exit("PyPho stopped!") - - - if unit == None and self.unit == None: - print ("WARNING: pypho_meanpow: No unit specified, so I am using dBm!") - self.unit = 'dBm' - elif unit != None: - self.unit = unit - - - if self.unit != "dBm" and self.unit != "W": - print ("ERROR: No valid unit used!") - sys.exit("PyPho stopped!") - - - if unit == "dBm": - self.power = dbm2w(power) - self.unit = 'W' - else: - self.power = power - diff --git a/pypho_meanpow.pyc b/pypho_meanpow.pyc deleted file mode 100644 index 9012148a8781c576c60ba704c2b519e6ecb40e38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3265 zcmb_e>uwuG6h6D_OPotnTnZ#r!v=(EA=I=1wWtcWLY0;uZnUWs)hetu-f^<&dUxv? zH#Ks8CH&+GcnzM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GGU7jE)Lp(Sn`{hQN zB8gD{^9dF(LSIIcm{y$nTlKm6)x~mswl*VAB75)kyTu^jZF12Wz8~z{uG7!jCdo4` dI_A3vs%?bln^8}Ev0=USB}*05V^7bP{sI5&enS8N diff --git a/pypho_oamp.py b/pypho_oamp.py new file mode 100644 index 0000000..5cf087a --- /dev/null +++ b/pypho_oamp.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +""" +Created on Mon Apr 23 13:44:16 2018 + +@author: lonstud7 +""" + +import numpy as np +import sys +from pypho_functions import * +from pypho_constants import pypho_constants +cv = pypho_constants(); + + +######################################################################## + +class pypho_oamp(object): + def __init__(self, glova = None, G = None, Pmean = None, Pmax = None, NF = None): + + if glova == None: + print ("ERROR: pypho_amp: You must define the global variables") + sys.exit("PyPho stopped!") + else: + self.glova = glova + + self.G = None + self.Pmean = None + self.Pmax = None + self.NF = None + self.mode = "none" + + self.set(G, Pmean, Pmax, NF) + + + +######################################################################## + def __call__(self, E = None, G = None, Pmean = None, Pmax = None, NF = None): + + self.set(G, Pmean, Pmax, NF) + + return self.out(E = E) + +######################################################################## + def out(self, E = None): + + if E == None: + print ("ERROR: pypho_amp: You must define an optical signal") + sys.exit("PyPho stopped!") + + if type(E) != list: + E = [E] + + z = 0 + + for Ei in E: + if self.mode == "Pmean": + (P1, P2) = getpower_W(E[z]['E']) + self.G = 10.0 *np.log10( 1.0e-3*10.0**(self.Pmean/10.0) / (P1+P2) ) + + elif self.mode == "Pmax": + P1 = np.max(np.abs(E[z]['E'][0])**2) + P2 = np.max(np.abs(E[z]['E'][1])**2) + self.G = 10.0 * np.log10( 1.0e-3*10.0**(self.Pmax / 10.0 ) / np.max( np.array([P1, P2]) ) ) + print ('G = ', self.G) + E[z]['E'] = E[z]['E'] * np.sqrt( 10.0**(self.G/10.0) ) + E[z]['noise'] = E[z]['noise'] * 10.0**(self.G/10.0) + + if self.G > 0: + E[z]['noise'] += ( 10.0**(self.G/10.0) - 1 ) * 10.0**(self.NF/10.0) * cv.pwquant * self.glova.f0 * self.glova.fres + else : + print ("WARNING: pypho_oamp: Gain G < 0dB! Signal is only attenuated.") + + z += 1 + return E + + +######################################################################## + def set(self, G = None, Pmean = None, Pmax = None, NF = None): + """Set amplifer parameter""" + + if NF == None and self.NF == None: + self.NF = 4 + print ("WARNING: pypho_oamp: Noise figure NF not defined! I set NF =", self.NF, " dB") + elif NF != None: + self.NF = NF + + + if G == None and Pmean == None and Pmax == None and self.G == None and self.Pmean == None and self.Pmax == None: + self.G = 0 + print ("WARNING: pypho_oamp: No gain or power value defined! I set G =", self.G, " dB") + self.mode = "G" + + if G != None : + self.G = G + self.mode = "G" + elif Pmean != None: + self.Pmean = Pmean + self.mode = "Pmean" + elif Pmax != None: + self.Pmax = Pmax + self.mode = "Pmax" + + if self.mode == "none": + self.G = 0 + print ("WARNING!: pypho_oamp: No gain or power value defined! I set G =", self.G, " dB") + self.mode = "G" diff --git a/pypho_optfi.py b/pypho_optfi.py index 3db40ed..3b1d82b 100644 --- a/pypho_optfi.py +++ b/pypho_optfi.py @@ -11,7 +11,7 @@ # Without Chirp # ######################################################################## - +import matplotlib.pyplot as plt import numpy as np import sys from pypho_functions import * @@ -19,68 +19,121 @@ from pypho_functions import * ######################################################################## class pypho_optfi(object): - def __init__(self, glova = None, Df = None, B = None): + def __init__(self, glova = None, Df = None, B = None, filtype = None, alpha = None, loss = None): if glova == None: print ("ERROR: pypho_optfi: You must define the global variables") sys.exit("PyPho stopped!") - self.glova = glova - self.Df = None - self.B = None + self.glova = glova + self.Df = None + self.B = None + self.filtype = None + self.alpha = None + self.loss = None - self.set(Df, B) + self.set(Df, B, filtype, alpha, loss) ######################################################################## - def __call__(self, E = None, Df = None, B = None): + def __call__(self, E = None, Df = None, B = None, filtype = None, alpha = None, loss = None): - self.set(Df, B) - return self.out(E, Df, B) + self.set(Df, B, filtype, alpha, loss) + return self.out(E, Df, B, filtype, alpha, loss) ######################################################################## - def out(self, E = None, Df = None, B = None): + def out(self, E = None, Df = None, B = None, filtype = None, alpha = None, loss = None): if E == None: print ("ERROR: pypho_optfi: You must define an optical signal") sys.exit("PyPho stopped!") - self.set(Df, B) + self.set(Df, B, filtype, alpha, loss) + + + if self.filtype == "gaussrolloff": + z=0 + self.filfunc=np.zeros(self.glova.nos*self.glova.sps) + res = (self.glova.symbolrate/self.glova.nos) + offset = -self.Df*1e9-(self.glova.sps*self.glova.nos/2)*(self.glova.symbolrate/self.glova.nos) - if type(self.Df) != list: - self.Df = [self.Df] + + while z<(self.glova.nos*self.glova.sps): + if(abs(z*res+offset)<=((1-self.alpha)*self.B/2*1e9)): + self.filfunc[z]=1 - if type(self.B) != list: - self.B = [self.B] - - if type(E) != list: - E = [E] - - if len(self.Df) != len(self.B): - print ("ERROR: pypho_optfi: Unequal numbers of frequencies, bandwidths and/or input signals!") - sys.exit("PyPho stopped!") - - if len(self.Df) != len(E): - print ("Warning: pypho_optfi: Unequal numbers of frequencies/ bandwidths and input signals! Using the first one") - self.f = np.zeros(len(E)) + self.f[0] - self.B = np.zeros(len(E)) + self.B[0] + elif(0z*res+offset+(1-self.alpha)*self.B/2*1e9): + self.filfunc[z]=np.exp(-(((z*res+offset)+(1-self.alpha)*self.B/2*1e9)*((np.sqrt(np.abs(np.log(0.5)))/(self.alpha*self.B/2*1e9))))**2) - z = 0 + z=z+1 + + + z = 0 + + + + + if self.filtype == "gauss": + + self.filfunc =np.exp(-( ( self.glova.freqax + ( - self.glova.f0 - self.Df*1e9 ) )/ (self.B*2.0e9 /2.3582))**2 / 2.0 )**2 + + + + if self.filtype == "rect": + + self.filfunc = np.zeros(self.glova.nos*self.glova.sps)+1e-12 + + self.filfunc[ np.where(np.abs(self.glova.freqax-self.glova.f0) <= self.B*0.5e9) ] = 1 - for Ei in E: - self.filfunc =np.exp(-( ( self.glova.freqax + ( - self.glova.f0 - self.Df[z]*1e9 ) )/ (self.B[z]*2.0e9 /2.3582))**2 / 2.0 )**2 + + if self.filtype == "cosrolloff": - E[z]['E'][0] = ifft( ( fft(E[z]['E'][0]) ) * fftshift( self.filfunc) ) - E[z]['E'][1] = ifft( ( fft(E[z]['E'][1]) ) * fftshift( self.filfunc) ) - E[z]['noise'] = E[z]['noise'] * self.filfunc + T1 = 1.0 / (self.B * 1.0e9) + + offset = -self.Df*1.0e9-(self.glova.sps*self.glova.nos/2.0)*(self.glova.symbolrate/self.glova.nos) + + z = 0 + + self.filfunc = np.zeros(self.glova.nos*self.glova.sps) + + + + while z<(self.glova.nos*self.glova.sps): + if(abs(z*self.glova.fres+offset)<=((1.0-self.alpha)/(2*T1))): + self.filfunc[z]=1.0 + elif (((1-self.alpha)/(2.0*T1)N>Pl1=^~JT2LqlP@xJaEp3w?YN}1E&{W8>y}QnHH@mLi zbBUuw2(>qETq+LyH$8Bv1b;y92#FJdEB(!^9hBlaFN zdb-h!Lu2N#`R3r}X6hN6cDrG4x>|(Da`3e@2`&3D10#ZPTU*PChM5Nq>wvowNv1Dn zdZDfIMo~6l9Qmy57nrcsDn>@c??kj8bO&|{i}kurw5`|Q053Y^lvG|VIMWJWXFsp( zMe=$E4Ce-PKQ}yAob92=MXIu+PD;eg0l zP!b^@n1@8T0;jM4=Ml0yiWh$`GRUXMb7j~9-E*n;)lkyLxsa$lp?rPmPS_Q=p;wDK$Wp%2@wP(x_~p^zoyoC0TEUtj0&olyR~LM2K_G$-$*>5o<@~= zMz@nj{E}`rw_aiFb`sw2V`tLeYKA@IrI8o)APSR~4$V2Q*+_zKbYM4)2kv~@^K{bf z+mWZ!rVYdEjb5UY_5olz-1PYarVrTlZW~w>FpG2#=mwC|a7FBo!lzF!4Vh<`+P`() z`}^@TXIXRKix|&kzXYn~l3;jBQfpj$A?Wri1Sr#hi0`$tQmNS#XfT>)I5SpjPN-p5Q*J|U28U4)_hDs4 zU&u)2rsnhn+-{1f4$H(_S zlN-XjwYoDdR=m9|AMWJZ`s$5wJG|0KW_x9IN8W<6GL~|Y>-RX0kzK!1+EPNY$_03M z!Ehe#Vwe*kpJT#x zDBU&oF5FAr3ViNUZcfAY3#vR{o+_W0W{`dZJaq?tnGN#k>=BUcy+Zm*r-_l)OPigr ZWyRX-ol5sDWzm1m77gdCq)KWg_Z)gx4MP9` diff --git a/pypho_osnr.py b/pypho_osnr.py new file mode 100644 index 0000000..4dcacce --- /dev/null +++ b/pypho_osnr.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +""" +Created on Mon Apr 23 13:44:16 2018 + +@author: lonstud7 +""" + +import numpy as np +import sys +from pypho_functions import * +from pypho_constants import pypho_constants + + +######################################################################## + +class pypho_osnr(object): + def __init__(self, glova = None, OSNR = None, f = None): + + if glova == None: + print ("ERROR: pypho_osnr: You must define the global variables") + sys.exit("PyPho stopped!") + else: + self.glova = glova + + self.OSNR = None + self.f = None + self.mode = "get" + self.glova = glova + + self.set(OSNR) + +######################################################################## + def __call__(self, E = None, OSNR = None, f = None): + + self.set(OSNR, f) + + return self.out(E = E) + +######################################################################## + def out(self, E = None): + + if E == None: + print ("ERROR: pypho_osnr: You must define an optical signal") + sys.exit("PyPho stopped!") + + if type(E) != list: + E = [E] + + idx_f = (np.abs(self.glova.freqax - self.f)).argmin() + + z = 0 + for Ei in E: + + (P1, P2) = getpower_W(E[z]['E']) + + if self.mode == "get": + + E = 10.0 * np.log10( (P1+P2) / (E[z]['noise'][idx_f] * 12.5e9 / self.glova.fres ) ) + + elif self.mode == "set": + + k_noise = (P1+P2) / 10**(self.OSNR/10) / 12.5e9 * self.glova.fres + + E[z]['noise'] *= k_noise / E[z]['noise'][idx_f] + + z += 1 + + return E + + +######################################################################## + def set(self, OSNR = None, f = None): + """Set or get OSNR value""" + + self.OSNR = OSNR + + if f == None and self.f == None: + self.f = self.glova.f0 + print ("WARNING: pypho_osnr: Frequency f not defined! I set f =", self.f, " Hz") + elif f != None: + self.f = gp.freqax[ (np.abs(self.glova.freqax - f)).argmin() ] + + if (np.abs(self.glova.freqax - self.f)).argmin() == 0 : + self.f = self.glova.freqax[0] + print ("WARNING: pypho_osnr: Frequency f smaller than lowest frequency ! I set f =", self.f, " Hz") + elif (np.abs(self.glova.freqax - self.f)).argmin() == (self.glova.sps * self.glova.nos - 1) : + self.f = self.glova.freqax[-1] + print ("WARNING: pypho_osnr: Frequency f higher than highest frequency ! I set f =", self.f, " Hz") + + if OSNR == None: + self.mode = "get" + else: + self.mode = "set" \ No newline at end of file diff --git a/pypho_poincare.pyc b/pypho_poincare.pyc deleted file mode 100644 index 490b685425170f3c638eea23be1297ede78cda60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5313 zcmcIoOLN@D5pH0YOL9qy6dw}xidPmLZDN~G>k(GUlp>|1lpVzdRz=npQz&o;y99{^ zR+ynlD%>1G>7HxyBXZBl=iKrWl4~w@D(6)4bq_$UWU3rF3YQqn^lN&$dwP0M`sY}6 z{FAR5P0IgDc;CUJ_s}S!23m)dOR+-@SNbK2OVlY-qfAbY8=&n9H3kJ;rg(@tL(~|u z=mCm{sZ*s!^_YBw8Y84C6pm60!UyR&(Gk&;#u(4EULRrwZlS5(%fi5fs+K0T$9Vlb z$ZEA)wWX!irH@uuZq}9;mu^?9cYW(2UrOKw!C4f9&wvXBjuw_azJn>4dqXvd}O zDhqz_&^WXWuefyNkdp|(A(4;y(MJc<+72eMoeIOZ2c<33p-YD)Ix4|61jDoUAL-j@ zf9iR^@K$TqQm|_)TCF`vcWa$pZE7lP!Ado=71r8ux*5c^FM=!zHserhHr!_ipKYZz zZPIQxR9D5Frp%(#Bs4sSKF|UP_akEl0Dzb;0xSj-%ea}wX(qnw1ldlQS+3C3S&Xpi zFm8E+7@Go<*D!}>w~;%^c6FzmCNK3o9u6Y0XbW1hUBsxcD9nQY z7cRA2y1=^u!QT%$a%rPXJ(qeV>Y+10c844h^$__LHaa$+lI?ipI6Z8HK{h+G5qpLQ z*eb|mL!^cQas*T%Rec2n667$UQlsqbBgb{r7>n}(g$6@phH1M>yZ}sDh|ZK)-Z#=@gZ~&EzksbXioo(x;N8dWoo*Or1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ltH#`z^Wzg;uPA@O7DfR9;C`LIzbkK!ZDIGzb-bl^Xv^#%3- diff --git a/pypho_sample.py b/pypho_sample.py new file mode 100644 index 0000000..fe9afdc --- /dev/null +++ b/pypho_sample.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# pypho.py +# +# Copyright 2018 Arne Striegler (arne.striegler@hm.edu) +# +# +# +# Samples a signal +# +# +######################################################################## + +import numpy as np +import sys +from pypho_functions import * +from pypho_signalsrc import pypho_signalsrc +import matplotlib.pyplot as plt + +######################################################################## + +class pypho_sample(object): + + def __init__(self, glova = None): + + if glova == None: + print ("ERROR: pypho_sample: You must define the global variables") + sys.exit("PyPho stopped!") + self.glova = glova + self.sampletime = None + self.E = [] + self.constpoints = None + self.bits = None + self.style = None + self.E_x_samp = [] + self.E_y_samp = [] + self.E_x_n_samp = [] + self.E_y_n_samp = [] + + +######################################################################## + + def __call__(self, E = None, sampletime = None, constpoints = None, bits = None, style = None): + + + if E == None: + print ("ERROR: pypho_sample: You must define an optical signal") + sys.exit("PyPho stopped!") + + self.set(sampletime, constpoints, bits, style) + + return self.out(E) + +######################################################################## + + def out(self, E = []): + + self.E_x_samp = [] + self.E_y_samp = [] + + if (self.style != None): + styles = self.style.split(',') + if len(styles) == 1: + styles.append(styles[0]) + + const_dec_x = [] + const_dec_y = []; + for const_bin in np.asarray( self.constpoints[0][4] ) : + const_dec_x.append( const_bin.dot(2**np.arange(const_bin.size)[::-1]) ) + for const_bin in np.asarray( self.constpoints[1][4] ) : + const_dec_y.append( const_bin.dot(2**np.arange(const_bin.size)[::-1]) ) + + for symbol in range(0, self.glova.nos): + # X-Pol + b = self.bits[0][symbol*self.M : symbol*self.M + self.M] + const_num = b.dot(2**np.arange(b.size)[::-1]) + if (styles[0] != 'NO'): + plt.subplot(2, 1, 1) + plt.plot(np.real( E[0]['E'][0][symbol*self.glova.sps + self.sampletime] ), np.imag(E[0]['E'][0][symbol*self.glova.sps + self.sampletime]), marker=styles[0], color= self.constpoints[0][2][const_dec_x.index(const_num)]) + + self.E_x_samp.append( E[0]['E'][0][symbol*self.glova.sps + self.sampletime] ) + self.E_x_n_samp.append(const_num) + + if (styles[0] != 'NO'): + plt.ylabel('$imag( E_{x})$'); plt.xlabel('$real( E_{x})$'); + + # Y-Pol + b = self.bits[1][symbol*self.M : symbol*self.M + self.M] + const_num = b.dot(2**np.arange(b.size)[::-1]) + if (styles[0] != 'NO'): + plt.subplot(2, 1, 2) + plt.plot(np.real( E[0]['E'][1][symbol*self.glova.sps + self.sampletime] ), np.imag(E[0]['E'][1][symbol*self.glova.sps+ self.sampletime]), marker=styles[1], color= self.constpoints[1][2][const_dec_y.index(const_num)]) + + self.E_y_samp.append( E[0]['E'][1][symbol*self.glova.sps + self.sampletime] ) + self.E_y_n_samp.append(const_num) + + if (styles[0] != 'NO'): + plt.ylabel('$imag( E_{y})$'); plt.xlabel('$real( E_{y})$'); + + return (self.E_x_samp, self.E_y_samp, self.E_x_n_samp, self.E_y_n_samp) + +######################################################################## + + def set(self, sampletime = None, constpoints = None, bits = None, style = None): + + + if constpoints == None and self.constpoints == None: + print ("ERROR: pypho_sample: You must define the constellation points") + sys.exit("PyPho stopped!") + elif constpoints != None: + self.constpoints = constpoints + self.M = int(np.floor( np.log2(len(constpoints[0][0])) )) + + if sampletime == None and self.sampletime == None: + self.sampletime = self.glova.sps/2 + print ("WARNING: Number of sample not specified, so I am using ", self.sampletime) + elif sampletime != None: + self.sampletime = sampletime + + if bits == None and self.bits == None: + print ("ERROR: pypho_sample: You must define the bits of the X- and Y-plane") + sys.exit("PyPho stopped!") + elif bits != None: + self.bits = bits + + if style == None and self.style == None: + self.style = 'NO' + elif style != None: + self.style = style + + +######################################################################## \ No newline at end of file diff --git a/pypho_setup.py b/pypho_setup.py index 71c6acd..e545ebf 100644 --- a/pypho_setup.py +++ b/pypho_setup.py @@ -92,9 +92,9 @@ class pypho_setup(object): elif sps != None: self.sps = sps - if f0 == None and self.f0 == None: - print ("WARNING: Center frequency f0 not specified, so I am using 193414489032258.06 Hz") + if f0 == None and self.f0 == None: self.f0 = 193414489032258.06 + print ("WARNING: Center frequency f0 not specified, so I am using ", self.f0, " Hz") elif f0 != None: self.f0 = f0 diff --git a/pypho_setup.pyc b/pypho_setup.pyc deleted file mode 100644 index 803a6a038b5c2561fdc3921f51e00098e39785d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2958 zcmbVOPjlNu6kkb}lekG++5`*?gF3^(gidkNKQtLAC7~o87}JptK!zEOVyzRUvLw9g zHfC}nz4i-m;=+LoAA{k{ci;=anStMXE6EOoHeh?#@9m%8{@&ZC_vHM((D>H>Wv3^K zkAwfaXzF8h5q_3PgxIl4*%muC%eF`yF>u6=BP{8NV=StP$Pv;NeXOpDCxQmQ*r^jn zx8(va{u7^0%Yvvcpv%YkeirnyROv9)N}sF7l+>fVB2~xu2ATq(kcQ5Th^Bu+JaLJO z1PP1Jw#1Ihs$HseR-ICvVbu`D;#pSRa(3<{KF+H15e?yYTeINNBUWYGBz9k-gUgPD z2-sgFu(L>T$|(>uYg}SVQ}B?@!VL8Xv*HNj7;(f=O&q!6*cBG`bXyJ%=x91zOQlCj z4)si-4{C;7^SQyIC>}wbXPiy(Ak&yfIggBi`^( zj?G4?TVx~8Dw*_s+ThcWPe=Pi#;1c@Xr@!=A(^Y?YrK|^nR5`tX{>|bWlXD!wA`Mv ziZ4laj{<`lQDu)361l|mmRRg^@TfO1z9qHSAIh&rGVP7MVVLeo4|aOX-o(5XAsMzr zlsEeeB%%E~TQaZDh;Kns1R|V&vb%&~bA=$dL_96A)a5hP>zE^kDjejA)bRl1DzAHQ z6VsSXH4NE{bn00d@-0@-E72Z#Icjm4`j))2*72sKVr|7BMED@eV)~g|Tqvt;*|_J)dJ@ z+8&}?7*ld*lZ-NLQn9jW41UR|)Z1baURf$lrh7dZT`*k5WH3Jr{tJ+NT4ih{>gKti zN8-O2Oz|5Y-oY+&eYMJ5I_%U(00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2-eTxKCsd(bs!LHL`oJx$vR0y9sv3*Bd@UzfWrr4)77IqZRAm|M1go&db%>s}kIRvYeDCwdau%+C zlX5(A`){BS1`5(N*tdH*87K|nZrBhWlYN{#R_x_D@tVU621BkyfVhp{GN>%l|hE3%}eRlHotx+=Yw zGZ_1!1AJq3U|=9)JwjxE5xfH%OB~m}U{~ z&o|Mxe%Eh))O;YE${tzM+f`v)s4<~|MtnBZ#U&10zTmzT?K3(!)B}xt^a%T zmh0uOA!HUQ>R!PuaE@Q8)lqBO1M4*2wpww}4_hs{Z?szdq%-WHY3-1porjcM3}o?R z7Y<1l>KH|v)K2(^fDcK<+>#SaO)s2Vm|u9Mey%=`@0)VKmh{2Vcd##8zFcV}+LO&4 Z?$y+Aw#g(XZrRm*pGPOd;{tq8`3gGcHSYib diff --git a/speedfiber.pyx b/speedfiber.pyx new file mode 100644 index 0000000..f4d5a24 --- /dev/null +++ b/speedfiber.pyx @@ -0,0 +1,313 @@ +# -*- coding: utf-8 -*- +""" +Created on Sun Jan 14 17:13:42 2018 + +python speedup.py build_ext --inplace + +@author: arne +""" +# cython speedfiber.pyx -a +# python speedup.py build_ext --inplace + +#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION + +from __future__ import division + +cimport numpy as np +import numpy as np + +#import pyfftw +import time +import sys + +import cython +from cython.parallel import prange +from cython.view cimport array as cvarra +from cython import boundscheck, wraparound + +cdef extern from "math.h" nogil: + double sin(double x) + double cos(double x) + double log(double x) + double sqrt(double x) + double exp(double x) + double pow(double x, double y) + + +cdef extern from "fftw3.h": + int fftw_init_threads() + void fftw_plan_with_nthreads(int) + + cdef int FFTW_FORWARD + cdef int FFTW_BACKWARD + cdef unsigned FFTW_MEASURE + cdef unsigned FFTW_ESTIMATE + cdef unsigned FFTW_PATIENT + cdef unsigned FFTW_DESTROY_INPUT + cdef unsigned FFTW_UNALIGNED + + ctypedef double fftw_complex[2] + + void *fftw_malloc(size_t) + void fftw_free(void *) + + ctypedef struct _fftw_plan: + pass + + ctypedef _fftw_plan *fftw_plan + + void fftw_execute(fftw_plan) + void fftw_destroy_plan(fftw_plan) + fftw_plan fftw_plan_dft_1d(int, fftw_complex*, fftw_complex*, int, unsigned) + void fftw_print_plan(fftw_plan) + + +cdef extern from "complex.h" nogil: + double cabs(double complex) + double complex cexp(double complex) + double creal( double complex z ); + double cimag( double complex z ); + + +@boundscheck(False) +@wraparound(False) +def cyfiber(int noofsamples,float l, complex[:] E_x, complex[:] E_y, float alpha, float gamma_intern, float phi_max, + double[:,:] birefarray, int birefsteps, float max_step, complex[:] beta_fac, complex[:] Domega, + complex[:] Ex_out, complex[:] Ey_out): + + N_cores = 4 + + cdef double noofsample_float = noofsamples + + fftw_init_threads() + fftw_plan_with_nthreads(N_cores) + cdef int n = E_x.shape[0] + cdef fftw_complex *Elx + cdef fftw_complex *Ely + cdef fftw_complex *outx + cdef fftw_complex *outy + Elx = fftw_malloc(n * sizeof(fftw_complex)) + Ely = fftw_malloc(n * sizeof(fftw_complex)) + outx = fftw_malloc(n * sizeof(fftw_complex)) + outy = fftw_malloc(n * sizeof(fftw_complex)) + cdef fftw_plan plan_xf = fftw_plan_dft_1d(n, Elx, outx, FFTW_FORWARD, (FFTW_MEASURE | FFTW_DESTROY_INPUT | FFTW_UNALIGNED)) + cdef fftw_plan plan_xb = fftw_plan_dft_1d(n, outx, Elx, FFTW_BACKWARD, (FFTW_MEASURE | FFTW_DESTROY_INPUT | FFTW_UNALIGNED)) + cdef fftw_plan plan_yf = fftw_plan_dft_1d(n, Ely, outy, FFTW_FORWARD, (FFTW_MEASURE | FFTW_DESTROY_INPUT | FFTW_UNALIGNED)) + cdef fftw_plan plan_yb = fftw_plan_dft_1d(n, outy, Ely, FFTW_BACKWARD, (FFTW_MEASURE | FFTW_DESTROY_INPUT | FFTW_UNALIGNED)) + + cdef float lc = 0 + cdef float powmax_x = 0.0 + cdef float powmax_y + cdef double[:] beta_xr = np.zeros(noofsamples) + cdef double[:] beta_yr = np.zeros(noofsamples) + cdef double[:] beta_xi = np.zeros(noofsamples) + cdef double[:] beta_yi = np.zeros(noofsamples) + cdef complex beta_x + cdef complex beta_y + + cdef double[:] power_x = np.zeros(noofsamples) + cdef double[:] power_y = np.zeros(noofsamples) + cdef double nl_x + cdef double nl_y + cdef double Exr_tmp, Exi_tmp, Eyr_tmp, Eyi_tmp + + cdef double power1_x + cdef double power1_y + + cdef double[:] E_x_r = np.zeros(noofsamples) + cdef double[:] E_x_i = np.zeros(noofsamples) + cdef double[:] E_y_r = np.zeros(noofsamples) + cdef double[:] E_y_i = np.zeros(noofsamples) + cdef double E_tmp + + cdef double cos_x + cdef double sin_x + cdef double cos_y + cdef double sin_y + + #cdef complex[noofsamples] beta_term + cdef complex delta_beta + cdef complex delta_beta_current + + cdef double[::1] zleff = -np.log( np.array([0.98, 0.95, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.4, 0.3, 0.25, 0.2, 0.1, 0.09, 0.08, 0.07, 0.06, 0.05, 0.04, 0.03, 0.02, 0.01, 1e-10]) ) / (alpha + 1.0e-12) #kleiner pfusch + + cdef int zleff_i = 0 + cdef doCoordRot = False + cdef doCalcLeff = True + cdef float next_l = 0 + cdef float next_leff = 0 + cdef float fak_xpm = 2.0/3.0 + + cdef float gamma_fast = -0.0000000001 + cdef int birefindex = 0 + cdef double cos_angle = 0.0 + cdef double sin_angle = 0.0 + cdef double biref_ang = 0.0 + + cdef int i + + for i in prange(noofsamples, nogil=True): + Elx[i][0] = creal(E_x[i]) + Elx[i][1] = cimag(E_x[i]) + Ely[i][0] = creal(E_y[i]) + Ely[i][1] = cimag(E_y[i]) + + print('Start ciber!!', alpha) + print (zleff[0]) + tic0 = time.time() + while lc < l : + + if birefindex < birefsteps and lc + next_l >= birefarray[birefindex][1]: + #print( lc + next_l , birefindex, birefarray[birefindex].z_point) + doCoordRot = True + + # TODO: stimmt das? + if (lc + next_l) >= l: + doCalcLeff = True + + if lc >= zleff[zleff_i] or doCoordRot or doCalcLeff: # calculate the steplength + doCalcLeff = False + #print (lc, zleff[zleff_i], zleff_i, sqrt(exp(-alpha * next_l))) + if lc >= zleff[zleff_i] : + zleff_i +=1 + + powmean_x = np.mean( Elx[i][0]*Elx[i][0] + Elx[i][1]*Elx[i][1] ) + powmean_y = np.mean( Ely[i][0]*Ely[i][0] + Ely[i][1]*Ely[i][1] ) + powmax_x = np.mean([powmean_x, powmean_y]) + #print (powmax_x) + next_leff = phi_max / powmax_x + + if next_leff*alpha < 1.0 and alpha > 0.0: + next_l = -log(1.0 - next_leff*alpha)/alpha + else: + next_l = next_leff + + if next_l > max_step: + next_l = max_step + if alpha > 0.0: + next_leff = (1.0 - exp(-alpha*next_l)) / alpha + elif alpha == 0.0: + next_leff = next_l + + if (lc + next_l) >= l: + next_l = l - lc + if alpha > 0.0: + next_leff = (1.0 - exp(-alpha*next_l)) / alpha + elif alpha == 0.0: + next_leff = next_l + + doCoordRot = False + if birefindex < birefsteps and lc + next_l >= birefarray[birefindex][1]: + if birefarray[birefindex][1] > 0 : + next_l = birefarray[birefindex][1] - lc + if alpha > 0.0: + next_leff = (1.0 - exp(-alpha*next_l)) / alpha + elif alpha == 0.0: + next_leff = next_l + delta_beta_current = birefarray[birefindex][2] + birefindex = birefindex + 1 + doCoordRot = True + doCalcLeff = True + + + for i in prange(noofsamples, nogil=True): + beta_x = cexp(beta_fac[i] * next_l) * sqrt(exp(-alpha * next_l)) # for x- and y-pol + beta_y = beta_x * cexp( 0.5 * Domega[i] * delta_beta_current * next_l)# x-pol + beta_x = beta_x * cexp(-0.5 * Domega[i] * delta_beta_current * next_l)# y-pol + + beta_xr[i] = creal(beta_x) + beta_xi[i] = cimag(beta_x) + + beta_yr[i] = creal(beta_y) + beta_yi[i] = cimag(beta_y) + + gamma_fast = -next_leff*gamma_intern + + # nonlinear fiber effects + tic = time.time() + for i in prange(noofsamples, nogil=True): + Exr_tmp = Elx[i][0] + Exi_tmp = Elx[i][1] + Eyr_tmp = Ely[i][0] + Eyi_tmp = Ely[i][1] + #print("---", Elx[i], Exr_tmp, fak_xpm, gamma_fast) + + nl_x = (Exr_tmp*Exr_tmp + Exi_tmp*Exi_tmp + (Eyr_tmp*Eyr_tmp + Eyi_tmp*Eyi_tmp ) * fak_xpm) * gamma_fast + nl_y = (Eyr_tmp*Eyr_tmp + Eyi_tmp*Eyi_tmp + (Exr_tmp*Exr_tmp + Exi_tmp*Exi_tmp ) * fak_xpm) * gamma_fast + + # schneller: cos & sin als taylorreihe, da für x<0.05 die ersten 2 bzw. 3 elemente ausreichen. nl ist < 0.05 + cos_x = cos(nl_x) #1.0 - nl_x*nl_x * (0.5 - nl_x*nl_x * 0.041666666666666664) + sin_x = sin(nl_x) #nl_x - nl_x*nl_x*nl_x * (0.16666666666666666 - nl_x*nl_x * 0.008333333333333333) + cos_y = cos(nl_y) #1.0 - nl_y*nl_y * (0.5 - nl_y*nl_y * 0.041666666666666664) + sin_y = sin(nl_y) #nl_y - nl_y*nl_y*nl_y * (0.16666666666666666 - nl_y*nl_y * 0.008333333333333333) + # (Exr + j*Exi)*(cos_x + j*sin_x) + + Elx[i][0] = Exr_tmp * cos_x - Exi_tmp * sin_x + Elx[i][1] = Exr_tmp * sin_x + Exi_tmp * cos_x + Ely[i][0] = Eyr_tmp * cos_y - Eyi_tmp * sin_y + Ely[i][1] = Eyr_tmp * sin_y + Eyi_tmp * cos_y + + + + # linear fiber effects + fftw_execute(plan_xf) # FFT fw x-pol + fftw_execute(plan_yf) # FFT fw y-pol + for i in prange(noofsamples, nogil=True): + outx[i][0] /= noofsample_float + outx[i][1] /= noofsample_float + outy[i][0] /= noofsample_float + outy[i][1] /= noofsample_float + Exr_tmp = outx[i][0] + outx[i][0] = Exr_tmp*beta_xr[i] - outx[i][1]*beta_xi[i]# x-pol linstep real + outx[i][1] = Exr_tmp*beta_xi[i] + outx[i][1]*beta_xr[i]# x-pol linstep imag + Eyr_tmp = outy[i][0] + outy[i][0] = Eyr_tmp*beta_yr[i] - outy[i][1]*beta_yi[i]# y-pol linstep real + outy[i][1] = Eyr_tmp*beta_yi[i] + outy[i][1]*beta_yr[i]# y-pol linstep imag + + fftw_execute(plan_xb) # FFT bw x-pol + fftw_execute(plan_yb) # FFT bw y-pol + + + if doCoordRot: + biref_ang += birefarray[birefindex][0] + sin_angle = sin(birefarray[birefindex][0]) + cos_angle = cos(birefarray[birefindex][0]) + for i in prange(noofsamples, nogil=True): + Exr_tmp = Elx[i][0] + Exi_tmp = Elx[i][1] + Eyr_tmp = Ely[i][0] + Eyi_tmp = Ely[i][1] + Elx[i][0] = Exr_tmp * cos_angle - Eyr_tmp * sin_angle + Elx[i][1] = Exi_tmp * cos_angle - Eyi_tmp * sin_angle + Ely[i][0] = Exr_tmp * sin_angle + Eyr_tmp * cos_angle + Ely[i][1] = Exi_tmp * sin_angle + Eyi_tmp * cos_angle + doCoordRot = False + + + lc += next_l + + curti = time.time() + sys.stdout.write( '\r[{0}{1}] {2}%, {3} m,{4} sec, {5} m, {6} steps/sec'.format('#'*int(50*lc/l),'.'*(50-int(50*lc/l)), round(100*lc/l, 2 ), lc ,round ((curti - tic0 ),2) , next_l, 1/(curti - tic))) + + #fftw_destroy_plan(plan_f) + #fftw_destroy_plan(plan_b) + #fftw_free(ain) + #fftw_free(aout) + + sin_angle = sin( -biref_ang ) + cos_angle = cos( -biref_ang ) + for i in prange(noofsamples, nogil=True): + Exr_tmp = Elx[i][0] + Exi_tmp = Elx[i][1] + Eyr_tmp = Ely[i][0] + Eyi_tmp = Ely[i][1] + Elx[i][0] = Exr_tmp * cos_angle - Eyr_tmp * sin_angle + Elx[i][1] = Exi_tmp * cos_angle - Eyi_tmp * sin_angle + Ely[i][0] = Exr_tmp * sin_angle + Eyr_tmp * cos_angle + Ely[i][1] = Exi_tmp * sin_angle + Eyi_tmp * cos_angle + + print('Ende loop!') + for i in prange(noofsamples, nogil=True): + Ex_out[i] = Elx[i][0] + 1j*Elx[i][1] + Ey_out[i] = Ely[i][0] + 1j*Ely[i][1] + #print('Ende ciber!') \ No newline at end of file diff --git a/speedup.py b/speedup.py new file mode 100644 index 0000000..6df7787 --- /dev/null +++ b/speedup.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +""" +Created on Sun Jan 14 19:57:42 2018 + +@author: arne +""" + +#from distutils.core import setup +#from distutils.extension import Extension +#from Cython.Distutils import build_ext +#import numpy + +#ext_modules=[ Extension("speedfiber", + #["speedfiber.pyx"], + #include_dirs=[numpy.get_include()], + #libraries=["m","fftw3"], + #extra_compile_args = ["-ffast-math", "-fopenmp", "-lfftw3 -lm"], + #extra_link_args=['-fopenmp'])] + +#setup( + #name = "speedfiber", + #cmdclass = {"build_ext": build_ext}, +# ext_modules = ext_modules) + +#from distutils.core import setup +from setuptools import setup, find_packages +from setuptools.extension import Extension +from Cython.Build import cythonize + +#from distutils.extension import Extension +#from Cython.Distutils import build_ext +#ext_modules + +extensions = [Extension("speedfiber", + ["speedfiber.pyx"], + include_dirs=['/usr/include/', '/usr/local/include/include'], # not needed for fftw unless it is installed in an unusual place + libraries=['m', 'fftw3','fftw3_omp'], + library_dirs=['/usr/lib/'], # not needed for fftw unless it is installed in an unusual place + extra_compile_args=['-ffast-math', '-lfftw3', '-lm', '-fopenmp'], # '-fopenmp', lpthread + extra_link_args=['-fopenmp'])] + + +setup( + name = 'Speedfiber', + #cmdclass = {'build_ext': build_ext}, + packages = find_packages(), + #ext_modules = ext_modules + ext_modules = cythonize(extensions) +) \ No newline at end of file -- GitLab