From f78cf336f1f5d2bc00239c5cc13851a0d9791c77 Mon Sep 17 00:00:00 2001 From: david-pl Date: Tue, 14 Aug 2018 16:01:36 +0200 Subject: [PATCH] Start renaming stuff --- src/QuantumOptics.jl | 4 ++-- src/bases.jl | 37 +++++++++++++++++----------------- src/stochastic_schroedinger.jl | 6 +++--- src/timeevolution_base.jl | 6 +++--- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/QuantumOptics.jl b/src/QuantumOptics.jl index fd24f638..d2fa87e8 100644 --- a/src/QuantumOptics.jl +++ b/src/QuantumOptics.jl @@ -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, @@ -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") diff --git a/src/bases.jl b/src/bases.jl index 1dea5230..56018c2d 100644 --- a/src/bases.jl +++ b/src/bases.jl @@ -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: ==, ^ @@ -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) @@ -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 @@ -214,22 +229,6 @@ 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) @@ -237,7 +236,7 @@ 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 diff --git a/src/stochastic_schroedinger.jl b/src/stochastic_schroedinger.jl index dc0824e8..c8f4ae20 100644 --- a/src/stochastic_schroedinger.jl +++ b/src/stochastic_schroedinger.jl @@ -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 @@ -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) diff --git a/src/timeevolution_base.jl b/src/timeevolution_base.jl index 73ea186a..9050ed38 100644 --- a/src/timeevolution_base.jl +++ b/src/timeevolution_base.jl @@ -2,7 +2,7 @@ using ..metrics import OrdinaryDiffEq, DiffEqCallbacks, StochasticDiffEq -export @skipchecks +export @skiptimechecks const DiffArray = Union{Vector{ComplexF64}, Array{ComplexF64, 2}} @@ -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))