Skip to main content

Unitcell

Struct Unitcell 

Source
pub struct Unitcell { /* private fields */ }

Implementations§

Source§

impl Unitcell

Source

pub fn new(dim: usize) -> Self

Examples found in repository?
examples/construct2.rs (line 9)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(1, 1, &[1.0]));
8
9    let mut unitcell = Unitcell::new(1);
10    unitcell.add_site(CoordinateVector::from_element(1, 0.0), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_element(1, 1), 0);
12
13    let extent = ExtentVector::from_element(1, 16);
14    let boundary = vec![Boundary::Periodic; 1];
15    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
16    support::print_graph(&graph);
17}
More examples
Hide additional examples
examples/construct4.rs (line 9)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(2, 2, &[1.0, 0.0, 0.0, 1.0]));
8
9    let mut unitcell = Unitcell::new(2);
10    unitcell.add_site(CoordinateVector::from_vec(vec![0.0, 0.0]), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![1, 0]), 0);
12    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![0, 1]), 0);
13
14    let extent = ExtentVector::from_vec(vec![4, 4]);
15    let boundary = vec![Boundary::Periodic; 2];
16    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
17    support::print_graph(&graph);
18}
Source

pub fn simple(dim: usize) -> Self

Source

pub fn dimension(&self) -> usize

Examples found in repository?
examples/construct_xml.rs (line 44)
6fn main() {
7    let args = std::env::args().collect::<Vec<_>>();
8
9    let mut file = support::resolve_lattices_xml().unwrap_or_else(|message| {
10        eprintln!("Error: {message}");
11        std::process::exit(127);
12    });
13    let mut basis_name = "square lattice".to_string();
14    let mut cell_name = "simple2d".to_string();
15    let mut length: usize = 4;
16
17    if args.len() > 1 {
18        if args.len() == 4 || args.len() == 5 {
19            file = std::path::PathBuf::from(&args[1]);
20            basis_name = args[2].clone();
21            cell_name = args[3].clone();
22            if args.len() == 5 {
23                length = args[4].parse::<usize>().unwrap_or_else(|_| {
24                    eprintln!("Error: invalid length: {}", args[4]);
25                    std::process::exit(127);
26                });
27            }
28        } else {
29            eprintln!("Error: {} xmlfile basis cell [length]", args[0]);
30            std::process::exit(127);
31        }
32    }
33
34    let basis = read_basis_from_file(&file, &basis_name).unwrap_or_else(|error| {
35        eprintln!("Failed to read basis XML entry '{basis_name}': {error}");
36        std::process::exit(127);
37    });
38
39    let cell = read_unitcell_from_file(&file, &cell_name).unwrap_or_else(|error| {
40        eprintln!("Failed to read unitcell XML entry '{cell_name}': {error}");
41        std::process::exit(127);
42    });
43
44    let extent = ExtentVector::from_element(cell.dimension(), length as i64);
45    let boundary = vec![Boundary::Periodic; cell.dimension()];
46    let graph = Graph::from_basis_unitcell_extent(&basis, &cell, &extent, &boundary);
47
48    support::print_graph(&graph);
49}
Source

pub fn num_sites(&self) -> usize

Source

pub fn num_bonds(&self) -> usize

Source

pub fn site(&self, index: usize) -> &Site

Source

pub fn bond(&self, index: usize) -> &Bond

Source

pub fn max_neighbors(&self) -> usize

Source

pub fn add_site( &mut self, coordinate: CoordinateVector, site_type: i32, ) -> usize

Examples found in repository?
examples/construct2.rs (line 10)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(1, 1, &[1.0]));
8
9    let mut unitcell = Unitcell::new(1);
10    unitcell.add_site(CoordinateVector::from_element(1, 0.0), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_element(1, 1), 0);
12
13    let extent = ExtentVector::from_element(1, 16);
14    let boundary = vec![Boundary::Periodic; 1];
15    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
16    support::print_graph(&graph);
17}
More examples
Hide additional examples
examples/construct4.rs (line 10)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(2, 2, &[1.0, 0.0, 0.0, 1.0]));
8
9    let mut unitcell = Unitcell::new(2);
10    unitcell.add_site(CoordinateVector::from_vec(vec![0.0, 0.0]), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![1, 0]), 0);
12    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![0, 1]), 0);
13
14    let extent = ExtentVector::from_vec(vec![4, 4]);
15    let boundary = vec![Boundary::Periodic; 2];
16    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
17    support::print_graph(&graph);
18}
Source

pub fn add_bond( &mut self, source: usize, target: usize, target_offset: OffsetVector, bond_type: i32, ) -> usize

Examples found in repository?
examples/construct2.rs (line 11)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(1, 1, &[1.0]));
8
9    let mut unitcell = Unitcell::new(1);
10    unitcell.add_site(CoordinateVector::from_element(1, 0.0), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_element(1, 1), 0);
12
13    let extent = ExtentVector::from_element(1, 16);
14    let boundary = vec![Boundary::Periodic; 1];
15    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
16    support::print_graph(&graph);
17}
More examples
Hide additional examples
examples/construct4.rs (line 11)
6fn main() {
7    let basis = Basis::new(BasisMatrix::from_row_slice(2, 2, &[1.0, 0.0, 0.0, 1.0]));
8
9    let mut unitcell = Unitcell::new(2);
10    unitcell.add_site(CoordinateVector::from_vec(vec![0.0, 0.0]), 0);
11    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![1, 0]), 0);
12    unitcell.add_bond(0, 0, OffsetVector::from_vec(vec![0, 1]), 0);
13
14    let extent = ExtentVector::from_vec(vec![4, 4]);
15    let boundary = vec![Boundary::Periodic; 2];
16    let graph = Graph::from_basis_unitcell_extent(&basis, &unitcell, &extent, &boundary);
17    support::print_graph(&graph);
18}

Trait Implementations§

Source§

impl Clone for Unitcell

Source§

fn clone(&self) -> Unitcell

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Unitcell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Unitcell

Source§

fn eq(&self, other: &Unitcell) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Unitcell

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,