AbstractGridVector
Creating a grid vector
WTP.make_grid_vector
β Functionmake_grid_vector(g, coefficients)
Make a grid vector that is at g[coefficients...].
julia> reciprocal_basis = CARTESIAN_BASIS;
julia> sizes = (4, 4, 4);
julia> lattice = make_grid(ReciprocalLattice3D, reciprocal_basis, size_to_domain(sizes));
julia> v = make_grid_vector(lattice, [0, 0, 0])
GridVector{ReciprocalLattice3D}:
coefficients: [0, 0, 0]
This is what is behind indexing a grid
julia> v = lattice[0, 0, 0]
GridVector{ReciprocalLattice3D}:
coefficients: [0, 0, 0]
Basic usage
The underlying grid.
WTP.grid
β Methodgrid(grid_vector)
Each grid vector is defined on a grid. This gets the grid on which the grid vector is defined.
Example:
julia> grid(v)
type: ReciprocalLattice3D
domain: ((-2, 1), (-2, 1), (-2, 1))
basis:
ket: 1.000, 0.000, 0.000
ket: 0.000, 1.000, 0.000
ket: 0.000, 0.000, 1.000
WTP.set_grid
β Functionset_grid(grid_vector, new_grid)
Put the gridvector on the `newgrid` while preserving the coefficients.
Example:
julia> vΜ = set_grid(v, expand(lattice));
julia> grid(vΜ)
type: ReciprocalLattice3D
domain: ((-4, 3), (-4, 3), (-4, 3))
basis:
ket: 1.000, 0.000, 0.000
ket: 0.000, 1.000, 0.000
ket: 0.000, 0.000, 1.000
set_grid(on_grid, new_grid)
Create a copy of on_grid
with a new_grid
.
Basis and coefficients
WTP.basis
β Methodbasis(linear_combination)
The basis of a linear combination. Since the basis are stored internally as kets, they have to be conjugated before returned if the linear combination is a bra.
WTP.coefficients
β Methodcoefficients(linear_combination)
The coefficients of the linear combination.
Overflow
WTP.overflow
β Functionoverflow(grid_vector)
A grid vector is allowed to be outside its underlying grid. One can move the grid vector by integer multiples of the grid domain so that they reside in the grid.
The overflow gives the number of times we have to translate a vector by a grid domain to bring them into the grid domain.
Example:
julia> overflow(lattice[0, 0, 0])
3-element Vector{Int64}:
0
0
0
julia> overflow(lattice[3, -3, -3])
3-element Vector{Int64}:
1
-1
-1
WTP.has_overflow
β Functionhas_overflow(grid_vector)
Whether there is any overflow.
Example:
julia> has_overflow(lattice[0, 0, 5])
true
julia> has_overflow(lattice[0, 0, 0])
false
WTP.wrapped
β Functionwrapped(grid_vector)
The grid vector modulo the domain of the grid. One can think of this a the remainder of the grid vector divided by the grid.
For grid vectors within the grid domain, this just gives the _coefficients. For those outside the grid domain, this move the vector by multiples of the grid domain to bring it into the grid domain.
Example:
julia> wrapped(lattice[0, 1, 0])
3-element Vector{Int64}:
0
1
0
julia> wrapped(lattice[3, -3, -3])
3-element Vector{Int64}:
-1
1
1
WTP.reset_overflow
β Functionreset_overflow(grid_vector)
The gives a image of the grid_vector within the grid domain.
Example:
julia> reset_overflow(lattice[0, 0, 5])
GridVector{ReciprocalLattice3D}:
coefficients: [0, 0, 1]
WTP.add_overflow
β Functionadd_overflow(grid_vector, overflow)
This moves the grid_vector by some multiples of the grid domain.
Example:
julia> add_overflow(lattice[0, 0, 1], [0, 0, 1])
GridVector{ReciprocalLattice3D}:
coefficients: [0, 0, 5]
Arithmatic
WTP.add
β Methodadd(grid_vector_1, grid_vector_2)
Add two grid vectors. Can also write grid_vector_1 + grid_vector_2
.
Example:
julia> lattice[0, 0, 1] + lattice[-1, 0, 0]
GridVector{ReciprocalLattice3D}:
coefficients: [-1, 0, 1]
WTP.negate
β Methodnegate(grid_vector_1)
Can also write -grid_vector_1
.
Example:
julia> -lattice[0, 0, 1]
GridVector{ReciprocalLattice3D}:
coefficients: [0, 0, -1]
WTP.mul
β Methodmul(s, grid_vector)
Scale a grid vector. Can also write s * grid_vector
or grid_vector * s
.
WTP.cartesian
β Methodcartesian(grid_vector)
The Cartesian coordinates of a grid vector.
Example:
julia> cartesian(lattice[1, 0, 1])
3-element Vector{Number}:
1.0
0.0
1.0
LinearAlgebra.norm
β Methodnorm(grid_vector)
The 2-norm of a grid vector
Example:
julia> norm(lattice[1, 1, 1])
1.7320508075688772
WTP.braket_
β Functionbraket(grid_vector_1, grid_vector_2)
Compute the inner product of two grid vectors. Can also write grid_vector_1' * grid_vector_2
PS: a braket_
function is created as a dummy anchor for documentation.
Example:
julia> homecell = transform_grid(lattice);
julia> homecell[0, 0, 1]' * lattice[1, 0, 1]
1.5707963267948966