Skip to content

Instantly share code, notes, and snippets.

@jebej
Created April 21, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jebej/ca21d3222ee4cdc4b3cab5f4b0cf225c to your computer and use it in GitHub Desktop.
Save jebej/ca21d3222ee4cdc4b3cab5f4b0cf225c to your computer and use it in GitHub Desktop.
Broadcast performance problem in 0.6
using BenchmarkTools
const ⊗ = kron
const ħ = 1.054571800E-34 # in Joules*seconds, 2014 CODATA
const ln2 = 0.6931471805599453
function liouvillian(H)
Id = eye(H)
return -1im/ħ * (Id⊗H - H.'⊗Id)
end
function gaussian(x,w)
return exp(-4ln2*(x/w)^2)
end
# Drive
ωd = 3.956828566477119e10
FWHM = 10E-9
tf = 3*FWHM
tspan = (0.0,tf)
ϕ = 0.0
# Matrices
Hc1 = [-1.59317e-23 0.0 0.0 0.0 0.0; 0.0 -1.1759e-23 0.0 0.0 0.0; 0.0 0.0 -7.72458e-24 0.0 0.0; 0.0 0.0 0.0 -3.83665e-24 0.0; 0.0 0.0 0.0 0.0 -1.05158e-25];
Hd1 = [0.0 2.78341e-28 0.0 5.59519e-30 0.0; 2.78341e-28 0.0 3.87005e-28 0.0 1.17167e-29; 0.0 3.87005e-28 0.0 4.65186e-28 0.0; 5.59519e-30 0.0 4.65186e-28 0.0 5.26016e-28; 0.0 1.17167e-29 0.0 5.26016e-28 0.0];
Lc = liouvillian(Hc1);
Ld = liouvillian(Hd1);
Nq1 = isqrt(size(Ld,1))
ρ0 = zeros(Complex128,Nq1,Nq1); ρ0[1,1] = 1/sqrt(2); ρ0[2,2] = 1/sqrt(2)
Lc_diag = diag(Lc)
ϵ = 112
function drivefun!(t,ρ,dρ)
A_mul_B!(dρ,Ld,ρ)
scale!(dρ,ϵ*gaussian(t-1.5FWHM,FWHM)*cos(ωd*t+ϕ))
dρ .+= Lc_diag.*ρ
end
vecρ0 = copy(vec(ρ0))
vecdρ = zeros(vecρ0)
@benchmark drivefun!($(3E-11),vecρ0,vecdρ)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment