How to use the netket.hilbert.Boson function in NetKet

To help you get started, we’ve selected a few NetKet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netket / netket / Test / Hilbert / test_hilbert.py View on Github external
hilberts["Spin 1/2"] = nk.hilbert.Spin(
    s=0.5, graph=nk.graph.Hypercube(length=20, n_dim=1)
)

hilberts["Spin 1/2 n"] = nk.hilbert.Spin(s=0.5, n=10)

# Spin 1/2 with total Sz
hilberts["Spin 1/2 with total Sz"] = nk.hilbert.Spin(
    s=0.5, total_sz=1.0, graph=nk.graph.Hypercube(length=20, n_dim=1)
)

# Spin 3
hilberts["Spin 3"] = nk.hilbert.Spin(s=3, graph=nk.graph.Hypercube(length=25, n_dim=1))

# Boson
hilberts["Boson"] = nk.hilbert.Boson(
    n_max=5, graph=nk.graph.Hypercube(length=21, n_dim=1)
)

# Boson with total number
hilberts["Bosons with total number"] = nk.hilbert.Boson(
    n_max=5, n_bosons=11, graph=nk.graph.Hypercube(length=21, n_dim=1)
)

# Qubit
hilberts["Qubit"] = nk.hilbert.Qubit(graph=nk.graph.Hypercube(length=32, n_dim=1))

hilberts["Qubit n=1"] = nk.hilbert.Qubit()

