ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
PotentialField.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#ifndef FIELD_COUPLING_EXTERNAL_POTENTIAL_HPP
20#define FIELD_COUPLING_EXTERNAL_POTENTIAL_HPP
21
22#include "detail/Base.hpp"
24
25#include <utils/Vector.hpp>
26
27namespace FieldCoupling {
28template <typename Coupling, typename Field>
29class PotentialField : public detail::Base<Coupling, Field> {
30 using Base = detail::Base<Coupling, Field>;
31
32 using Base::m_coupling;
33 using Base::m_field;
34
35public:
36 using Base::Base;
37
38 template <typename Particle>
39 Utils::Vector3d force(const Particle &p, const Utils::Vector3d &folded_pos,
40 double t) const {
41 using detail::make_bind_coupling;
42 return m_coupling(p, -m_field.jacobian(folded_pos, t));
43 }
44
45 template <typename Particle>
46 double energy(const Particle &p, const Utils::Vector3d &folded_pos,
47 double t) const {
48 return m_coupling(p, m_field(folded_pos, t));
49 }
50};
51} /* namespace FieldCoupling */
52
53#endif
Vector implementation and trait types for boost qvm interoperability.
double energy(const Particle &p, const Utils::Vector3d &folded_pos, double t) const
Utils::Vector3d force(const Particle &p, const Utils::Vector3d &folded_pos, double t) const
Struct holding all information for one particle.
Definition Particle.hpp:395