Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
ljcos.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef CORE_NB_IA_LJCOS_HPP
22#define CORE_NB_IA_LJCOS_HPP
23/** \file
24 * Routines to calculate the Lennard-Jones+cosine potential between
25 * particle pairs.
26 *
27 * Implementation in \ref ljcos.cpp.
28 */
29
30#include "config/config.hpp"
31
32#ifdef LJCOS
33
35
37#include <utils/math/sqr.hpp>
38
39#include <cmath>
40
41/** Calculate Lennard-Jones cosine force factor */
42inline double ljcos_pair_force_factor(IA_parameters const &ia_params,
43 double dist) {
44 auto fac = 0.0;
45 if (dist < (ia_params.ljcos.cut + ia_params.ljcos.offset)) {
46 auto const r_off = dist - ia_params.ljcos.offset;
47 /* cos part of ljcos potential. */
48 if (dist > ia_params.ljcos.rmin + ia_params.ljcos.offset) {
49 fac = (r_off / dist) * ia_params.ljcos.alfa * ia_params.ljcos.eps *
50 (sin(ia_params.ljcos.alfa * Utils::sqr(r_off) +
51 ia_params.ljcos.beta));
52 }
53 /* Lennard-Jones part of the potential. */
54 else if (dist > 0) {
55 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos.sig / r_off);
56 fac = 48.0 * ia_params.ljcos.eps * frac6 * (frac6 - 0.5) / (r_off * dist);
57 }
58 }
59 return fac;
60}
61
62/** Calculate Lennard-Jones cosine energy */
63inline double ljcos_pair_energy(IA_parameters const &ia_params, double dist) {
64 if (dist < (ia_params.ljcos.cut + ia_params.ljcos.offset)) {
65 auto const r_off = dist - ia_params.ljcos.offset;
66 /* Lennard-Jones part of the potential. */
67 if (dist < (ia_params.ljcos.rmin + ia_params.ljcos.offset)) {
68 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos.sig / r_off);
69 return 4.0 * ia_params.ljcos.eps * (Utils::sqr(frac6) - frac6);
70 }
71 /* cosine part of the potential. */
72 return .5 * ia_params.ljcos.eps *
73 (cos(ia_params.ljcos.alfa * Utils::sqr(r_off) +
74 ia_params.ljcos.beta) -
75 1.);
76 }
77 return 0.0;
78}
79
80#endif // LJCOS
81#endif
This file contains the defaults for ESPResSo.
double ljcos_pair_force_factor(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine force factor.
Definition ljcos.hpp:42
double ljcos_pair_energy(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine energy.
Definition ljcos.hpp:63
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:28
Various procedures concerning interactions between particles.
Parameters for non-bonded interactions.