39 void push_back(std::unique_ptr<Pseudopotential> pseudopotential) {
40 pseudopotentials_.push_back(std::move(pseudopotential));
45 assert(index >= 0 && index <
static_cast<int>(pseudopotentials_.size()));
46 return *pseudopotentials_[index];
51 assert(index >= 0 && index <
static_cast<int>(pseudopotentials_.size()));
52 return *pseudopotentials_[index];
64 assert(index >= 0 && index <
static_cast<int>(pseudopotentials_.size()));
67 if (result ==
nullptr) {
68 throw std::logic_error(
69 "as_ultrasoft(" + std::to_string(index) +
"): species '" +
70 pseudopotentials_[index]->element +
71 "' carries no augmentation, so there is no ultrasoft form to return. A cell "
72 "mixing norm-conserving species with ultrasoft or PAW ones reaches this when a "
73 "caller asks for the augmented form per species without gating on the species. "
74 "This was an assert, which a release build compiles out -- so the null it "
75 "guarded was dereferenced instead of reported.");
82 assert(index >= 0 && index <
static_cast<int>(pseudopotentials_.size()));
85 if (result ==
nullptr) {
86 throw std::logic_error(
87 "as_paw(" + std::to_string(index) +
"): species '" +
88 pseudopotentials_[index]->element +
89 "' is not a PAW dataset, so there is no one-center form to return. A cell mixing "
90 "PAW species with norm-conserving or ultrasoft ones reaches this when a caller "
91 "asks for the one-center form per species without gating on the species. This "
92 "was an assert, which a release build compiles out -- so the null it guarded was "
93 "dereferenced instead of reported.");
98 [[nodiscard]]
int size()
const {
99 return static_cast<int>(pseudopotentials_.size());
103 return pseudopotentials_.empty();
110 for (
int index = 0; index <
size(); ++index) {
111 if ((*
this)[index].pseudopotential_type_enum() == target_type) {
130 for (
int index = 0; index <
size(); ++index) {
131 if ((*
this)[index].has_augmentation_charges()) {
141 for (
const auto& pseudopotential : pseudopotentials_) {
142 result.
push_back(pseudopotential->clone());
148 std::vector<std::unique_ptr<Pseudopotential>> pseudopotentials_;
PAW pseudopotential — extends ultrasoft with one-center (on-site) data.
PseudopotentialSet & operator=(PseudopotentialSet &&)=default
bool has_pseudopotential_type(PseudopotentialType target_type) const
const UltrasoftPseudopotential & as_ultrasoft(int index) const
PseudopotentialSet()=default
Pseudopotential & operator[](int index)
Access by index (mutable reference).
void push_back(std::unique_ptr< Pseudopotential > pseudopotential)
Move a unique_ptr into the set.
PseudopotentialSet clone() const
Deep-clone the entire set (preserves derived types).
const PawPseudopotential & as_paw(int index) const
Access as PAW pseudopotential.
PseudopotentialSet(const PseudopotentialSet &)=delete
const Pseudopotential & operator[](int index) const
Access by index (const reference).
PseudopotentialSet & operator=(const PseudopotentialSet &)=delete
PseudopotentialSet(PseudopotentialSet &&)=default
bool has_augmentation_charges() const
Base class for all pseudopotential types.
Ultrasoft pseudopotential — extends base with augmentation data.
PseudopotentialType
Pseudopotential type classification.