Esempio n. 1
0
def bFctV0(n1, n2, rho, b, V0, modes, delta):
    NA = sqrt(n1**2 - n2**2)

    pyplot.figure()
    sim = Simulator(delta=delta)

    sim.setWavelength(Wavelength(k0=(v0 / b / NA)) for v0 in V0)
    sim.setMaterials(Fixed, Fixed, Fixed)
    sim.setRadii((rho * b, ), (b, ))
    sim.setMaterialsParams((n2, ), (n1, ), (n2, ))

    fiber = fixedFiber(0, [rho * b, b], [n2, n1, n2])

    for m in modes:
        neff = sim.getNeff(m)
        bnorm = (neff - n2) / (n1 - n2)

        pyplot.plot(V0, bnorm, color=COLORS[m.family], label=str(m))

        c = fiber.cutoffV0(m)
        pyplot.axvline(c, color=COLORS[m.family], ls='--')

    pyplot.xlim((0, V0[-1]))
    pyplot.title("$n_1 = {}, n_2 = {}, \\rho = {}$".format(n1, n2, rho))
    pyplot.xlabel("Normalized frequency ($V_0$)")
    pyplot.ylabel("Normalized propagation constant ($\widetilde{\\beta}$)")
Esempio n. 2
0
 def getSimulator(self):
     sim = Simulator(delta=self.delta)
     sim.setWavelength(self.wavelength)
     sim.setMaterials(Silica, SiO2GeO2, Silica)
     sim.setMaterialParam(1, 0, (self.X, ))
     sim.setRadii((self._a, ), (self._b, ))
     return sim
Esempio n. 3
0
def analyseFiber(f):
    print(f.name)
    # wl = numpy.linspace(2100e-9, 2400e-9, 1000)
    wl = numpy.linspace(1500e-9, 5000e-9, 100)
    # wl = numpy.linspace(7000e-9, 20000e-9, 50)
    sim = Simulator(delta=f.delta)
    sim.setWavelength(wl)
    sim.setMaterials(*[Fixed] * len(f.n))
    sim.setRadii(*f.rho)
    for i, idx in enumerate(f.n):
        sim.setMaterialParam(i, 0, idx)

    V0 = sim.getV0()
    # print(V0[0], V0[-1])
    # return

    # modes = sim.findLPModes()
    modes = sim.findVModes()
    # modes = [Mode("TM", 0, 1), Mode("TM", 0, 2)]
    fiber = next(iter(sim))

    for m in modes:
        cutoff = sim.getCutoffV0(fiber, m)
        if cutoff < V0[-1]:
            continue

        # pyplot.plot(V0, sim.getNeff(m), label=str(m))
        pl, = pyplot.plot(V0, sim.getBnorm(m), label=str(m))
        c = pl.get_color()

        if str(m) in ("HE(1,1)", "LP(0,1)"):
            continue

        print(str(m), cutoff)
        pyplot.axvline(cutoff, ls=':', color=c)
        # if m.nu > 1:
        #     cutoffs = findCutoffs(f, m.nu, V0)
        #     for c in cutoffs:
        #         pyplot.axvline(c, ls=':', color='k')

    # pyplot.legend(loc="best")
    pyplot.xlim((2.5, 7))
    # pyplot.ylim((0, 1))
    pyplot.ylim((0, 0.3))
    # pyplot.xlabel("Normalized frequency ($V_0$)")
    # pyplot.ylabel("Normalized propagation constant ($b$)")
    pyplot.title(f.name)
