Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding hint for master and Schrödinger solver #395

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "QuantumOptics"
uuid = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c"
version = "1.0.15"
version = "1.0.16"

[deps]
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
Expand Down
1 change: 1 addition & 0 deletions src/QuantumOptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ end
include("timecorrelations.jl")
include("spectralanalysis.jl")
include("semiclassical.jl")
include("debug.jl")
module stochastic
include("stochastic_base.jl")
include("stochastic_definitions.jl")
Expand Down
21 changes: 21 additions & 0 deletions src/debug.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function __init__()
if isdefined(Base.Experimental, :register_error_hint)
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
if (exc.f == timeevolution.master) && (length(argtypes) >= 3)
# Check if the given Hamiltonian is constant.
if !(QuantumOpticsBase.is_const(exc.args[3]))
printstyled(io, "\nHint", color=:green)
print(io, ": You are attempting to use a time-dependent Hamiltonian with a solver that assumes constant dynamics. To avoid errors, please use the dynamic solvers instead, e.g. `master_dynamic` instead of `master`.")
end
end

if (exc.f == timeevolution.schroedinger) && (length(argtypes) >= 3)
# Check if the given Hamiltonian is constant.
if !(QuantumOpticsBase.is_const(exc.args[3]))
printstyled(io, "\nHint", color=:green)
print(io, ": You are attempting to use a time-dependent Hamiltonian with a solver that assumes constant dynamics. To avoid errors, please use the dynamic solvers instead, e.g. `schroedinger_dynamic` instead of `schroedinger`.")
end
end
end
end
end
2 changes: 2 additions & 0 deletions src/master.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Time-evolution according to a master equation with a Liouvillian superoperator `
permanent! It is still in use by the ode solver and therefore must not
be changed.
* `kwargs...`: Further arguments are passed on to the ode solver.

See also: [`master_dynamic`](@ref)
"""
function master(tspan, rho0::Operator, L::SuperOperator; fout=nothing, kwargs...)
# Rewrite rho as Ket and L as Operator
Expand Down
Loading