Struct castep_model_core::atom::AtomCollection
source · pub struct AtomCollection<T: ModelInfo> { /* private fields */ }Expand description
Struct of Atom as data-driven design.
Implementations§
source§impl<T: ModelInfo> AtomCollection<T>
impl<T: ModelInfo> AtomCollection<T>
sourcepub fn update_symbol_at(
&mut self,
index: usize,
new_symbol: &str
) -> Result<(), InvalidIndex>
pub fn update_symbol_at(
&mut self,
index: usize,
new_symbol: &str
) -> Result<(), InvalidIndex>
Update the element_symbol at the given index.
Errors
This function will return an error if the index is out of bounds.
Examples found in repository?
src/atom/mod.rs (line 146)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
pub fn update_atom_at(&mut self, index: usize, new_atom: Atom<T>) -> Result<(), InvalidIndex> {
let Atom {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: _,
} = new_atom;
self.update_symbol_at(index, &element_symbol)?;
self.update_elm_id_at(index, element_id)?;
self.update_xyz_at(index, xyz)?;
self.update_frac_xyz_at(index, fractional_xyz)?;
self.update_atom_id_at(index, atom_id)?;
Ok(())
}sourcepub fn update_elm_id_at(
&mut self,
index: usize,
new_elm_id: u8
) -> Result<(), InvalidIndex>
pub fn update_elm_id_at(
&mut self,
index: usize,
new_elm_id: u8
) -> Result<(), InvalidIndex>
Update the element_id at the given index.
Errors
This function will return an error if the index is out of bounds.
Examples found in repository?
src/atom/mod.rs (line 147)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
pub fn update_atom_at(&mut self, index: usize, new_atom: Atom<T>) -> Result<(), InvalidIndex> {
let Atom {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: _,
} = new_atom;
self.update_symbol_at(index, &element_symbol)?;
self.update_elm_id_at(index, element_id)?;
self.update_xyz_at(index, xyz)?;
self.update_frac_xyz_at(index, fractional_xyz)?;
self.update_atom_id_at(index, atom_id)?;
Ok(())
}sourcepub fn update_xyz_at(
&mut self,
index: usize,
new_xyz: Point3<f64>
) -> Result<(), InvalidIndex>
pub fn update_xyz_at(
&mut self,
index: usize,
new_xyz: Point3<f64>
) -> Result<(), InvalidIndex>
Update the xyz at the given index.
Errors
This function will return an error if the index is out of bounds.
Examples found in repository?
src/atom/mod.rs (line 148)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
pub fn update_atom_at(&mut self, index: usize, new_atom: Atom<T>) -> Result<(), InvalidIndex> {
let Atom {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: _,
} = new_atom;
self.update_symbol_at(index, &element_symbol)?;
self.update_elm_id_at(index, element_id)?;
self.update_xyz_at(index, xyz)?;
self.update_frac_xyz_at(index, fractional_xyz)?;
self.update_atom_id_at(index, atom_id)?;
Ok(())
}sourcepub fn update_frac_xyz_at(
&mut self,
index: usize,
new_frac: Option<Point3<f64>>
) -> Result<(), InvalidIndex>
pub fn update_frac_xyz_at(
&mut self,
index: usize,
new_frac: Option<Point3<f64>>
) -> Result<(), InvalidIndex>
Update the fractional_xyz at the given index.
Errors
This function will return an error if the index is out of bounds.
Examples found in repository?
src/atom/mod.rs (line 149)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
pub fn update_atom_at(&mut self, index: usize, new_atom: Atom<T>) -> Result<(), InvalidIndex> {
let Atom {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: _,
} = new_atom;
self.update_symbol_at(index, &element_symbol)?;
self.update_elm_id_at(index, element_id)?;
self.update_xyz_at(index, xyz)?;
self.update_frac_xyz_at(index, fractional_xyz)?;
self.update_atom_id_at(index, atom_id)?;
Ok(())
}sourcepub fn update_atom_id_at(
&mut self,
index: usize,
new_atom_id: u32
) -> Result<(), InvalidIndex>
pub fn update_atom_id_at(
&mut self,
index: usize,
new_atom_id: u32
) -> Result<(), InvalidIndex>
Update the atom_id at the given index.
Errors
This function will return an error if the index is out of bounds.
Examples found in repository?
src/atom/mod.rs (line 150)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
pub fn update_atom_at(&mut self, index: usize, new_atom: Atom<T>) -> Result<(), InvalidIndex> {
let Atom {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: _,
} = new_atom;
self.update_symbol_at(index, &element_symbol)?;
self.update_elm_id_at(index, element_id)?;
self.update_xyz_at(index, xyz)?;
self.update_frac_xyz_at(index, fractional_xyz)?;
self.update_atom_id_at(index, atom_id)?;
Ok(())
}sourcepub fn update_atom_at(
&mut self,
index: usize,
new_atom: Atom<T>
) -> Result<(), InvalidIndex>
pub fn update_atom_at(
&mut self,
index: usize,
new_atom: Atom<T>
) -> Result<(), InvalidIndex>
Update the whole atom at the given index.
Errors
This function will return an error if the index is out of bounds.
sourcepub fn element_symbols(&self) -> &[String]
pub fn element_symbols(&self) -> &[String]
Examples found in repository?
src/model_type/msi.rs (line 85)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}More examples
src/atom/visitor.rs (line 64)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn view_atom_at_index(&self, index: usize) -> Result<AtomView<T>, InvalidIndex> {
let element_symbol = self
.element_symbols()
.get(index)
.ok_or(InvalidIndex)?
.as_str();
let element_id = self.atomic_nums.get(index).ok_or(InvalidIndex)?;
let xyz = self.xyz_coords.get(index).ok_or(InvalidIndex)?;
let fractional_xyz = self.fractional_xyz.get(index).ok_or(InvalidIndex)?.as_ref();
let atom_id = self.atom_ids.get(index).ok_or(InvalidIndex)?;
Ok(AtomView {
element_symbol,
atomic_number: element_id,
xyz,
fractional_xyz,
atom_id,
format_type: T::default(),
})
}
fn view_atom_by_id(&self, atom_id: u32) -> Result<AtomView<T>, InvalidIndex> {
let index = (atom_id - 1) as usize;
self.view_atom_at_index(index)
}
fn get_vector_ab(&self, a_id: u32, b_id: u32) -> Result<Vector3<f64>, InvalidIndex> {
if a_id != b_id {
let atom_a_xyz = self.get_xyz_by_id(a_id).unwrap();
let atom_b_xyz = self.get_xyz_by_id(b_id).unwrap();
Ok(atom_b_xyz - atom_a_xyz)
} else {
Err(InvalidIndex)
}
}
fn element_set(&self) -> Vec<String> {
let mut elm_list: Vec<(String, u8)> = vec![];
elm_list.extend(
self.element_symbols()
.iter()
.zip(self.atomic_nums().iter())
.map(|(sym, id)| (sym.to_string(), *id))
.collect::<Vec<(String, u8)>>()
.drain(..)
.collect::<HashSet<(String, u8)>>()
.into_iter(),
);
elm_list.sort_unstable_by(|a, b| {
let (_, id_a) = a;
let (_, id_b) = b;
id_a.cmp(id_b)
});
elm_list
.iter()
.map(|(name, _)| name.to_string())
.collect::<Vec<String>>()
}
fn spin_total(&self) -> u8 {
self.element_symbols()
.iter()
.map(|symbol| -> u8 { ELEMENT_TABLE.get_by_symbol(symbol).unwrap().spin })
.reduce(|total, next| total + next)
.unwrap()
}src/model_type/cell.rs (line 250)
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let all_positions_str: Vec<String> = self
.element_symbols()
.iter()
.zip(self.fractional_xyz().iter())
.map(|(symbol, frac_xyz)| -> String {
let spin = ELEMENT_TABLE.get_by_symbol(symbol).unwrap().spin();
let spin_str = if spin > 0 {
format!(" SPIN={:14.10}", spin)
} else {
"".into()
};
let frac_xyz = frac_xyz.unwrap();
format!(
"{:>3}{:20.16}{:20.16}{:20.16}{spin_str}",
symbol, frac_xyz.x, frac_xyz.y, frac_xyz.z
)
})
.collect();
let joined_positions_str = all_positions_str.join("\n");
write!(f, "{}", joined_positions_str)
}sourcepub fn atomic_nums(&self) -> &[u8] ⓘ
pub fn atomic_nums(&self) -> &[u8] ⓘ
Examples found in repository?
src/model_type/msi.rs (line 87)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}More examples
src/atom/visitor.rs (line 101)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
fn element_set(&self) -> Vec<String> {
let mut elm_list: Vec<(String, u8)> = vec![];
elm_list.extend(
self.element_symbols()
.iter()
.zip(self.atomic_nums().iter())
.map(|(sym, id)| (sym.to_string(), *id))
.collect::<Vec<(String, u8)>>()
.drain(..)
.collect::<HashSet<(String, u8)>>()
.into_iter(),
);
elm_list.sort_unstable_by(|a, b| {
let (_, id_a) = a;
let (_, id_b) = b;
id_a.cmp(id_b)
});
elm_list
.iter()
.map(|(name, _)| name.to_string())
.collect::<Vec<String>>()
}sourcepub fn xyz_coords(&self) -> &[Point3<f64>]
pub fn xyz_coords(&self) -> &[Point3<f64>]
Examples found in repository?
src/atom/visitor.rs (line 18)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
pub fn get_xyz_by_id<T: ModelInfo>(
atom_collection: &AtomCollection<T>,
atom_id: u32,
) -> Option<&Point3<f64>> {
atom_collection.xyz_coords().get((atom_id - 1) as usize)
}
pub fn get_multiple_xyz_by_id<'a, 'b, T: ModelInfo>(
atom_collection: &'a AtomCollection<T>,
atom_ids: &'b [u32],
) -> Vec<Option<&'a Point3<f64>>> {
atom_ids
.iter()
.map(|&id| atom_collection.xyz_coords().get((id - 1) as usize))
.collect()
}
pub trait VisitCollection<T: ModelInfo> {
fn get_xyz_by_id(&self, atom_id: u32) -> Option<&Point3<f64>>;
fn get_multiple_xyz_by_id<'a, 'b>(
&'a self,
atom_ids: &'b [u32],
) -> Vec<Option<&'a Point3<f64>>>;
fn view_atom_at_index(&self, index: usize) -> Result<AtomView<T>, InvalidIndex>;
fn view_atom_by_id(&self, atom_id: u32) -> Result<AtomView<T>, InvalidIndex>;
fn get_vector_ab(&self, a_id: u32, b_id: u32) -> Result<Vector3<f64>, InvalidIndex>;
fn element_set(&self) -> Vec<String>;
fn spin_total(&self) -> u8;
fn get_final_cutoff_energy(&self, potentials_loc: &str) -> Result<f64, io::Error>;
}
impl<T> VisitCollection<T> for AtomCollection<T>
where
T: ModelInfo,
{
fn get_xyz_by_id(&self, atom_id: u32) -> Option<&Point3<f64>> {
self.xyz_coords().get((atom_id - 1) as usize)
}
fn get_multiple_xyz_by_id<'a, 'b>(
&'a self,
atom_ids: &'b [u32],
) -> Vec<Option<&'a Point3<f64>>> {
atom_ids
.iter()
.map(|&id| self.xyz_coords().get((id - 1) as usize))
.collect()
}More examples
src/model_type/msi.rs (line 89)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}src/model_type/cell.rs (line 67)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
fn from(mut msi_model: T) -> Self {
let x_axis: Vector3<f64> = Vector::x();
let a_vec = msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.column(0);
let a_to_x_angle = a_vec.angle(&x_axis);
if a_to_x_angle != 0.0 {
let rot_axis = a_vec.cross(&x_axis).normalize();
let rot_quatd: UnitQuaternion<f64> = UnitQuaternion::new(rot_axis * a_to_x_angle);
msi_model.as_mut().rotate(&rot_quatd);
}
let new_lat_vec = LatticeVectors::new(
msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.to_owned(),
);
let fractional_coord_matrix = msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.fractional_coord_matrix();
let mut cell_atoms: AtomCollection<CellModel> = msi_model.as_ref().atoms().clone().into();
let frac_coords: Vec<Point3<f64>> = cell_atoms
.xyz_coords()
.iter()
.map(|xyz| fractional_coord_matrix * xyz)
.collect();
cell_atoms
.fractional_xyz_mut()
.iter_mut()
.enumerate()
.for_each(|(i, f_xyz)| {
*f_xyz = Some(*frac_coords.get(i).unwrap());
});
Self::new(Some(new_lat_vec), cell_atoms, Settings::default())
}pub fn xyz_coords_mut(&mut self) -> &mut [Point3<f64>]
sourcepub fn fractional_xyz(&self) -> &[Option<Point3<f64>>]
pub fn fractional_xyz(&self) -> &[Option<Point3<f64>>]
Examples found in repository?
src/model_type/msi.rs (line 91)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}More examples
src/model_type/cell.rs (line 252)
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let all_positions_str: Vec<String> = self
.element_symbols()
.iter()
.zip(self.fractional_xyz().iter())
.map(|(symbol, frac_xyz)| -> String {
let spin = ELEMENT_TABLE.get_by_symbol(symbol).unwrap().spin();
let spin_str = if spin > 0 {
format!(" SPIN={:14.10}", spin)
} else {
"".into()
};
let frac_xyz = frac_xyz.unwrap();
format!(
"{:>3}{:20.16}{:20.16}{:20.16}{spin_str}",
symbol, frac_xyz.x, frac_xyz.y, frac_xyz.z
)
})
.collect();
let joined_positions_str = all_positions_str.join("\n");
write!(f, "{}", joined_positions_str)
}sourcepub fn fractional_xyz_mut(&mut self) -> &mut [Option<Point3<f64>>]
pub fn fractional_xyz_mut(&mut self) -> &mut [Option<Point3<f64>>]
Examples found in repository?
src/model_type/cell.rs (line 72)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
fn from(mut msi_model: T) -> Self {
let x_axis: Vector3<f64> = Vector::x();
let a_vec = msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.column(0);
let a_to_x_angle = a_vec.angle(&x_axis);
if a_to_x_angle != 0.0 {
let rot_axis = a_vec.cross(&x_axis).normalize();
let rot_quatd: UnitQuaternion<f64> = UnitQuaternion::new(rot_axis * a_to_x_angle);
msi_model.as_mut().rotate(&rot_quatd);
}
let new_lat_vec = LatticeVectors::new(
msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.to_owned(),
);
let fractional_coord_matrix = msi_model
.as_ref()
.lattice_vectors()
.unwrap()
.fractional_coord_matrix();
let mut cell_atoms: AtomCollection<CellModel> = msi_model.as_ref().atoms().clone().into();
let frac_coords: Vec<Point3<f64>> = cell_atoms
.xyz_coords()
.iter()
.map(|xyz| fractional_coord_matrix * xyz)
.collect();
cell_atoms
.fractional_xyz_mut()
.iter_mut()
.enumerate()
.for_each(|(i, f_xyz)| {
*f_xyz = Some(*frac_coords.get(i).unwrap());
});
Self::new(Some(new_lat_vec), cell_atoms, Settings::default())
}sourcepub fn atom_ids(&self) -> &[u32]
pub fn atom_ids(&self) -> &[u32]
Examples found in repository?
More examples
src/model_type/msi.rs (line 93)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Examples found in repository?
src/model_type/msi.rs (line 83)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
fn from(src: T) -> Self {
let builder = AtomCollectionBuilder::<MsiModel, No>::new(src.as_ref().size());
builder
.with_element_symbols(src.as_ref().element_symbols())
.unwrap()
.with_atomic_nums(src.as_ref().atomic_nums())
.unwrap()
.with_xyz_coords(src.as_ref().xyz_coords())
.unwrap()
.with_fractional_xyz(src.as_ref().fractional_xyz())
.unwrap()
.with_atom_ids(src.as_ref().atom_ids())
.unwrap()
.finish()
.unwrap()
.build()
}
}
impl<T> From<T> for LatticeModel<MsiModel>
where
T: AsRef<LatticeModel<CellModel>>,
{
fn from(cell_model: T) -> Self {
let new_lat_vec = LatticeVectors::new(
cell_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.to_owned(),
);
// Convert the SoA to AoS for easier sorting.
let msi_atoms: AtomCollection<MsiModel> = cell_model.as_ref().atoms().into();
let mut msi_atom_array: Vec<Atom<MsiModel>> = msi_atoms.into();
msi_atom_array.sort_by_key(|a| a.atom_id());
// Convert AoS back to SoA.
let msi_atom_collection: AtomCollection<MsiModel> = msi_atom_array.into();
let mut msi_model = Self::new(Some(new_lat_vec), msi_atom_collection, Settings::default());
let y_axis: Vector3<f64> = Vector::y();
let b_vec = cell_model
.as_ref()
.lattice_vectors()
.unwrap()
.vectors()
.column(1);
let b_to_y_angle = b_vec.angle(&y_axis);
if b_to_y_angle != 0.0 {
let rot_axis = b_vec.cross(&y_axis).normalize();
let rot_quatd: UnitQuaternion<f64> = UnitQuaternion::new(rot_axis * b_to_y_angle);
msi_model.rotate(&rot_quatd);
}
msi_model
}
}
impl<T> DefaultExport<MsiModel> for T
where
T: AsRef<LatticeModel<MsiModel>>,
{
fn export(&self) -> String {
if let Some(lattice_vectors) = self.as_ref().lattice_vectors() {
let headers_vectors: Vec<String> = vec![
"# MSI CERIUS2 DataModel File Version 4 0\n".to_string(),
"(1 Model\n".to_string(),
" (A I CRY/DISPLAY (192 256))\n".to_string(),
format!(
" (A I PeriodicType {})\n",
self.as_ref().settings().periodic_type()
),
format!(
" (A C SpaceGroup \"{}\")\n",
self.as_ref().settings().space_group()
),
format!("{}", lattice_vectors),
format!(
" (A D CRY/TOLERANCE {})\n",
self.as_ref().settings().cry_tolerance()
),
];
format!("{}{})", headers_vectors.concat(), self.as_ref().atoms())
} else {
let headers = "# MSI CERIUS2 DataModel File Version 4 0\n(1 Model\n";
format!("{}{})", headers, self.as_ref().atoms())
}
}
}
impl<'a> Display for AtomView<'a, MsiModel> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
r#" ({item_id} Atom
(A C ACL "{elm_id} {elm}")
(A C Label "{elm}")
(A D XYZ ({x:.12} {y:.12} {z:.12}))
(A I Id {atom_id})
)
"#,
item_id = self.atom_id() + 1,
elm_id = self.atomic_number(),
elm = self.element_symbol(),
x = self.xyz().x,
y = self.xyz().y,
z = self.xyz().z,
atom_id = self.atom_id(),
)
}
}
impl Display for AtomCollection<MsiModel> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let msi_atom_strings: Vec<String> = (0..self.size())
.into_iter()
.map(|i| {
let atom_view = self.view_atom_at_index(i).unwrap();
format!("{}", atom_view)
})
.collect();
write!(f, "{}", msi_atom_strings.concat())
}Trait Implementations§
source§impl<T: ModelInfo> Add<AtomCollection<T>> for AtomCollection<T>
impl<T: ModelInfo> Add<AtomCollection<T>> for AtomCollection<T>
source§impl<T: ModelInfo> AsRef<AtomCollection<T>> for &AtomCollection<T>
impl<T: ModelInfo> AsRef<AtomCollection<T>> for &AtomCollection<T>
source§fn as_ref(&self) -> &AtomCollection<T>
fn as_ref(&self) -> &AtomCollection<T>
Converts this type into a shared reference of the (usually inferred) input type.
source§impl<T: Clone + ModelInfo> Clone for AtomCollection<T>
impl<T: Clone + ModelInfo> Clone for AtomCollection<T>
source§fn clone(&self) -> AtomCollection<T>
fn clone(&self) -> AtomCollection<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<T: Default + ModelInfo> Default for AtomCollection<T>
impl<T: Default + ModelInfo> Default for AtomCollection<T>
source§fn default() -> AtomCollection<T>
fn default() -> AtomCollection<T>
Returns the “default value” for a type. Read more
source§impl Display for AtomCollection<CellModel>
impl Display for AtomCollection<CellModel>
source§impl Display for AtomCollection<MsiModel>
impl Display for AtomCollection<MsiModel>
source§impl<'a, T: ModelInfo> From<&'a AtomCollection<T>> for Vec<AtomView<'a, T>>
impl<'a, T: ModelInfo> From<&'a AtomCollection<T>> for Vec<AtomView<'a, T>>
source§fn from(src: &'a AtomCollection<T>) -> Self
fn from(src: &'a AtomCollection<T>) -> Self
Converts to this type from the input type.
source§impl From<AtomCollection<MsiModel>> for AtomCollection<CellModel>
impl From<AtomCollection<MsiModel>> for AtomCollection<CellModel>
source§fn from(src: AtomCollection<MsiModel>) -> Self
fn from(src: AtomCollection<MsiModel>) -> Self
Converts to this type from the input type.
source§impl<T: ModelInfo> From<AtomCollection<T>> for Vec<Atom<T>>
impl<T: ModelInfo> From<AtomCollection<T>> for Vec<Atom<T>>
source§fn from(src: AtomCollection<T>) -> Self
fn from(src: AtomCollection<T>) -> Self
Converts to this type from the input type.
source§impl<T> From<T> for AtomCollection<MsiModel>where
T: AsRef<AtomCollection<CellModel>>,
impl<T> From<T> for AtomCollection<MsiModel>where
T: AsRef<AtomCollection<CellModel>>,
source§impl<T> Transformation for AtomCollection<T>where
T: ModelInfo,
impl<T> Transformation for AtomCollection<T>where
T: ModelInfo,
fn rotate(&mut self, rotate_quatd: &UnitQuaternion<f64>)
fn translate(&mut self, translate_matrix: &Translation<f64, 3>)
source§impl<T> VisitCollection<T> for AtomCollection<T>where
T: ModelInfo,
impl<T> VisitCollection<T> for AtomCollection<T>where
T: ModelInfo,
fn get_xyz_by_id(&self, atom_id: u32) -> Option<&Point3<f64>>
fn get_multiple_xyz_by_id<'a, 'b>(
&'a self,
atom_ids: &'b [u32]
) -> Vec<Option<&'a Point3<f64>>> ⓘ
fn view_atom_at_index(
&self,
index: usize
) -> Result<AtomView<'_, T>, InvalidIndex>
fn view_atom_by_id(&self, atom_id: u32) -> Result<AtomView<'_, T>, InvalidIndex>
fn get_vector_ab(
&self,
a_id: u32,
b_id: u32
) -> Result<Vector3<f64>, InvalidIndex>
fn element_set(&self) -> Vec<String> ⓘ
fn spin_total(&self) -> u8
fn get_final_cutoff_energy(&self, potentials_loc: &str) -> Result<f64, Error>
Auto Trait Implementations§
impl<T> RefUnwindSafe for AtomCollection<T>where
T: RefUnwindSafe,
impl<T> Send for AtomCollection<T>where
T: Send,
impl<T> Sync for AtomCollection<T>where
T: Sync,
impl<T> Unpin for AtomCollection<T>where
T: Unpin,
impl<T> UnwindSafe for AtomCollection<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.