Skip to content

Commit

Permalink
Add clone_system for EntangledSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
ddahlbom committed Sep 10, 2024
1 parent 3d34a21 commit b272f65
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/EntangledUnits/TypesAndAliasing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ struct CrystalContractionInfo
inverse :: Vector{Vector{InverseData}} # List ordered according to contracted crystal sites. Each element is itself a list containing original crystal site indices and corresponding offset information
end

function Base.copy(cci::CrystalContractionInfo)
return CrystalContractionInfo(copy(cci.forward), copy(cci.inverse))
end


################################################################################
# System
Expand Down Expand Up @@ -116,6 +120,16 @@ eachunit(esys::EntangledSystem) = eachsite(esys.sys)
energy(esys::EntangledSystem) = energy(esys.sys)
energy_per_site(esys::EntangledSystem) = energy(esys.sys) / length(eachsite(esys.sys_origin))

function clone_system(esys::EntangledSystem)
sys = clone_system(esys.sys)
sys_origin = clone_system(esys.sys_origin)
contraction_info = copy(esys.contraction_info)
dipole_operators = copy(esys.dipole_operators)
source_idcs = copy(esys.source_idcs)

return EntangledSystem(sys, sys_origin, contraction_info, dipole_operators, source_idcs)
end

function set_field!(esys::EntangledSystem, B)
(; sys, sys_origin, dipole_operators, source_idcs) = esys
B_old = sys_origin.extfield[1,1,1,1]
Expand Down

0 comments on commit b272f65

Please sign in to comment.