Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add :x and :y polarisation #331

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/Interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ peak power specified.
- `mode::Symbol`: Mode in which this input should be coupled. Can be `:lowest` for the
lowest-order mode in the simulation, or a mode designation
(e.g. `:HE11`, `:HE12`, `:TM01`, etc.). Defaults to `:lowest`.
- `polarisation`: Can be `:linear`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
- `polarisation`: Can be `:linear`, `:x`, `:y`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
where ε=-1 corresponds to left-hand circular, ε=1 to right-hand circular,
and ε=0 to linear polarisation.
- `propagator`: A function `propagator!(Eω, grid)` which **mutates** its first argument to
Expand Down Expand Up @@ -71,7 +71,7 @@ specified.
- `mode::Symbol`: Mode in which this input should be coupled. Can be `:lowest` for the
lowest-order mode in the simulation, or a mode designation
(e.g. `:HE11`, `:HE12`, `:TM01`, etc.). Defaults to `:lowest`.
- `polarisation`: Can be `:linear`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
- `polarisation`: Can be `:linear`, `:x`, `:y`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
where ε=-1 corresponds to left-hand circular, ε=1 to right-hand circular,
and ε=0 to linear polarisation.
- `propagator`: A function `propagator!(Eω, grid)` which **mutates** its first argument to
Expand Down Expand Up @@ -105,7 +105,7 @@ specified, and duration given either as `τfwhm` or `τw`.
- `mode::Symbol`: Mode in which this input should be coupled. Can be `:lowest` for the
lowest-order mode in the simulation, or a mode designation
(e.g. `:HE11`, `:HE12`, `:TM01`, etc.). Defaults to `:lowest`.
- `polarisation`: Can be `:linear`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
- `polarisation`: Can be `:linear`, `:x`, `:y`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
where ε=-1 corresponds to left-hand circular, ε=1 to right-hand circular,
and ε=0 to linear polarisation.
- `propagator`: A function `propagator!(Eω, grid)` which **mutates** its first argument to
Expand Down Expand Up @@ -149,7 +149,7 @@ A custom pulse defined by tabulated data to be used with `prop_capillary`.
- `mode::Symbol`: Mode in which this input should be coupled. Can be `:lowest` for the
lowest-order mode in the simulation, or a mode designation
(e.g. `:HE11`, `:HE12`, `:TM01`, etc.). Defaults to `:lowest`.
- `polarisation`: Can be `:linear`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
- `polarisation`: Can be `:linear`, `:x`, `:y`, `:circular`, or an ellipticity number -1 ≤ ε ≤ 1,
where ε=-1 corresponds to left-hand circular, ε=1 to right-hand circular,
and ε=0 to linear polarisation.
- `propagator`: A function `propagator!(Eω, grid)` which **mutates** its first argument to
Expand Down Expand Up @@ -280,8 +280,8 @@ In this case, all keyword arguments except for `λ0` are ignored.
- `power`: Peak power **after any spectral phases are added**.
- `pulseshape`: Shape of the transform-limited pulse. Can be `:gauss` for a Gaussian pulse
or `:sech` for a sech² pulse.
- `polarisation`: Polarisation of the input pulse. Can be `:linear` (default), `:circular`,
or an ellipticity number -1 ≤ ε ≤ 1, where ε=-1 corresponds to left-hand circular,
- `polarisation`: Polarisation of the input pulse. Can be `:linear` (default), `:x`, `:y`,
`:circular`, or an ellipticity number -1 ≤ ε ≤ 1, where ε=-1 corresponds to left-hand circular,
ε=1 to right-hand circular, and ε=0 to linear polarisation. The major axis for
elliptical polarisation is always the y-axis.
- `propagator`: A function `propagator!(Eω, grid)` which **mutates** its first argument to
Expand Down Expand Up @@ -407,12 +407,13 @@ end
function needpol(pol)
if pol == :linear
return false
elseif pol == :circular
elseif pol in (:circular, :x, :y)
return true
else
error("Polarisation must be :linear, :circular, or an ellipticity, not $pol")
error("Polarisation must be :linear, :circular, :x/:y, or an ellipticity, not $pol")
end
end

needpol(pol::Number) = true
needpol(pulse::Pulses.AbstractPulse) = needpol(pulse.polarisation)
needpol(pulses::Vector{<:Pulses.AbstractPulse}) = any(needpol, pulses)
Expand Down Expand Up @@ -661,8 +662,10 @@ _findmode(mode_s, md) = _findmode([mode_s], md)
function makeinputs(mode_s, λ0, pulse::Pulses.AbstractPulse)
idcs = findmode(mode_s, pulse)
(length(idcs) > 0) || error("Mode $(pulse.mode) not found in mode list: $mode_s")
if pulse.polarisation == :linear
if pulse.polarisation == :linear || pulse.polarisation == :x
((mode=idcs[1], fields=(pulse.field,)),)
elseif pulse.polarisation == :y
((mode=idcs[2], fields=(pulse.field,)),)
else
(length(idcs) == 2) || error("Modes not set up for circular/elliptical polarisation")
f1, f2 = ellfields(pulse)
Expand Down
9 changes: 9 additions & 0 deletions test/test_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ old_logger = Logging.global_logger(logger)
o2 = prop_capillary(args...; polarisation=:linear, modes=4, kwargs...)
@test o1["Eω"][:, 1:2:end, :] ≈ o2["Eω"][:, :, :]
end
@testset "x/y" begin
o1 = prop_capillary(args...; polarisation=:x, modes=4, kwargs...)
o2 = prop_capillary(args...; polarisation=:y, modes=4, kwargs...)
@test o1["Eω"][:, 1:2:end, :] ≈ o2["Eω"][:, 2:2:end, :]
@test all(iszero, o1["Eω"][:, 2:2:end, 1])
@test isapprox(o1["stats"]["energy"][1, 1], kwargs.energy; rtol=1e-4)
@test isapprox(o2["stats"]["energy"][2, 1], kwargs.energy; rtol=1e-4)
@test all(iszero, o2["Eω"][:, 1:2:end, 1])
end
@testset "circular, $modes" for modes in (:HE11, :HE12, 1, 2)
o1 = prop_capillary(args...; modes, polarisation=:circular, kwargs...)
o2 = prop_capillary(args...; modes, polarisation=1.0, kwargs...)
Expand Down
Loading