35#include <unordered_map>
40namespace Interactions {
54 std::shared_ptr<::BondedInteractionsMap> m_handle;
55 std::unique_ptr<VariantMap> m_params;
61 m_handle = std::make_shared<::BondedInteractionsMap>();
62 m_params = std::make_unique<VariantMap>(
params);
67 system.bonded_ias = m_handle;
68 m_handle->bind_system(m_system.lock());
69 m_handle->on_ia_change();
70 if (m_params
and not m_params->empty()) {
78 context()->parallel_try_catch(
79 [&]() {
key = m_handle->insert(
obj_ptr->bonded_ia()); });
85 context()->parallel_try_catch(
86 [&]() { m_handle->insert(
key,
obj_ptr->bonded_ia()); });
94 if (name ==
"get_size") {
95 return {
static_cast<int>(m_handle->size())};
98 if (name ==
"get_bond_ids") {
100 for (
auto const &kv : *m_handle)
105 if (name ==
"has_bond") {
107 return {
elements().contains(bond_id)};
110 if (name ==
"get_bond") {
114 if (
not context()->is_head_node())
118 throw std::out_of_range(
"The bond with id " + std::to_string(bond_id) +
119 " is not yet defined.");
124 if (name ==
"get_zero_based_type") {
126 return m_handle->get_zero_based_type(bond_id);
The ScriptInterface counterparts of the bonded interactions parameters structs from the core are defi...
Data structures for bonded interactions.
Bind parameters in the script interface.
~BondedInteractions() override
void insert_in_core(key_type const &key, mapped_type const &obj_ptr) override
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
typename Base::mapped_type mapped_type
void erase_in_core(key_type const &key) final
void do_construct(VariantMap const ¶ms) override
void on_bind_system(::System::System &system) override
typename Base::key_type key_type
key_type insert_in_core(mapped_type const &obj_ptr) override
Owning map of object handles.
std::shared_ptr< ManagedType > mapped_type
key_type get_key(Variant const &key) const
auto const & elements() const
Map elements.
void restore_from_checkpoint(VariantMap const ¶ms)
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Script interface wrapper for a component of the system class.
ObjectMap< BondedInteraction, AutoParameters< ObjectMap< BondedInteraction, System::Leaf >, System::Leaf > > BondedInteractionsBase_t
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
static SteepestDescentParameters params
Currently active steepest descent instance.