Let's start with a simple setup up, which generates a single channel OOK-signal and transmits it over a fiber.
First of all all you have to import all classes we need:
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_meanpow import pypho_meanpow from pypho_fiber import pypho_fiber import numpy as np import matplotlib.pyplot as plt import copy
As you can see we imported copy and matplotlib. We will use them to plot the signal befor and after the transmission.
Before defining the network elements we have to define some global variables:
gp = pypho_setup(nos = 64, sps = 128, symbolrate = 10e9)
pypho_setup the simulation world is defined. Here you have to define parameters such as the number of samples per symbol $SPS$, the number of symbols $NOS$, the symbol rate $f_S$ and center frequency $f_0$.
These parameters are available in
If you don't set a parameter pypho will use a default value and inform you.
You can get here more informations on this function and which helpful feature it has.
Next you have to define the network elements as instances of the classes:
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random') esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.30) sig_1550 = pypho_lasmod(glova = gp, power = 3) amp = pypho_meanpow (glova = gp, power = 3, unit ="dBm") SSMF = pypho_fiber(glova = gp, l = 100.0e3, D = 17, S = 5.8e-2, alpha = 0.2, gamma = 1.14) DCF = pypho_fiber(glova = gp, l = 10.00e3, D = -170, S = -0.58, alpha = 0.8, gamma = 1.80)
At first we create a network element named
bitgenerator by the function
pypho_bits which creates a bitsequence. As can be seen in each initial call of the class we have to set the global variables
defines here the numbers of bits you want to create. You can also define the bitpattern to be random, a single '1' or a pulse train of '1'.
Representing these bits as an electrical signal is done by a network element named
esigsrc by the function
pypho_signalsrc. Here you can define the pulse shape and width.
An ideal laserdiode transforming the electrical signal to an optical signal is done by the element
Using the function
pypho_meanpow defines an ideal amplifier
amp. With this module you can define the mean power of the optical signal.
One of the most important function is
pypho_fiber. You can define several fiber types like
Now, all the network elements needed for the first simulationa are defined. Let's connect them by defining input and output signals from these network elements:
bits = bitsrc() esig = esigsrc(bitsequence = bits) E_Tx = sig_1550(esig = esig) E = amp( E = copy.deepcopy(E_Tx)) E = SSMF(E = E) #E = DCF(E = E)
You can uncomment the DCF to compensate the accumulated dispersion of the SSMF.
After the simulation we plot the input signal
E_Tx before the transmission and the output signal
E after transmission.
plt.subplot(211) plt.plot(gp.timeax*1.0e12, 1e3*np.abs(E_Tx['E'])**2, 'r') plt.title('X-Pol. before transmission'); plt.ylabel('Power [mW]') plt.subplot(212) plt.plot(gp.timeax*1.0e12, 1e3*np.abs(E['E'])**2, 'r') plt.title('X-Pol. after transmission'); plt.ylabel('Power [mW]'); plt.xlabel('Time [ps]') plt.show()
The plots show the results of the example. As the bits are random. Your results may look different.
Fig. 2 : Results of the basic example