Closed ExpHP closed 6 years ago
that can be done, it's not really any dumber than anything else you see in a generated input file. (I just wish Phonopy could read multiple conf files, so that something big like this could live in its own file)
Make a src/tasks/types/structure.rs
pub struct Metadata {
pub element: Element,
pub mass: f64,
}
pub type Structure = ::rsp2_structure::Structure<Metadata>;
// a trait so we can define methods on Structure
// (this can also be simplified using the extension_trait! macro)
trait StructureExt {
fn to_element_structure(&self) -> ElementStructure;
// this one can replace existing calls to `map_metadata_to(|_| ())`
fn to_coords_structure(&self) -> CoordsStructure;
}
impl StructureExt for Structure {
fn to_element_structure(&self) -> ElementStructure { ... }
fn to_coords_structure(&self) -> CoordsStructure;
}
src/tasks/cmd/mod.rs should be changed to use the new Structure type where possible.
As for how to add the mass to the structure in the first place, it won't be possible to do this from the functions for reading structure files (since those are in another crate), but then again none of those formats have masses anyways.
The config file in src/tasks
could take a map of elements to masses (and there could be a utility function for inserting them, which would be called by code in cmd/mod.rs
), or they could be hacked in with a function like carbon
in src/tasks/cmd/mod.rs
in config, add masses field
struct Masses(HashMap<String, f64>);
somewhere in rsp2-tasks
(probably cmd/mod.rs) make an function for taking config::Masses and producing HashMap<Element, f64>
Take that hashmap in tasks/phonopy/somewhere-idunno
and as a field added to each of the potentials in src/tasks/lammps/
Huzzah!! Masses are now configurable, and are received by all things that need it.
This was done as part of The Great Structure Removal: eb216bc50bf77348d13ce01bb30a69b7602d3831...a1d49dbf6368928ca499256c76c447bb0b22a4ee
The most correct way of fixing this would just be to always set the masses explicitly in the phonopy input configs (e.g.
MASS = 1.007940 1.00794 ... 12.010700 ...
), but it feels pretty dumb when you have 1k atoms and their masses actually match the default...