36#include <boost/algorithm/string/predicate.hpp>
37#include <boost/variant.hpp>
54namespace Interactions {
62 std::shared_ptr<const ::Bonded_IA_Parameters>
bonded_ia()
const {
74 [](
auto const &
key) { return std::string{key}; });
80 auto const valid_keys = get_valid_parameters();
83 throw std::runtime_error(
"Parameter '" +
key +
"' is missing");
86 for (
auto const &kv :
params) {
88 throw std::runtime_error(
"Parameter '" + kv.first +
89 "' is not recognized");
95 context()->parallel_try_catch([&]() {
96 check_valid_parameters(
params);
105 return m_bonded_ia ==
other.m_bonded_ia;
111 if (name ==
"is_same_bond") {
116 if (name ==
"get_num_partners") {
128 return boost::get<CoreBondedInteraction>(*bonded_ia());
136 {
"k", AutoParameter::read_only, [
this]() {
return get_struct().k; }},
137 {
"d_r_max", AutoParameter::read_only,
138 [
this]() {
return get_struct().drmax; }},
139 {
"r_0", AutoParameter::read_only, [
this]() {
return get_struct().r0; }},
145 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
147 get_value<double>(
params,
"d_r_max"),
148 get_value<double>(
params,
"r_0")));
156 {
"k", AutoParameter::read_only, [
this]() {
return get_struct().k; }},
157 {
"r_0", AutoParameter::read_only, [
this]() {
return get_struct().r; }},
158 {
"r_cut", AutoParameter::read_only,
159 [
this]() {
return get_struct().r_cut; }},
167 get_value<double>(
params,
"k"), get_value<double>(
params,
"r_0"),
168 get_value<double>(
params,
"r_cut")));
176 {
"k0", AutoParameter::read_only, [
this]() {
return get_struct().k0; }},
177 {
"k1", AutoParameter::read_only, [
this]() {
return get_struct().k1; }},
178 {
"r", AutoParameter::read_only, [
this]() {
return get_struct().r; }},
179 {
"r_cut", AutoParameter::read_only,
180 [
this]() {
return get_struct().r_cut; }},
188 get_value<double>(
params,
"k0"), get_value<double>(
params,
"k1"),
189 get_value<double>(
params,
"r"),
190 get_value<double>(
params,
"r_cut")));
198 {
"prefactor", AutoParameter::read_only,
199 [
this]() {
return get_struct().prefactor; }},
205 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
214 {
"q1q2", AutoParameter::read_only,
215 [
this]() {
return get_struct().q1q2; }},
221 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
230 {
"bend", AutoParameter::read_only,
231 [
this]() {
return get_struct().bend; }},
232 {
"phi0", AutoParameter::read_only,
233 [
this]() {
return get_struct().phi0; }},
239 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
241 get_value<double>(
params,
"phi0")));
249 {
"bend", AutoParameter::read_only,
250 [
this]() {
return get_struct().bend; }},
251 {
"phi0", AutoParameter::read_only,
252 [
this]() {
return get_struct().phi0; }},
258 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
260 get_value<double>(
params,
"phi0")));
268 {
"bend", AutoParameter::read_only,
269 [
this]() {
return get_struct().bend; }},
270 {
"phi0", AutoParameter::read_only,
271 [
this]() {
return get_struct().phi0; }},
277 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
279 get_value<double>(
params,
"phi0")));
287 {
"mult", AutoParameter::read_only,
288 [
this]() {
return get_struct().mult; }},
289 {
"bend", AutoParameter::read_only,
290 [
this]() {
return get_struct().bend; }},
291 {
"phase", AutoParameter::read_only,
292 [
this]() {
return get_struct().phase; }},
300 get_value<int>(
params,
"mult"), get_value<double>(
params,
"bend"),
301 get_value<double>(
params,
"phase")));
310 {
"min", AutoParameter::read_only,
311 [
this]() {
return get_struct().pot->minval; }},
312 {
"max", AutoParameter::read_only,
313 [
this]() {
return get_struct().pot->maxval; }},
314 {
"energy", AutoParameter::read_only,
315 [
this]() {
return get_struct().pot->energy_tab; }},
316 {
"force", AutoParameter::read_only,
317 [
this]() {
return get_struct().pot->force_tab; }},
325 get_value<double>(
params,
"min"), get_value<double>(
params,
"max"),
326 get_value<std::vector<double>>(
params,
"energy"),
327 get_value<std::vector<double>>(
params,
"force")));
335 {
"min", AutoParameter::read_only,
336 [
this]() {
return get_struct().pot->minval; }},
337 {
"max", AutoParameter::read_only,
338 [
this]() {
return get_struct().pot->maxval; }},
339 {
"energy", AutoParameter::read_only,
340 [
this]() {
return get_struct().pot->energy_tab; }},
341 {
"force", AutoParameter::read_only,
342 [
this]() {
return get_struct().pot->force_tab; }},
350 get_value<double>(
params,
"min"), get_value<double>(
params,
"max"),
351 get_value<std::vector<double>>(
params,
"energy"),
352 get_value<std::vector<double>>(
params,
"force")));
361 {
"min", AutoParameter::read_only,
362 [
this]() {
return get_struct().pot->minval; }},
363 {
"max", AutoParameter::read_only,
364 [
this]() {
return get_struct().pot->maxval; }},
365 {
"energy", AutoParameter::read_only,
366 [
this]() {
return get_struct().pot->energy_tab; }},
367 {
"force", AutoParameter::read_only,
368 [
this]() {
return get_struct().pot->force_tab; }},
376 get_value<double>(
params,
"min"), get_value<double>(
params,
"max"),
377 get_value<std::vector<double>>(
params,
"energy"),
378 get_value<std::vector<double>>(
params,
"force")));
386 {
"temp_com", AutoParameter::read_only,
387 [
this]() {
return get_struct().temp_com; }},
388 {
"gamma_com", AutoParameter::read_only,
389 [
this]() {
return get_struct().gamma_com; }},
390 {
"temp_distance", AutoParameter::read_only,
391 [
this]() {
return get_struct().temp_distance; }},
392 {
"gamma_distance", AutoParameter::read_only,
393 [
this]() {
return get_struct().gamma_distance; }},
394 {
"r_cut", AutoParameter::read_only,
395 [
this]() {
return get_struct().r_cut; }},
401 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
403 get_value<double>(
params,
"gamma_com"),
404 get_value<double>(
params,
"temp_distance"),
405 get_value<double>(
params,
"gamma_distance"),
406 get_value<double>(
params,
"r_cut")));
414 {
"r", AutoParameter::read_only,
415 [
this]() {
return std::sqrt(get_struct().d2); }},
416 {
"ptol", AutoParameter::read_only,
417 [
this]() {
return 0.5 * get_struct().p_tol; }},
418 {
"vtol", AutoParameter::read_only,
419 [
this]() {
return get_struct().v_tol; }},
427 get_value<double>(
params,
"r"), get_value<double>(
params,
"ptol"),
428 get_value<double>(
params,
"vtol")));
436 {
"k1", AutoParameter::read_only, [
this]() {
return get_struct().k1; }},
437 {
"k2", AutoParameter::read_only, [
this]() {
return get_struct().k2; }},
438 {
"ind1", AutoParameter::read_only,
439 [
this]() {
return std::get<0>(get_struct().p_ids); }},
440 {
"ind2", AutoParameter::read_only,
441 [
this]() {
return std::get<1>(get_struct().p_ids); }},
442 {
"ind3", AutoParameter::read_only,
443 [
this]() {
return std::get<2>(get_struct().p_ids); }},
444 {
"maxDist", AutoParameter::read_only,
445 [
this]() {
return get_struct().maxDist; }},
446 {
"elasticLaw", AutoParameter::read_only,
449 return std::string(
"NeoHookean");
451 return std::string(
"Skalak");
453 {
"is_initialized", AutoParameter::read_only,
454 [
this]() {
return get_struct().is_initialized; }},
455 {
"_cache", AutoParameter::read_only,
457 auto &s = get_struct();
458 return std::vector<double>{{s.l0, s.lp0, s.sinPhi0, s.cosPhi0,
459 s.area0, s.a1, s.a2, s.b1, s.b2}};
466 auto const law_name = get_value<std::string>(
params,
"elasticLaw");
468 if (law_name ==
"NeoHookean") {
470 }
else if (law_name ==
"Skalak") {
473 throw std::invalid_argument(
474 "Invalid value for parameter 'elasticLaw': '" + law_name +
"'");
477 get_value<int>(
params,
"ind1"), get_value<int>(
params,
"ind2"),
478 get_value<int>(
params,
"ind3"), get_value<double>(
params,
"maxDist"),
479 elastic_law, get_value<double>(
params,
"k1"),
480 get_value<double>(
params,
"k2"));
481 if (get_value_or<bool>(
params,
"is_initialized",
false)) {
482 auto const cache = get_value<std::vector<double>>(
params,
"_cache");
483 assert(cache.size() == 9ul);
486 bond.sinPhi0 = cache[2];
487 bond.cosPhi0 = cache[3];
488 bond.area0 = cache[4];
493 bond.is_initialized =
true;
495 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(std::move(bond));
503 {
"softID", AutoParameter::read_only,
504 [
this]() {
return static_cast<int>(get_struct().softID); }},
505 {
"kappaV", AutoParameter::read_only,
506 [
this]() {
return get_struct().kappaV; }},
512 if (name ==
"current_volume") {
513 return get_struct().get_current_volume();
515 return BondedInteraction::do_call_method(name,
params);
520 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(
522 get_value<double>(
params,
"kappaV")));
530 {
"kb", AutoParameter::read_only, [
this]() {
return get_struct().kb; }},
531 {
"ind1", AutoParameter::read_only,
532 [
this]() {
return std::get<0>(get_struct().p_ids); }},
533 {
"ind2", AutoParameter::read_only,
534 [
this]() {
return std::get<1>(get_struct().p_ids); }},
535 {
"ind3", AutoParameter::read_only,
536 [
this]() {
return std::get<2>(get_struct().p_ids); }},
537 {
"ind4", AutoParameter::read_only,
538 [
this]() {
return std::get<3>(get_struct().p_ids); }},
539 {
"refShape", AutoParameter::read_only,
541 return std::string((get_struct().flat) ?
"Flat" :
"Initial");
543 {
"theta0", AutoParameter::read_only,
544 [
this]() {
return get_struct().theta0; }},
545 {
"is_initialized", AutoParameter::read_only,
546 [
this]() {
return get_struct().is_initialized; }},
552 auto const shape_name = get_value<std::string>(
params,
"refShape");
554 if (shape_name ==
"Flat") {
556 }
else if (shape_name ==
"Initial") {
559 throw std::invalid_argument(
"Invalid value for parameter 'refShape': '" +
563 get_value<int>(
params,
"ind1"), get_value<int>(
params,
"ind2"),
564 get_value<int>(
params,
"ind3"), get_value<int>(
params,
"ind4"),
565 get_value<double>(
params,
"kb"), flat);
566 if (get_value_or<bool>(
params,
"is_initialized",
false)) {
567 bond.theta0 = get_value<double>(
params,
"theta0");
568 bond.is_initialized =
true;
570 m_bonded_ia = std::make_shared<::Bonded_IA_Parameters>(std::move(bond));
579 {
"A0_g", AutoParameter::read_only,
580 [
this]() {
return get_struct().A0_g; }},
581 {
"ka_g", AutoParameter::read_only,
582 [
this]() {
return get_struct().ka_g; }},
583 {
"V0", AutoParameter::read_only, [
this]() {
return get_struct().V0; }},
584 {
"kv", AutoParameter::read_only, [
this]() {
return get_struct().kv; }},
592 get_value<double>(
params,
"A0_g"),
593 get_value<double>(
params,
"ka_g"), get_value<double>(
params,
"V0"),
594 get_value<double>(
params,
"kv")));
602 {
"r0", AutoParameter::read_only, [
this]() {
return get_struct().r0; }},
603 {
"ks", AutoParameter::read_only, [
this]() {
return get_struct().ks; }},
604 {
"kslin", AutoParameter::read_only,
605 [
this]() {
return get_struct().kslin; }},
606 {
"phi0", AutoParameter::read_only,
607 [
this]() {
return get_struct().phi0; }},
608 {
"kb", AutoParameter::read_only, [
this]() {
return get_struct().kb; }},
609 {
"A01", AutoParameter::read_only,
610 [
this]() {
return get_struct().A01; }},
611 {
"A02", AutoParameter::read_only,
612 [
this]() {
return get_struct().A02; }},
613 {
"kal", AutoParameter::read_only,
614 [
this]() {
return get_struct().kal; }},
615 {
"kvisc", AutoParameter::read_only,
616 [
this]() {
return get_struct().kvisc; }},
624 get_value<double>(
params,
"r0"), get_value<double>(
params,
"ks"),
625 get_value<double>(
params,
"kslin"),
626 get_value<double>(
params,
"phi0"), get_value<double>(
params,
"kb"),
627 get_value<double>(
params,
"A01"), get_value<double>(
params,
"A02"),
628 get_value<double>(
params,
"kal"),
629 get_value<double>(
params,
"kvisc")));
Data structures for bonded interactions.
int number_of_partners(Bonded_IA_Parameters const &iaparams)
Get the number of bonded partners for the specified bond.
Bind parameters in the script interface.
std::span< const boost::string_ref > valid_parameters() const final
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
CoreBondedInteraction & get_struct()
CoreIA CoreBondedInteraction
virtual std::set< std::string > get_valid_parameters() const
std::shared_ptr<::Bonded_IA_Parameters > m_bonded_ia
bool operator==(BondedInteraction const &other) const
std::shared_ptr< const ::Bonded_IA_Parameters > bonded_ia() const
void do_construct(VariantMap const ¶ms) override
virtual void construct_bond(VariantMap const ¶ms)=0
std::shared_ptr<::Bonded_IA_Parameters > bonded_ia()
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const ¶ms) override
void construct_bond(VariantMap const &) override
Context * context() const
Responsible context.
Implementation in thermostat.cpp.
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.