You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Hard-core lattice gas refers to a model used in statistical physics to study the behavior of particles on a lattice, where the particles are subject to an exclusion principle known as the "hard-core" interaction that characterized by a blockade radius. Distances between two particles can not be smaller than this radius.
4
+
#
5
+
# * Nath T, Rajesh R. Multiple phase transitions in extended hard-core lattice gas models in two dimensions[J]. Physical Review E, 2014, 90(1): 012120.
6
+
# * Fernandes H C M, Arenzon J J, Levin Y. Monte Carlo simulations of two-dimensional hard core lattice gases[J]. The Journal of chemical physics, 2007, 126(11).
7
+
#
8
+
# Let define a $10 \times 10$ triangular lattice, with unit vectors
9
+
# ```math
10
+
# \begin{align}
11
+
# \vec a &= \left(\begin{matrix}1 \\ 0\end{matrix}\right)\\
12
+
# \vec b &= \left(\begin{matrix}\frac{1}{2} \\ \frac{\sqrt{3}}{2}\end{matrix}\right)
13
+
# \end{align}
14
+
# ```
15
+
16
+
a, b = (1, 0), (0.5, 0.5*sqrt(3))
17
+
Na, Nb =10, 10
18
+
sites = [a .* i .+ b .* j for i=1:Na, j=1:Nb]
19
+
20
+
# There exists blockade interactions between hard-core particles.
21
+
# We connect two lattice sites within blockade radius by an edge.
22
+
# Two ends of an edge can not both be occupied by particles.
23
+
blockade_radius =1.1
24
+
using GenericTensorNetworks: show_graph, unit_disk_graph
# where $n_i \in \{0, 1\}$ is the number of particles at site $i$, and $w_i$ is the weight associated with it. For unweighted graphs, the weights are uniform.
35
+
# The solution space hard-core lattice gas is equivalent to that of an independent set problem. The independent set problem involves finding a set of vertices in a graph such that no two vertices in the set are adjacent (i.e., there is no edge connecting them).
36
+
# One can create a tensor network based modeling of an independent set problem with package [`GenericTensorNetworks.jl`](https://github.com/QuEraComputing/GenericTensorNetworks.jl).
37
+
using GenericTensorNetworks
38
+
problem =IndependentSet(graph; optimizer=GreedyMethod());
39
+
40
+
# There has been a lot of discussions related to solution space properties in the `GenericTensorNetworks` [documentaion page](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/IndependentSet/).
41
+
# In this example, we show how to use `TensorInference` to use probabilistic inference for understand the finite temperature properties of this statistic physics model.
42
+
# We use [`TensorNetworkModel`](@ref) to convert a combinatorial optimization problem to a probabilistic model.
43
+
# Here, we let the inverse temperature be $\beta = 3$.
44
+
45
+
# ## Probabilistic modeling correlation functions
46
+
using TensorInference
47
+
β =3.0
48
+
pmodel =TensorNetworkModel(problem, β)
49
+
50
+
# The partition function of this statistical model can be computed with the [`probability`](@ref) function.
51
+
partition_func =probability(pmodel)
52
+
53
+
# The default return value is a log-rescaled tensor. Use indexing to get the real value.
54
+
partition_func[]
55
+
56
+
# The marginal probabilities can be computed with the [`marginals`](@ref) function, which measures how likely a site is occupied.
57
+
mars =marginals(pmodel)
58
+
show_graph(graph; locs=sites, vertex_colors=[(1-b, 1-b, 1-b) for b ingetindex.(mars, 2)], texts=fill("", nv(graph)))
59
+
# The can see the sites at the corner is more likely to be occupied.
60
+
# To obtain two-site correlations, one can set the variables to query marginal probabilities manually.
61
+
pmodel2 =TensorNetworkModel(problem, β; mars=[[e.src, e.dst] for e inedges(graph)])
62
+
mars =marginals(pmodel2);
63
+
64
+
# We show the probability that both sites on an edge are not occupied
65
+
show_graph(graph; locs=sites, edge_colors=[(b=mar[1, 1]; (1-b, 1-b, 1-b)) for mar in mars], texts=fill("", nv(graph)), edge_line_width=5)
66
+
67
+
# ## The most likely configuration
68
+
# The MAP and MMAP can be used to get the most likely configuration given an evidence.
69
+
# The relavant function is [`most_probable_config`](@ref).
70
+
# If we fix the vertex configuration at one corner to be one, we get the most probably configuration as bellow.
0 commit comments