Esempio n. 4
0
def compute_fiber(filename, nrho, R2, C2, wl, numax=None, mmax=None):
    # Initialize simulators
    sim = []
    for i, r2 in enumerate(R2):
        r1 = numpy.linspace(0, r2, nrho, endpoint=False)
        factory = FiberFactory()
        factory.addLayer(radius=r1, material='Silica')
        factory.addLayer(radius=r2, material='SiO2GeO2', x=C2)
        factory.addLayer(material='Silica')
        sim.append(Simulator(factory, wl))

    nr2 = R2.size
    nc2 = C2.size
    ckfile, _ = os.path.splitext(filename)
    ckfile += '.ckp.npz'
    if os.path.isfile(ckfile):
        # Restore checkpoint
        data = numpy.load(ckfile)
        modes = [Mode(*a) for a in data['modes']]
        results = {'modes': modes}
        for fct in ('cutoff', 'neff', 'beta1', 'beta2', 'beta3'):
            results[fct] = data[fct]
    else:
        # Find modes
        sim[-1].numax = numax
        sim[-1].mmax = mmax
        modes = find_mode_list(sim[-1])

        # Initialize arrays
        shape = (nrho, nr2, C2.size, len(modes))
        results = {'modes': modes}
        for fct in ('cutoff', 'neff', 'beta1', 'beta2', 'beta3'):
            results[fct] = numpy.empty(shape)
            results[fct].fill(numpy.nan)

    Rho = numpy.linspace(0, 1, nrho, endpoint=False)
    for i, r2 in enumerate(R2[::-1], 1):
        print("Solving when r2={:.3f}µm".format(r2 * 1e6))
        if numpy.all(numpy.isnan(results['cutoff'][:, nr2 - i, :, :])):
            numax, mmax = compute_fiber_r2(results, modes, sim[-i], nr2 - i,
                                           Rho, r2, nc2, numax, mmax)
            numpy.savez_compressed(ckfile, **results)  # Save checkpoint

    os.rename(ckfile, filename)
    return results
Esempio n. 5
0
def plotDneffvsb():
    global n1, n2

    pyplot.figure()

    B = numpy.linspace(2, 4.5, 200)

    sim = Simulator(delta=1e-4)
    sim.setWavelength(1550e-9)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setRadius(1, B * 1e-6)
    sim.setRadiusFct(0, mul, ('value', rho), ('radius', 1))
    sim.setMaterialParam(1, 0, X)

    # modes = sim.findLPModes()
    # for m in modes:
    #     b = (numpy.fromiter(sim.getNeff(m),
    #                         dtype=numpy.float) - n1a) / (n2a - n1a)
    #     pyplot.plot(V0a, b, label=str(m))

    modes = sim.findVModes()
    neff = {}
    for m in modes:
        neff[m] = sim.getNeff(m)

    for (m1, m2) in [(modes[1], modes[2]),
                     (modes[2], modes[3]),
                     (modes[4], modes[5])]:
        dneff = numpy.abs(neff[m1] - neff[m2]) * 1e4
        pyplot.plot(B, dneff, label="{} - {}".format(str(m1), str(m2)))

    for i, bb in enumerate(b, 1):
        pyplot.axvline(bb, ls='--')
        pyplot.annotate('fiber {}'.format(i),
                        xy=(bb, 2),
                        xytext=(0, 5),
                        textcoords='offset points',
                        horizontalalignment='center')

    pyplot.axhline(1, ls=":")

    pyplot.xlabel("Outer core radius (um)")
    pyplot.ylabel("Mode separation ($\\Delta n_{eff} \\cdot 10^{-4}$)")
    pyplot.legend(loc="bottom right")
Esempio n. 6
0
def plotBvsV0():
    global n1, n2

    pyplot.figure()

    b = 4e-6
    V0a = numpy.linspace(2, 5, 200)
    NA = sqrt(n1*n1 - n2*n2)

    sim = Simulator(delta=1e-4)
    sim.setWavelength(Wavelength(k0=(v0 / b / NA)) for v0 in V0a)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setRadius(1, b)
    sim.setRadiusFct(0, mul, ('value', rho), ('radius', 1))
    sim.setMaterialParam(1, 0, X)

    n1a = numpy.fromiter((f['index', 0] for f in iter(sim)),
                         dtype=numpy.float)
    n2a = numpy.fromiter((f['index', 1] for f in iter(sim)),
                         dtype=numpy.float)

    # modes = sim.findLPModes()
    # for m in modes:
    #     b = (numpy.fromiter(sim.getNeff(m),
    #                         dtype=numpy.float) - n1a) / (n2a - n1a)
    #     pyplot.plot(V0a, b, label=str(m))

    modes = sim.findVModes()
    for m in modes:
        b = (numpy.fromiter(sim.getNeff(m),
                            dtype=numpy.float) - n1a) / (n2a - n1a)
        pyplot.plot(V0a, b, label=str(m))

    for i, v0 in enumerate(V0, 1):
        pyplot.axvline(v0, ls='--')
        pyplot.annotate('fiber {}'.format(i),
                        xy=(v0, 0.7),
                        xytext=(0, 5),
                        textcoords='offset points',
                        horizontalalignment='center')

    pyplot.xlabel("Normalized frequency ($V_0$)")
    pyplot.ylabel("Normalized propagation constant ($\\widetilde{\\beta}$)")
    pyplot.legend(loc="upper left")
