You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Krastanov Currently, there are a number of special operator structures that aim to increase performance. For example the operations $a^\dagger w$ and $a w^\dagger$ have the CavitWaveguideOperators:
The waveguide interactions have not been optimized much as of now but just using CavityWaveguideOperators instead of a standard LazyTensor gives a speedup of like 1.5.
See the following test:
ξfun2(t1,t2,σ1,σ2,t0) = sqrt(2/σ1)* (log(2)/pi)^(1/4)*exp(-2*log(2)*(t1-t0)^2/σ1^2)*sqrt(2/σ2)* (log(2)/pi)^(1/4)*exp(-2*log(2)*(t2-t0)^2/σ2^2)
function special()
times = 0:0.1:10
be = FockBasis(1)
bw = WaveguideBasis(2,2,times)
bw_single = WaveguideBasis(1,2,times)
b = bw ⊗ be
a = embed(b,2,destroy(be))
ad = embed(b,2,create(be))
wdL = emission(bw,be,1)
wL = absorption(bw,be,1)
wdR = emission(bw,be,2)
wR = absorption(bw,be,2)
wdL_in = create(bw,1) ⊗ identityoperator(be)
wL_in = destroy(bw,1) ⊗ identityoperator(be)
wdR_in = create(bw,2) ⊗ identityoperator(be)
wR_in = destroy(bw,2) ⊗ identityoperator(be)
V = 1
H = im*sqrt(κ1/dt)*(wL-wdL) + im*sqrt(κ2/dt)*(wR-wdR) + V/dt *(LazyProduct(wdR_in,wL_in)+ LazyProduct(wdL_in,wR_in))
psi_int = twophoton(bw,1,ξfun2,1,1,5) ⊗ fockstate(be,1)
psi_out = waveguide_evolution(times,psi_int,H)
end
function lazy()
times = 0:0.1:10
be = FockBasis(1)
bw = WaveguideBasis(2,2,times)
bw_single = WaveguideBasis(1,2,times)
b = bw ⊗ be
a = embed(b,2,destroy(be))
ad = embed(b,2,create(be))
wdL = LazyTensor(b,b,(1,2),(create(bw,1),destroy(be)))
wL = LazyTensor(b,b,(1,2),(destroy(bw,1),create(be)))
wdR = LazyTensor(b,b,(1,2),(create(bw,2),destroy(be)))
wR = LazyTensor(b,b,(1,2),(destroy(bw,2),create(be)))
wdL_in = create(bw,1) ⊗ identityoperator(be)
wL_in = destroy(bw,1) ⊗ identityoperator(be)
wdR_in = create(bw,2) ⊗ identityoperator(be)
wR_in = destroy(bw,2) ⊗ identityoperator(be)
V = 1
H = im*sqrt(κ1/dt)*(wL-wdL) + im*sqrt(κ2/dt)*(wR-wdR) + V/dt *(LazyProduct(wdR_in,wL_in)+ LazyProduct(wdL_in,wR_in))
psi_int = twophoton(bw,1,ξfun2,1,1,5) ⊗ fockstate(be,1)
psi_out = waveguide_evolution(times,psi_int,H)
end
using BenchmarkTools
@btime special()
@btime lazy()
Giving:
930.162 ms (395625 allocations: 31.62 MiB)
1.498 s (219224 allocations: 28.54 MiB)
Right now, we are performing a lot of tests when doing the tensor product between a waveguide operator and any operator see for example:
This is to ensure that if the input is a cavity annihilation or creation operator, then the more efficient CavityWaveguideOperator structure is used. This is, however, very specialized, and maybe could cause problems? Instead, we could just create a LazyTensor per default (which is slower but requires much less code and instead we will be using code already tested in QuantumOpticsBase). Then if one wishes to enhance performance, you have to explicitly create the CavityWaveguideOperator via emission(bc,bw) and absorption(bc,bw). See:
emission(b1::WaveguideBasis{T},b2::FockBasis) where T
emission(b1::FockBasis,b2::WaveguideBasis{T}) where T
Create [`CavityWaveguideEmission`](@ref) that applies `destroy(b::FockBasis)` on `FockBasis` and create(b::WaveguideBasis{T}) on [`WaveguideBasis{T}`](@ref).
"""
functionemission(b1::WaveguideBasis{T,Nw},b2::FockBasis,idx) where {T,Nw}
What do you think? Should we automatically try to increase performance with the risk that we are reducing flexibility (and possible unexpected errors) or should we just create regular LazyTensor and leave the option for performance enhancement in the functions emission and absorption.
The text was updated successfully, but these errors were encountered:
@Krastanov Currently, there are a number of special operator structures that aim to increase performance. For example the operations$a^\dagger w$ and $a w^\dagger$ have the CavitWaveguideOperators:
WaveguideQED.jl/src/CavityWaveguideOperator.jl
Lines 50 to 77 in c609dc5
and also for waveguide interactions$w_k^\dagger w_j$ :
WaveguideQED.jl/src/WaveguideInteraction.jl
Lines 36 to 43 in c609dc5
The waveguide interactions have not been optimized much as of now but just using CavityWaveguideOperators instead of a standard LazyTensor gives a speedup of like 1.5.
See the following test:
Giving:
Right now, we are performing a lot of tests when doing the tensor product between a waveguide operator and any operator see for example:
https://github.com/qojulia/WaveguideQED.jl/blob/c609dc544214b994585f05fe3159be518d28391f/src/CavityWaveguideOperator.jl#L284-L295C4
This is to ensure that if the input is a cavity annihilation or creation operator, then the more efficient CavityWaveguideOperator structure is used. This is, however, very specialized, and maybe could cause problems? Instead, we could just create a LazyTensor per default (which is slower but requires much less code and instead we will be using code already tested in QuantumOpticsBase). Then if one wishes to enhance performance, you have to explicitly create the CavityWaveguideOperator via emission(bc,bw) and absorption(bc,bw). See:
WaveguideQED.jl/src/CavityWaveguideOperator.jl
Lines 131 to 221 in c609dc5
What do you think? Should we automatically try to increase performance with the risk that we are reducing flexibility (and possible unexpected errors) or should we just create regular LazyTensor and leave the option for performance enhancement in the functions emission and absorption.
The text was updated successfully, but these errors were encountered: