Skip to content

Commit

Permalink
Started adding documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjishnubose committed Sep 15, 2023
1 parent 192f2d2 commit 1e85f9c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
24 changes: 23 additions & 1 deletion src/MFTBonds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ module MFTBonds
using TightBindingToolkit, LinearAlgebra, Tullio


@doc """
```julia
GetBondCoorelation(Gr::Array{Matrix{ComplexF64}, T}, base::Int64, target::Int64, offset::Vector{Int64}, uc::UnitCell, bz::BZ) --> Matrix{ComplexF64}
GetBondCoorelation(Gr::Array{Matrix{ComplexF64}, T}, bond::Bond, uc::UnitCell, bz::BZ) --> Matrix{ComplexF64}
```
Returns the Greens function (correlations) on the given bond from the full Array in `Gr`.
"""
function GetBondCoorelation(Gr::Array{Matrix{ComplexF64}, T}, base::Int64, target::Int64, offset::Vector{Int64}, uc::UnitCell, bz::BZ) :: Matrix{ComplexF64} where {T}
index = mod.((-offset) , bz.gridSize) .+ ones(Int64, length(offset))
##### TODO : the extra - sign in offset is because right now G[r] = <f^{dagger}_0 . f_{-r}> ===> NEED TO FIX THIS
Expand All @@ -25,6 +33,13 @@ module MFTBonds
end


@doc """
```julia
GetBondDictionary(BondLookup::Dict{Tuple, Matrix{ComplexF64}}, BondKey::Tuple{Int64, Int64, Vector{Int64}}, localDim::Int64) --> Dict{String, Matrix{ComplexF64}}
```
Given a lookup dictionary `BondLookup`, and a bond with `BondKey=(i, j, offset)`, returns a dictionary containing the effective on-site matrices as well the bond matrices on sites `i, j` and bond `i->j`.
"""
function GetBondDictionary(BondLookup::Dict{Tuple, Matrix{ComplexF64}}, BondKey::Tuple{Int64, Int64, Vector{Int64}}, localDim::Int64) :: Dict{String, Matrix{ComplexF64}}
base, target, offset = BondKey
AdjBondKey = (target, base, -offset)
Expand All @@ -47,7 +62,14 @@ module MFTBonds

end



@doc """
```julia
GetMFTBonds(DecomposedBonds::Dict{String, Matrix{ComplexF64}} ; BondKey::Tuple{Int64, Int64, Vector{Int64}}, uc::UnitCell{2}, scaling::Dict{String, Float64} = Dict("ij" => 1.0, "ii" => 1.0, "jj" => 1.0), labels::Dict{String, String} = Dict("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site"))
```
Returns a vector of `Bond` objects using the bond dictionary created by [`GetBondDictionary`][@ref]. The bond objects have `labels`, and are scaled according to `scaling`.
"""
function GetMFTBonds(DecomposedBonds::Dict{String, Matrix{ComplexF64}} ; BondKey::Tuple{Int64, Int64, Vector{Int64}}, uc::UnitCell{2}, scaling::Dict{String, Float64} = Dict("ij" => 1.0, "ii" => 1.0, "jj" => 1.0), labels::Dict{String, String} = Dict("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site")) :: Vector{Bond{2}}

base, target, offset = BondKey
Expand Down
8 changes: 8 additions & 0 deletions src/MFTEnergies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ module MFTEnergies

using TightBindingToolkit
#### /// TODO : Add relative scaling to energy calculation -----> Bonds are already scaled, so dont need to do this!!!

