From 03c25d897ebd2727d74a953e9cf52deaa7b438dc Mon Sep 17 00:00:00 2001 From: cbrahms Date: Wed, 13 Oct 2021 14:18:22 +0100 Subject: [PATCH 01/13] unpack variable names --- src/Capillary.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Capillary.jl b/src/Capillary.jl index 717393d7..58563f90 100644 --- a/src/Capillary.jl +++ b/src/Capillary.jl @@ -261,15 +261,16 @@ dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), 2π)) # we use polar coords, so xs = (r, θ) function field(m::MarcatiliMode, xs; z=0) + r, θ = xs if m.kind == :HE - return (besselj(m.n-1, xs[1]*m.unm/radius(m, z)) .* SVector( - cos(xs[2])*sin(m.n*(xs[2] + m.ϕ)) - sin(xs[2])*cos(m.n*(xs[2] + m.ϕ)), - sin(xs[2])*sin(m.n*(xs[2] + m.ϕ)) + cos(xs[2])*cos(m.n*(xs[2] + m.ϕ)) + return (besselj(m.n-1, r*m.unm/radius(m, z)) .* SVector( + cos(θ)*sin(m.n*(θ + m.ϕ)) - sin(θ)*cos(m.n*(θ + m.ϕ)), + sin(θ)*sin(m.n*(θ + m.ϕ)) + cos(θ)*cos(m.n*(θ + m.ϕ)) )) elseif m.kind == :TE - return besselj(1, xs[1]*m.unm/radius(m, z)) .* SVector(-sin(xs[2]), cos(xs[2])) + return besselj(1, r*m.unm/radius(m, z)) .* SVector(-sin(θ), cos(θ)) elseif m.kind == :TM - return besselj(1, xs[1]*m.unm/radius(m, z)) .* SVector(cos(xs[2]), sin(xs[2])) + return besselj(1, r*m.unm/radius(m, z)) .* SVector(cos(θ), sin(θ)) end end From 4554b81228f54db586ba878122ef37933b2c739f Mon Sep 17 00:00:00 2001 From: cbrahms Date: Wed, 13 Oct 2021 15:07:04 +0100 Subject: [PATCH 02/13] =?UTF-8?q?geomfac,=20integrate=20(0,=20=CF=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Capillary.jl | 6 ++++-- src/Modes.jl | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Capillary.jl b/src/Capillary.jl index 58563f90..a225a7f0 100644 --- a/src/Capillary.jl +++ b/src/Capillary.jl @@ -7,7 +7,7 @@ using Reexport @reexport using Luna.Modes import Luna: Maths, Grid import Luna.PhysData: c, ε_0, μ_0, ref_index_fun, roomtemp, densityspline, sellmeier_gas -import Luna.Modes: AbstractMode, dimlimits, neff, field, Aeff, N +import Luna.Modes: AbstractMode, dimlimits, neff, field, Aeff, N, geomfac import Luna.LinearOps: make_linop, conj_clamp, neff_grid, neff_β_grid import Luna.PhysData: wlfreq import Luna.Utils: subscript @@ -257,7 +257,9 @@ end radius(m::MarcatiliMode{<:Number, Tco, Tcl, LT}, z) where {Tcl, Tco, LT} = m.a radius(m::MarcatiliMode, z) = m.a(z) -dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), 2π)) +dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), π)) + +geomfac(m::MarcatiliMode) = 2 # we use polar coords, so xs = (r, θ) function field(m::MarcatiliMode, xs; z=0) diff --git a/src/Modes.jl b/src/Modes.jl index 5bc7370c..ff0cd62c 100644 --- a/src/Modes.jl +++ b/src/Modes.jl @@ -31,6 +31,8 @@ Maximum dimensional limits of validity for mode `m` at position `z`. """ function dimlimits end +geomfac(m::AbstractMode) = 1 + """ field(m::AbstractMode, xs; z=0.0) From 9c983bef943572b03a9d6dd848f6d6f8baf90bda Mon Sep 17 00:00:00 2001 From: cbrahms Date: Wed, 13 Oct 2021 15:07:23 +0100 Subject: [PATCH 03/13] implement geomfac --- src/NonlinearRHS.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NonlinearRHS.jl b/src/NonlinearRHS.jl index 46e5affd..0b5998fa 100644 --- a/src/NonlinearRHS.jl +++ b/src/NonlinearRHS.jl @@ -291,6 +291,7 @@ function (t::TransModal)(nl, Eω, z) reltol=t.rtol, abstol=t.atol, maxevals=t.mfcn, error_norm=Cubature.L2) end nl .= reshape(reinterpret(ComplexF64, val), size(nl)) + nl .*= Modes.geomfac(t.ts.ms[1]) end """ From 3a3a2573ca714bfc0fd84cb1c145ecab4466e111 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Wed, 13 Oct 2021 15:07:26 +0100 Subject: [PATCH 04/13] some tests --- test/test_multimode.jl | 4 ++- test/test_polarisation_field.jl | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/test/test_multimode.jl b/test/test_multimode.jl index 3bf05ec8..1af778bc 100644 --- a/test/test_multimode.jl +++ b/test/test_multimode.jl @@ -58,7 +58,9 @@ end energyfun, energyfunω = Fields.energyfuncs(grid) dens0 = PhysData.density(gas, pres) - densityfun(z) = dens0 + densityfun = let dens0=PhysData.density(gas, pres) + z -> dens0 + end responses = (Nonlinear.Kerr_field(PhysData.γ3_gas(gas)),) linop, βfun!, frame_vel, αfun = LinearOps.make_const_linop(grid, m, λ0) inputs = Fields.GaussField(λ0=λ0, τfwhm=τ, energy=1e-6) diff --git a/test/test_polarisation_field.jl b/test/test_polarisation_field.jl index 387723bc..51de727c 100644 --- a/test/test_polarisation_field.jl +++ b/test/test_polarisation_field.jl @@ -60,3 +60,67 @@ import Luna: Output @test all(output["stats"]["energy"] .≈ sum(outputp["stats"]["energy"], dims=1)) @test all(output["stats"]["fwhm_r"] .≈ outputp["stats"]["fwhm_r"]) end + +## +@testset "Linear, LP11" begin + using Luna + import LinearAlgebra: norm + a = 125e-6 + gas = :Ar + pres = 0.167 + flength = 0.1 + + τ = 10e-15 + λ0 = 800e-9 + energy = 150e-6 + grid = Grid.RealGrid(5e-2, 800e-9, (160e-9, 3000e-9), 1e-12) + + densityfun = let dens0=PhysData.density(gas, pres) + z -> dens0 + end + responses = (Nonlinear.Kerr_field(PhysData.γ3_gas(gas)),) + energyfun, energyfunω = Fields.energyfuncs(grid) + modes = ( + Capillary.MarcatiliMode(a, gas, pres, n=0, m=1, kind=:TM, ϕ=0.0, loss=false), + Capillary.MarcatiliMode(a, gas, pres, n=2, m=1, kind=:HE, ϕ=π/4, loss=false), + ) + inf = (Fields.GaussField(λ0=λ0, τfwhm=τ, energy=energy/2.0),) + # same field in each mode + inputs = ((mode=1, fields=inf), (mode=2, fields=inf)) + Eω, transform, FT = Luna.setup(grid, densityfun, responses, inputs, + modes, :xy; full=true) + statsfun = Stats.collect_stats(grid, Eω, + Stats.ω0(grid), + Stats.peakintensity(grid, modes), + Stats.fwhm_r(grid, modes), + Stats.energy(grid, energyfunω)) + output = Output.MemoryOutput(0, grid.zmax, 201, statsfun) + linop = LinearOps.make_const_linop(grid, modes, λ0) + Luna.run(Eω, grid, linop, transform, FT, output, status_period=10) + + modes = ( + Capillary.MarcatiliMode(a, gas, pres, n=0, m=1, kind=:TM, ϕ=0.0, loss=false), + Capillary.MarcatiliMode(a, gas, pres, n=2, m=1, kind=:HE, ϕ=-π/4, loss=false), + ) + inf = (Fields.GaussField(λ0=λ0, τfwhm=τ, energy=energy/2.0),) + # same field in each mode + inputs = ((mode=1, fields=inf), (mode=2, fields=inf)) + Eω, transform, FT = Luna.setup(grid, densityfun, responses, inputs, + modes, :xy; full=true) + statsfun = Stats.collect_stats(grid, Eω, + Stats.ω0(grid), + Stats.peakintensity(grid, modes, components=:xy), + Stats.fwhm_r(grid, modes, components=:xy), + Stats.energy(grid, energyfunω)) + outputp = Output.MemoryOutput(0, grid.zmax, 201, statsfun) + linop = LinearOps.make_const_linop(grid, modes, λ0) + Luna.run(Eω, grid, linop, transform, FT, outputp, status_period=10) + + Iω = dropdims(sum(abs2.(output.data["Eω"]), dims=2), dims=2) + Iωp = dropdims(sum(abs2.(outputp.data["Eω"]), dims=2), dims=2) + + @test norm(Iω - Iωp)/norm(Iω) < 1.07e-12 + @test all(output["stats"]["peakintensity"] .≈ outputp["stats"]["peakintensity"]) + @test all(sum(output["stats"]["energy"], dims=1) .≈ sum(outputp["stats"]["energy"], dims=1)) + @test all(output["stats"]["fwhm_r"] .≈ outputp["stats"]["fwhm_r"]) +end From e9e9b80736d001eec40827b6cbf65313dd4ab394 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Wed, 13 Oct 2021 16:14:40 +0100 Subject: [PATCH 05/13] handle dimlimits/geomfac differently --- src/Capillary.jl | 2 +- src/NonlinearRHS.jl | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Capillary.jl b/src/Capillary.jl index a225a7f0..96c778f1 100644 --- a/src/Capillary.jl +++ b/src/Capillary.jl @@ -257,7 +257,7 @@ end radius(m::MarcatiliMode{<:Number, Tco, Tcl, LT}, z) where {Tcl, Tco, LT} = m.a radius(m::MarcatiliMode, z) = m.a(z) -dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), π)) +dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), 2π)) geomfac(m::MarcatiliMode) = 2 diff --git a/src/NonlinearRHS.jl b/src/NonlinearRHS.jl index 0b5998fa..2ed49410 100644 --- a/src/NonlinearRHS.jl +++ b/src/NonlinearRHS.jl @@ -278,16 +278,20 @@ end function (t::TransModal)(nl, Eω, z) reset!(t, Eω, z) if t.full + coords, ll, ul = t.dimlimits + if coords == :polar + ul = (ul[1], ul[2]/Modes.geomfac(t.ts.ms[1])) + end val, err = Cubature.pcubature_v( length(Eω)*2, (x, fval) -> pointcalc!(fval, x, t), - t.dimlimits[2], t.dimlimits[3], + ll, ul, reltol=t.rtol, abstol=t.atol, maxevals=t.mfcn, error_norm=Cubature.L2) else val, err = Cubature.pcubature_v( length(Eω)*2, (x, fval) -> pointcalc!(fval, x, t), - (t.dimlimits[2][1],), (t.dimlimits[3][1],), + (ll[1],), (ul[1],), reltol=t.rtol, abstol=t.atol, maxevals=t.mfcn, error_norm=Cubature.L2) end nl .= reshape(reinterpret(ComplexF64, val), size(nl)) From fa2b327f56f128f39a9efb3b489d435151fb8dd4 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Thu, 14 Oct 2021 17:35:26 +0100 Subject: [PATCH 06/13] fix non-full, remove extra array multiply --- src/NonlinearRHS.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NonlinearRHS.jl b/src/NonlinearRHS.jl index 2ed49410..bb1799a5 100644 --- a/src/NonlinearRHS.jl +++ b/src/NonlinearRHS.jl @@ -259,6 +259,9 @@ function pointcalc!(fval, xs, t::TransModal) pre = 1.0 end end + if t.full + pre *= Modes.geomfac(t.ts.ms[1]) + end x = (x1,x2) Modes.to_space!(t.Erω, t.Emω, x, t.ts, z=t.z) to_time!(t.Er, t.Erω, t.Erωo, inv(t.FT)) @@ -277,8 +280,8 @@ end function (t::TransModal)(nl, Eω, z) reset!(t, Eω, z) + coords, ll, ul = t.dimlimits if t.full - coords, ll, ul = t.dimlimits if coords == :polar ul = (ul[1], ul[2]/Modes.geomfac(t.ts.ms[1])) end @@ -295,7 +298,6 @@ function (t::TransModal)(nl, Eω, z) reltol=t.rtol, abstol=t.atol, maxevals=t.mfcn, error_norm=Cubature.L2) end nl .= reshape(reinterpret(ComplexF64, val), size(nl)) - nl .*= Modes.geomfac(t.ts.ms[1]) end """ From 629ce35462517474293aec3e44a3b125a60fa3a5 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Thu, 14 Oct 2021 17:35:41 +0100 Subject: [PATCH 07/13] add mode-average vs full test for LP11 --- test/test_multimode.jl | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/test_multimode.jl b/test/test_multimode.jl index 1af778bc..956e3b8a 100644 --- a/test/test_multimode.jl +++ b/test/test_multimode.jl @@ -88,6 +88,56 @@ end @test norm(Iω - Iωf)/norm(Iω) < 0.003 end +@testset "Full, LP11 vs TM01" begin + # mode average and full integral should be identical for only Kerr and TM01 and LP11 + using Luna + import LinearAlgebra: norm + a = 13e-6 + gas = :Ar + pres = 5 + τ = 30e-15 + λ0 = 800e-9 + energy = 1e-6 + grid = Grid.RealGrid(5e-2, 800e-9, (160e-9, 3000e-9), 0.4e-12) + m = Capillary.MarcatiliMode(a, gas, pres; kind=:TM, n=0, m=1, loss=false) + aeff(z) = 2/3*Modes.Aeff(m, z=z) + energyfun, energyfunω = Fields.energyfuncs(grid) + + dens0 = PhysData.density(gas, pres) + densityfun = let dens0=PhysData.density(gas, pres) + z -> dens0 + end + responses = (Nonlinear.Kerr_field(PhysData.γ3_gas(gas)),) + linop, βfun!, frame_vel, αfun = LinearOps.make_const_linop(grid, m, λ0) + inputs = Fields.GaussField(λ0=λ0, τfwhm=τ, energy=energy) + Eω, transform, FT = Luna.setup( + grid, densityfun, responses, inputs, βfun!, aeff) + statsfun = Stats.collect_stats(grid, Eω, + Stats.ω0(grid), + Stats.energy(grid, energyfunω)) + output = Output.MemoryOutput(0, grid.zmax, 201, statsfun) + Luna.run(Eω, grid, linop, transform, FT, output, status_period=5) + + # vertical LP11 double-lobe + modes = ( + Capillary.MarcatiliMode(a, gas, pres, n=0, m=1, kind=:TM, ϕ=0.0, loss=false), + Capillary.MarcatiliMode(a, gas, pres, n=2, m=1, kind=:HE, ϕ=-π/4, loss=false), + ) + + field = Fields.GaussField(λ0=λ0, τfwhm=τ, energy=energy/2) + inputs = ((mode=1, fields=(field,)), (mode=2, fields=(field,))) + # inputs = Fields.GaussField(λ0=λ0, τfwhm=τ, energy=energy) + Eω, transform, FT = Luna.setup(grid, densityfun, responses, inputs, + modes, :xy; full=true) + outputf = Output.MemoryOutput(0, grid.zmax, 201, statsfun) + linop = LinearOps.make_const_linop(grid, modes, λ0) + Luna.run(Eω, grid, linop, transform, FT, outputf, status_period=10) + + Iω = abs2.(output["Eω"]) + Iωf = dropdims(sum(abs2.(outputf["Eω"]); dims=2), dims=2) + @test norm(Iω - Iωf)/norm(Iω) < 0.0003 +end + @testset "FieldInputs" begin using Luna import LinearAlgebra: norm From 2d5f7b1015631d020990c7832c193001097c8c50 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Thu, 14 Oct 2021 17:38:24 +0100 Subject: [PATCH 08/13] rm extra if --- src/NonlinearRHS.jl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/NonlinearRHS.jl b/src/NonlinearRHS.jl index bb1799a5..bf8fb80c 100644 --- a/src/NonlinearRHS.jl +++ b/src/NonlinearRHS.jl @@ -239,16 +239,16 @@ function pointcalc!(fval, xs, t::TransModal) fval[:, i] .= 0.0 continue end - if size(xs, 1) > 1 + if size(xs, 1) > 1 # full 2-D mode integral x2 = xs[2, i] if t.dimlimits[1] == :polar - pre = x1 + pre = Modes.geomfac(t.ts.ms[1])*x1 else if x2 <= t.dimlimits[2][2] || x1 >= t.dimlimits[3][2] fval[:, i] .= 0.0 continue end - pre = 1.0 + pre = Modes.geomfac(t.ts.ms[1])*1.0 end else if t.dimlimits[1] == :polar @@ -259,9 +259,6 @@ function pointcalc!(fval, xs, t::TransModal) pre = 1.0 end end - if t.full - pre *= Modes.geomfac(t.ts.ms[1]) - end x = (x1,x2) Modes.to_space!(t.Erω, t.Emω, x, t.ts, z=t.z) to_time!(t.Er, t.Erω, t.Erωo, inv(t.FT)) From 2673aa58365602ce695deccfa358bf1ee9ffa5ef Mon Sep 17 00:00:00 2001 From: cbrahms Date: Thu, 14 Oct 2021 17:43:53 +0100 Subject: [PATCH 09/13] comments in test --- test/test_multimode.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_multimode.jl b/test/test_multimode.jl index 956e3b8a..664bd616 100644 --- a/test/test_multimode.jl +++ b/test/test_multimode.jl @@ -89,7 +89,9 @@ end end @testset "Full, LP11 vs TM01" begin - # mode average and full integral should be identical for only Kerr and TM01 and LP11 + # TM01 and LP11 (which is TM01+HE21) have the same dispersion and a ratio of effective + # areas of 2/3 -- mode averaged propagation in TM01 with 2/3x Aeff should be identical + # to full modal propagation in LP11, as long as only Kerr is considered. using Luna import LinearAlgebra: norm a = 13e-6 @@ -100,7 +102,7 @@ end energy = 1e-6 grid = Grid.RealGrid(5e-2, 800e-9, (160e-9, 3000e-9), 0.4e-12) m = Capillary.MarcatiliMode(a, gas, pres; kind=:TM, n=0, m=1, loss=false) - aeff(z) = 2/3*Modes.Aeff(m, z=z) + aeff(z) = 2/3*Modes.Aeff(m, z=z) # Aeff of LP11 is 2/3x smaller than that of TM01 energyfun, energyfunω = Fields.energyfuncs(grid) dens0 = PhysData.density(gas, pres) From 80a2f120c64192cafeb71d92a8b35c50ef4965f4 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Fri, 15 Oct 2021 09:35:07 +0100 Subject: [PATCH 10/13] take geomfac back out, switch to hcubature --- src/Capillary.jl | 4 +--- src/Modes.jl | 2 -- src/NonlinearRHS.jl | 12 +++++------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Capillary.jl b/src/Capillary.jl index 96c778f1..58563f90 100644 --- a/src/Capillary.jl +++ b/src/Capillary.jl @@ -7,7 +7,7 @@ using Reexport @reexport using Luna.Modes import Luna: Maths, Grid import Luna.PhysData: c, ε_0, μ_0, ref_index_fun, roomtemp, densityspline, sellmeier_gas -import Luna.Modes: AbstractMode, dimlimits, neff, field, Aeff, N, geomfac +import Luna.Modes: AbstractMode, dimlimits, neff, field, Aeff, N import Luna.LinearOps: make_linop, conj_clamp, neff_grid, neff_β_grid import Luna.PhysData: wlfreq import Luna.Utils: subscript @@ -259,8 +259,6 @@ radius(m::MarcatiliMode, z) = m.a(z) dimlimits(m::MarcatiliMode; z=0) = (:polar, (0.0, 0.0), (radius(m, z), 2π)) -geomfac(m::MarcatiliMode) = 2 - # we use polar coords, so xs = (r, θ) function field(m::MarcatiliMode, xs; z=0) r, θ = xs diff --git a/src/Modes.jl b/src/Modes.jl index ff0cd62c..5bc7370c 100644 --- a/src/Modes.jl +++ b/src/Modes.jl @@ -31,8 +31,6 @@ Maximum dimensional limits of validity for mode `m` at position `z`. """ function dimlimits end -geomfac(m::AbstractMode) = 1 - """ field(m::AbstractMode, xs; z=0.0) diff --git a/src/NonlinearRHS.jl b/src/NonlinearRHS.jl index bf8fb80c..ccea798a 100644 --- a/src/NonlinearRHS.jl +++ b/src/NonlinearRHS.jl @@ -242,13 +242,13 @@ function pointcalc!(fval, xs, t::TransModal) if size(xs, 1) > 1 # full 2-D mode integral x2 = xs[2, i] if t.dimlimits[1] == :polar - pre = Modes.geomfac(t.ts.ms[1])*x1 + pre = x1 else if x2 <= t.dimlimits[2][2] || x1 >= t.dimlimits[3][2] fval[:, i] .= 0.0 continue end - pre = Modes.geomfac(t.ts.ms[1])*1.0 + pre = 1.0 end else if t.dimlimits[1] == :polar @@ -264,6 +264,7 @@ function pointcalc!(fval, xs, t::TransModal) to_time!(t.Er, t.Erω, t.Erωo, inv(t.FT)) # get nonlinear pol at r,θ Et_to_Pt!(t.Pr, t.Er, t.resp, t.density) + t.ncalls += 1 @. t.Pr *= t.grid.towin to_freq!(t.Prω, t.Prωo, t.Pr, t.FT) @. t.Prω *= t.grid.ωwin @@ -277,12 +278,9 @@ end function (t::TransModal)(nl, Eω, z) reset!(t, Eω, z) - coords, ll, ul = t.dimlimits + _, ll, ul = t.dimlimits if t.full - if coords == :polar - ul = (ul[1], ul[2]/Modes.geomfac(t.ts.ms[1])) - end - val, err = Cubature.pcubature_v( + val, err = Cubature.hcubature_v( length(Eω)*2, (x, fval) -> pointcalc!(fval, x, t), ll, ul, From 605663448eaf47c1f8fc0b3e2732da84b1b95137 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Fri, 15 Oct 2021 09:52:59 +0100 Subject: [PATCH 11/13] fix test --- test/test_multimode.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_multimode.jl b/test/test_multimode.jl index 664bd616..aa7202ea 100644 --- a/test/test_multimode.jl +++ b/test/test_multimode.jl @@ -137,7 +137,7 @@ end Iω = abs2.(output["Eω"]) Iωf = dropdims(sum(abs2.(outputf["Eω"]); dims=2), dims=2) - @test norm(Iω - Iωf)/norm(Iω) < 0.0003 + @test norm(Iω - Iωf)/norm(Iω) < 0.0006 end @testset "FieldInputs" begin From a7ebef89eee3a06812cfac6fd1d1694f5fd3cac8 Mon Sep 17 00:00:00 2001 From: cbrahms Date: Fri, 15 Oct 2021 11:12:50 +0100 Subject: [PATCH 12/13] extra test --- test/test_multimode.jl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/test_multimode.jl b/test/test_multimode.jl index aa7202ea..5fb978a1 100644 --- a/test/test_multimode.jl +++ b/test/test_multimode.jl @@ -170,3 +170,45 @@ end @test Eω_single ≈ Eω_tuple @test Eω_single ≈ Eω_tuple_of_namedtuples end + +@testset "Nonlinear coupling" begin + using Luna + import LinearAlgebra: norm + a = 125e-6 + gas = :Ar + pres = 0.167 + flength = 3 + + τfwhm = 10e-15 + λ0 = 800e-9 + energy = 150e-6 + + # HE11 and LP11 (consisting of HE21 + TM01) + modes = ( + Capillary.MarcatiliMode(a, gas, pres, n=0, m=1, kind=:TM, ϕ=0.0), + Capillary.MarcatiliMode(a, gas, pres, n=2, m=1, kind=:HE, ϕ=float(-π/4)), + Capillary.MarcatiliMode(a, gas, pres, n=1, m=1, kind=:HE, ϕ=float(0.0)), + ) + + grid = Grid.RealGrid(flength, λ0, (160e-9, 3000e-9), 0.4e-12) + + densityfun = let dens0=PhysData.density(gas, pres) + z -> dens0 + end + responses = (Nonlinear.Kerr_field(PhysData.γ3_gas(gas)),) + + field = Fields.GaussField(;λ0, τfwhm, energy=energy/2) + inputs = ((mode=1, fields=(field,)), (mode=2, fields=(field,))) + + Eω, transform, FT = Luna.setup( + grid, densityfun, responses, inputs, modes, :xy; full=true) + nl = similar(Eω) + + transform(nl, Eω, 0.0); + # nonlinear polarisation in LP11 + Inl12 = dropdims(sum(abs2.(nl[:, 1:2]); dims=2); dims=2) + # nonlinear polarisation in HE11 + Inl3 = abs2.(nl[:, 3]) + # LP11 should not couple nonlinearly to HE11 + @test norm(Inl3)/norm(Inl12) < 1e-32 +end \ No newline at end of file From bc3bbfe4d25c83b9af402a2538b6eb8950bf90ad Mon Sep 17 00:00:00 2001 From: cbrahms Date: Mon, 25 Oct 2021 09:31:41 +0100 Subject: [PATCH 13/13] bump version to 0.1.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fd18b391..e0250310 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Luna" uuid = "30eb0fb0-5147-11e9-3356-d75b018717ce" authors = ["chrisbrahms <38351086+chrisbrahms@users.noreply.github.com>"] -version = "0.1.0" +version = "0.1.2" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"