diff --git a/Project.toml b/Project.toml index c631f60..47b052d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "WaveguideQED" uuid = "c4555495-0e8d-488d-8e6a-965ecefe9055" authors = ["Matias Bundgaard-Nielsen , Mikkel Heuck , and Stefan Krastanov "] -version = "0.2.3" +version = "0.2.4" [deps] FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 8f0c952..663368c 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.0" +julia_version = "1.10.0" manifest_format = "2.0" project_hash = "d6a5993505edb88a10fbee1b0a4d47aa45a4e462" @@ -190,7 +190,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.2+0" +version = "1.0.5+1" [[deps.ConcurrentUtilities]] deps = ["Serialization", "Sockets"] @@ -633,21 +633,26 @@ version = "1.0.0" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" +version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" +version = "8.4.0+0" [[deps.LibGit2]] -deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.6.4+0" + [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" +version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -772,7 +777,7 @@ version = "1.1.7" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+0" +version = "2.28.2+1" [[deps.Missings]] deps = ["DataAPI"] @@ -785,7 +790,7 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2022.10.11" +version = "2023.1.10" [[deps.MuladdMacro]] git-tree-sha1 = "cac9cc5499c25554cba55cd3c30543cff5ca4fab" @@ -829,12 +834,12 @@ version = "1.12.9" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.21+4" +version = "0.3.23+2" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+0" +version = "0.8.1+2" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -892,7 +897,7 @@ version = "2.7.1" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.9.0" +version = "1.10.0" [[deps.PoissonRandom]] deps = ["Random"] @@ -993,7 +998,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.Random]] -deps = ["SHA", "Serialization"] +deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.Random123]] @@ -1174,6 +1179,7 @@ version = "1.1.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.10.0" [[deps.SparseDiffTools]] deps = ["ADTypes", "Adapt", "ArrayInterface", "Compat", "DataStructures", "FiniteDiff", "ForwardDiff", "Graphs", "LinearAlgebra", "Reexport", "Requires", "SciMLOperators", "Setfield", "SparseArrays", "StaticArrayInterface", "StaticArrays", "Tricks", "VertexSafeGraphs"] @@ -1240,7 +1246,7 @@ version = "1.4.0" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.9.0" +version = "1.10.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -1303,9 +1309,9 @@ deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "5.10.1+6" +version = "7.2.1+1" [[deps.SymbolicIndexingInterface]] deps = ["DocStringExtensions"] @@ -1422,7 +1428,7 @@ version = "0.2.0" deps = ["FFTW", "LinearAlgebra", "Parameters", "PrecompileTools", "QuantumOptics", "QuantumOpticsBase", "SparseArrays", "Strided", "UnsafeArrays"] path = ".." uuid = "c4555495-0e8d-488d-8e6a-965ecefe9055" -version = "0.2.1" +version = "0.2.4" [[deps.WignerSymbols]] deps = ["HalfIntegers", "LRUCache", "Primes", "RationalRoots"] @@ -1439,7 +1445,7 @@ version = "0.4.9" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.13+0" +version = "1.2.13+1" [[deps.ZygoteRules]] deps = ["ChainRulesCore", "MacroTools"] @@ -1450,14 +1456,14 @@ version = "0.2.3" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.7.0+0" +version = "5.8.0+1" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" +version = "1.52.0+1" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+0" +version = "17.4.0+2" diff --git a/docs/make.jl b/docs/make.jl index 0d800fe..8667666 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -21,6 +21,7 @@ pages = [ "theoreticalbackground.md", "tutorial.md", "multiplewaveguides_v2.md", +"beamsplitter.md", "input_output.md", "time_delay.md", #"Examples" => ["Scattering on two level system" => "example_lodahl.md"], diff --git a/docs/src/beamsplitter.md b/docs/src/beamsplitter.md new file mode 100644 index 0000000..03e782d --- /dev/null +++ b/docs/src/beamsplitter.md @@ -0,0 +1,120 @@ +# [Beamsplitters](@id Beamsplitter) + +Having introduced multiple waveguides in [Multiple Waveguides](@id multiple), it is natural to implement the beamsplitter operation and consider some of the common measurements one would make on states having undergone a beamsplitter transformation. + +We start by introducing how a beamsplitter can be implemented using two waveguides that interact. For simplicity, we start by considering only a single photon in one waveguide. First we create the basis, operators of the multiple waveguides and an initial single photon state with a gaussian wavefunction residing in waveguide 1: + +```@example bs +using WaveguideQED #hide +using QuantumOptics #hide +times = 0:0.1:10 +dt = times[2] - times[1] +NPhotons = 2 +NWaveguides = 2 +bw = WaveguideBasis(NPhotons,NWaveguides,times) +w1 = destroy(bw,1) +wd1 = create(bw,1) +w2 = destroy(bw,2) +wd2 = create(bw,2) + + +ξ(t, t0=5, σ=1) = complex(√(2/σ)*(log(2)/pi)^(1/4)*exp(-2*log(2)*(t-t0)^2/σ^2)) +psi = onephoton(bw,1, ξ) +nothing #hide +``` + +We now want to consider the following beamsplitter transformation: $w_{k,1} \rightarrow \cos(V) w_{k,1} - i \sin(V) w_{k,2}$ and equivalently for waveguide 2: $w_{k,2} \rightarrow - i \sin(V) w_{k,2} + \cos(V) w_{k,1}$. Having access to our initial Gaussian wavefunction we could just create the transformed state as: + +```@example bs +V = pi/4 +psi_trans_manual = cos(V) * onephoton(bw,1, ξ) -im*sin(V)*onephoton(bw,2, ξ) +nothing #hide +``` + +A more automatic and equivalent method is, however, instead to let the waveguide state undergo evolution under the Hamiltonian: $H = V( w_{k,1}^\dagger w_{k,2} + w_{k,2}^\dagger w_{k,1})$, which performs the same transformation. See [Section 4.3](https://github.com/qojulia/WaveguideQED.jl/blob/main/Thesis/Master_s_thesis__Modeling_Tools_For_Quantum_Networks%20(9).pdf) for details of the derivation. We can confirm this by: + +```@example bs +Vs = 0:pi/32:pi +reflection = zeros(length(Vs)) +transmission = zeros(length(Vs)) +n1 = wd1 *w1 +n2 = wd2 *w2 +psi = onephoton(bw,1, ξ) +for (i,V) in enumerate(Vs) + H = V/dt*(wd1 * w2 + wd2*w1) + + psi_trans = waveguide_evolution(times,psi,H) + + transmission[i] = expect_waveguide(n1,psi_trans) + reflection[i] = expect_waveguide(n2,psi_trans) +end +using PyPlot #hide +fig,ax = subplots(1,1,figsize=(9,4.5)) +ax.plot(Vs/pi,reflection,"b-",label="Waveguide a") +ax.plot(Vs/pi,transmission,"r-",label="Waveguide b") +ax.set_xlabel(L"V [$\pi$]") +ax.set_ylabel("Population") +plt.tight_layout() +plt.savefig("beamsplitter_trans.svg") #hide +nothing #hide +``` +![beamsplitter](beamsplitter_trans.svg) + + +Here we see this population of waveguide 1 and 2 after the transformation vary as cosines and sines as we change the interaction parameter V. Thus, we confirm that we are applying the desired transformation. For an even beamsplitter, we thus choose $V=\pi/4$ + +## [Hong Ou Mandel with twophotons](@id hom) +As a more advanced example, we now consider a Hong Ou Mandel setup, where we have one photon in each waveguide impinging on a beamsplitter. If the two photons equivalent, we will see the Hong Ou Mandel effect and thus expect no photons in both waveguide simultanouesly after the transformation. As a measure of this, we calcuate the chance of having a coincedence count where one photon is in waveguide 1 while the other is in waveguide 2. This calculated using the two projection operators: + +$$P_1 = \int_0^T dt w_1^\dagger(t) |0\rangle\langle0| w_1(t) \qquad P_2 = \int_0^T dt w_2^\dagger(t) |0\rangle\langle0| w_2(t)$$ + +where $w_1(t)$ and $w_2(t)$ are lowering operators for two waveguides. The chance of coincidence count is computed by $\langle\psi|P_1 P_2 |\psi\rangle$. + +To compute the councidence count expectation we create our own custom expectation value function: + +```@example bs +n1 = wd1*w1 +n2 = wd2*w2 +expval_op = n1*n2 +using LinearAlgebra +function expect_waveguide2(O,psi,times) + psi_c = copy(psi) + expval = 0 + for i in eachindex(times) + set_waveguidetimeindex!(n1,i) + for j in eachindex(times) + set_waveguidetimeindex!(n2,j) + mul!(psi_c, O, psi) + expval += dot(psi_c.data,psi.data) + end + end + return expval +end +nothing #hide +``` + +Here we evaluate $w_1^\dagger(t) w_1(t)$ at one timeidex `i`, while we evaluate $w_2^\dagger(t) w_2(t)$ at another timeidex `j`. Together this gives us the total coincedence count chance. In the following, we use the Hamiltonian from the previous section with $V=\pi/4$ and consider two Gaussian photons in each their waveguide with different centers of time $t_0$. By changing the difference in $t_0$, we can see the transition from a perfect overlap meaning no coincedence count, to no overlap meaning that the two photons never interact. In this case, the two photons will split up randomly and $1/4$ of the time they will end up in waveguide 1, similarly $1/4$ of the time they will end up in waveguide 2, and the remaining $1/2$ time they will end up in each of their waveguides. Thus, we expect a coincedence count of $1/2$ when the two pulses are fully seperated. Note that in the above function, we can just use the waveguide operators as projectors as we never have twophotons in both waveguides. + +```@example bs +taus = 0:0.2:4 +ξ_twophoton(t1, t2, t01, t02) = ξ(t1, t01) * ξ(t2, t02) +V = pi/4 +H = V/dt*(wd1*w2 + wd2*w1) +coincedences = zeros(length(taus)) +t01 = 5 +for (i, τ) in enumerate(taus) + t02 = 5 + τ + psi_pre = twophoton(bw, [1,2], ξ_twophoton, t01,t02) + ψ = waveguide_evolution(times,psi_pre,H) + coincedences[i] = expect_waveguide2(expval_op, ψ,times) +end + +fig, ax = subplots(1,1, figsize=(6,4)) +ax.plot(taus, coincedences) +ax.set_xlabel(L"Delay between pules $\tau$") +ax.set_ylabel("Coincedence chance") +tight_layout() +savefig("hom.svg") #hide +nothing #hide +``` +![hom_plot](hom.svg) diff --git a/docs/src/tutorial.md b/docs/src/tutorial.md index 62536bd..74060cb 100644 --- a/docs/src/tutorial.md +++ b/docs/src/tutorial.md @@ -98,13 +98,13 @@ If we also want to know the number of photons in the waveguide state as a functi n = (ad*a) ⊗ identityoperator(bw) n_w = identityoperator(bc) ⊗ (create(bw)*destroy(bw)) function exp_na_and_nw(time,psi) - (expect(n,psi),expect(n_w,psi)) + (expect(n,psi),expect_waveguide(n_w,psi)) end ψ_out,na,nw = waveguide_evolution(times,ψ_in,H,fout=exp_na_and_nw) nothing #hide ``` -Where `expect(n_w,psi)` calculates the expectation value of all times of the pulse at each timestep: $\mathrm{expect(n_w,psi)} = \bra{\psi} \sum_k I \otimes w_k^\dagger w_k \ket{\psi}$ +Where `expect_waveguide(n_w,psi)` calculates the expectation value of all times of the pulse at each timestep: $\mathrm{expect_waveguide(n_w,psi)} = \bra{\psi} \sum_k I \otimes w_k^\dagger w_k \ket{\psi}$ This can be plotted as: diff --git a/src/WaveguideInteraction.jl b/src/WaveguideInteraction.jl index e676dbc..79dce85 100644 --- a/src/WaveguideInteraction.jl +++ b/src/WaveguideInteraction.jl @@ -55,6 +55,45 @@ end Base.:*(x::WaveguideInteraction{BL,BR},y::WaveguideInteraction{BL,BR}) where {BL,BR} = LazyProduct((x,y),x.factor*y.factor) + + + +function Base.:*(a::O1,b::O2) where {O1 <: WaveguideOperator,O2 <: WaveguideOperator} + WaveguideInteraction(basis(a),basis(a),complex(1.0),a,b,1) +end + +function Base.:*(a::O1,b::O2) where {O1 <: WaveguideInteraction,O2 <: WaveguideOperator} + LazyProduct((a,b),a.factor*b.factor) +end +function Base.:*(a::O1,b::O2) where {O1 <: WaveguideOperator,O2 <: WaveguideInteraction} + LazyProduct((a,b),a.factor*b.factor) +end + +function Base.:*(a::T1,b::T2) where {T1<: WaveguideOperatorT,T2<: WaveguideOperatorT} + @assert a.indices[1] == b.indices[1] + WaveguideInteraction(basis(a),basis(a),a.factor*b.factor,a.operators[1],b.operators[1],a.indices[1]) +end + +const TensorWaveguideInteraction = LazyTensor{B,B,F,V,T} where {B,F,V,T<:Tuple{Vararg{Union{WaveguideInteraction,WaveguideOperator,CavityWaveguideOperator}}}} +const WaveguideSum = LazySum{B,B,F,T} where {B,F,T<:Tuple{Vararg{Union{WaveguideInteraction,WaveguideOperator,CavityWaveguideOperator}}}} + +function zerophoton_projector(psi::Ket) + zerophoton_projector(basis(psi)) +end + +function zerophoton_projector(basis::WaveguideBasis) + dm(zerophoton(basis)) +end + +function zerophoton_projector(basis::Basis) + identityoperator(basis) +end + +function zerophoton_projector(b::CompositeBasis) + tensor([zerophoton_projector(b.bases[i]) for i in 1:length(b.bases)]...) +end + + identityoperator(x::WaveguideInteraction) = identityoperator(x.basis_l) function identityoperator(::Type{T},::Type{ComplexF64}, b1::Basis, b2::Basis) where {T<:WaveguideInteraction} @assert b1==b2 @@ -297,55 +336,3 @@ function waveguide_interaction_mul!(result,a::WaveguideDestroy{B1,B2,Np,idx1},bo @inbounds result[1+(idx1-1)*nsteps+timeindex] += alpha*a.factor*bop.factor*b[1+(idx2-1)*nsteps+timeindex] result end - - -function Base.:*(a::O1,b::O2) where {O1 <: WaveguideOperator,O2 <: WaveguideOperator} - WaveguideInteraction(basis(a),basis(a),complex(1.0),a,b,1) -end -function Base.:*(a::T1,b::T2) where {T1<: WaveguideOperatorT,T2<: WaveguideOperatorT} - @assert a.indices[1] == b.indices[1] - WaveguideInteraction(basis(a),basis(a),a.factor*b.factor,a.operators[1],b.operators[1],a.indices[1]) -end - -const TensorWaveguideInteraction = LazyTensor{B,B,F,V,T} where {B,F,V,T<:Tuple{Vararg{Union{WaveguideInteraction,WaveguideOperator,CavityWaveguideOperator}}}} -const WaveguideSum = LazySum{B,B,F,T} where {B,F,T<:Tuple{Vararg{Union{WaveguideInteraction,WaveguideOperator,CavityWaveguideOperator}}}} - -function zerophoton_projector(psi::Ket) - zerophoton_projector(basis(psi)) -end - -function zerophoton_projector(basis::WaveguideBasis) - dm(zerophoton(basis)) -end - -function zerophoton_projector(basis::Basis) - identityoperator(basis) -end - -function zerophoton_projector(b::CompositeBasis) - tensor([zerophoton_projector(b.bases[i]) for i in 1:length(b.bases)]...) -end - -function expect(a::T,psi::Ket) where T<:Union{WaveguideOperator,WaveguideInteraction,TensorWaveguideInteraction,CavityWaveguideOperator} - out = 0 - tmp_ket = Ket(psi.basis) - projector = zerophoton_projector(psi) - set_waveguidetimeindex!(a,1) - mul!(tmp_ket,a,psi,a.factor,0) - zero_part = dot(psi.data,(projector*tmp_ket).data) - out += dot(psi.data,tmp_ket.data) - for i in 2:get_nsteps(basis(a)) - set_waveguidetimeindex!(a,i) - mul!(tmp_ket,a,psi,a.factor,0) - out += (dot(psi.data,tmp_ket.data) - zero_part) - end - out -end - -function expect(a::T,psi::Ket) where T<:Union{WaveguideSum} - out = 0 - for (i,O) in enumerate(a.operators) - out += expect(O,psi)*a.factors[i] - end - out -end diff --git a/src/WaveguideOperator.jl b/src/WaveguideOperator.jl index 78247f6..9b48f01 100644 --- a/src/WaveguideOperator.jl +++ b/src/WaveguideOperator.jl @@ -71,6 +71,8 @@ Base.:+(a::LazySum{B1,B2},b::WaveguideOperator{B1,B2}) where {B1,B2} = LazySum(a Base.:-(a::WaveguideOperator{B1,B2},b::LazySum{B1,B2}) where {B1,B2}= LazySum(a) - LazySum(b) Base.:-(a::LazySum{B1,B2},b::WaveguideOperator{B1,B2}) where {B1,B2}= LazySum(a) - LazySum(b) +Base.:*(a::WaveguideOperator{B1,B2},b::LazyProduct{B1,B2}) where {B1,B2} = LazyProduct(a) * b +Base.:*(a::LazyProduct{B1,B2},b::WaveguideOperator{B1,B2}) where {B1,B2} = a * LazyProduct(b) """ destroy(basis::WaveguideBasis{Np,1}) where {Np} destroy(basis::WaveguideBasis{Np,Nw},i::Int) where {Np,Nw} @@ -178,6 +180,27 @@ function identityoperator(::Type{T},::Type{ComplexF64}, b1::Basis, b2::Basis) wh identityoperator(b1) end +""" + expect_waveguide(O, psi) + +Returns the sum of expectation values of O over waveguide time indeces. This is usefull to extract information from waveguide states. +For example the number of photons can be computed as: `expect_waveguide(create(bw)*destroy(bw), psi, times)`, where BW is the waveguidebasis. Mathematically this is equivalent to ``sum_n \\langle \\psi | O(t_n) | \\psi \\rangle``. +For ``O(t_k) = w_k^\\dagger w_k`` acting on a single photon state ``|\\psi \\rangle = \\sum_k \\xi(t_k) w_k^\\dagger |0\\rangle``, one would therefore have: ``\\langle O \\rangle = \\sum_k |\\xi(t_k)|^2 = 1``, where the last follows from ``\\xi(t)`` being normalized. +""" +function expect_waveguide(O,psi) + psi_c = copy(psi) + expval = 0 + ops = get_waveguide_operators(O) + for i in 1:get_nsteps(basis(O)) + set_waveguidetimeindex!(ops,i) + mul!(psi_c, O, psi) + expval += dot(psi_c.data,psi.data) + end + return expval +end + + + """ mul!(result::Ket{B1}, a::LazyTensor{B1,B2,F,I,T}, b::Ket{B2}, alpha, beta) diff --git a/src/WaveguideQED.jl b/src/WaveguideQED.jl index 782a6aa..ccb9631 100644 --- a/src/WaveguideQED.jl +++ b/src/WaveguideQED.jl @@ -8,7 +8,7 @@ import LinearAlgebra: axpy!, dot, mul!, rmul!,I import QuantumOpticsBase: create, dagger, destroy, expect, identityoperator, tensor,set_time! export TwoPhotonTimestepView,TwoWaveguideTimestepView,OnePhotonView,TwoPhotonView,TwoWaveguideView, - WaveguideBasis,zerophoton,onephoton,twophoton,view_waveguide,get_waveguidetimeindex,set_waveguidetimeindex!,get_dt,get_nsteps,get_waveguide_location,get_waveguide_basis,get_number_of_waveguides,get_waveguide_operators, + WaveguideBasis,zerophoton,onephoton,twophoton,view_waveguide,get_waveguidetimeindex,set_waveguidetimeindex!,get_dt,get_nsteps,get_waveguide_location,get_waveguide_basis,get_number_of_waveguides,get_waveguide_operators,expect_waveguide, WaveguideOperator,WaveguideDestroy,WaveguideCreate, CavityWaveguideAbsorption,CavityWaveguideEmission,emission,absorption, WaveguideInteraction, @@ -17,7 +17,7 @@ export TwoPhotonTimestepView,TwoWaveguideTimestepView,OnePhotonView,TwoPhotonVie detect_single_click,detect_single_click!,LazyTensorKet,LazyTensorBra,LazySumKet,get_all_projectors,detect_double_click,detect_double_click!,Detector, plot_twophoton!, WaveguideTransform,effective_hamiltonian,fftket, - destroy,create,tensor,⊗,dagger,identityoperator,expect,set_time! + destroy,create,tensor,⊗,dagger,identityoperator,set_time! include("view.jl") include("basis.jl") diff --git a/src/basis.jl b/src/basis.jl index de2ec70..9317dc2 100644 --- a/src/basis.jl +++ b/src/basis.jl @@ -582,9 +582,16 @@ function twophoton(b::WaveguideBasis{T,1},ξ::Function,args...;norm=true) where state = Ket(b) nsteps = get_nsteps(b) viewed_data = TwoPhotonView(state.data,nsteps,nsteps+1) + offset = nsteps+1 for l in 1:nsteps - for m in l:nsteps - viewed_data[l,m] = ξ((l-1)*b.dt,(m-1)*b.dt,args...)*b.dt + for m in 1:nsteps + if ltypeof(x)<:WaveguideBasis,basis.bases)] end - -