Esempio n. 7
0
def plotNeff():
    b = 4e-6
    ncl = 1.444
    nco = ncl + 0.05
    wl = numpy.linspace(1500e-9, 5000e-9, 50)
    V = 2 * numpy.pi / wl * b * numpy.sqrt(nco * nco - ncl * ncl)

    sim = Simulator()
    sim.setWavelength(wl)
    sim.setMaterials(Fixed, Fixed)
    sim.setMaterialParam(0, 0, nco)
    sim.setMaterialParam(1, 0, ncl)
    sim.setRadius(0, b)

    modes = sim.findVModes()

    for m in modes:
        neff = sim.getBnorm(m)
        pyplot.plot(V, neff, label=str(m))

    pyplot.show()
Esempio n. 8
0
def plotNgvsb():
    global n1, n2

    pyplot.figure()

    B = numpy.linspace(2, 4.5, 200)

    sim = Simulator(delta=1e-4)
    sim.setWavelength(1550e-9)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setRadius(1, B * 1e-6)
    sim.setRadiusFct(0, mul, ('value', rho), ('radius', 1))
    sim.setMaterialParam(1, 0, X)

    # modes = sim.findLPModes()
    # for m in modes:
    #     b = (numpy.fromiter(sim.getNeff(m),
    #                         dtype=numpy.float) - n1a) / (n2a - n1a)
    #     pyplot.plot(V0a, b, label=str(m))

    modes = [Mode('HE', 1, 1),
             Mode('TE', 0, 1), Mode('HE', 2, 1), Mode('TM', 0, 1),
             Mode('EH', 1, 1), Mode('HE', 3, 1)]

    for m in modes:
        ng = sim.getNg(m)
        pyplot.plot(B, ng, label=str(m))

    for i, bb in enumerate(b, 1):
        pyplot.axvline(bb, ls='--')
        pyplot.annotate('fiber {}'.format(i),
                        xy=(bb, 1.505),
                        xytext=(0, 5),
                        textcoords='offset points',
                        horizontalalignment='center')

    pyplot.xlabel("Outer core radius (um)")
    pyplot.ylabel("Group index ($n_g$)")
    pyplot.legend(loc="bottom right")
    pyplot.ylim((1.48, 1.505))
Esempio n. 9
0
def plotDvsb():
    global n1, n2

    pyplot.figure()

    wl = Wavelength(1550e-9)
    V0a = numpy.linspace(2, 5, 100)
    NA = sqrt(n1*n1 - n2*n2)

    ba = V0a / wl.k0 / NA

    sim = Simulator(delta=1e-4)
    sim.setWavelength(wl)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setRadius(1, ba)
    sim.setRadiusFct(0, mul, ('value', rho), ('radius', 1))
    sim.setMaterialParam(1, 0, X)

    modes = sim.findVModes()

    for m in modes:
        D = sim.getD(m)
        pyplot.plot(ba*1e6, D, label=str(m))

    for i, bb in enumerate(b, 1):
        pyplot.axvline(bb, ls='--')
        pyplot.annotate('fiber {}'.format(i),
                        xy=(bb, 50),
                        xytext=(0, 5),
                        textcoords='offset points',
                        horizontalalignment='center')

    pyplot.ylim((-100, 50))
    pyplot.axhspan(-100, -40, color='k', alpha=0.3)
    pyplot.axhspan(40, 100, color='k', alpha=0.3)
    pyplot.xlabel("Ring-core outer radius (µm)")
    pyplot.ylabel("Dispersion (ps / (nm km) )")
    pyplot.legend(loc="lower left")
