Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Brian gun/issue315 fix beam energy calculation #316

Merged
merged 7 commits into from
Nov 9, 2021
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
3 changes: 0 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ JSServe = "1"
JuMP = "0.21"
LazySets = "1"
Luxor = "2.10"
Makie = "0.14, 0.15"
MeshIO = "0.4"
NLopt = "0.6"
Optim = "1.2"
PackageCompiler = "1.2, 2"
Plots = "1.10"
Expand Down
12 changes: 9 additions & 3 deletions src/Optical/ParaxialAnalysis/LensletAssembly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,21 @@ function beamenergy(assy::LensletAssembly{T},displaypoint::AbstractVector{T},pup
llens::ParaxialLens{T} = lens(assy)
virtpoint = point(virtualpoint(llens,displaypoint))
projectedpoints = project(assy,displaypoint,pupilpoints)
beampupil = SphericalPolygon(pupilpoints,virtpoint,T(1))
lensverts = vertices(llens)
rows,cols = size(lensverts)
temp = SMatrix{1,cols,T}(reshape(fill(0,cols),1,cols))
lensverts3D = vcat(lensverts,temp)
beamlens = SphericalPolygon(lensverts3D,virtpoint,T(1))

intsct = LazySets.VPolygon(projectedpoints) ∩ LazySets.VPolygon(vertices(llens)) #this could be slow, especially multithreaded, because it will allocate. Lazysets.vertices returns Vector{SVector}, rather than SMatrix or SVector{SVector}.
projpoly = LazySets.VPolygon(projectedpoints)
lenspoly = LazySets.VPolygon(lensverts)
intsct = projpoly ∩ lenspoly #this could be slow, especially multithreaded, because it will allocate. Lazysets.vertices returns Vector{SVector}, rather than SMatrix or SVector{SVector}.

if isempty(intsct)
return T(0)
else
beamintsct = SphericalPolygon(convertlazysets(LazySets.vertices(intsct)),virtpoint,T(1))
return OpticSim.area(beamintsct)/OpticSim.area(beampupil)
return OpticSim.area(beamintsct)/OpticSim.area(beamlens)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/testsets/ParaxialAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using Unitful.DefaultSymbols
pupil = Rectangle(1.0,1.0,SVector(0.0,0.0,-1.0),SVector(2.0,2.0,40.0))

@test isapprox(
0.250234,
1/16,
ParaxialAnalysis.beamenergy(lenslet,displaypoint,Geometry.vertices3d(pupil)),
atol = 1e-4)
end
Expand Down