Skip to content

Commit

Permalink
Fix the bugs of Γ"z" and DM"z".
Browse files Browse the repository at this point in the history
  • Loading branch information
waltergu committed Nov 21, 2022
1 parent 6fc1805 commit 3682da9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ Ising"z" => SparseMatrixCSC([0 0 0; 0 0 0; 0 0 1])
# Γ terms
Γ"x" => SparseMatrixCSC([0 0 0; 0 0 1; 0 1 0])
Γ"y" => SparseMatrixCSC([0 0 1; 0 0 0; 1 0 0])
Γ"z" => SparseMatrixCSC([0 1 0; 0 1 0; 0 0 0])
Γ"z" => SparseMatrixCSC([0 1 0; 1 0 0; 0 0 0])

# Dzyaloshinskii–Moriya terms
DM"x" => SparseMatrixCSC([0 0 0; 0 0 1; 0 -1 0])
DM"y" => SparseMatrixCSC([0 0 -1; 0 0 0; 1 0 0])
DM"z" => SparseMatrixCSC([0 1 0; 0 -1 0; 0 0 0])
DM"z" => SparseMatrixCSC([0 1 0; -1 0 0; 0 0 0])
```

[`MatrixCoupling`](@ref)s can be producted or summed.
Expand Down Expand Up @@ -416,7 +416,7 @@ Hopping(
id::Symbol,
value,
bondkind,
coupling=Coupling(Index(:, FID(:, :, :)), Index(:, FID(:, :, :));
coupling=Coupling(Index(:, FID(:, :, :)), Index(:, FID(:, :, :)));
amplitude::Union{Function, Nothing}=nothing
)

Expand Down
8 changes: 4 additions & 4 deletions src/QuantumSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,28 +657,28 @@ end
"""
Γ"x" => SparseMatrixCSC([0 0 0; 0 0 1; 0 1 0])
Γ"y" => SparseMatrixCSC([0 0 1; 0 0 0; 1 0 0])
Γ"z" => SparseMatrixCSC([0 1 0; 0 1 0; 0 0 0])
Γ"z" => SparseMatrixCSC([0 1 0; 1 0 0; 0 0 0])
The Γ coupling matrix.
"""
macro Γ_str(str::String)
str=="x" && return SparseMatrixCSC([0 0 0; 0 0 1; 0 1 0])
str=="y" && return SparseMatrixCSC([0 0 1; 0 0 0; 1 0 0])
str=="z" && return SparseMatrixCSC([0 1 0; 0 1 0; 0 0 0])
str=="z" && return SparseMatrixCSC([0 1 0; 1 0 0; 0 0 0])
error("@Γ_str error: wrong input string.")
end

"""
DM"x" => SparseMatrixCSC([0 0 0; 0 0 1; 0 -1 0])
DM"y" => SparseMatrixCSC([0 0 -1; 0 0 0; 1 0 0])
DM"z" => SparseMatrixCSC([0 1 0; 0 -1 0; 0 0 0])
DM"z" => SparseMatrixCSC([0 1 0; -1 0 0; 0 0 0])
The DM coupling matrix.
"""
macro DM_str(str::String)
str=="x" && return SparseMatrixCSC([0 0 0; 0 0 1; 0 -1 0])
str=="y" && return SparseMatrixCSC([0 0 -1; 0 0 0; 1 0 0])
str=="z" && return SparseMatrixCSC([0 1 0; 0 -1 0; 0 0 0])
str=="z" && return SparseMatrixCSC([0 1 0; -1 0 0; 0 0 0])
error("@DM_str error: wrong input string.")
end

Expand Down
4 changes: 2 additions & 2 deletions test/QuantumSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,13 @@ end
@testset "Γ" begin
@test Γ"x" == SparseMatrixCSC([0 0 0; 0 0 1; 0 1 0])
@test Γ"y" == SparseMatrixCSC([0 0 1; 0 0 0; 1 0 0])
@test Γ"z" == SparseMatrixCSC([0 1 0; 0 1 0; 0 0 0])
@test Γ"z" == SparseMatrixCSC([0 1 0; 1 0 0; 0 0 0])
end

@testset "DM" begin
@test DM"x" == SparseMatrixCSC([0 0 0; 0 0 1; 0 -1 0])
@test DM"y" == SparseMatrixCSC([0 0 -1; 0 0 0; 1 0 0])
@test DM"z" == SparseMatrixCSC([0 1 0; 0 -1 0; 0 0 0])
@test DM"z" == SparseMatrixCSC([0 1 0; -1 0 0; 0 0 0])
end

@testset "SpinTerm" begin
Expand Down

0 comments on commit 3682da9

Please sign in to comment.