Esempio n. 10
0
def plotRhoVsV0():
    global n1, n2

    pyplot.figure()

    wl = Wavelength(1550e-9)
    V0a = numpy.linspace(2, 5, 15)  # 75
    NA = sqrt(n1*n1 - n2*n2)

    b = V0a / wl.k0 / NA
    rho = numpy.linspace(0, 1, 15)  # 75

    sim = Simulator(delta=1e-4)
    sim.setWavelength(wl)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setMaterialParam(1, 0, X)

    # coupures
    sim.setRadius(1, b[-1])
    sim.setRadius(0, rho * b[-1])
    modes = sim.findVModes()
    for m in modes:
        coupure = numpy.zeros(rho.size)
        for i, fiber in enumerate(iter(sim)):
            coupure[i] = fiber.cutoffV0(m)
            if coupure[i] > 5:
                break
        coupure = numpy.ma.masked_equal(coupure, 0)
        pyplot.plot(coupure, rho, label=str(m), color='k')

    # dneff
    sim.setRadius(1, b)
    neff = numpy.empty((len(modes), len(rho), len(b)))
    for j, r in enumerate(rho):
        sim.setRadiusFct(0, mul, ('value', r), ('radius', 1))

        for i, m in enumerate(modes):
            neff[i, j] = sim.getNeff(m).filled(0)
            if numpy.sum(neff[i, j]) == 0:
                break

        if i == 1:
            break

    dneff = numpy.ones((len(rho), len(b)))
    for i in range(len(rho)):
        for j in range(len(b)):
            for k in range(2, len(modes)):
                if neff[k, i, j]:
                    if abs(neff[k, i, j] - neff[k-1, i, j]) < dneff[i, j]:
                        dneff[i, j] = abs(neff[k, i, j] - neff[k-1, i, j])
    dneff = numpy.ma.masked_greater(dneff, 5e-4)
    pyplot.imshow(dneff, aspect='auto', extent=(V0a[0], V0a[-1], 1, 0))
    pyplot.colorbar()

    pyplot.axhline(0.35, ls='--', color='k')
    pyplot.plot(V0, [0.35] * V0.size, 'ok')

    pyplot.xlim((V0a[0], V0a[-1]))
    pyplot.ylim((0, 1))
    pyplot.xlabel("Normalized frequency ($V_0$)")
    pyplot.ylabel("Inner / outer radius ratio ($\\rho = a / b$)")
Esempio n. 11
0
# n2 = Silica.n(wl)
# n1 = n2 + dn
# X = SiO2GeO2.xFromN(wl, n1)

# Values as 1550 nm
wl = Wavelength(1550e-9)
n2 = Silica.n(wl)
n1 = n2 + dn
X = SiO2GeO2.xFromN(wl, n1)
# n1 = SiO2GeO2.n(wl, X)
V0 = wl.k0 * b * 1e-6 * sqrt(n1*n1 - n2*n2)
# dn = n1 - n2
n02 = n1**2 / n2**2


sim = Simulator(delta=1e-4)
sim.setWavelength(wl)
sim.setMaterials(Silica, SiO2GeO2, Silica)
# sim.setMaterials(Fixed, Fixed, Fixed)
sim.setRadius(1, b * 1e-6)
sim.setRadiusFct(0, mul, ('value', rho), ('radius', 1))
sim.setMaterialParam(1, 0, X)
# sim.setMaterialsParams((1.444,), (1.474,), (1.444,))

modes = sim.findVModes()
# modes = [Mode('LP', 0, 1), Mode('LP', 1, 1), Mode('LP', 2, 1)]


def latexSI(value, unit=None):
    if unit:
        return "\\SI{{{}}}{{\\{}}}".format(value, unit)
