pub struct Unitcell { /* private fields */ }Implementations§
Source§impl Unitcell
impl Unitcell
Sourcepub fn new(dim: usize) -> Self
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
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}pub fn simple(dim: usize) -> Self
Sourcepub fn dimension(&self) -> usize
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}pub fn num_sites(&self) -> usize
pub fn num_bonds(&self) -> usize
pub fn site(&self, index: usize) -> &Site
pub fn bond(&self, index: usize) -> &Bond
pub fn max_neighbors(&self) -> usize
Sourcepub fn add_site(
&mut self,
coordinate: CoordinateVector,
site_type: i32,
) -> usize
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
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}Sourcepub fn add_bond(
&mut self,
source: usize,
target: usize,
target_offset: OffsetVector,
bond_type: i32,
) -> usize
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
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§
impl StructuralPartialEq for Unitcell
Auto Trait Implementations§
impl Freeze for Unitcell
impl RefUnwindSafe for Unitcell
impl Send for Unitcell
impl Sync for Unitcell
impl Unpin for Unitcell
impl UnsafeUnpin for Unitcell
impl UnwindSafe for Unitcell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.