# Custom Hilbert
hilberts["Custom Hilbert"] = nk.hilbert.CustomHilbert(
    local_states=[-1232, 132, 0], graph=nk.graph.Hypercube(length=34, n_dim=1)
github netket / netket / Test / Hilbert / test_hilbert.py View on Github external
# Spin 1/2 with total Sz
hilberts["Spin 1/2 with total Sz"] = nk.hilbert.Spin(
    s=0.5, total_sz=1.0, graph=nk.graph.Hypercube(length=20, n_dim=1)
)

# Spin 3
hilberts["Spin 3"] = nk.hilbert.Spin(s=3, graph=nk.graph.Hypercube(length=25, n_dim=1))

# Boson
hilberts["Boson"] = nk.hilbert.Boson(
    n_max=5, graph=nk.graph.Hypercube(length=21, n_dim=1)
)

# Boson with total number
hilberts["Bosons with total number"] = nk.hilbert.Boson(
    n_max=5, n_bosons=11, graph=nk.graph.Hypercube(length=21, n_dim=1)
)

# Qubit
hilberts["Qubit"] = nk.hilbert.Qubit(graph=nk.graph.Hypercube(length=32, n_dim=1))

hilberts["Qubit n=1"] = nk.hilbert.Qubit()

# Custom Hilbert
hilberts["Custom Hilbert"] = nk.hilbert.CustomHilbert(
    local_states=[-1232, 132, 0], graph=nk.graph.Hypercube(length=34, n_dim=1)
)

hilberts["Custom Hilbert n"] = nk.hilbert.CustomHilbert(
    local_states=[-1232, 132, 0], n=2
)
github netket / netket / Test / Sampler / test_sampler.py View on Github external
ha = nk.operator.Ising(hilbert=hi, h=1.0)
sa = nk.sampler.MetropolisHamiltonian(machine=ma, hamiltonian=ha)
samplers["MetropolisHamiltonian RbmSpin"] = sa

# Test with uniform probability
maz = nk.machine.RbmSpin(hilbert=hi, alpha=1)
maz.init_random_parameters(seed=1234, sigma=0)
sa = nk.sampler.MetropolisLocal(machine=maz)
samplers["MetropolisLocal RbmSpin ZeroPars"] = sa

mas = nk.machine.RbmSpinSymm(hilbert=hi, alpha=1)
mas.init_random_parameters(seed=1234, sigma=0.2)
sa = nk.sampler.MetropolisHamiltonianPt(machine=mas, hamiltonian=ha, n_replicas=4)
samplers["MetropolisHamiltonianPt RbmSpinSymm"] = sa

hi = nk.hilbert.Boson(graph=g, n_max=4)
ma = nk.machine.RbmSpin(hilbert=hi, alpha=1)
ma.init_random_parameters(seed=1234, sigma=0.2)
sa = nk.sampler.MetropolisLocal(machine=ma)
g = nk.graph.Hypercube(length=4, n_dim=1)
samplers["MetropolisLocal Boson"] = sa

sa = nk.sampler.MetropolisLocalPt(machine=ma, n_replicas=4)
samplers["MetropolisLocalPt Boson"] = sa

ma = nk.machine.RbmMultiVal(hilbert=hi, alpha=1)
ma.init_random_parameters(seed=1234, sigma=0.2)
sa = nk.sampler.MetropolisLocal(machine=ma)
samplers["MetropolisLocal Boson MultiVal"] = sa

hi = nk.hilbert.Spin(s=0.5, graph=g)
g = nk.graph.Hypercube(length=6, n_dim=1)
github netket / netket / Test / Operator / test_operator.py View on Github external
operators = {}

# Ising 1D
g = nk.graph.Hypercube(length=20, n_dim=1, pbc=True)
hi = nk.hilbert.Spin(s=0.5, graph=g)
operators["Ising 1D"] = nk.operator.Ising(h=1.321, hilbert=hi)

# Heisenberg 1D
g = nk.graph.Hypercube(length=20, n_dim=1, pbc=True)
hi = nk.hilbert.Spin(s=0.5, total_sz=0, graph=g)
operators["Heisenberg 1D"] = nk.operator.Heisenberg(hilbert=hi)

# Bose Hubbard
g = nk.graph.Hypercube(length=3, n_dim=2, pbc=True)
hi = nk.hilbert.Boson(n_max=3, n_bosons=6, graph=g)
operators["Bose Hubbard"] = nk.operator.BoseHubbard(U=4.0, hilbert=hi)

# Graph Hamiltonian
sigmax = [[0, 1], [1, 0]]
mszsz = [[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]
edges = [
    [0, 1],
    [1, 2],
    [2, 3],
    [3, 4],
    [4, 5],
    [5, 6],
    [6, 7],
    [7, 8],
    [8, 9],
    [9, 10],
github netket / netket / Test / Hilbert / test_hilbert.py View on Github external
hilberts["Custom Hilbert"] = nk.hilbert.CustomHilbert(
    local_states=[-1232, 132, 0], graph=nk.graph.Hypercube(length=34, n_dim=1)
)

hilberts["Custom Hilbert n"] = nk.hilbert.CustomHilbert(
    local_states=[-1232, 132, 0], n=2
)

# Heisenberg 1d
g = nk.graph.Hypercube(length=20, n_dim=1, pbc=True)
hi = nk.hilbert.Spin(s=0.5, total_sz=0.0, graph=g)
hilberts["Heisenberg 1d"] = hi

# Bose Hubbard
g = nk.graph.Hypercube(length=20, n_dim=1, pbc=True)
hi = nk.hilbert.Boson(n_max=4, n_bosons=20, graph=g)
hilberts["Bose Hubbard"] = hi

#
# Small hilbert space tests
#

# Spin 1/2
hilberts["Spin 1/2 Small"] = nk.hilbert.Spin(
    s=0.5, graph=nk.graph.Hypercube(length=10, n_dim=1)
)

# Spin 3
hilberts["Spin 1/2 with total Sz Small"] = nk.hilbert.Spin(
    s=3, total_sz=1.0, graph=nk.graph.Hypercube(length=4, n_dim=1)
)
github netket / netket / Examples / BoseHubbard1d / bosehubbard1d_jastrow.py View on Github external
#    http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import netket as nk

# 1D Periodic Lattice
g = nk.graph.Hypercube(length=12, n_dim=1, pbc=True)

# Boson Hilbert Space
hi = nk.hilbert.Boson(graph=g, n_max=3, n_bosons=12)

# Bose Hubbard Hamiltonian
ha = nk.operator.BoseHubbard(U=4.0, hilbert=hi)

# Jastrow Machine with Symmetry
ma = nk.machine.JastrowSymm(hilbert=hi)
ma.init_random_parameters(seed=1234, sigma=0.01)

# Sampler
sa = nk.sampler.MetropolisHamiltonian(machine=ma, hamiltonian=ha)

# Stochastic gradient descent optimization
op = nk.optimizer.Sgd(learning_rate=0.1)

# Variational Monte Carlo
vmc = nk.variational.Vmc(
github netket / netket / Tutorials / BoseHubbard1d / bosehubbard1d_jastrow.py View on Github external
#    http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import netket as nk

# 1D Periodic Lattice
g = nk.graph.Hypercube(length=12, n_dim=1, pbc=True)

# Boson Hilbert Space
hi = nk.hilbert.Boson(graph=g, n_max=3, n_bosons=12)

# Bose Hubbard Hamiltonian
ha = nk.operator.BoseHubbard(U=4.0, hilbert=hi)

# Jastrow Machine with Symmetry
ma = nk.machine.JastrowSymm(hilbert=hi)
ma.init_random_parameters(seed=1234, sigma=0.01)

# Sampler
sa = nk.sampler.MetropolisHamiltonian(machine=ma, hamiltonian=ha)

# Stochastic gradient descent optimization
op = nk.optimizer.Sgd(learning_rate=0.1)

# Variational Monte Carlo
vmc = nk.gs.Vmc(
github netket / netket / Examples / BoseHubbard1d / bosehubbard1d.py View on Github external
#    http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import netket as nk

# 1D Periodic Lattice
g = nk.graph.Hypercube(length=12, n_dim=1, pbc=True)

# Boson Hilbert Space
hi = nk.hilbert.Boson(graph=g, n_max=3, n_bosons=12)

# Bose Hubbard Hamiltonian
ha = nk.operator.BoseHubbard(U=4.0, hilbert=hi)

# Jastrow Machine with Symmetry
ma = nk.machine.RbmSpinSymm(alpha=4, hilbert=hi)
ma.init_random_parameters(seed=1234, sigma=0.01)

# Sampler
sa = nk.sampler.MetropolisHamiltonian(machine=ma, hamiltonian=ha)

# Stochastic gradient descent optimization
op = nk.optimizer.AdaMax()

# Variational Monte Carlo
vmc = nk.variational.Vmc(