pub struct Parameters {
pub elements: HashMap<u8, ElementData>,
}Expand description
A collection of atomic parameters for multiple elements.
This struct serves as a container for element-specific data required by the charge equilibration solver. Parameters are indexed by atomic number for efficient lookup during calculations.
Fields§
§elements: HashMap<u8, ElementData>A mapping from atomic number to the corresponding element parameters.
The keys are atomic numbers (1 for hydrogen, 6 for carbon, etc.), and the values contain all the parameters needed for charge equilibration calculations.
Implementations§
Source§impl Parameters
impl Parameters
Sourcepub fn load_from_file(path: &Path) -> Result<Self, CheqError>
pub fn load_from_file(path: &Path) -> Result<Self, CheqError>
Loads atomic parameters from a TOML file.
This method reads the contents of a TOML file and parses it into a Parameters instance.
The file should contain an [elements] table with element data keyed by atomic number or
element symbol.
§Arguments
path- The path to the TOML file containing the parameter data.
§Returns
Returns a Parameters instance on success.
§Errors
Returns a CheqError::IoError if the file cannot be read, or a CheqError::DeserializationError
if the TOML content is invalid or contains unrecognized element keys.
§Examples
use cheq::Parameters;
use std::path::Path;
let params = Parameters::load_from_file(Path::new("parameters.toml")).unwrap();Sourcepub fn load_from_str(toml_str: &str) -> Result<Self, CheqError>
pub fn load_from_str(toml_str: &str) -> Result<Self, CheqError>
Parses atomic parameters from a TOML string.
This method deserializes TOML-formatted parameter data into a Parameters instance.
The string should contain an [elements] table with element data keyed by atomic number or
element symbol.
§Arguments
toml_str- A string slice containing valid TOML parameter data.
§Returns
Returns a Parameters instance on success.
§Errors
Returns a CheqError::DeserializationError if the TOML content is invalid or contains
unrecognized element keys.
§Examples
use cheq::Parameters;
let toml_data = r#"
[elements]
"1" = { chi = 2.20, j = 13.60, radius = 0.37, n = 1 }
"6" = { chi = 2.55, j = 10.39, radius = 0.77, n = 2 }
"#;
let params = Parameters::load_from_str(toml_data).unwrap();
assert_eq!(params.elements.len(), 2);Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty Parameters instance.
This constructor initializes a Parameters struct with an empty elements map. Parameters
can be added programmatically or loaded from a file/string.
§Returns
Returns a new Parameters instance with no elements.
§Examples
use cheq::Parameters;
let params = Parameters::new();
assert_eq!(params.elements.len(), 0);Trait Implementations§
Source§impl Clone for Parameters
impl Clone for Parameters
Source§fn clone(&self) -> Parameters
fn clone(&self) -> Parameters
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Parameters
impl Debug for Parameters
Source§impl Default for Parameters
impl Default for Parameters
Source§impl<'de> Deserialize<'de> for Parameters
impl<'de> Deserialize<'de> for Parameters
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Parameters
impl PartialEq for Parameters
impl StructuralPartialEq for Parameters
Auto Trait Implementations§
impl Freeze for Parameters
impl RefUnwindSafe for Parameters
impl Send for Parameters
impl Sync for Parameters
impl Unpin for Parameters
impl UnwindSafe for Parameters
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more