Esempio n. 12
0
def plotCMap(dn):
    V0 = numpy.linspace(2, 5, 50)
    rho = numpy.linspace(0, 1, 50)
    wl = Wavelength(1550e-9)
    n1 = Silica.n(wl)
    n2 = n1 + dn
    X = SiO2GeO2.xFromN(wl, n2)
    b = 6e-6
    a = b * rho

    sim = Simulator(delta=1e-4)
    sim.setWavelength(wl)
    sim.setMaterials(Silica, SiO2GeO2, Silica)
    sim.setMaterialParam(1, 0, X)
    sim.setRadii(a, (b, ))

    ssif = SSIF(wl, (SiO2GeO2, b, X), (Silica, b))

    cutoffs = {}
    for m in MODES[1:]:
        cutoffs[m] = []
        for i, fiber in enumerate(iter(sim)):
            if i == 0:
                cutoffs[m].append(ssif.cutoffV0(m, 2))
            else:
                if cutoffs[m][i - 1] > V0[-1]:
                    cutoffs[m].append(cutoffs[m][i - 1])
                else:
                    cutoffs[m].append(fiber.cutoffV0(m, 2))
        pyplot.plot(cutoffs[m], rho, label=str(m))

    wl = constants.tpi * b * ssif.na / V0
    sim.setWavelength(wl)

    neff = {}
    for m in MODES:
        neff[m] = numpy.zeros((rho.size, V0.size))
        for i, r in enumerate(rho):
            if i == 0:
                sim.setMaterials(SiO2GeO2, Silica)
                sim.setMaterialParam(0, 0, X)
                sim.setRadius(0, b)
            else:
                sim.setMaterials(Silica, SiO2GeO2, Silica)
                sim.setMaterialParam(1, 0, X)
                sim.setRadii((a[i], ), (b, ))
            if m in cutoffs and cutoffs[m][i] > V0[-1]:
                continue
            neff[m][i, :] = sim.getNeff(m)

    dneff = numpy.zeros((rho.size, V0.size))
    for i, r in enumerate(rho):
        for j, v in enumerate(V0):
            n = []
            mm = []
            for m in MODES:
                if m in cutoffs and cutoffs[m][i] > v:
                    continue
                if neff[m][i, j]:
                    n.append(neff[m][i, j])
                    mm.append(m)
            if len(n) > 1:
                n = numpy.array(n)
                n.sort()
                dneff[i, j] = min(n[1:] - n[:-1])

    numpy.save('dneff', dneff)

    dneff = numpy.ma.masked_greater(dneff, 1e-3)
    pyplot.imshow(dneff, aspect='auto', extent=(V0[0], V0[-1], 1, 0))

    pyplot.title("$\Delta n = {}$".format(dn))
    pyplot.xlim((V0[0], V0[-1]))
    pyplot.ylim((0, 1))
    pyplot.colorbar()
Esempio n. 13
0
from fibermodes import Wavelength, Mode, constants
from fibermodes.material import Silica, SiO2GeO2, Fixed
from fibermodes.simulator import PSimulator as Simulator
import numpy
from matplotlib import pyplot

wl = numpy.linspace(800e-9, 1800e-9, 200)
print(wl[1] - wl[0])

sim = Simulator(delta=1e-4, epsilon=1e-12)
sim.setWavelength(wl)
sim.setMaterials(SiO2GeO2, Silica)
sim.setMaterialParam(0, 0, 0.05)
sim.setRadii(4.5e-6)

modes = sim.findVModes()
#modes = [Mode('HE', 1, 2)]

### Neff ###
pyplot.figure()
pyplot.subplot(221)
pyplot.title("Neff")
for m in modes:
    pyplot.plot(wl * 1e6, sim.getNeff(m), '-', label=str(m))
n1 = sim.getIndex(0)
n2 = sim.getIndex(1)
pyplot.plot(wl * 1e6, n1, ls='--', label="Core")
pyplot.plot(wl * 1e6, n2, ls='--', label="Cladding")
pyplot.legend()

### Ng ###