-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
212 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +0,0 @@ | ||
""" | ||
Generates the translation operator T for a chain of L sites with local dimension d. | ||
The system is assumed to be uniform, i.e. the local dimension is the same for all sites. | ||
The system, in order to perform a translation, must be in periodic boundary conditions. | ||
Inputs: | ||
- `L` is the number of sites of the chain. | ||
- `d` is the local dimension. | ||
Outputs: | ||
- The translation operator `T`. | ||
""" | ||
function translation_operator( | ||
L::Integer, # The length of the system | ||
d::Integer # The local dimension | ||
)::Matrix{ComplexF64} | ||
|
||
N::Integer = d^L | ||
𝐓::Matrix{ComplexF64} = zeros(N,N) | ||
|
||
Lst = [] | ||
c = 0 | ||
for i ∈ 1:d | ||
lst = [] | ||
for j in 1:(N/d) | ||
c = c + 1 | ||
push!(lst, c) | ||
end | ||
push!(Lst, lst) | ||
end | ||
|
||
print(Lst) | ||
|
||
for indL in eachindex(Lst) | ||
lst = Lst[indL] | ||
for ind in eachindex(lst) | ||
j = lst[ind] | ||
𝐓[j, ((d*(j-1)+1)%N) + indL - 1] = 1 | ||
end | ||
end | ||
|
||
return 𝐓 | ||
end | ||
export translation_operator | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
println("Testing Scattensor.jl") | ||
"""________________________________________________________""" | ||
|
||
|
||
# 𝒮 = ExactDiagSystem(3, 2) | ||
# 𝛔ˣ::Matrix{ComplexF64} = [0 1;1 0] | ||
# println(product_local_operators(𝒮,(𝛔ˣ,1),(𝛔ˣ,2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
"""Insert the description of the struct.""" | ||
abstract type Model end | ||
|
||
"""Mutable struct for the Ising Model.""" | ||
mutable struct IsingModel <: Model | ||
spin_interaction ::Real | ||
transverse_field ::Real | ||
longitudinal_field ::Real | ||
mutable struct IsingModelParameters | ||
spin_interaction :: Real | ||
transverse_field :: Real | ||
longitudinal_field :: Real | ||
end | ||
export IsingModel | ||
export IsingModelParameters | ||
|
||
ising_model(; J::Real = 1, hx::Real = 0, hz::Real = 0) = IsingModelParameters(J, hx, hz) | ||
interaction(ℳ::IsingModelParameters) = ℳ.spin_interaction | ||
spin_interaction(ℳ::IsingModelParameters) = ℳ.spin_interaction | ||
transverse_field(ℳ::IsingModelParameters) = ℳ.transverse_field | ||
longitudinal_field(ℳ::IsingModelParameters) = ℳ.longitudinal_field | ||
|
||
IsingModel::Type = Union{IsingModelParameters} | ||
|
||
"""Mutable struct for the Heisenberg Model.""" | ||
mutable struct HeisenbergModel <: Model | ||
x_spin_interaction ::Real | ||
y_spin_interaction ::Real | ||
z_spin_interaction ::Real | ||
x_field ::Real | ||
y_field ::Real | ||
z_field ::Real | ||
|
||
mutable struct HeisenbergModelParameters <: Model | ||
x_spin_interaction :: Real | ||
y_spin_interaction :: Real | ||
z_spin_interaction :: Real | ||
x_field :: Real | ||
y_field :: Real | ||
z_field :: Real | ||
end | ||
export HeisenbergModel | ||
export HeisenbergModel | ||
|
||
heisenberg_model(; Jx::Real = 1, Jy::Real = 1, Jz::Real = 1, hx::Real = 0, hy::Real = 0, hz::Real = 0) = HeisenbergModel(Jx, Jy, Jz, hx, hy, hz) | ||
interaction(ℳ::HeisenbergModel) = (ℳ.x_spin_interaction, ℳ.y_spin_interaction, ℳ.z_spin_interaction) | ||
spin_interaction(ℳ::HeisenbergModel) = interaction(ℳ) | ||
x_spin_interaction(ℳ::HeisenbergModel) = ℳ.x_spin_interaction | ||
y_spin_interaction(ℳ::HeisenbergModel) = ℳ.y_spin_interaction | ||
z_spin_interaction(ℳ::HeisenbergModel) = ℳ.z_spin_interaction | ||
field(ℳ::HeisenbergModel) = (ℳ.x_field, ℳ.y_field, ℳ.z_field) | ||
x_field(ℳ::HeisenbergModel) = ℳ.x_field | ||
y_field(ℳ::HeisenbergModel) = ℳ.y_field | ||
z_field(ℳ::HeisenbergModel) = ℳ.z_field | ||
|
||
HeisenbergModel::Type = Union{HeisenbergModelParameters} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"""Insert the description of the struct.""" | ||
|
||
mutable struct EmptyOperator | ||
end | ||
|
||
operator() = EmptyOperator() | ||
|
||
mutable struct OperatorProperties | ||
hilbert_space_dimension :: Integer | ||
hermiticity :: Bool | ||
unitarity :: Bool | ||
end | ||
|
||
operator_properties() = OperatorProperties(false, false, 0) | ||
operator_properties(::EmptyOperator) = operator_properties() | ||
function operator_properties(𝐌::Matrix) | ||
hermiticity = (𝐌 == 𝐌') | ||
unitarity = (𝐌 * 𝐌' == 𝐌' * 𝐌 == I) | ||
hilbert_space_dimension = size(𝐌)[1] | ||
return OperatorProperties(hermiticity, unitarity, hilbert_space_dimension) | ||
end | ||
hermiticity(𝒪::OperatorProperties) = 𝒪.hermiticity | ||
unitarity(𝒪::OperatorProperties) = 𝒪.unitarity | ||
hilbert_space_dimension(𝒪::OperatorProperties) = 𝒪.hilbert_space_dimension | ||
|
||
mutable struct MatrixFormOperator | ||
matrix :: Matrix{ComplexF64} | ||
operator_properties :: OperatorProperties | ||
end | ||
|
||
operator(𝐌::Matrix{ComplexF64}) = MatrixFormOperator(𝐌, operator_properties(𝐌)) | ||
matrix(𝒪::MatrixFormOperator) = 𝒪.matrix | ||
operator_properties(𝒪::MatrixFormOperator) = 𝒪.operator_properties | ||
hermiticity(𝒪::MatrixFormOperator) = hermiticity(operator_properties(𝒪)) | ||
unitarity(𝒪::MatrixFormOperator) = unitarity(operator_properties(𝒪)) | ||
|
||
mutable struct ExactDiagMatrixFormOperator | ||
matrix_form_operator :: MatrixFormOperator | ||
parent_system :: ExactDiagSystem | ||
translational_invariance :: Bool | ||
end | ||
export ExactDiagOperator | ||
|
||
operator(𝐌::MatrixFormOperator, 𝒮::ExactDiagSystem) = ExactDiagMatrixFormOperator(𝐌, 𝒮, translational_invariance(𝐌, 𝒮)) | ||
matrix(𝒪::ExactDiagMatrixFormOperator) = matrix(𝒪.matrix_form_operator) | ||
operator_properties(𝒪::ExactDiagMatrixFormOperator) = operator_properties(𝒪.matrix_form_operator) | ||
hermiticity(𝒪::ExactDiagMatrixFormOperator) = hermiticity(𝒪.matrix_form_operator) | ||
unitarity(𝒪::ExactDiagMatrixFormOperator) = unitarity(𝒪.matrix_form_operator) | ||
translational_invariance(𝒪::ExactDiagMatrixFormOperator) = 𝒪.translational_invariance | ||
|
||
function translational_invariance(𝐌::Matrix{ComplexF64}, 𝒮::ExactDiagSystem)::Bool | ||
𝐓 = matrix(translation_operator(𝒮)) | ||
return 𝐌 * 𝐓 == 𝐓 * 𝐌 | ||
end | ||
|
||
""" | ||
Generates the translation operator T for a chain of L sites with local dimension d. | ||
The system is assumed to be uniform, i.e. the local dimension is the same for all sites. | ||
The system, in order to perform a translation, must be in periodic boundary conditions. | ||
Inputs: | ||
- `L` is the number of sites of the chain. | ||
- `d` is the local dimension. | ||
Outputs: | ||
- The translation operator `T`. | ||
""" | ||
|
||
translation_operator(d::Integer,L::Integer)::Matrix{ComplexF64} | ||
N::Integer = d^L | ||
𝐓::Matrix{ComplexF64} = zeros(N,N) | ||
|
||
Lst = [] | ||
c = 0 | ||
for _ in 1:d | ||
lst = [] | ||
for _ in 1:(N/d) | ||
c = c + 1 | ||
push!(lst, c) | ||
end | ||
push!(Lst, lst) | ||
end | ||
|
||
for indL in eachindex(Lst) | ||
lst = Lst[indL] | ||
for ind in eachindex(lst) | ||
j = lst[ind] | ||
𝐓[j, ((d*(j-1)+1)%N) + indL - 1] = 1 | ||
end | ||
end | ||
|
||
return 𝐓 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""Insert the description of the struct.""" | ||
|
||
# TYPE DEFINITION | ||
|
||
mutable struct ExactDiagState | ||
vector :: Vector{ComplexF64} | ||
parent_system :: Union{ExactDiagSystem, Missing} | ||
average_energy :: Union{Float64, Missing} | ||
average_momentum :: Union{Float64, Missing} | ||
end | ||
export ExactDiagState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Insert the description of the struct.""" | ||
|
||
# TYPE DEFINITION | ||
|
||
mutable struct ExactDiagStatesSet | ||
states_set :: Vector{ExactDiagState} | ||
end | ||
export ExactDiagStatesSet |
Oops, something went wrong.