@doc """
```julia
GetMFTBondEnergies(Chis::Dict{String, Matrix{ComplexF64}}, DecomposedBonds::Dict{String, Matrix{ComplexF64}}, uc::UnitCell ; scaling :: Dict{String, Float64} = Dict{String, Float64}("ij" => 1.0, "ii" => 1.0, "jj" => 1.0) ) --> Float64
```
Returns the mean-field energy contribution given an interaction and expectation value `Chis`. Everything is re-scaled according to `scaling`.
"""
function GetMFTBondEnergies(Chis::Dict{String, Matrix{ComplexF64}}, DecomposedBonds::Dict{String, Matrix{ComplexF64}}, uc::UnitCell ; scaling :: Dict{String, Float64} = Dict{String, Float64}("ij" => 1.0, "ii" => 1.0, "jj" => 1.0) ) :: Float64

t_ij = get(DecomposedBonds, "ij", zeros(ComplexF64, repeat([uc.localDim], 2)...))
Expand Down
32 changes: 30 additions & 2 deletions src/TightBindingMFT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ module TBMFT
using ..MeanFieldToolkit.MFTBonds: GetBondCoorelation
using ..MeanFieldToolkit.Blocks: ParamBlock


@doc """
`TightBindingMFT{T, R}` is a data type representing a general mean-field simulation on a tight-binding model.
# Attributes
- `TightBindingModel :: Model`: The tight-binding model on which mean-field simulations are going to run.
- `HoppingBlock :: ParamBlock{2, R}`: a block of order parameters to decompose the interactions in during MFT.
- `InteractionBlock :: ParamBlock{2, FLoat64}`: the block containing all the information of the interactions acting on the model.
- `MFTDecomposition :: Vector{Function}` : the decomposition function which describes how to take an interaction array + expectation values and give back tight-binding hoppings.
- `MFTScaling :: Dict{String, Float64}`: relative scaling parameters for different mean-field channels.
- `ChannelLabels :: Dict{String, String}`: The labels of the different mean-field channels.
Initialize this structure using
```julia
TightBindingMFT(TightBindingModel::Model, HoppingBlock::ParamBlock{2, R}, InteractionBlock::Vector{ParamBlock{T, Float64}} , MFTDecomposition::Vector{Function} ; ChannelLabels :: Dict{String, String} = Dict{String, String}("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site"))
TightBindingMFT(TightBindingModel::Model, HoppingBlock::ParamBlock{2, R}, InteractionBlock::Vector{ParamBlock{T, Float64}}, MFTDecomposition::Vector{Function}, MFTScaling::Dict{String, Float64} ; ChannelLabels :: Dict{String, String} = Dict{String, String}("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site"))
TightBindingMFT(TightBindingModel::Model, HoppingBlock::ParamBlock{2, R}, InteractionBlock::ParamBlock{T, Float64} , MFTDecomposition::Function ; ChannelLabels :: Dict{String, String} = Dict{String, String}("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site"))
TightBindingMFT(TightBindingModel::Model, HoppingBlock::ParamBlock{2, R}, InteractionBlock::ParamBlock{T, Float64}, MFTDecomposition::Function, MFTScaling::Dict{String, Float64} ; ChannelLabels :: Dict{String, String} = Dict{String, String}("ij" => "Hopping", "ii" => "Hopping On-Site", "jj" => "Hopping On-Site"))
```
"""
mutable struct TightBindingMFT{T, R}
##### TightBinding Model for MFT, and the ParamBlock containing the expected order parameters of MFT
TightBindingModel :: Model
Expand Down Expand Up @@ -51,9 +71,17 @@ module TBMFT

end

##### /// TODO: Add Free Hopping energies also
##### /// TODO: Test!!!!

@doc """
```julia
GetMFTEnergy(tbMFT::TightBindingMFT{T, R}) --> Float64
```
Returns the total mean-field energy of the model including decomposed interactions.
"""
function GetMFTEnergy(tbMFT::TightBindingMFT{T, R}) :: Float64 where {T, R}
##### /// TODO: Add Free Hopping energies also
##### /// TODO: Test!!!!

Energy = 0.0
lookup = Lookup(tbMFT.TightBindingModel.uc)
Expand Down

0 comments on commit 1e85f9c

Please sign in to comment.