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

Commit

Permalink
Add functions to access cluster basis to lattices (fixes #298) (#299)
Browse files Browse the repository at this point in the history
* No function for accessing cluster basis in lattice cluster
Fixes #298

* added license to Repeat.jl testset

* No function for accessing cluster basis in lattice cluster
Fixes #298

had to update Schott glass catalog download URL since this was causing our documentation build to fail.
  • Loading branch information
BrianGun authored Oct 15, 2021
1 parent fb1e92d commit ef3b1c9
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/GlassCat/data/sources.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NIKON a49714470fa875ad4fd8d11cbc0edbf1adfe877f42926d7612c1649dd9441e75 https://www.nikon.com/products/components/assets/pdf/nikon_zemax_data.zip
OHARA 0c9021bf11b8d4e660012191818685ad3110d4f9490699cabdc89aae1fd26d2e https://www.oharacorp.com/xls/OHARA_201130_CATALOG.zip
HOYA b02c203e5a5b7a8918cc786badf0a9db1fe2572372c1c163dc306b0a8a908854 http://www.hoya-opticalworld.com/common/agf/HOYA20210105.agf
SCHOTT 02c3212e6984a553994caf7533c6c08f284f6ebc9312dbf90e605226577577e8 https://www.schott.com/d/advanced_optics/6959f9a4-0e4f-4ef2-a302-2347468a82f5/1.32/schott-optical-glass-overview-zemax-format.zip
SCHOTT 02c3212e6984a553994caf7533c6c08f284f6ebc9312dbf90e605226577577e8 https://mss-p-009-delivery.stylelabs.cloud/api/public/content/a79c07aa61da4c05a2c0bbab93d09a7f?v=3b65e351&download=true
SUMITA fad12bfb1754ee9e33f7a6ec65c784c1dd1b8e87fde1ac2e440d24e85630c758 https://www.sumita-opt.co.jp/en/wp/wp-content/themes/sumita-opt-en/download-files.php files%5B%5D=new_sumita.agf&category=data
ARCHER 7df8c42fb499720165c86d77dc8065db5126541a71b4e9d6a4849e27b25dd82d https://raw.githubusercontent.com/nzhagen/zemaxglass/master/AGF_files/archer.agf
ARTON d214e050f7330257c8cfcd517b1f35b64077dac62cf2729f73b3723e00a59263 https://raw.githubusercontent.com/nzhagen/zemaxglass/master/AGF_files/arton.agf
Expand Down
4 changes: 4 additions & 0 deletions src/RepeatingStructures/Cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ clusterelements(a::LatticeCluster) = a.clusterelements
export clusterelements
elementbasis(a::LatticeCluster) = a.elementbasis
clustersize(a::LatticeCluster) = length(a.clusterelements)
clusterbasis(a::LatticeCluster) = a.clusterbasis
export clusterbasis

"""returns the positions of every element in a cluster given the cluster indices"""
function Base.getindex(A::LatticeCluster{N1,N,T,B1,B2}, indices::Vararg{Int, N}) where{N1,N,T,B1<:Basis{N,Int},B2<:Basis{N,T}}
Expand Down Expand Up @@ -92,3 +94,5 @@ elementbasis(a::ClusterWithProperties) = elementbasis(cluster(a))
export elementbasis
clustersize(a::ClusterWithProperties) = clustersize(a.cluster)
export clustersize
clusterbasis(a::ClusterWithProperties) = clusterbasis(a.cluster)
export clusterbasis
4 changes: 2 additions & 2 deletions src/RepeatingStructures/HexagonalLattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct HexBasis1{N,T} <: Basis{N,T}
end
export HexBasis1

basis(::HexBasis1{2,T}) where{T} = SMatrix{2,2,T}(T(1.5),T(.5)*sqrt(T(3)),T(1.5),T(-.5)*(sqrt(T(3))))
basismatrix(::HexBasis1{2,T}) where{T} = SMatrix{2,2,T}(T(1.5),T(.5)*sqrt(T(3)),T(1.5),T(-.5)*(sqrt(T(3))))

# SVector{2,SVector{2,T}}(hexe₁(T),hexe₂(T))

Expand Down Expand Up @@ -180,5 +180,5 @@ function tilevertices(::HexBasis3{2,T}) where{T}
sin60, cos60)
end

