Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamuraphys committed Oct 27, 2021
1 parent 75cd864 commit 652ad04
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Lattice"""
"""A class containing information about the Lattice."""
from .hyper_cubic_lattice import HyperCubicLattice
from .lattice import Lattice
from .line_lattice import LineLattice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@


class HyperCubicLattice(Lattice):
"""Hyper-cubic lattice in d dimension."""
"""Hyper-cubic lattice in d dimension.
The :class:`HyperCubicLattice` can be initialized with
tuples of `size`, `edge_parameters`, and `boundary_conditions`.
For example,
.. jupyter-execute::
from qiskit_nature.problems.second_quantization.lattice import HyperCubicLattice
lattice = HyperCubicLattice(
size = (3, 4, 5),
edge_parameter = (1.0, -2.0, 3.0),
onsite_parameter = 2.0,
boundary_condition = ("open", "open", "open")
is a three-dimensional lattice of size 3 by 4 by 5, which has weights 1.0, -2.0, 3.0 on edges
in x, y, and z directions, respectively, and weights 2.0 on self-loops.
The boundary conditions are "open" for all the directions.
"""

def __init__(
self,
Expand All @@ -34,11 +53,17 @@ def __init__(
"""
Args:
size: Lengths of each dimension.
edge_parameter: Weights on the unit edges. Defaults to 1.0.
edge_parameter: Weights on the edges in each direction.
When it is a single value, it is interpreted as a tuple of the same length as `size`
consisting of the same values.
Defaults to 1.0.
onsite_parameter: Weight on the self-loops, which are edges connecting a node to itself.
This is uniform over the lattice points.
Defaults to 0.0.
boundary_condition: Boundary condition for each dimension.
The available boundary conditions are: "open", "periodic".
When it is a single value, it is interpreted as a tuple of the same length as `size`
consisting of the same values.
Defaults to "open".
Raises:
Expand Down Expand Up @@ -100,8 +125,8 @@ def __init__(
self.boundary_edges = []
for i in range(self.dim):
# add edges when the boundary condition is periodic.
# The periodic boundary condition in the i-th direction.
# It makes sense only when size[i] is greater than 2.
# when the boundary condition in the i-th direction is periodic,
# it makes sense only when size[i] is greater than 2.
if boundary_condition[i] == "periodic":
if size[i] <= 2:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Line lattice"""
"""The line lattice"""
from .hyper_cubic_lattice import HyperCubicLattice


Expand All @@ -31,7 +31,7 @@ def __init__(
onsite_parameter: Weight on the self-loops, which are edges connecting a node to itself.
Defaults to 0.0.
boundary_condition: Boundary condition.
Boundary condition must be specified by "open" or "periodic".
The available boundary conditions are: "open", "periodic".
Defaults to "open".
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Square lattice"""
"""The square lattice"""
from typing import Tuple, Union

from .hyper_cubic_lattice import HyperCubicLattice
Expand All @@ -31,11 +31,16 @@ def __init__(
Args:
rows: Length of the x direction.
cols: Length of the y direction.
edge_parameter: Weights on the unit edges. Defaults to 1.0.
edge_parameter: Weights on the edges in x and y direction.
When it is a single value, it is interpreted as a tuple of length 2
consisting of the same values.
Defaults to 1.0.
onsite_parameter: Weight on the self-loops, which are edges connecting a node to itself.
Defaults to 0.0.
boundary_condition: Boundary condition for each direction.
Boundary condition must be specified by "open" or "periodic".
The available boundary conditions are: "open", "periodic".
When it is a single value, it is interpreted as a tuple of length 2
consisting of the same values.
Defaults to "open".
"""
self.rows = rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Triangular lattice"""
"""The triangular lattice"""
from itertools import product
from math import pi
from typing import Callable, List, Optional, Tuple, Union
Expand All @@ -36,12 +36,17 @@ def __init__(
Args:
rows: Length of the x direction.
cols: Length of the y direction.
edge_parameter: Weights on the unit edges.
This is specified as a tuple of length 3 or a single number.Defaults to 1.0,
edge_parameter: Weights on the edges in x, y and diagonal directions.
This is specified as a tuple of length 3 or a single value.
When it is a single value, it is interpreted as a tuple of length 3
consisting of the same values.
Defaults to 1.0,
onsite_parameter: Weight on the self-loops, which are edges connecting a node to itself.
Defaults to 0.0.
boundary_condition: Boundary condition for each direction.
Boundary condition must be specified by "open" or "periodic".
The available boundary conditions are: "open", "periodic".
When it is a single value, it is interpreted as a tuple of length 3
consisting of the same values.
Defaults to "open".
Raises:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ def from_parameters(
Returns:
FermiHubbardModel: The Fermi-Hubbard model generated
from the given hopping matrix and on-site interaction.
from the given hopping matrix and on-site interaction.
Raises:
ValueError: If the shape of the hopping matrix is invalid.
ValueError: If the hopping matrix is not square matrix,
it is invalid.
"""
# make a graph from the hopping matrix.
# This should be replaced by from_adjacency_matrix of retworkx.
Expand Down

0 comments on commit 652ad04

Please sign in to comment.