示例#1
0
def tmm():
    wl = 532e-9
    metalD = 60e-9

    prism = Material.Static(1.5)
    metal = Material.Static(0.054007 + 3.4290j)
    dielectric = Material.Static(1.0)

    res = TMM(wl=wl)
    res.AddLayer(float("inf"), prism)
    res.AddLayer(metalD, metal)
    res.AddLayer(float("inf"), dielectric)

    return res
def tmms(polP1, polP2, polGen, process):
    wlP1 = 700e-9
    wlP2 = 1500e-9
    I0P1 = 1.0
    I0P2 = 2.0
    dValues = {"d11": 1e-12, "d22": 2e-12, "d33": 3e-12, "d12": 4e-12, "d23": 5e-12}
    
    chi2 = LabPy.Chi2Tensor(**dValues)
    prism = LabPy.Material("Static", n = 1.5)
    metal = LabPy.Material("main/Ag/Johnson")
    crystal = LabPy.Material("special/gaussian_test")
    dielectric = LabPy.Material("Static", n = 1.0)
    crystalD = 1000e-6
    metalD = 5e-9
    
    tmmPy = LabPy.SecondOrderNLTmm(wlP1 = wlP1, wlP2 = wlP2, \
        polP1 = polP1, polP2 = polP2, polGen = polGen, \
        I0P1 = I0P1, I0P2 = I0P2, process = process)
    
    tmmPy.AddLayer(float("inf"), prism)
    tmmPy.AddLayer(metalD, metal)
    tmmPy.AddLayer(crystalD, crystal, chi2)
    tmmPy.AddLayer(float("inf"), dielectric)
    
    # C++
    prismCpp = Material.FromLabPy(prism)
    metalCpp = Material.FromLabPy(metal)
    crystalCpp = Material.FromLabPy(crystal)
    dielectricCpp = Material.FromLabPy(dielectric)
    crystalCpp.chi2.Update(**dValues)
    
    tmmCpp = SecondOrderNLTMM(process)
    tmmCpp.P1.SetParams(wl = wlP1, pol = polP1, I0 = I0P1)
    tmmCpp.P2.SetParams(wl = wlP2, pol = polP2, I0 = I0P2)
    tmmCpp.Gen.SetParams(pol = polGen)
    
    tmmCpp.AddLayer(float("inf"), prismCpp)
    tmmCpp.AddLayer(metalD, metalCpp)
    tmmCpp.AddLayer(crystalD, crystalCpp)
    tmmCpp.AddLayer(float("inf"), dielectricCpp)
    
    return tmmPy, tmmCpp
示例#3
0
def GetTMMs(wl, pol, I0, prism, metal, dielectric, metalD, overrideE0):
    # C++ TMM
    tmmCpp = TMM()
    tmmCpp.SetParams(wl = wl, pol = pol, I0 = I0)
    
    if overrideE0 is not None:
        tmmCpp.SetParams(overrideE0 = True, E0 = overrideE0)
    
    tmmCpp.AddLayer(float("inf"), Material.FromLabPy(prism))
    tmmCpp.AddLayer(metalD, Material.FromLabPy(metal))
    tmmCpp.AddLayer(float("inf"), Material.FromLabPy(dielectric))
    

    # Python TMM
    tmmPy = LabPy._Tmm._NonlinearTmm._NonlinearTmm(wl = wl, pol = pol, I0 = I0, mode = "incident", overrideE0 = overrideE0) # @UndefinedVariable
    tmmPy.AddLayer(float("inf"), prism)
    tmmPy.AddLayer(metalD, metal)
    tmmPy.AddLayer(float("inf"), dielectric)
    tmmPy.SetParams(beta = 0.0)
    
    return tmmCpp, tmmPy
