Skip to content

[ITensors] [ENHANCEMENT] Fermionic sign operator for Generic SiteType #1689

@matanlotem

Description

@matanlotem

At the moment, op(s,"F") returns the identity operator unless explicitly specified for the SiteType of s.
I would suggest that if isfermionic(s) == true, then this should return the parity operator.
This is useful, for example, on combine indices of multiple fermionic sites, where I would not want to explicitly define a new SiteType for each combination. Could be implemented maybe like this:

function ITensors.op!(o::ITensor, ::OpName"F", st::SiteType"Generic", s::Index; kwargs...)
    op!(o, OpName("Id"), st, s; kwargs...)
    if isfermionic(s)
        [o[Block(b,b)] *= (1-2f) for (b,f) in enumerate(fparity.(qn.(s.space)))]
    end
    return o
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    ITensorsIssues or pull requests related to the `ITensors` package.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions