3 #include "aux/json_support.h" 5 #include <range/v3/range/conversion.hpp> 18 using key_type = std::string;
19 std::map<key_type, double> data;
23 bool contains(
const key_type& name)
const;
24 double at(
const key_type& name)
const;
25 double& at(
const key_type& name);
26 void insert_or_assign(
const key_type& name,
double value);
50 double chiral_angle = 0.0;
52 double patch_angle = 0.0;
53 double patch_angle_switch =
73 using index_type = std::size_t;
77 friend void to_json(
json&,
const AtomData&);
78 friend void from_json(
const json&, AtomData&);
88 std::optional<double> dp = std::nullopt;
89 std::optional<double> dprot = std::nullopt;
94 bool hydrophobic =
false;
95 bool implicit =
false;
96 double scattering_f0 = 1.0;
102 const index_type& id()
const;
105 void to_json(
json& j,
const AtomData& a);
106 void from_json(
const json& j, AtomData& a);
114 void from_json(
const json& j, std::vector<AtomData>& atom_vector);
116 extern std::vector<AtomData>
atoms;
119 template <
typename T>
122 { db.begin()->name } -> std::convertible_to<std::string>;
123 { std::is_integral_v<typename std::ranges::range_value_t<T>::index_type> };
134 auto findName(RequireNamedElements
auto& range, std::string_view name)
136 return std::find_if(range.begin(), range.end(), [&](
auto& i) {
return i.name == name; });
139 auto findName(
const RequireNamedElements
auto& range, std::string_view name)
141 return std::find_if(range.begin(), range.end(), [&](
const auto& i) {
return i.name == name; });
177 template <RequireNamedElements T>
178 auto names2ids(
const T& database,
const std::vector<std::string>& names)
180 namespace rv = std::views;
182 auto is_wildcard = [](
auto& name) {
return name ==
"*"; };
183 if (std::ranges::any_of(names, is_wildcard)) {
184 return database | rv::transform([](
auto& i) {
return i.id(); }) | ranges::to_vector;
187 auto name_to_id = [&](
auto& name) {
188 if (
auto iter =
findName(database, name); iter != database.end()) {
191 throw std::out_of_range(
"name '" + name +
"' not found");
193 return names | rv::transform(name_to_id) | ranges::to_vector;
nlohmann::json json
JSON object.
Definition: json_support.h:10
Eigen::Vector3d Point
3D vector used for positions, velocities, forces etc.
Definition: coordinates.h:7
AtomData & findAtomByName(std::string_view name)
Finds an atom by its name in the global Faunus atoms lexicon.
Definition: atomdata.cpp:301
PatchType
Definition: atomdata.h:43
auto names2ids(const T &database, const std::vector< std::string > &names)
Search for name in database and return id()
Definition: atomdata.h:178
double T
floating point size
Definition: units.h:73
Static properties for patchy sphero cylinders (PSC)
Definition: atomdata.h:36
Common ancestor of Faunus specific runtime errors.
Definition: core.h:50
Used to detect invalid input.
std::vector< Faunus::AtomData > atoms
Global instance of atom list.
Definition: atomdata.cpp:242
Patch stops before the end caps.
Patch runs the full length of the SC.
Cell list class templates.
Definition: actions.cpp:11
NLOHMANN_JSON_SERIALIZE_ENUM(SpheroCylinderData::PatchType, {{SpheroCylinderData::PatchType::Invalid, nullptr}, {SpheroCylinderData::PatchType::Full, "full"}, {SpheroCylinderData::PatchType::Capped, "capped"}, {SpheroCylinderData::PatchType::None, "none"}}) class AtomData
General properties for atoms.
Definition: atomdata.h:61
auto findName(RequireNamedElements auto &range, std::string_view name)
Finds the first element with a member attribute name matching the input.
Definition: atomdata.h:134
Like json, but delete entries after access.
Definition: json_support.h:26
concept RequireNamedElements
Concept for named database such as vector<AtomData>, vector<MoleculeData> etc.
Definition: atomdata.h:120
A stub to hold various parameters of interactions.
Definition: atomdata.h:16
An exception to indicate an unknown atom name in the input.
Definition: atomdata.h:147