示例#4
0
def tmm():
    wlP1 = 1000e-9
    wlP2 = 1000e-9
    polP1 = "s"
    polP2 = "s"
    polGen = "s"
    Ly = 2e-3
    w0P1 = 4000e-6
    w0P2 = 4000e-6
    pwrP1 = 1.1
    E0P2 = 12.0
    
    crystalD = 50e-6
    
    # Define materials
    wlsCrystal = np.array([400e-9, 1100e-9])
    nsCrystal = np.array([1.54, 1.53], dtype = complex)
    prism = Material.Static(1.5)
    crystal = Material(wlsCrystal, nsCrystal)
    dielectric = Material.Static(1.6)
    crystal.chi2.Update(d11 = 1e-12, d22 = 1e-12, d33 = 1e-12)
    
    # Init SecondOrderNLTMM
    tmm = SecondOrderNLTMM()
    tmm.P1.SetParams(wl = wlP1, pol = polP1, beta = 0.0, I0 = pwrP1 / (Ly * w0P1))
    tmm.P2.SetParams(wl = wlP2, pol = polP2, beta = 0.0, overrideE0 = True, E0 = E0P2)
    tmm.Gen.SetParams(pol = polGen)
    
    # Add layers
    tmm.AddLayer(float("inf"), prism)
    tmm.AddLayer(crystalD, crystal)
    tmm.AddLayer(float("inf"), dielectric)

    # Init waves
    waveP1Params = {"waveType": "tukey", "pwr": pwrP1, "w0": w0P1, "Ly": Ly, "dynamicMaxXCoef": 5, "nPointsInteg": 200, "maxPhi": np.radians(10.0)}
    waveP2Params = {"waveType": "planewave", "w0": w0P2, "Ly": Ly, "overrideE0": True, "E0": E0P2}
    tmm.P1.wave.SetParams(**waveP1Params)
    tmm.P2.wave.SetParams(**waveP2Params)
    
    return tmm
示例#5
0
def chi2s():
    dValues = {
        "d11": 1e-12,
        "d22": 2e-12,
        "d33": 3e-12,
        "d12": 4e-12,
        "d23": 5e-12
    }
    materialCpp = Material.FromLabPy(LabPy.Material("Static", n=1.0))
    chi2Cpp = materialCpp.chi2
    chi2Cpp.Update(**dValues)
    chi2Py = LabPy.Chi2Tensor(**dValues)
    return chi2Cpp, chi2Py
示例#6
0
def tmmParams(crystalD, pwrP1, n1, n2):
    # Define params
    wlP1 = 450e-9
    wlP2 = 800e-9
    polP1 = "s"
    polP2 = "s"
    polGen = "s"
    w0 = 1e-3
    Ly = 1e-3
    I0 = pwrP1  / (w0 * Ly)
    
    deltaThetaSpdc = np.radians(0.5)
    solidAngleSpdc = 7.61543549467e-05
    deltaWlSpdc = 2.5e-9
    chi2 = 1.4761823412e-12
    
    # Define materials
    wlsCrystal = np.array([100e-9, 1200.0001e-9])
    nsCrystal = np.array([n1, n2], dtype = complex)
    prism = Material(wlsCrystal, nsCrystal)
    crystal = Material(wlsCrystal, nsCrystal)
    dielectric = Material(wlsCrystal, nsCrystal)
    crystal.chi2.Update(chi222 = chi2, chi111 = chi2, chi333 = chi2)
    
    # Init SecondOrderNLTMM
    tmm = SecondOrderNLTMM(mode = "spdc", deltaWlSpdc = deltaWlSpdc, \
                           solidAngleSpdc = solidAngleSpdc, deltaThetaSpdc = deltaThetaSpdc)
    tmm.P1.SetParams(wl = wlP1, pol = polP1, I0 = I0)
    tmm.P2.SetParams(wl = wlP2, pol = polP2, overrideE0 = True, E0 = 1.0)
    tmm.Gen.SetParams(pol = polGen)
    
    # Add layers
    tmm.AddLayer(float("inf"), prism)
    tmm.AddLayer(crystalD, crystal)
    tmm.AddLayer(float("inf"), dielectric)
    
    return tmm, prism, chi2, w0, Ly
