Coordinate Systems
Header: fiction/layouts/coordinates.hpp
Coordinate types identify positions in a coordinate system, e.g., a Cartesian or hexagonal grid. This file provides implementations for various types of coordinates.
Offset coordinates
An offset coordinate is a coordinate that defines a location via an offset from a fixed point (origin). Cartesian coordinates are offset coordinates.
-
struct ucoord_t
Unsigned offset coordinates.
This implementation is optimized for memory-efficiency and fits within 64 bits. Coordinates span from \((0, 0, 0)\) to \((2^{31} - 1, 2^{31} - 1, 1)\). Each coordinate has a dead indicator
d
that can be used to represent that it is not in use.
- class mnt.pyfiction.offset_coordinate
Unsigned offset coordinates.
This implementation is optimized for memory-efficiency and fits within 64 bits. Coordinates span from \((0, 0, 0)\) to \((2^{31} - 1, 2^{31} - 1, 1)\). Each coordinate has a dead indicator d that can be used to represent that it is not in use.
Cube coordinates
Cube coordinates are used as a way to identify faces in a hexagonal grid. A wonderful resource on the topic is: https://www.redblobgames.com/grids/hexagons/#coordinates-cube At the same time, they can be used to address 3-dimensional grids.
-
struct coord_t
Signed cube coordinates.
This implementation allows for negative coordinate values and offers a balance between memory consumption and range of values. Coordinates span from \((-2^{31}, -2^{31}, -2^{31})\) to \((2^{31} - 1, 2^{31} - 1, 2^{31} - 1)\). Each coordinate has a dead indicator
d
that can be used to represent that it is not in use.
- class mnt.pyfiction.cube_coordinate
Signed cube coordinates.
This implementation allows for negative coordinate values and offers a balance between memory consumption and range of values. Coordinates span from \((-2^{31}, -2^{31}, -2^{31})\) to \((2^{31} - 1, 2^{31} - 1, 2^{31} - 1)\). Each coordinate has a dead indicator d that can be used to represent that it is not in use.
SiQAD coordinates
SiQAD coordinates are used to describe locations of Silicon Dangling Bonds on the H-Si(100) 2x1 surface were dimer columns and rows are identified by x and y values, respectively, while the z value (0,1) points to the top or bottom Si atom in the dimer. The coordinates are originally used in the SiQAD simulator (https://github.com/siqad).
-
struct coord_t
SiQAD coordinates.
Coordinates span from \((-2^{31}, -2^{31}, 0)\) to \((2^{31} - 1 , 2^{31} - 1, 1)\).
x
is the SiDB’s x-coordinate,y
is the dimer pair’s row number, andz
represents the two possible SiDB positions in one SiDB dimer pair. Each coordinate has a dead indicatord
that can be used to represent that it is not in use.
- class mnt.pyfiction.siqad_coordinate
SiQAD coordinates.
Coordinates span from \((-2^{31}, -2^{31}, 0)\) to \((2^{31} - 1 , 2^{31} - 1, 1)\). x is the SiDB’s x-coordinate, y is the dimer pair’s row number, and z represents the two possible SiDB positions in one SiDB dimer pair. Each coordinate has a dead indicator d that can be used to represent that it is not in use.
Coordinate iterator
An iterator type that allows to enumerate coordinates in order within a boundary.
-
template<typename CoordinateType>
class coord_iterator An iterator type that allows to enumerate coordinates in order within a boundary.
- Template Parameters:
CoordinateType – Type of coordinate to enumerate.
Utility functions
-
template<typename CoordinateType>
uint64_t fiction::area(const CoordinateType &coord) noexcept Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1)\) by default. The exception is SiQAD coordinates, for which it computes \((|x| + 1) \cdot (2 \cdot |y| + |z| + 1)\).
- Template Parameters:
CoordinateType – Coordinate type.
- Parameters:
coord – Coordinate.
- Returns:
Area of coord.
-
template<typename CoordinateType>
uint64_t fiction::volume(const CoordinateType &coord) noexcept Computes the volume of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1) \cdot (|z| + 1)\) by default. For SiQAD coordinates, which are planar by definition, the area is returned.
- Template Parameters:
CoordinateType – Coordinate type.
- Parameters:
coord – Coordinate.
- Returns:
Volume of coord.
-
template<typename CoordinateType>
constexpr CoordinateType fiction::siqad::to_fiction_coord(const siqad::coord_t &coord) noexcept Converts SiQAD coordinates to other coordinates (offset, cube).
- Template Parameters:
CoordinateType – The desired coordinate type.
- Parameters:
coord – SiQAD coordinate to convert.
- Returns:
Coordinate of type
CoordinateType
.
-
template<typename CoordinateType>
constexpr coord_t fiction::siqad::to_siqad_coord(const CoordinateType &coord) noexcept Converts any coordinate type to SiQAD coordinates.
- Template Parameters:
CoordinateType – Coordinate type to convert.
- Parameters:
coord – Coordinate to convert.
- Returns:
SiQAD coordinate representation of
coord
.
- mnt.pyfiction.offset_area(coord: mnt.pyfiction.pyfiction.offset_coordinate) int
Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1)\) by default. The exception is SiQAD coordinates, for which it computes \((|x| + 1) \cdot (2 \cdot |y| + |z| + 1)\).
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Area of coord.
- Template parameter
- mnt.pyfiction.cube_area(coord: mnt.pyfiction.pyfiction.cube_coordinate) int
Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1)\) by default. The exception is SiQAD coordinates, for which it computes \((|x| + 1) \cdot (2 \cdot |y| + |z| + 1)\).
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Area of coord.
- Template parameter
- mnt.pyfiction.siqad_area(coord: mnt.pyfiction.pyfiction.siqad_coordinate) int
Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1)\) by default. The exception is SiQAD coordinates, for which it computes \((|x| + 1) \cdot (2 \cdot |y| + |z| + 1)\).
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Area of coord.
- Template parameter
- mnt.pyfiction.offset_volume(coord: mnt.pyfiction.pyfiction.offset_coordinate) int
Computes the volume of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1) \cdot (|z| + 1)\) by default. For SiQAD coordinates, which are planar by definition, the area is returned.
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Volume of coord.
- Template parameter
- mnt.pyfiction.cube_volume(coord: mnt.pyfiction.pyfiction.cube_coordinate) int
Computes the volume of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1) \cdot (|z| + 1)\) by default. For SiQAD coordinates, which are planar by definition, the area is returned.
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Volume of coord.
- Template parameter
- mnt.pyfiction.siqad_volume(coord: mnt.pyfiction.pyfiction.siqad_coordinate) int
Computes the volume of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1) \cdot (|z| + 1)\) by default. For SiQAD coordinates, which are planar by definition, the area is returned.
- Template parameter
CoordinateType
: Coordinate type.
- Parameter
coord
: Coordinate.
- Returns:
Volume of coord.
- Template parameter
- mnt.pyfiction.to_offset_coord(coord: mnt.pyfiction.pyfiction.siqad_coordinate) mnt.pyfiction.pyfiction.offset_coordinate
Converts SiQAD coordinates to other coordinates (offset, cube).
- Template parameter
CoordinateType
: The desired coordinate type.
- Parameter
coord
: SiQAD coordinate to convert.
- Returns:
Coordinate of type CoordinateType.
- Template parameter
- mnt.pyfiction.to_cube_coord(coord: mnt.pyfiction.pyfiction.siqad_coordinate) mnt.pyfiction.pyfiction.cube_coordinate
Converts SiQAD coordinates to other coordinates (offset, cube).
- Template parameter
CoordinateType
: The desired coordinate type.
- Parameter
coord
: SiQAD coordinate to convert.
- Returns:
Coordinate of type CoordinateType.
- Template parameter
- mnt.pyfiction.to_siqad_coord(*args, **kwargs)
Overloaded function.
to_siqad_coord(coord: mnt.pyfiction.pyfiction.offset_coordinate) -> mnt.pyfiction.pyfiction.siqad_coordinate
Converts any coordinate type to SiQAD coordinates.
- Template parameter
CoordinateType
: Coordinate type to convert.
- Parameter
coord
: Coordinate to convert.
- Returns:
SiQAD coordinate representation of coord.
to_siqad_coord(coord: mnt.pyfiction.pyfiction.cube_coordinate) -> mnt.pyfiction.pyfiction.siqad_coordinate
Converts any coordinate type to SiQAD coordinates.
- Template parameter
CoordinateType
: Coordinate type to convert.
- Parameter
coord
: Coordinate to convert.
- Returns:
SiQAD coordinate representation of coord.