Skip to content

Commit 07edec0

Browse files
committed
Merge branch 'main' into dev/map_solvers
2 parents a470f78 + 5a4f8a2 commit 07edec0

File tree

11 files changed

+141
-21
lines changed

11 files changed

+141
-21
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
os: 'ubuntu-latest'
6969
arch: 'x64'
7070
group: 'Makie_Ext'
71-
- version: '1'
71+
- version: '1.11'
7272
node:
7373
os: 'ubuntu-latest'
7474
arch: 'x64'

.github/workflows/CleanPreviewDoc.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,62 @@ name: Cleanup Preview Documentation
33
on:
44
pull_request:
55
types: [closed]
6+
schedule:
7+
- cron: "0 0 * * 0" # Run weekly on Sunday at midnight
8+
workflow_dispatch:
69

710
permissions:
811
contents: write
9-
deployments: write
1012

1113
jobs:
1214
cleanup-preview-doc:
1315
runs-on: ubuntu-latest
1416
steps:
1517
- name: Checkout gh-pages branch
16-
uses: actions/checkout@v5
18+
uses: actions/checkout@v4
1719
with:
1820
ref: gh-pages
19-
- name: Delete preview and history + push changes
21+
- name: Delete preview(s) and reset history
2022
run: |
21-
if [ -d "previews/PR$PRNUM" ]; then
23+
# If triggered by PR close, delete that specific preview
24+
if [ "${{ github.event_name }}" = "pull_request" ]; then
25+
PRNUM=${{ github.event.number }}
26+
if [ -d "previews/PR$PRNUM" ]; then
27+
echo "Deleting preview for PR #$PRNUM"
28+
git rm -rf "previews/PR$PRNUM"
29+
fi
30+
else
31+
# Scheduled/manual run: check all previews against open PRs
32+
echo "Checking all preview folders for stale PRs..."
33+
34+
# Get list of all PR preview folders
35+
if [ -d "previews" ]; then
36+
for dir in previews/PR*; do
37+
[ -d "$dir" ] || continue
38+
PRNUM=$(echo "$dir" | grep -oP 'PR\K\d+')
39+
40+
# Check if PR is still open via GitHub API
41+
STATUS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
42+
"https://api.github.com/repos/${{ github.repository }}/pulls/$PRNUM" \
43+
| jq -r '.state // "closed"')
44+
45+
if [ "$STATUS" != "open" ]; then
46+
echo "Deleting stale preview for closed PR #$PRNUM"
47+
git rm -rf "$dir"
48+
fi
49+
done
50+
fi
51+
fi
52+
53+
# Only commit and push if there are changes
54+
if ! git diff --cached --quiet; then
2255
git config user.name "Documenter.jl"
2356
git config user.email "[email protected]"
24-
git rm -rf "previews/PR$PRNUM"
25-
git commit -m "delete preview"
57+
git commit -m "delete preview(s)"
2658
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
2759
git push --force origin gh-pages-new:gh-pages
60+
else
61+
echo "No stale previews found"
2862
fi
2963
env:
3064
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
PRNUM: ${{ github.event.number }}

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- uses: actions/checkout@v5
4747
- uses: julia-actions/setup-julia@v2
4848
with:
49-
version: '1'
49+
version: '1.11'
5050
- uses: julia-actions/cache@v2
5151
- uses: julia-actions/julia-buildpkg@v1
5252
- uses: julia-actions/julia-docdeploy@v1

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Fix `cite()` bibtex output. ([#552])
1111
- Implement `sesolve_map` and `mesolve_map` for solving multiple initial states and parameter sets in parallel. ([#554])
1212
- Add `qeye_like` and `qzero_like`, which are synonyms of `one` and `zero`. ([#555])
13+
- Add steadystate and DSF benchmarks. The `SteadyStateODESOlver` tolerances are lowered to `terminate_reltol=1e-4` and `terminate_abstol=1e-6` to improve speed at the cost of accuracy. ([#557])
1314

1415
## [v0.36.0]
1516
Release date: 2025-09-29
@@ -330,3 +331,4 @@ Release date: 2024-11-13
330331
[#552]: https://github.com/qutip/QuantumToolbox.jl/issues/552
331332
[#554]: https://github.com/qutip/QuantumToolbox.jl/issues/554
332333
[#555]: https://github.com/qutip/QuantumToolbox.jl/issues/555
334+
[#557]: https://github.com/qutip/QuantumToolbox.jl/issues/557

benchmarks/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[deps]
22
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3-
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
4-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
53
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
4+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
function benchmark_dsf!(SUITE)
2+
F = 2
3+
Δ = 0.25
4+
κ = 1
5+
U = 0.01
6+
J = 0.5
7+
tlist = LinRange(0, 15, 300)
8+
9+
N = 5
10+
a1 = kron(destroy(N), qeye(N))
11+
a2 = kron(qeye(N), destroy(N))
12+
function H_dsf(op_list, p)
13+
Δ = p.Δ
14+
F = p.F
15+
U = p.U
16+
J = p.J
17+
a1, a2 = op_list
18+
return Δ * a1' * a1 +
19+
Δ * a2' * a2 +
20+
U * a1'^2 * a1^2 +
21+
U * a2'^2 * a2^2 +
22+
F * (a1 + a1') +
23+
J * (a1' * a2 + a1 * a2')
24+
end
25+
function c_ops_dsf(op_list, p)
26+
κ = p.κ
27+
a1, a2 = op_list
28+
return [κ * a1, κ * a2]
29+
end
30+
function e_ops_dsf(op_list, p)
31+
a1, a2 = op_list
32+
return [a1' * a1, a2' * a2]
33+
end
34+
op_list = [a1, a2]
35+
ψ0 = kron(fock(N, 0), fock(N, 0))
36+
α0 = 1.5
37+
α0_l = [α0, α0]
38+
dsf_params == Δ, F = F, κ = κ, U = U, J = J)
39+
40+
SUITE["Time Evolution"]["Dynamical Shifted Fock"]["mesolve"] = @benchmarkable dsf_mesolve(
41+
$H_dsf,
42+
$ψ0,
43+
$tlist,
44+
$c_ops_dsf,
45+
$op_list,
46+
$α0_l,
47+
$dsf_params,
48+
e_ops = $e_ops_dsf,
49+
progress_bar = Val(false),
50+
)
51+
52+
SUITE["Time Evolution"]["Dynamical Shifted Fock"]["mcsolve"]["Serial"] = @benchmarkable dsf_mcsolve(
53+
$H_dsf,
54+
$ψ0,
55+
$tlist,
56+
$c_ops_dsf,
57+
$op_list,
58+
$α0_l,
59+
$dsf_params,
60+
ntraj = 100,
61+
e_ops = $e_ops_dsf,
62+
progress_bar = Val(false),
63+
ensemblealg = EnsembleSerial(),
64+
)
65+
66+
SUITE["Time Evolution"]["Dynamical Shifted Fock"]["mcsolve"]["Multithreaded"] = @benchmarkable dsf_mcsolve(
67+
$H_dsf,
68+
$ψ0,
69+
$tlist,
70+
$c_ops_dsf,
71+
$op_list,
72+
$α0_l,
73+
$dsf_params,
74+
ntraj = 100,
75+
e_ops = $e_ops_dsf,
76+
progress_bar = Val(false),
77+
ensemblealg = EnsembleThreads(),
78+
)
79+
80+
return nothing
81+
end

benchmarks/runbenchmarks.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ using BenchmarkTools
22
using LinearAlgebra
33
using SparseArrays
44
using QuantumToolbox
5-
using OrdinaryDiffEq
6-
using LinearSolve
5+
using SciMLBase: EnsembleSerial, EnsembleThreads
76

87
BLAS.set_num_threads(1)
98

109
const SUITE = BenchmarkGroup()
1110

1211
include("correlations_and_spectrum.jl")
1312
include("dynamical_fock_dimension.jl")
13+
include("dynamical_shifted_fock.jl")
1414
include("eigenvalues.jl")
1515
include("steadystate.jl")
1616
include("timeevolution.jl")
1717

1818
benchmark_correlations_and_spectrum!(SUITE)
1919
benchmark_dfd!(SUITE)
20+
benchmark_dsf!(SUITE)
2021
benchmark_eigenvalues!(SUITE)
2122
benchmark_steadystate!(SUITE)
2223
benchmark_timeevolution!(SUITE)

benchmarks/steadystate.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ function benchmark_steadystate!(SUITE)
1111

1212
SUITE["Steadystate"]["Direct"] = @benchmarkable steadystate($H, $c_ops)
1313

14+
SUITE["Steadystate"]["Iterative"] = @benchmarkable steadystate($H, $c_ops; solver = SteadyStateLinearSolver())
15+
16+
SUITE["Steadystate"]["ODE"] = @benchmarkable steadystate($H, $c_ops; solver = SteadyStateODESolver())
17+
1418
return nothing
1519
end

src/qobj/superoperators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ See also [`spre`](@ref), [`spost`](@ref), and [`lindblad_dissipator`](@ref).
160160
function liouvillian(
161161
H::AbstractQuantumObject{OpType},
162162
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
163-
Id_cache = I(prod(H.dimensions)),
163+
Id_cache::Diagonal = I(prod(H.dimensions)),
164164
) where {OpType<:Union{Operator,SuperOperator}}
165165
L = liouvillian(H, Id_cache)
166166
if !(c_ops isa Nothing)

src/steadystate.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ end
4747
alg = Tsit5(),
4848
ψ0 = nothing,
4949
tmax = Inf,
50-
terminate_reltol = 1e-5,
51-
terminate_abstol = 1e-7
50+
terminate_reltol = 1e-4,
51+
terminate_abstol = 1e-6
5252
)
5353
5454
An ordinary differential equation (ODE) solver for solving [`steadystate`](@ref). It solves the stationary state based on [`mesolve`](@ref) with a termination condition.
@@ -69,8 +69,8 @@ or
6969
- `alg::OrdinaryDiffEqAlgorithm=Tsit5()`: The algorithm to solve the ODE.
7070
- `ψ0::Union{Nothing,QuantumObject}=nothing`: The initial state of the system. If not specified, a random pure state will be generated.
7171
- `tmax::Real=Inf`: The final time step for the steady state problem.
72-
- `terminate_reltol` = The relative tolerance for stationary state terminate condition. Default to `1e-5`.
73-
- `terminate_abstol` = The absolute tolerance for stationary state terminate condition. Default to `1e-7`.
72+
- `terminate_reltol` = The relative tolerance for stationary state terminate condition. Default to `1e-4`.
73+
- `terminate_abstol` = The absolute tolerance for stationary state terminate condition. Default to `1e-6`.
7474
7575
!!! warning "Tolerances for terminate condition"
7676
The terminate condition tolerances `terminate_reltol` and `terminate_abstol` should be larger than `reltol` and `abstol` of [`mesolve`](@ref), respectively.
@@ -87,8 +87,8 @@ Base.@kwdef struct SteadyStateODESolver{
8787
alg::MT = Tsit5()
8888
ψ0::ST = nothing
8989
tmax::TT = Inf
90-
terminate_reltol::RT = 10 * DEFAULT_ODE_SOLVER_OPTIONS.reltol
91-
terminate_abstol::AT = 10 * DEFAULT_ODE_SOLVER_OPTIONS.abstol
90+
terminate_reltol::RT = 1e-4
91+
terminate_abstol::AT = 1e-6
9292
end
9393

9494
@doc raw"""

0 commit comments

Comments
 (0)