示例#7
0
def CalcSpp():
    # Parameters
    #---------------------------------------------------------------------------
    wl = 532e-9  # Wavelength
    pol = "p"  # Polarization
    I0 = 1.0  # Intensity of incident wave
    metalD = 50e-9  # Metal film thickness
    enhLayer = 2  # Measure enhancment in the last layer
    ths = np.radians(np.linspace(0.0, 80.0, 500))  # Angle of incidences
    xs = np.linspace(-2e-6, 2e-6, 200)  # Field calculation coordinates
    zs = np.linspace(-2e-6, 2e-6, 201)  # Field calculation coordinates
    
    # Specify materials
    #---------------------------------------------------------------------------
    prism = Material.Static(1.5)
    ag = Material.Static(0.054007 + 3.4290j)  # Johnson & Christie @ 532nm
    dielectric = Material.Static(1.0)
    
    # Init TMM
    #---------------------------------------------------------------------------
    tmm = TMM(wl = wl, pol = pol, I0 = I0)
    tmm.AddLayer(float("inf"), prism)
    tmm.AddLayer(metalD, ag)
    tmm.AddLayer(float("inf"), dielectric)
    
    # Solve
    #---------------------------------------------------------------------------
    
    # Calculate reflection, transmission and field enhancement
    betas = np.sin(ths) * prism.GetN(wl).real
    sweepRes = tmm.Sweep("beta", betas, outEnh = True, layerNr = enhLayer) 
    
    # Calculate fields at the reflection dip (excitation of SPPs)
    betaMaxEnh = betas[np.argmax(sweepRes.enh)]
    tmm.Solve(beta = betaMaxEnh)
    
    # Calculate 1D fields
    fields1D = tmm.GetFields(zs)
    
    # Calculate 2D fields
    fields2D = tmm.GetFields2D(zs, xs)
    
    # Ploting
    #---------------------------------------------------------------------------
    plt.figure()
    thMaxEnh = np.arcsin(betaMaxEnh / prism.GetN(wl).real)
    
    # Reflection / transmission
    plt.subplot(221)
    plt.plot(np.degrees(ths), sweepRes.Ir, label = "R")
    plt.plot(np.degrees(ths), sweepRes.It, label = "T")
    plt.axvline(np.degrees(thMaxEnh), ls = "--", color = "red", lw = 1.0)
    plt.xlabel(r"$\theta$ ($\degree$)")
    plt.ylabel(r"Intensity (a.u)")
    plt.legend()
    
    # Field enhancement
    plt.subplot(222)
    plt.plot(np.degrees(ths), sweepRes.enh)
    plt.axvline(np.degrees(thMaxEnh), ls = "--", color = "red", lw = 1.0)
    plt.xlabel(r"$\theta$ ($\degree$)")
    plt.ylabel(r"Field enhancement")
    
    # Fields 1D
    plt.subplot(223)
    plt.plot(1e6 * zs, fields1D.E[:, 0].real, label = r"$E_x$")
    plt.plot(1e6 * zs, fields1D.E[:, 2].real, label = r"$E_z$")
    plt.plot(1e6 * zs, np.linalg.norm(fields1D.E, axis = 1), label = r"‖E‖")
    plt.xlabel(r"z (μm)")
    plt.ylabel(r"(V/m)")
    plt.legend()
    
    # Fields 2D
    plt.subplot(224)
    plt.pcolormesh(1e6 * zs, 1e6 * xs, fields2D.Ez.real.T, rasterized = True)
    plt.xlabel(r"z (μm)")
    plt.ylabel(r"x (μm)")
    plt.colorbar(label = r"$E_z$ (V/m)")

    plt.tight_layout()
    plt.show()
if __name__ == "__main__":
    # Define params
    wlP1 = 1000e-9
    wlP2 = 1000e-9
    polP1 = "s"
    polP2 = "s"
    polGen = "s"
    I0P1 = 1.0
    I0P2 = I0P1
    betas = np.linspace(0.0, 0.99, 10000)
    crystalD = 1000e-6

    # Define materials
    wlsCrystal = np.array([400e-9, 1100e-9])
    nsCrystal = np.array([1.54, 1.53], dtype=complex)
    prism = Material.Static(1.0)
    crystal = Material(wlsCrystal, nsCrystal)
    dielectric = Material.Static(1.0)
    crystal.chi2.Update(d22=1e-12)

    # Init SecondOrderNLTMM
    tmm = SecondOrderNLTMM()
    tmm.P1.SetParams(wl=1000e-9, pol="s", beta=0.2, I0=1.0)
    tmm.P2.SetParams(wl=1000e-9, pol="s", beta=0.2, I0=1.0)
    tmm.Gen.SetParams(pol="s")

    # Add layers
    tmm.AddLayer(float("inf"), prism)
    tmm.AddLayer(crystalD, crystal)
    tmm.AddLayer(float("inf"), dielectric)
