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

RFC: possible Fields module #147

Merged
merged 49 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
99a8952
Add Field module
jtravs Apr 15, 2020
ac27dc2
Add type parameter
jtravs Apr 15, 2020
6973407
Use passed FFT
jtravs Apr 15, 2020
b990d54
Merge branch 'master' of https://github.com/jtravs/Luna into fields
jtravs Apr 20, 2020
2b528b8
fix Field after merege
jtravs Apr 20, 2020
2e5e891
working
jtravs Apr 20, 2020
22d7936
Fix Maths.gauss
jtravs Apr 20, 2020
c4d6805
remove t ω argument from energy functions
jtravs Apr 20, 2020
3d2cd13
add Sech field
jtravs Apr 20, 2020
163cb71
simplify input field definitions
jtravs Apr 20, 2020
287ab90
test_main works with this
jtravs Apr 20, 2020
ed1df1a
Merge branch 'master' of https://github.com/jtravs/Luna into fields
jtravs Apr 21, 2020
42abb26
start adding SpatioTemporalGrid
jtravs Apr 21, 2020
0c9d64b
Merge branch 'master' of https://github.com/jtravs/Luna into fields
jtravs Apr 21, 2020
0196a8c
fix spatiotemporal propagation
jtravs Apr 21, 2020
c1f7b0b
working radial fields
jtravs Apr 21, 2020
4232e49
radial now works and t-r field generalised
jtravs Apr 21, 2020
d769a6c
full 3D fields work
jtravs Apr 21, 2020
2fb3ab3
full3D env now works
jtravs Apr 21, 2020
b2d7aba
few comments
jtravs Apr 21, 2020
1f55619
fixup shotnoise and main examples
jtravs Apr 22, 2020
fd97ece
fixup more examples
jtravs Apr 22, 2020
7a6bcae
fix test_maths
jtravs Apr 22, 2020
ea0ee0f
fix test_output and test_gradient
jtravs Apr 22, 2020
69fd1f4
fix test_tapers
jtravs Apr 22, 2020
31267d7
fix test_radial
jtravs Apr 22, 2020
3911a83
fix test_multimode
jtravs Apr 22, 2020
261748d
fix test_full_freespace
jtravs Apr 22, 2020
73f0544
fix test_modes
jtravs Apr 22, 2020
21ab984
fix example basic_modal_full_nothpolarisations
jtravs Apr 22, 2020
a0c308f
fix basic_modal_full
jtravs Apr 22, 2020
d7b23e1
fix polarisation tests
jtravs Apr 22, 2020
e8815f4
elliptical examples are broken
jtravs Apr 22, 2020
733d443
gradient examples work
jtravs Apr 22, 2020
e996eaf
fix Raman examples
jtravs Apr 22, 2020
4e0cef0
fix rectangular examples
jtravs Apr 22, 2020
ef4e693
fix taper examples
jtravs Apr 22, 2020
df03100
Update src/Fields.jl
jtravs Apr 22, 2020
e593165
Update src/Fields.jl
jtravs Apr 22, 2020
c01c169
Update src/Fields.jl
jtravs Apr 22, 2020
3f1b887
Update src/Fields.jl
jtravs Apr 22, 2020
49e77d2
fix τfwhm for Sech pule
jtravs Apr 22, 2020
57d2441
Merge branch 'fields' of https://github.com/jtravs/Luna into fields
jtravs Apr 22, 2020
82d7af9
fix scan documentation
jtravs Apr 22, 2020
26dcbbb
ad test_fields.jl
jtravs Apr 22, 2020
7fb2357
correct envelope CEO test
jtravs Apr 22, 2020
3e7244e
ignore coverage files
jtravs Apr 23, 2020
c87efc0
fix fields CEO test
chrisbrahms Apr 23, 2020
0abedec
Merge branch 'fields' of https://github.com/jtravs/Luna into fields
jtravs Apr 23, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ deps/deps.jl
Manifest.toml
_git2_*
docs/build
*.info
16 changes: 2 additions & 14 deletions docs/src/scans.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ The first step is to write a standard Luna script to run a *single* simulation i
```julia
# Lots of setup work...
gausspulse = let τ=30e-15, λ=λ0
function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)*cos(ω0*t)
end

end
in1 = (func=gausspulse, energy=1e-6)
inputs = (in1, )
Expand Down Expand Up @@ -38,15 +34,7 @@ Then, make the following changes:

@scan begin
# Lots of setup work...
gausspulse = let τ=$τ, λ=λ0
function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)*cos(ω0*t)
end
end
in1 = (func=gausspulse, energy=$energy)
inputs = (in1, )
inputs = Fields.GaussField(λ0=λ0, τfwhm=$τ, energy=$energy)
# More setup work...
Luna.run(...) # run the simulation
end
Expand Down
43 changes: 19 additions & 24 deletions examples/MI_modeAvg_env.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import Luna
import Luna: Grid, Maths, Capillary, PhysData, Nonlinear, Ionisation, NonlinearRHS, Output, Stats, LinearOps, Modes
import Logging
import FFTW
import NumericalIntegration: integrate, SimpsonEven
Logging.disable_logging(Logging.BelowMinLevel)

import PyPlot:pygui, plt
using Luna

a = 15e-6
gas = :Ar
pres = 25

τ = 600e-15
τfwhm = 600e-15
λ0 = 800e-9
flength = 80e-2
energy = 10e-6

grid = Grid.EnvGrid(80e-2, 800e-9, (220e-9, 3000e-9), 4e-12)
grid = Grid.EnvGrid(flength, λ0, (220e-9, 3000e-9), 4e-12)

m = Capillary.MarcatilliMode(a, gas, pres, loss=false)
aeff(z) = Modes.Aeff(m, z=z)

energyfun = NonlinearRHS.energy_modal()

function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)
end
energyfun, energyfunω = Fields.energyfuncs(grid)

dens0 = PhysData.density(gas, pres)
densityfun(z) = dens0
Expand All @@ -40,16 +29,22 @@ ionrate = Ionisation.ionrate_fun!_ADK(ionpot)
responses = (Nonlinear.Kerr_env(PhysData.γ3_gas(gas)),)
# Nonlinear.PlasmaCumtrapz(grid.to, grid.to, ionrate, ionpot))

in1 = (func=gausspulse, energy=10e-6)
inputs = (in1, )
inputs = (Fields.GaussField(λ0=λ0, τfwhm=τfwhm, energy=energy), Fields.ShotNoise())

Eω, transform, FT = Luna.setup(grid, energyfun, densityfun, normfun, responses, inputs, aeff)
Luna.shotnoise!(Eω, grid)
Eω, transform, FT = Luna.setup(grid, densityfun, normfun, responses, inputs, aeff)

statsfun = Stats.collect_stats((Stats.ω0(grid), ))
output = Output.MemoryOutput(0, grid.zmax, 201, (length(grid.ω),), statsfun)
statsfun = Stats.collect_stats(grid, Eω,
Stats.ω0(grid),
Stats.energy(grid, energyfunω),
Stats.peakpower(grid),
Stats.fwhm_t(grid),
Stats.density(densityfun))
output = Output.MemoryOutput(0, grid.zmax, 201, statsfun)
Luna.run(Eω, grid, linop, transform, FT, output)

import FFTW
import PyPlot:pygui, plt

ω = grid.ω
t = grid.t
f = FFTW.fftshift(ω, 1)./2π.*1e-15
Expand All @@ -68,7 +63,7 @@ zpeak = argmax(dropdims(maximum(It, dims=1), dims=1))

energy = zeros(length(zout))
for ii = 1:size(Etout, 2)
energy[ii] = energyfun(t, Etout[:, ii])
energy[ii] = energyfun(Etout[:, ii])
end

pygui(true)
Expand Down
27 changes: 10 additions & 17 deletions examples/Raman/Raman_modeAvg.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
using Luna
import Logging
import FFTW
Logging.disable_logging(Logging.BelowMinLevel)

a = 13e-6
gas = :H2
pres = 5
flength = 200e-2

τ = 20e-15
τfwhm = 20e-15
λ0 = 800e-9
energy = 1e-6

grid = Grid.RealGrid(200e-2, 800e-9, (180e-9, 3000e-9), 4e-12)
grid = Grid.RealGrid(flength, λ0, (180e-9, 3000e-9), 4e-12)

m = Capillary.MarcatilliMode(a, gas, pres, loss=false)
aeff(z) = Modes.Aeff(m, z=z)

energyfun, energyfunω = NonlinearRHS.energy_modal(grid)

function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)*cos(ω0*t)
end
energyfun, energyfunω = Fields.energyfuncs(grid)

dens0 = PhysData.density(gas, pres)
densityfun(z) = dens0
Expand All @@ -34,10 +26,9 @@ linop, βfun, frame_vel, αfun = LinearOps.make_const_linop(grid, m, λ0)

normfun = NonlinearRHS.norm_mode_average(grid.ω, βfun, aeff)

in1 = (func=gausspulse, energy=energy)
inputs = (in1, )
inputs = Fields.GaussField(λ0=λ0, τfwhm=τfwhm, energy=energy)

Eω, transform, FT = Luna.setup(grid, energyfun, densityfun, normfun, responses, inputs, aeff)
Eω, transform, FT = Luna.setup(grid, densityfun, normfun, responses, inputs, aeff)

statsfun = Stats.collect_stats(grid, Eω,
Stats.ω0(grid),
Expand All @@ -46,10 +37,12 @@ statsfun = Stats.collect_stats(grid, Eω,
Stats.peakintensity(grid, aeff),
Stats.fwhm_t(grid),
Stats.density(densityfun))
output = Output.MemoryOutput(0, grid.zmax, 201, (length(grid.ω),), statsfun)
output = Output.MemoryOutput(0, grid.zmax, 201, statsfun)

Luna.run(Eω, grid, linop, transform, FT, output)

import FFTW

ω = grid.ω
t = grid.t

Expand All @@ -69,7 +62,7 @@ zpeak = argmax(dropdims(maximum(It, dims=1), dims=1))
Et = Maths.hilbert(Etout)
energy = zeros(length(zout))
for ii = 1:size(Etout, 2)
energy[ii] = energyfun(t, Etout[:, ii])
energy[ii] = energyfun(Etout[:, ii])
end

import PyPlot:pygui, plt
Expand Down
27 changes: 10 additions & 17 deletions examples/Raman/Raman_modeAvg_env.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
using Luna
import Logging
import FFTW
Logging.disable_logging(Logging.BelowMinLevel)

a = 13e-6
gas = :H2
pres = 5
flength = 200e-2

τ = 20e-15
τfwhm = 20e-15
λ0 = 800e-9
energy = 1e-6

grid = Grid.EnvGrid(200e-2, 800e-9, (180e-9, 3000e-9), 4e-12)
grid = Grid.EnvGrid(flength, λ0, (180e-9, 3000e-9), 4e-12)

m = Capillary.MarcatilliMode(a, gas, pres, loss=false)
aeff(z) = Modes.Aeff(m, z=z)

energyfun, energyfunω = NonlinearRHS.energy_modal(grid)

function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
Et = @. sqrt(It)
end
energyfun, energyfunω = Fields.energyfuncs(grid)

dens0 = PhysData.density(gas, pres)
densityfun(z) = dens0
Expand All @@ -33,22 +26,22 @@ linop, βfun, frame_vel, αfun = LinearOps.make_const_linop(grid, m, λ0)

normfun = NonlinearRHS.norm_mode_average(grid.ω, βfun, aeff)

in1 = (func=gausspulse, energy=energy)
inputs = (in1, )
inputs = Fields.GaussField(λ0=λ0, τfwhm=τfwhm, energy=energy)

Eω, transform, FT = Luna.setup(grid, energyfun, densityfun, normfun, responses, inputs, aeff)
Eω, transform, FT = Luna.setup(grid, densityfun, normfun, responses, inputs, aeff)

statsfun = Stats.collect_stats(grid, Eω,
Stats.ω0(grid),
Stats.energy(grid, energyfunω),
Stats.energy_λ(grid, energyfunω, (150e-9, 300e-9), label="RDW"),
Stats.peakpower(grid),
Stats.fwhm_t(grid),
Stats.density(densityfun))
output = Output.MemoryOutput(0, grid.zmax, 201, (length(grid.ω),), statsfun)
output = Output.MemoryOutput(0, grid.zmax, 201, statsfun)

Luna.run(Eω, grid, linop, transform, FT, output)

import FFTW

ω = grid.ω
t = grid.t
f = FFTW.fftshift(ω, 1)./2π.*1e-15
Expand All @@ -68,7 +61,7 @@ zpeak = argmax(dropdims(maximum(It, dims=1), dims=1))

energy = zeros(length(zout))
for ii = 1:size(Etout, 2)
energy[ii] = energyfun(t, Etout[:, ii])
energy[ii] = energyfun(Etout[:, ii])
end

import PyPlot:pygui, plt
Expand Down
32 changes: 12 additions & 20 deletions examples/Raman/Raman_modeAvg_noTHG.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import Luna
import Luna: Grid, Maths, Capillary, PhysData, Nonlinear, Ionisation, NonlinearRHS, Output, Stats, LinearOps, Modes, Raman
import Logging
import FFTW
Logging.disable_logging(Logging.BelowMinLevel)
using Luna

a = 13e-6
gas = :H2
pres = 5
flength = 200e-2

τ = 20e-15
τfwhm = 20e-15
λ0 = 800e-9
energy = 1e-6

grid = Grid.RealGrid(200e-2, 800e-9, (180e-9, 3000e-9), 4e-12)
grid = Grid.RealGrid(flength, λ0, (180e-9, 3000e-9), 4e-12)

m = Capillary.MarcatilliMode(a, gas, pres, loss=false)
aeff(z) = Modes.Aeff(m, z=z)

energyfun = NonlinearRHS.energy_modal()

function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)*cos(ω0*t)
end
energyfun, energyfunω = Fields.energyfuncs(grid)

dens0 = PhysData.density(gas, pres)
densityfun(z) = dens0
Expand All @@ -35,16 +26,17 @@ linop, βfun, frame_vel, αfun = LinearOps.make_const_linop(grid, m, λ0)

normfun = NonlinearRHS.norm_mode_average(grid.ω, βfun, aeff)

in1 = (func=gausspulse, energy=energy)
inputs = (in1, )
inputs = Fields.GaussField(λ0=λ0, τfwhm=τfwhm, energy=energy)

Eω, transform, FT = Luna.setup(grid, energyfun, densityfun, normfun, responses, inputs, aeff)
Eω, transform, FT = Luna.setup(grid, densityfun, normfun, responses, inputs, aeff)

statsfun = Stats.collect_stats((Stats.ω0(grid), ))
output = Output.MemoryOutput(0, grid.zmax, 201, (length(grid.ω),), statsfun)
statsfun = Stats.collect_stats(grid, Eω, Stats.ω0(grid))
output = Output.MemoryOutput(0, grid.zmax, 201, statsfun)

Luna.run(Eω, grid, linop, transform, FT, output)

import FFTW

ω = grid.ω
t = grid.t

Expand All @@ -64,7 +56,7 @@ zpeak = argmax(dropdims(maximum(It, dims=1), dims=1))
Et = Maths.hilbert(Etout)
energy = zeros(length(zout))
for ii = 1:size(Etout, 2)
energy[ii] = energyfun(t, Etout[:, ii])
energy[ii] = energyfun(Etout[:, ii])
end

import PyPlot:pygui, plt
Expand Down
37 changes: 14 additions & 23 deletions examples/arpcf_modeAvg.jl
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
using Luna
import Logging
import FFTW
import NumericalIntegration: integrate, SimpsonEven
Logging.disable_logging(Logging.BelowMinLevel)

# import DSP.Unwrap: unwrap

import PyPlot:pygui, plt

a = 13e-6
gas = :Ar
pres = 5
flength = 15e-2

τ = 30e-15
τfwhm = 30e-15
λ0 = 800e-9
energy = 1e-6

grid = Grid.RealGrid(15e-2, 800e-9, (160e-9, 3000e-9), 1e-12)
grid = Grid.RealGrid(flength, λ0, (160e-9, 3000e-9), 1e-12)

m = Antiresonant.ZeisbergerMode(a, gas, pres, wallthickness=200e-9, loss=false)
aeff = let m=m
z -> Modes.Aeff(m, z=z)
end

energyfun, energyfunω = NonlinearRHS.energy_modal(grid)

function gausspulse(t)
It = Maths.gauss(t, fwhm=τ)
ω0 = 2π*PhysData.c/λ0
Et = @. sqrt(It)*cos(ω0*t)
end
energyfun, energyfunω = Fields.energyfuncs(grid)

dens0 = PhysData.density(gas, pres)
densityfun(z) = dens0
Expand All @@ -44,11 +32,10 @@ linop, βfun, β1, αfun = LinearOps.make_const_linop(grid, m, λ0)

normfun = NonlinearRHS.norm_mode_average(grid.ω, βfun, aeff)

in1 = (func=gausspulse, energy=1e-6)
inputs = (in1, )
inputs = Fields.GaussField(λ0=λ0, τfwhm=τfwhm, energy=energy)

Eω, transform, FT = Luna.setup(
grid, energyfun, densityfun, normfun, responses, inputs, aeff)
grid, densityfun, normfun, responses, inputs, aeff)

statsfun = Stats.collect_stats(grid, Eω,
Stats.ω0(grid),
Expand All @@ -59,9 +46,13 @@ statsfun = Stats.collect_stats(grid, Eω,
Stats.fwhm_t(grid),
Stats.electrondensity(grid, ionrate, densityfun, aeff),
Stats.density(densityfun))
output = Output.MemoryOutput(0, grid.zmax, 201, (length(grid.ω),), statsfun)
output = Output.MemoryOutput(0, grid.zmax, 201, statsfun)

Luna.run(Eω, grid, linop, transform, FT, output)

import FFTW
import PyPlot:pygui, plt

##
ω = grid.ω
t = grid.t
Expand All @@ -80,8 +71,8 @@ Itlog = log10.(Maths.normbymax(It))
zpeak = argmax(dropdims(maximum(It, dims=1), dims=1))

Et = Maths.hilbert(Etout)
energy = [energyfun(t, Etout[:, ii]) for ii=1:size(Etout, 2)]
energyω = [energyfunω(ω, Eout[:, ii]) for ii=1:size(Eout, 2)]
energy = [energyfun(Etout[:, ii]) for ii=1:size(Etout, 2)]
energyω = [energyfunω(Eout[:, ii]) for ii=1:size(Eout, 2)]

pygui(true)
##
Expand Down
Loading