basis(::HexBasis3{2,T}) where{T} = SMatrix{2,2,T}(T(2*sin60),T(0),T(sin60),T(1.5))
basismatrix(::HexBasis3{2,T}) where{T} = SMatrix{2,2,T}(T(2*sin60),T(0),T(sin60),T(1.5))

4 changes: 2 additions & 2 deletions src/RepeatingStructures/Lattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract type Basis{N,T<:Real} end
export Basis

function Base.getindex(A::B1, indices::Vararg{Int, N}) where{N,T,B1<:Basis{N,T}}
return basis(A)*SVector{N,Int}(indices)
return basismatrix(A)*SVector{N,Int}(indices)
end

# temp::SVector{N,T} = (basis(A)*SVector{N,Int}(indices))::SVector{N,T}
Expand Down Expand Up @@ -77,7 +77,7 @@ struct LatticeBasis{N,T<:Real} <: Basis{N,T}
end
export LatticeBasis

function basis(a::LatticeBasis{N,T})::SMatrix{N,N,T,N*N} where{N,T}
function basismatrix(a::LatticeBasis{N,T})::SMatrix{N,N,T,N*N} where{N,T}
return a.basisvectors
end

Expand Down
2 changes: 1 addition & 1 deletion src/RepeatingStructures/RectangularLattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct RectangularBasis{N,T} <: Basis{N,T}
end
export RectangularBasis

basis(::RectangularBasis{2,T}) where{T} = SMatrix{2,2,T}(T(1),T(0),T(0),T(1))
basismatrix(::RectangularBasis{2,T}) where{T} = SMatrix{2,2,T}(T(1),T(0),T(0),T(1))

# SVector{2,SVector{2,T}}(hexe₁(T),hexe₂(T))

Expand Down
2 changes: 1 addition & 1 deletion src/RepeatingStructures/Repeat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Repeat

export basis
export basismatrix

using Base: offset_if_vec
using StaticArrays:SVector,MVector,SMatrix,MMatrix
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Suppressor
using Random
using Unitful
using Plots
using DataFrames

using OpticSim
# Geometry Module
Expand Down Expand Up @@ -94,6 +95,7 @@ end
include("Benchmarks/Benchmarks.jl")

alltestsets = [
"Repeat",
"ParaxialAnalysis",
"Paraxial",
"JuliaLang",
Expand All @@ -109,7 +111,7 @@ alltestsets = [
"Visualization",
"Allocations",
"GlassCat",
"Transform",
"Transform"
]

runtestsets = ALL_TESTS ? alltestsets : intersect(alltestsets, ARGS)
Expand Down
18 changes: 18 additions & 0 deletions test/testsets/Repeat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MIT license
# Copyright (c) Microsoft Corporation. All rights reserved.
# See LICENSE in the project root for full license information.

@testset "Repeat" begin
function hex3RGB()
clusterelements = SVector((0,0),(-1,0),(-1,1))
colors = [colorant"red",colorant"green",colorant"blue"]
names = ["R","G","B"]
eltlattice = Repeat.HexBasis1()
clusterbasis = Repeat.LatticeBasis(( -1,2),(2,-1))
lattice = Repeat.LatticeCluster(clusterbasis,eltlattice,clusterelements)
properties = DataFrame(Color = colors, Name = names)
return Repeat.ClusterWithProperties(lattice,properties)
end

@test [-1 2;2 -1] == Repeat.basismatrix(Repeat.clusterbasis(hex3RGB()))
end

0 comments on commit ef3b1c9

Please sign in to comment.