Skip to content

Commit

Permalink
Start renaming stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
david-pl committed Aug 14, 2018
1 parent c5f8bd6 commit f78cf33
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/QuantumOptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export bases, Basis, GenericBasis, CompositeBasis, basis,
entropy_vn, fidelity, ptranspose, PPT,
negativity, logarithmic_negativity,
spectralanalysis, eigenstates, eigenenergies, simdiag,
timeevolution, diagonaljumps, @skipchecks,
timeevolution, diagonaljumps, @skiptimecheck,
steadystate,
timecorrelations,
semiclassical,
Expand Down Expand Up @@ -63,7 +63,7 @@ include("transformations.jl")
include("phasespace.jl")
include("metrics.jl")
module timeevolution
export diagonaljumps, @skipchecks
export diagonaljumps, @skiptimechecks
include("timeevolution_base.jl")
include("master.jl")
include("schroedinger.jl")
Expand Down
37 changes: 18 additions & 19 deletions src/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export Basis, GenericBasis, CompositeBasis, basis,
tensor, , ptrace, permutesystems,
IncompatibleBases,
samebases, multiplicable,
check_samebases, check_multiplicable, @ismultiplicable
check_samebases, check_multiplicable, @inbases

import Base: ==, ^

Expand Down Expand Up @@ -175,6 +175,21 @@ Exception that should be raised for an illegal algebraic operation.
"""
mutable struct IncompatibleBases <: Exception end

const BASES_CHECK = Ref(true)
"""
@ismultiplicable
Macro to skip multiplicability checks.
"""
macro inbases(ex)
return quote
BASES_CHECK.x = false
local val = $(esc(ex))
BASES_CHECK.x = true
val
end
end

"""
samebases(a, b)
Expand All @@ -189,7 +204,7 @@ Throw an [`IncompatibleBases`](@ref) error if the objects don't have
the same bases.
"""
function check_samebases(b1, b2)
if !samebases(b1, b2)
if BASES_CHECK[] && !samebases(b1, b2)
throw(IncompatibleBases())
end
end
Expand All @@ -214,30 +229,14 @@ function multiplicable(b1::CompositeBasis, b2::CompositeBasis)
return true
end


const MULTI_CHECK = Ref(true)
"""
@ismultiplicable
Macro to skip multiplicability checks.
"""
macro ismultiplicable(ex)
return quote
MULTI_CHECK.x = false
local val = $(esc(ex))
MULTI_CHECK.x = true
val
end
end

"""
check_multiplicable(a, b)
Throw an [`IncompatibleBases`](@ref) error if the objects are
not multiplicable.
"""
function check_multiplicable(b1, b2)
if MULTI_CHECK[] && !multiplicable(b1, b2)
if BASES_CHECK[] && !multiplicable(b1, b2)
throw(IncompatibleBases())
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/stochastic_schroedinger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using ...bases, ...states, ...operators
using ...operators_dense, ...operators_sparse
using ...timeevolution
using LinearAlgebra
import ...timeevolution: integrate_stoch, recast!
import ...timeevolution: integrate_stoch, recast!, QO_CHECKS
import ...timeevolution.timeevolution_schroedinger: dschroedinger, dschroedinger_dynamic, check_schroedinger

import DiffEqCallbacks
Expand Down Expand Up @@ -130,14 +130,14 @@ end

function dschroedinger_stochastic(dx::Vector{ComplexF64}, psi::Ket, Hs::Vector{T},
dpsi::Ket, index::Int) where T <: Operator
check_schroedinger(psi, Hs[index])
QO_CHECKS[] && check_schroedinger(psi, Hs[index])
recast!(dx, dpsi)
dschroedinger(psi, Hs[index], dpsi)
end
function dschroedinger_stochastic(dx::Array{ComplexF64, 2}, psi::Ket, Hs::Vector{T},
dpsi::Ket, n::Int) where T <: Operator
for i=1:n
check_schroedinger(psi, Hs[i])
QO_CHECKS[] && check_schroedinger(psi, Hs[i])
dx_i = @view dx[:, i]
recast!(dx_i, dpsi)
dschroedinger(psi, Hs[i], dpsi)
Expand Down
6 changes: 3 additions & 3 deletions src/timeevolution_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using ..metrics

import OrdinaryDiffEq, DiffEqCallbacks, StochasticDiffEq

export @skipchecks
export @skiptimechecks

const DiffArray = Union{Vector{ComplexF64}, Array{ComplexF64, 2}}

Expand Down Expand Up @@ -180,11 +180,11 @@ end

const QO_CHECKS = Ref(true)
"""
@skipchecks
@skiptimechecks
Macro to skip checks during time evolution.
"""
macro skipchecks(ex)
macro skiptimechecks(ex)
return quote
QO_CHECKS.x = false
local val = $(esc(ex))
Expand Down

0 comments on commit f78cf33

Please sign in to comment.