ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/pair_criteria/EnergyCriterion.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-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#pragma once
21
22#include "pair_criteria/PairCriterion.hpp"
23
24#include "BoxGeometry.hpp"
25#include "Particle.hpp"
26#include "energy_inline.hpp"
28#include "system/System.hpp"
29
30namespace PairCriteria {
31/**
32 * @brief True if the short-range energy is larger than a cutoff value.
33 */
35public:
36 EnergyCriterion(System::System const &system) : m_system{system} {}
37 bool decide(Particle const &p1, Particle const &p2) const override {
38 // Distance between particles
39 auto const d = m_system.box_geo->get_mi_vector(p1.pos(), p2.pos());
40
41 // Interaction parameters for particle types
42 auto const &ia_params =
43 m_system.nonbonded_ias->get_ia_param(p1.type(), p2.type());
44 auto const coulomb_kernel = m_system.coulomb.pair_energy_kernel();
45
46 auto const energy = calc_non_bonded_pair_energy(
47 p1, p2, ia_params, d, d.norm(), *m_system.bonded_ias,
48 get_ptr(coulomb_kernel));
49
50 return energy >= m_cut_off;
51 }
52 double get_cut_off() { return m_cut_off; }
53 void set_cut_off(double c) { m_cut_off = c; }
54
55private:
56 double m_cut_off;
57 System::System const &m_system;
58};
59} // namespace PairCriteria
True if the short-range energy is larger than a cutoff value.
bool decide(Particle const &p1, Particle const &p2) const override
Criterion which returns a true/false value for a pair of particles.
Main system class.
std::shared_ptr< BondedInteractionsMap > bonded_ias
Coulomb::Solver coulomb
std::shared_ptr< BoxGeometry > box_geo
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
const T * get_ptr(std::optional< T > const &opt)
Energy calculation.
double calc_non_bonded_pair_energy(Particle const &p1, Particle const &p2, IA_parameters const &ia_params, Utils::Vector3d const &d, double const dist, BondedInteractionsMap const &bonded_ias, Coulomb::ShortRangeEnergyKernel::kernel_type const *coulomb_kernel)
Calculate non-bonded energies between a pair of particles.
Various procedures concerning interactions between particles.
std::optional< ShortRangeEnergyKernel > pair_energy_kernel() const
Struct holding all information for one particle.
Definition Particle.hpp:395
auto const & type() const
Definition Particle.hpp:418
auto const & pos() const
Definition Particle.hpp:431