Ejemplo n.º 1
0
        return output_ports, output_fields


if __name__ == "__main__":
    """Give an example of Sech usage.
    This piece of code is standalone, i.e. can be used in a separate
    file as an example.
    """

    from typing import Callable, List, Optional

    import numpy as np

    import optcom as oc

    lt: oc.Layout = oc.Layout(oc.Domain(samples_per_bit=4096))

    channels: int = 3
    center_lambda: List[float] = [1552.0, 1549.0, 1596.0]
    position: List[float] = [0.3, 0.5]
    width: List[float] = [5.3, 6.]
    peak_power: List[float] = [1e-3, 2e-3, 6e-3]
    rep_freq: List[float] = [0.03, 0.04]
    offset_nu: List[float] = [1.56, -1.6]
    chirp: List[float] = [0.5, 0.1]
    init_phi: List[float] = [1.0, 0.0]

    sech = oc.Sech(channels=channels,
                   center_lambda=center_lambda,
                   position=position,
                   fwhm=width,
Ejemplo n.º 2
0
 nu_bw = oc.lambda_bw_to_nu_bw(lambda_bw, center_lambda)
 tf = oc.GaussianFilter.transfer_function(nu, center_nu, nu_bw, 0.0)  #1.5)
 lambdas = oc.nu_to_lambda(nu)
 oc.plot2d(lambdas,
           tf,
           x_labels=['nu'],
           y_labels=['Amplitude (a.u.)'],
           plot_titles=[
               "Transfer function centered at "
               "{} nm with bandwidth {} nm".format(round(center_lambda, 2),
                                                   round(lambda_bw))
           ])
 # Apply on pulse and plot
 bit_width = 1000.
 domain = oc.Domain(samples_per_bit=2**13,
                    bit_width=bit_width,
                    noise_samples=int(1e3),
                    noise_range=(center_lambda - 1.0, center_lambda + 1.0))
 lt: oc.Layout = oc.Layout(domain)
 lambda_bw = 0.05  # nm
 nu_bw = oc.lambda_bw_to_nu_bw(lambda_bw, center_lambda)
 pulse: oc.Gaussian = oc.Gaussian(channels=2,
                                  peak_power=[10.0, 19.0],
                                  width=[10., 6.],
                                  center_lambda=[center_lambda],
                                  noise=100 * np.ones(domain.noise_samples))
 filter: oc.GaussianFilter = oc.GaussianFilter(nu_bw=nu_bw,
                                               nu_offset=0.,
                                               order=1,
                                               center_nu=center_nu)
 lt.add_link(pulse[0], filter[0])
 lt.run(pulse)
Ejemplo n.º 3
0
        return output_ports, output_fields


if __name__ == "__main__":
    """Give an example of CW usage.
    This piece of code is standalone, i.e. can be used in a separate
    file as an example.
    """

    from typing import List

    import numpy as np

    import optcom as oc

    dm: oc.Domain = oc.Domain(samples_per_bit=512, bit_width=100.0)
    lt: oc.Layout = oc.Layout(dm)

    channels: int = 1
    center_lambda: List[float] = [1552.0, 1549.0, 1596.0]
    peak_power: List[float] = [1e-3, 2e-3, 6e-3]
    offset_nu: List[float] = [0.0, 1.56, -1.6]
    init_phi: List[float] = [1.0, 1.0, 0.0]

    cw: oc.CW = oc.CW(channels=channels,
                      center_lambda=center_lambda,
                      peak_power=peak_power,
                      offset_nu=offset_nu,
                      init_phi=init_phi,
                      save=True)
Ejemplo n.º 4
0
if __name__ == "__main__":
    """Give an example of IdealFilter usage.
    This piece of code is standalone, i.e. can be used in a separate
    file as an example.
    """

    from typing import Callable, List, Optional

    import numpy as np

    import optcom as oc

    center_lambda = 1030.

    domain = oc.Domain(bit_width=600.,
                       noise_samples=int(1e3),
                       noise_range=(center_lambda - 1.0, center_lambda + 1.0))
    lt: oc.Layout = oc.Layout(domain)

    nu_bw: float = 0.01
    center_nu = oc.lambda_to_nu(center_lambda)
    pulse: oc.Gaussian = oc.Gaussian(channels=2,
                                     peak_power=[10.0, 19.0],
                                     width=[10., 6.],
                                     center_lambda=[center_lambda],
                                     noise=100 * np.ones(domain.noise_samples))
    filter: oc.IdealFilter = oc.IdealFilter(nu_bw=nu_bw,
                                            nu_offset=0.,
                                            center_nu=center_nu,
                                            NOISE=True)
    lt.add_link(pulse[0], filter[0])
Ejemplo n.º 5
0
    """Give an example of FiberCoupler usage.
    This piece of code is standalone, i.e. can be used in a separate
    file as an example.
    """

    import math
    from typing import Callable, List, Optional, Union

    import numpy as np

    import optcom as oc

    noise_samples: int = 100
    lt: oc.Layout = oc.Layout(
        oc.Domain(bit_width=20.0,
                  samples_per_bit=1024,
                  noise_samples=noise_samples))

    Lambda: float = 1030.0
    pulse_1: oc.Gaussian = oc.Gaussian(channels=1,
                                       peak_power=[38.5, 0.5],
                                       fwhm=[1.],
                                       center_lambda=[Lambda],
                                       noise=np.ones(noise_samples) * 12)
    pulse_2: oc.Gaussian = oc.Gaussian(channels=1,
                                       peak_power=[23.5, 0.3],
                                       fwhm=[1.],
                                       center_lambda=[1050.0],
                                       noise=np.ones(noise_samples) * 5)

    steps: int = int(100)
Ejemplo n.º 6
0
    import numpy as np

    import optcom as oc

    plot_groups: List[int] = []
    line_labels: List[Optional[str]] = []
    plot_titles: List[str] = []
    x_datas: List[np.ndarray] = []
    y_datas: List[np.ndarray] = []

    nlse_methods: List[str] = ["ssfm", "ssfm_reduced", "ssfm_symmetric",
                               "ssfm_opti_reduced", "ssfm_super_sym",
                               "ssfm_opti_super_sym", "rk4ip", "rk4ip"]
    # ---------------- NLSE solvers test -------------------------------
    lt: oc.Layout = oc.Layout(oc.Domain(bit_width=100.0, samples_per_bit=4096))

    pulse: oc.Gaussian = oc.Gaussian(channels=2, peak_power=[0.5, 1.0], width=[0.5, 0.8])

    steps: int = int(5e3)
    fiber: oc.Fiber
    SS: bool = True
    for j, nlse_method in enumerate(nlse_methods):
        if (j == len(nlse_methods)-2):  # To compute rk4ip and rk4ip_gnlse
            oc.set_rk4ip_opti_gnlse(False)   # Can make slighty diff. output
        else:
            oc.set_rk4ip_opti_gnlse(True)
        # Propagation
        fiber = oc.Fiber(length=0.2, nlse_method=nlse_method, alpha=[0.5],
                      beta_order=3, gamma=4.0, nl_approx=False, SPM=True,
                      XPM=True, SS=True, RS=True, steps=steps, save=True)
Ejemplo n.º 7
0
if __name__ == "__main__":
    """Give an example of Fiber usage.
    This piece of code is standalone, i.e. can be used in a separate
    file as an example.
    """

    from typing import Callable, List, Optional

    import numpy as np

    import optcom as oc

    noise_samples = 200
    domain: oc.Domain = oc.Domain(samples_per_bit=2048,
                                  bit_width=70.0,
                                  noise_samples=noise_samples)
    lt: oc.Layout = oc.Layout(domain)

    pulse: oc.Gaussian
    pulse = oc.Gaussian(channels=4,
                        peak_power=[10.0, 10e-1, 5.0, 7.0],
                        width=[0.1, 5.0, 3.0, 4.0],
                        center_lambda=[1050.0, 1048.0, 1049.0, 1051.0],
                        noise=np.ones(noise_samples) * 4)
    fiber = oc.Fiber(length=0.05,
                     nlse_method="ssfm",
                     alpha=[.46],
                     nl_approx=False,
                     ATT=True,
                     DISP=True,