示例#9
0
def CalcSppGaussianBeam():
    # Parameters
    #---------------------------------------------------------------------------
    wl = 532e-9  # Wavelength
    pol = "p"  # Polarization
    I0 = 1.0  # Intensity of incident wave
    metalD = 50e-9  # Metal film thickness
    enhLayer = 2  # Measure enhancment in the last layer
    ths = np.radians(np.linspace(0.0, 75.0, 500))  # Angle of incidences
    xs = np.linspace(-50e-6, 50e-6, 200)  # Field calculation coordinates
    zs = np.linspace(-25e-6, 5e-6, 201)  # Field calculation coordinates
    waveType = "gaussian"  # Wave type
    pwr = 10e-3  # Beam power [W]
    w0 = 10e-6  # Beam waist size

    # Specify materials
    #---------------------------------------------------------------------------
    prism = Material.Static(1.5)
    ag = Material.Static(0.054007 + 3.4290j)  # Johnson & Christie @ 532nm
    dielectric = Material.Static(1.0)

    # Init TMM
    #---------------------------------------------------------------------------
    tmm = TMM(wl=wl, pol=pol, I0=I0)
    tmm.AddLayer(float("inf"), prism)
    tmm.AddLayer(metalD, ag)
    tmm.AddLayer(float("inf"), dielectric)

    # Init wave params
    tmm.wave.SetParams(waveType = waveType, w0 = w0, pwr = pwr, \
                       dynamicMaxX = False, maxX = xs[-1])

    # Solve
    #---------------------------------------------------------------------------

    # Calculate reflection, transmission and field enhancement
    betas = np.sin(ths) * prism.GetN(wl).real
    sweepRes = tmm.WaveSweep("beta", betas, outEnh=True, layerNr=enhLayer)

    # Calculate fields at the reflection dip (excitation of SPPs)
    betaMaxEnh = betas[np.argmax(sweepRes.enh)]
    tmm.Solve(beta=betaMaxEnh)
    fields2D = tmm.WaveGetFields2D(zs, xs)

    # Ploting
    #---------------------------------------------------------------------------
    plt.figure()
    ax1 = plt.subplot2grid((2, 2), (0, 0))
    ax2 = plt.subplot2grid((2, 2), (1, 0))
    ax3 = plt.subplot2grid((2, 2), (0, 1), rowspan=2)
    thMaxEnh = np.arcsin(betaMaxEnh / prism.GetN(wl).real)

    # Reflection / transmission
    ax1.plot(np.degrees(ths), 1e3 * sweepRes.Pi, label=r"$P_i$")
    ax1.plot(np.degrees(ths), 1e3 * sweepRes.Pr, label=r"$P_r$")
    ax1.plot(np.degrees(ths), 1e3 * sweepRes.Pt, label=r"$P_t$")
    ax1.axvline(np.degrees(thMaxEnh), ls="--", color="red", lw=1.0)
    ax1.set_xlabel(r"$\theta$ ($\degree$)")
    ax1.set_ylabel(r"Power (mW)")
    ax1.legend()

    # Field enhancement
    ax2.plot(np.degrees(ths), sweepRes.enh)
    ax2.axvline(np.degrees(thMaxEnh), ls="--", color="red", lw=1.0)
    ax2.set_xlabel(r"$\theta$ ($\degree$)")
    ax2.set_ylabel(r"Field enhancement")

    # Fields 2D
    cm = ax3.pcolormesh(1e6 * zs,
                        1e6 * xs,
                        1e-3 * fields2D.EN.real.T,
                        vmax=5e1)
    ax3.set_xlabel(r"z (μm)")
    ax3.set_ylabel(r"x (μm)")
    plt.colorbar(cm, label=r"$‖E‖$ (kV/m)")

    plt.tight_layout()
    plt.show()
示例#10
0
def materials(request):
    labpyMaterial = LabPy.Material(request.param)
    tmmMaterial = Material.FromLabPy(labpyMaterial)
    return (tmmMaterial, labpyMaterial)