Struct vegas_lattice::Vertex
source · pub struct Vertex { /* private fields */ }
Expand description
Represents a vertex in a lattice.
The source
and target
fields are the indices of the sites that the vertex connects.
The delta
field is a tuple of the displacements of the target site from the source site.
A delta
of (0, 0, 1)
would mean that the target site is one unit along the z axis from the
source site.
For a simple cubic lattice the source
and target
for all the vertices would be the same,
0
. While delta would be (1, 0, 0)
, (0, 1, 0)
, (0, 0, 1)
. Those 3 vertices would connect
all the sites in the lattice.
§Examples
Here is an example of how to create a vertex and access its fields:
use vegas_lattice::Vertex;
let vertex = Vertex::new(0, 1, (0, 0, 1));
assert_eq!(vertex.source(), 0);
assert_eq!(vertex.target(), 1);
assert_eq!(vertex.delta(), (0, 0, 1));
Here’s how to move a vertex along an axis:
use vegas_lattice::{Vertex, Axis};
let vertex = Vertex::new(0, 1, (0, 0, 1)).move_along(Axis::Z, 1, 2, 3);
assert_eq!(vertex.source(), 2);
assert_eq!(vertex.target(), 5);
assert_eq!(vertex.delta(), (0, 0, 0));
Implementations§
source§impl Vertex
impl Vertex
sourcepub fn new(source: usize, target: usize, delta: (i32, i32, i32)) -> Self
pub fn new(source: usize, target: usize, delta: (i32, i32, i32)) -> Self
Creates a new vertex with the given source and target
sourcepub fn delta_along(&self, axis: Axis) -> i32
pub fn delta_along(&self, axis: Axis) -> i32
Returns the delta
of the vertex alogn a given axis
Chagges the tags of the vertex
sourcepub fn move_along(
self,
axis: Axis,
amount: usize,
nsites: usize,
limit: usize
) -> Self
pub fn move_along( self, axis: Axis, amount: usize, nsites: usize, limit: usize ) -> Self
Move the vertex along a given axis by a given amount
The only reason you would want to move a vertex along an axis is to grow a lattice along
that axis. That’s why we’re going to need to know the parameters of how much the lattice is
going to grow by. This function takes in the nsites
, the number of sites in the original
lattice, and the limit
, the total number of units the lattice will be grown by. The
vertex will be changed assuming that the new number of sites will be limit * nsites
.
§Warning
This function is so complicated it should be private!
§Arguments
axis
- The axis along which to move the vertexamount
- The number of units to move the vertexnsites
- The number of sites in the original latticelimit
- The total number of units the lattice will be grown by