Coder Social home page Coder Social logo

Comments (12)

gcarleo avatar gcarleo commented on September 22, 2024

I agree with both proposals, they would improve code readability

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

Concerning long-range potentials, they should be implemented as well, I agree, also taking into account that computing the sum over periodic images can be tricky, so we want to have this implemented once for all!

from netket.

gpescia avatar gpescia commented on September 22, 2024

I also agree with both. Though do you think it makes sense to put the second proposal into nk.utils? I‘m not sure it belongs to hilbert and like this, other functionality can be added as well such as Ewald or radial distribution etc. (or maybe these actually belong in operator…)

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

The main issue is that in continuous space we are not using Graph or similar as we do on the lattice, so this means that all the geometry info (pbc etc) that should be contained in the geometry is instead contained only in hilbert. In theory, I agree with you that the distance shouldn't be in hilbert, it should be in some Geometry class that you pass to Hilbert. Geometry could also take into account specific things such as Ewald, returning reciprocal vectors etc.

For the observables, I am not sure... I think we should just consider them as operators?

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

so a more complete proposal is something like:

geo=Cell(d=3, L=1, pbc=True)

hi = Particle(N=N, geometry=geo)
... 
geo.distance(R1,R2)

notice that I would also add to Particle the possibility of specifying other quantum numbers for each particle, for example the spin:

geo_fermions=Cell(d=3, L=1, pbc=True)
geo_bosons=FreeSpace(d=2)

#mixture of fermions and bosons where bosons are confined in 2D
hi = Particle(N=N1, spin=1/2, geometry=geo_fermions) + Particle(N=N2, spin=0, geometry=geo_bosons) 
... 
geo.distance(R1,R2)

in theory, this allows to use Particle also for the lattice, and have a unified interface:

lattice=Square(L=3)

hi = Particle(N=N,geometry=lattice,spin=1/2)

#equivalent to 
hi = SpinOrbitalFermions(n_orbitals=lattice.n_nodes,n_fermions=N)
 
#similarly for Particle(N=N,geometry=lattice,spin=0) calling Fock(...) internally 

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

@dalin27 you are our best hope here

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

I think implementing Geometry. Cell and Geometry.FreeSpace shouldn't be too complicated to start with , this will give us also an idea on the abstract interface of Geometry objects

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

Hierarchy wise I think that abstract Graph should be inherited from the abstract Geometry or, we should have the constructors above accept both Graphs and Geometries (a bit less elegant), what do you think @PhilipVinc ?

from netket.

PhilipVinc avatar PhilipVinc commented on September 22, 2024

I think they have not much to do with each other

from netket.

gcarleo avatar gcarleo commented on September 22, 2024

so we make Particle accept both Geometry and Graph? makes sense, it's just that a Graph however is a special form of Geometry ...

from netket.

dalin27 avatar dalin27 commented on September 22, 2024

Regarding @PhilipVinc's second point about adding a distance method to the Particle Hilbert space, should the method return a distance function (min_imag_conv) like this:

def distance(self):
    
    pbc = np.array(self._pbc)
    L = np.array(self._extent)

    if np.all(pbc):

        def min_imag_conv(x: Array):
            """Compute distances between particles using the minimum image convention"""
            x = x.reshape(self._N, self._D)  # not batched!
            distances = x[None,:,:] - x[:,None,:]
            distances = distances[jnp.triu_indices(self._N, 1)]  # upper triangular part of the matrix
            distances = jnp.remainder(distances + L/2.0, L) - L/2.0  # shape=(N(N-1)/2,D)
            distances = jnp.linalg.norm(distances, axis=-1)
            return distances
        
        return min_imag_conv

    elif np.all(pbc == False):
        raise ValueError(
            " Not yet implemented. "
        )
    else:
        raise ValueError(
            " Not yet implemented. "
        )

or instead return the evaluated distance values? The code above also requires adding the line self._D = len(L) if D is None else D in the __init__ method

from netket.

PhilipVinc avatar PhilipVinc commented on September 22, 2024

I think it should be a function

class AbstractGeometry:
    def min_imag_convention(self, x: Array) -> Array:
       ....
       return min image 

An important thing that we should keep in mind is how to handle the composed space of two different geometries. (Aka, imagine you have two sublattices each with a different set of fermions, for example..

Also, Is there anything else that would be useful to compute something?

Also, the AbstractGeometry should define __hash__ and __eq__ so that it plays nice with jax, as Hilbert spaces do.

from netket.

Related Issues (20)

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.