Skip to content

Commit

Permalink
Adding hint for master and Schrödinger solver (#395)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Stefan Krastanov <github.acc@krastanov.org>
  • Loading branch information
a-eghrari and Krastanov committed Jun 10, 2024
1 parent d2c71fe commit b515a2b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
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

2 comments on commit b515a2b

@Krastanov
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/108674

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.16 -m "<description of version>" b515a2b4c19b0c5c8e47518c80202d8c4b7f0298
git push origin v1.0.16

Please sign in to comment.