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

Allow for surface type extensibility in AxisymmetricOpticalSystem #179

Merged
merged 14 commits into from
May 13, 2021
Merged
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "OpticSim"
uuid = "24114763-4efb-45e7-af0e-cde916beb153"
authors = ["Brian Guenter", "Charlie Hewitt", "Ran Gal", "Alfred Wong"]
repository = "https://github.com/microsoft/OpticSim.jl"
version = "0.5.0-DEV"
version = "0.5.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
2 changes: 1 addition & 1 deletion samples/notebooks/EmittersIntro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ begin

# defining the optical system
sys = AxisymmetricOpticalSystem(
DataFrame(Surface = [:Object, 1, 2, 3, :Stop, 5, 6, :Image],
DataFrame(SurfaceType = ["Object", "Standard", "Standard", "Standard", "Stop", "Standard", "Standard", "Image"],
Radius = [Inf, 26.777, 66.604, -35.571, 35.571, 35.571, -26.777, Inf],
Thickness = [Inf, 4.0, 2.0, 4.0, 2.0, 4.0, 44.748, missing],
Material = [OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SK16, OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SF2, OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SK16, OpticSim.GlassCat.Air, missing],
Expand Down
2 changes: 1 addition & 1 deletion samples/notebooks/Samples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ begin

# defining the optical system
sys_cooke = AxisymmetricOpticalSystem(
DataFrame(Surface = [:Object, 1, 2, 3, :Stop, 5, 6, :Image],
DataFrame(SurfaceType= ["Object", "Standard", "Standard", "Standard", "Stop", "Standard", "Standard", "Image"],
Radius = [Inf, 26.777, 66.604, -35.571, 35.571, 35.571, -26.777, Inf],
Thickness = [Inf, 4.0, 2.0, 4.0, 2.0, 4.0, 44.748, missing],
Material = [OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SK16, OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SF2, OpticSim.GlassCat.Air, OpticSim.GlassCat.SCHOTT.N_SK16, OpticSim.GlassCat.Air, missing],
Expand Down
19 changes: 12 additions & 7 deletions src/Examples/docs_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export draw_cooketriplet, draw_schmidtcassegraintelescope, draw_lensconstruction
function draw_cooketriplet(filename::Union{Nothing,AbstractString} = nothing)
g1, g2 = SCHOTT.N_SK16, SCHOTT.N_SF2
sys = AxisymmetricOpticalSystem{Float64}(DataFrame(
Surface = [:Object, 1, 2, 3, :Stop, 5, 6, :Image ],
Radius = [Inf, 26.777, 66.604, -35.571, 35.571, 35.571, -26.777, Inf ],
Thickness = [Inf, 4.0, 2.0, 4.0, 2.0, 4.0, 44.748, missing],
Material = [Air, g1, Air, g2, Air, g1, Air, missing],
SemiDiameter = [Inf, 8.580, 7.513, 7.054, 6.033, 7.003, 7.506, 15.0 ],
SurfaceType = ["Object", "Standard", "Standard", "Standard", "Stop", "Standard", "Standard", "Image"],
Radius = [Inf, 26.777, 66.604, -35.571, 35.571, 35.571, -26.777, Inf ],
Thickness = [Inf, 4.0, 2.0, 4.0, 2.0, 4.0, 44.748, missing],
Material = [Air, g1, Air, g2, Air, g1, Air, missing],
SemiDiameter = [Inf, 8.580, 7.513, 7.054, 6.033, 7.003, 7.506, 15.0 ],
))

origins = Origins.Hexapolar(8, 15.0, 15.0)
Expand Down Expand Up @@ -40,11 +40,16 @@ function draw_zoomlenses(filenames::Vector{<:Union{Nothing,AbstractString}} = re
directions = Directions.Constant(0.0, 0.0, -1.0)
raygenerator = Sources.Source(; transform, origins, directions)

aspherics = [
[4 => 1.0386E-04, 6 => 1.4209E-07, 8 => -8.8495E-09, 10 => 1.2477E-10, 12 => -1.0367E-12, 14 => 3.6556E-15],
[4 => 4.2721E-05, 6 => 1.2484E-07, 8 => 9.7079E-09, 10 => -1.8444E-10, 12 => 1.8644E-12, 14 => -7.7975E-15],
[4 => 1.1339E-04, 6 => 4.8165E-07, 8 => 1.8778E-08, 10 => -5.7571E-10, 12 => 8.9994E-12, 14 => -4.6768E-14],
Comment on lines +44 to +46
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite a dictionary, but I think Pairs here are more expressive than tuples regarding our intended usage. This will easily convert to a Dict if needed later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think there is a better way to do this still eg where surface type is the actual type name allowing you to get the constructor for the surface dynamically and then you could pass the parameter dict as keyword args. This is a pretty fundamental change and might mean modifying the surface constructors too (ughh) but would mean that new surface types would be supported directly and there wouldn’t be any need for hard coding stuff when setting up axisymmetric systems.

Anyway this seems reasonable for now, but I think there is a better solution there that might be easiest to achieve by starting almost from scratch on the design of AxisymmetricOpticalSystem

Copy link
Collaborator Author

@alfredclwong alfredclwong May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean - got the wrong idea earlier!

It'll definitely require a lot of changes, and it'll get mixed up with some other discussions we're having now about prescription DataFrames for non-axisymmetric systems... (although this also means it's a good time for a rewrite). Let's go with this for now - in the short term, all I want is to add support for Zernike surfaces. I'll factor this into our discussions and work towards something smoother in the future.

side note: i'd still like to stick with Vector{Pair} for coefficients

]
syss = [
AxisymmetricOpticalSystem{Float64}(DataFrame(
Surface = [:Object, :Stop, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, :Image],
SurfaceType = ["Object", "Stop", "Standard", "Standard", "Standard", "Aspheric", "Standard", "Standard", "Aspheric", "Aspheric", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Image"],
Radius = [Inf64, Inf64, -1.6202203499676E+01, -4.8875855327468E+01, 1.5666614444619E+01, -4.2955326460481E+01, 1.0869565217391E+02, 2.3623907394283E+01, -1.6059097478722E+01, -4.2553191489362E+02, -3.5435861091425E+01, -1.4146272457208E+01, -2.5125628140704E+02, -2.2502250225023E+01, -1.0583130489999E+01, -4.4444444444444E+01, Inf64],
Aspherics = [missing, missing, missing, missing, missing, [(4, 1.0386E-04), (6, 1.4209E-07), (8, -8.8495E-09), (10, 1.2477E-10), (12, -1.0367E-12), (14, 3.6556E-15)], missing, missing, [(4, 4.2721E-05), (6, 1.2484E-07), (8, 9.7079E-09), (10, -1.8444E-10), (12, 1.8644E-12), (14, -7.7975E-15)], [(4, 1.1339E-04), (6, 4.8165E-07), (8, 1.8778E-08), (10, -5.7571E-10), (12, 8.9994E-12), (14, -4.6768E-14)], missing, missing, missing, missing, missing, missing, missing],
Parameters = [missing, missing, missing, missing, missing, aspherics[1], missing, missing, aspherics[2], aspherics[3], missing, missing, missing, missing, missing, missing, missing],
Thickness = [Inf64, 0.0, 5.18, 0.10, 4.40, 0.16, 1.0, 4.96, zoom, 4.04, 1.35, 1.0, 2.80, 3.0, 1.22, dist, missing],
Material = [Air, Air, OHARA.S_LAH66, Air, NIKON.LLF6, Air, OHARA.S_TIH6, OHARA.S_FSL5, Air, OHARA.S_FSL5, Air, OHARA.S_LAL8, OHARA.S_FSL5, Air, OHARA.S_LAH66, Air, missing],
SemiDiameter = [Inf64, stop, 3.85433218451, 3.85433218451, 4.36304692871, 4.36304692871, 4.72505505439, 4.72505505439, 4.72505505439, 4.45240784026, 4.45240784026, 4.50974054117, 4.50974054117, 4.50974054117, 4.76271114409, 4.76271114409, 15.0]))
Expand Down
Loading