Giter VIP home page Giter VIP logo

Comments (5)

thchr avatar thchr commented on June 28, 2024 1

@jaemolihm I added this in 933853e with the name reduce_to_wignerseitz, which takes a point and a basis as arguments.
Let me know if you feel another name is more suitable: otherwise I'll probably tag a new version in a day or so.

Here's a quick visualization of the results:

Unreduced points Reduced points
image image

The implementation itself is quite simple[edit: a little tricky]: first, reduce the input point to the "rectangular" reduced unit cell with coordinates in [-1/2, 1/2); next, check all immediately neighboring point to see if there's a point with smaller norm in cartesian space; [edit: then do that recursively until convergence]; finally, return point with minimum norm.

reduce_to_symmetric_unitcell(x::Real) = mod(x + 1//2, 1) - 1//2
reduce_to_symmetric_unitcell(v::AbstractVector{<:Real}) = reduce_to_symmetric_unitcell.(v)

function reduce_to_wignerseitz(v::StaticVector{D, <:Real}, Vs::BasisLike{D}) where D
    # reduce `v` to "rectangular" unit cell with coordinates in [-1/2, 1/2)
    v₀ = reduce_to_symmetric_unitcell(v)
    v₀ᶜ = cartesianize(v₀, Vs)
    d₀ = norm(v₀ᶜ)
    # check whether `v₀` has the smallest norm of all adjacent equivalent points; if not,
    # we initiate a recursive search the new possible minimum until convergence
    return search_shortest_norm_among_neighbors_recursive(v₀, d₀, Vs)
end

function search_shortest_norm_among_neighbors_recursive(
            v₀::StaticVector{D, <:Real}, d₀::Real, Vs::BasisLike{D}) where D

    for I in CartesianIndices(ntuple(_->-1:1, Val(D)))
        iszero(I) && continue
        v′ = v₀ .+ Tuple(I)
        v′ᶜ = cartesianize(v′ᶜ, Vs)
        d′ = norm(v′ᶜ)
        if d′ < d₀
            return search_shortest_norm_among_neighbors_recursive(v′, d′, Vs)
        end
    end
    return v₀
end

I'm sure there is a faster way, but this doesn't seem likely to occur in performance sensitive contexts.

Edit 2: If a faster version of this is ever needed, I think the best way forward would be to define a function is_reduced_in_wingerseitz that performs an inclusion test using the convex hull structure of a provided Wigner-Seitz cell, e.g. via its facets normal vectors & origins (as here) and then use that to test whether the current candidate is actually already the right one before searching for alternatives.

from brillouin.jl.

jaemolihm avatar jaemolihm commented on June 28, 2024 1

Thanks a lot for this feature! The visualization is also very nice 😄 The name reduce_to_wignerseitz seems adequate to me.

from brillouin.jl.

antoine-levitt avatar antoine-levitt commented on June 28, 2024

Can't you just convert to reduced coordinates, use modulo and then convert back?

from brillouin.jl.

thchr avatar thchr commented on June 28, 2024

Hmm, that would just transform the point back to the "cubic" (reduced) unit cell though, not necessarily the associated Wigner-Seitz cell - right?

There is indeed a function in SymmetryReduceBZ: seems it first reduces to the "cubic" (reduced coordinates) unit cell and then searches through the immediately neighboring points for whichever one has the shortest Cartesian norm. That seems sound.

from brillouin.jl.

thchr avatar thchr commented on June 28, 2024

Closed by 933853e

from brillouin.jl.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.