ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Polymer.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "Polymer.hpp"
21
24
25#include "core/polymer.hpp"
27
28#include <utils/Vector.hpp>
29
30#include <string>
31#include <vector>
32
33namespace ScriptInterface {
34namespace Particles {
35
36Variant Polymer::do_call_method(std::string const &name,
37 VariantMap const &parameters) {
38 if (name == "draw_polymer_positions") {
41 auto const positions = draw_polymer_positions(
43 get_value<int>(parameters, "beads_per_chain"),
44 get_value<double>(parameters, "bond_length"),
45 get_value<std::vector<Utils::Vector3d>>(parameters,
46 "start_positions"),
47 get_value<double>(parameters, "min_distance"),
48 get_value<int>(parameters, "max_tries"),
49 get_value<bool>(parameters, "use_bond_angle"),
50 get_value_or<double>(parameters, "bond_angle", 0.),
51 get_value<bool>(parameters, "respect_constraints"),
52 get_value<int>(parameters, "seed"));
53 std::vector<Variant> pack;
54 for (auto const &chain : positions) {
55 pack.emplace_back(make_vector_of_variants(chain));
56 }
58 });
59 return output;
60 }
61 return {};
62}
63
64} // namespace Particles
65} // namespace ScriptInterface
Vector implementation and trait types for boost qvm interoperability.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
boost::string_ref name() const
Context * context() const
Responsible context.
Variant do_call_method(std::string const &name, VariantMap const &parameters) override
Definition Polymer.cpp:36
PackedVariant pack(const Variant &v)
Transform a Variant to a PackedVariant.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
auto make_vector_of_variants(std::vector< T > const &v)
Definition Variant.hpp:88
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.
Definition Variant.hpp:67
System & get_system()
std::vector< std::vector< Utils::Vector3d > > draw_polymer_positions(System::System const &system, int const n_polymers, int const beads_per_chain, double const bond_length, std::vector< Utils::Vector3d > const &start_positions, double const min_distance, int const max_tries, int const use_bond_angle, double const bond_angle, int const respect_constraints, int const seed)
Determines valid polymer positions and returns them.
Definition polymer.cpp:143
This file contains everything needed to create a start-up configuration of polymer chains which may r...