50 std::vector<int>
const &
pids,
54 for (std::size_t i = 0; i <
pids.size(); ++i) {
55 auto const pid =
pids[i];
60 if (p !=
nullptr and not p->is_ghost()) {
68 system.on_particle_change();
73#ifdef ESPRESSO_EXCLUSIONS
77 boost::mpi::communicator
const &comm,
80 for (std::size_t i = 0; i <
pids.size(); ++i) {
81 auto const pid =
pids[i];
87 if (p !=
nullptr and not p->is_ghost()) {
100 system.on_particle_change();
106 std::vector<Utils::Vector3d>
const &positions) {
107 for (std::size_t i = 0; i <
pids.size(); ++i) {
108 auto const pid =
pids[i];
109 auto const pos = positions[i];
116 std::vector<int>
const &
types,
119 for (std::size_t i = 0; i <
pids.size(); ++i) {
120 auto const pid =
pids[i];
122 if (p !=
nullptr and not p->is_ghost()) {
126 throw std::domain_error(
error_msg(
"type",
"must be an integer >= 0"));
135#ifdef ESPRESSO_ELECTROSTATICS
137 std::vector<double>
const &charges,
140 for (std::size_t i = 0; i <
pids.size(); ++i) {
141 auto const pid =
pids[i];
143 if (p !=
nullptr and not p->is_ghost()) {
147 system.on_particle_charge_change();
152 if (
params.contains(
"__cell_structure")) {
154 params,
"__cell_structure");
155 so->configure(*
this);
156 m_cell_structure =
so;
158 if (
params.contains(
"__bonded_ias")) {
167 for (
auto const pid : m_id_selection) {
169 throw std::out_of_range(
"Particle does not exist: " +
170 std::to_string(pid));
177 if (
name ==
"set_param_parallel") {
182 if (
not params.contains(
"all_bonds_ids")) {
183 throw Exception(
"Parameter 'all_bonds_ids' is missing");
185 if (
not params.contains(
"all_bonds_partner_ids")) {
186 throw Exception(
"Parameter 'all_bonds_partner_ids' is missing");
189 throw Exception(
"Parameter 'values' is missing");
194 if (m_special_parameters.contains(
param_name)) {
203 *get_cell_structure(), *get_system());
205#ifdef ESPRESSO_ELECTROSTATICS
207 std::vector<double> charges;
210 charges = std::vector<double>(
tmp.begin(),
tmp.end());
219#ifdef ESPRESSO_EXCLUSIONS
226 context()->get_comm(), *get_cell_structure(), *get_system());
233 get_value<std::vector<std::vector<std::vector<int>>>>(
234 params,
"all_bonds_partner_ids"),
235 *get_cell_structure(), *get_system());
244 context(), m_cell_structure.lock(),
245 m_bonded_ias.lock());
252 if (
name ==
"get_param_parallel") {
259 *get_cell_structure());
264 *get_cell_structure());
267 auto const &box_geo = *get_system()->box_geo;
269 return box_geo.unfolded_position(p.pos(), p.image_box());
275 auto const &box_geo = *get_system()->box_geo;
277 return box_geo.folded_position(p.pos());
284 if (!
context()->is_head_node()) {
287 std::vector<Variant> result;
288 result.reserve(m_id_selection.size());
289 auto so = std::dynamic_pointer_cast<ParticleModifier>(
290 context()->make_shared(
"Particles::ParticleModifier",
292 {
"__cell_structure", m_cell_structure.lock()},
293 {
"__bonded_ias", m_bonded_ias.lock()}}));
294 for (
int pid : m_id_selection) {
304 if (
name ==
"prefetch_particle_data") {
309 if (
name ==
"get_particle") {
311 "Particles::ParticleHandle",
313 {
"__cell_structure", m_cell_structure.lock()},
314 {
"__bonded_ias", m_bonded_ias.lock()}});
ScriptInterface::Context decorates ScriptInterface::ObjectHandle objects with a context: a creation p...
Vector implementation and trait types for boost qvm interoperability.
bool add_bond(System::System &system, int bond_id, std::vector< int > const &particle_ids)
Add a bond to a particle.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
virtual std::shared_ptr< ObjectHandle > make_shared(std::string const &name, const VariantMap ¶meters)=0
Get a new reference counted instance of a script interface by name.
virtual bool is_head_node() const =0
Context * context() const
Responsible context.
std::string_view name() const
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void do_construct(VariantMap const ¶ms) override
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static void set_particles_charges(std::vector< int > const &pids, std::vector< double > const &charges, CellStructure &cell_structure, ::System::System &system)
static void set_particles_bonds(std::vector< int > const &pids, std::vector< std::vector< int > > const &all_bonds_ids, std::vector< std::vector< std::vector< int > > > const &all_bonds_partner_ids, ::CellStructure &cell_structure, ::System::System &system)
void particle_exclusion_sanity_checks(int pid1, int pid2, ::CellStructure &cell_structure, auto const &comm)
void local_remove_exclusion(int pid1, int pid2, ::CellStructure &cell_structure)
Locally remove an exclusion to a particle.
static void set_particles_types(std::vector< int > const &pids, std::vector< int > const &types, CellStructure &cell_structure, ::System::System &system)
void particle_checks(int p_id, Utils::Vector3d const &pos)
auto error_msg(std::string const &name, std::string const &reason)
static void set_particles_exclusions(std::vector< int > const &pids, std::vector< std::vector< int > > const &exclusion_lists, boost::mpi::communicator const &comm, ::CellStructure &cell_structure, ::System::System &system)
static void set_particles_positions(std::vector< int > const &pids, std::vector< Utils::Vector3d > const &positions)
void local_add_exclusion(int pid1, int pid2, ::CellStructure &cell_structure)
Locally add an exclusion to a particle.
constexpr bool is_type(Variant const &v)
Check is a Variant holds a specific type.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Various procedures concerning interactions between particles.
void set_particle_pos(int p_id, Utils::Vector3d const &pos)
Move particle to a new position.
void prefetch_particle_data(std::span< const int > in_ids)
Fetch a range of particle into the fetch cache.
void on_particle_type_change(int p_id, int old_type, int new_type)
bool particle_exists(int p_id)
Check if particle exists.
Particles creation and deletion.
static SteepestDescentParameters params
Currently active steepest descent instance.
Struct holding all information for one particle.
auto const & type() const
auto const & bonds() const
Recursive variant implementation.