ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ljcos2.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_LJCOS2_HPP
22#define CORE_NB_IA_LJCOS2_HPP
23
24/** \file
25 * Routines to calculate the Lennard-Jones with cosine tail potential
26 * between particle pairs. Cosine tail is different from that in
27 * \ref ljcos.hpp. Used for attractive tail/tail interactions in lipid
28 * bilayer calculations.
29 *
30 * Implementation in \ref ljcos2.cpp.
31 */
32
33#include "config/config.hpp"
34
35#ifdef LJCOS2
36
38
40#include <utils/math/sqr.hpp>
41
42#include <cmath>
43#include <numbers>
44
45/** Calculate Lennard-Jones cosine squared force factor */
46inline double ljcos2_pair_force_factor(IA_parameters const &ia_params,
47 double dist) {
48 if (dist < (ia_params.ljcos2.cut + ia_params.ljcos2.offset)) {
49 auto const r_off = dist - ia_params.ljcos2.offset;
50 auto fac = 0.;
51 if (r_off < ia_params.ljcos2.rchange) {
52 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos2.sig / r_off);
53 fac = 48. * ia_params.ljcos2.eps * frac6 * (frac6 - 0.5) / (r_off * dist);
54 } else if (r_off < ia_params.ljcos2.rchange + ia_params.ljcos2.w) {
55 fac = -ia_params.ljcos2.eps * std::numbers::pi / 2. / ia_params.ljcos2.w /
56 dist *
57 sin(std::numbers::pi * (r_off - ia_params.ljcos2.rchange) /
58 ia_params.ljcos2.w);
59 }
60 return fac;
61 }
62 return 0.;
63}
64
65/** Calculate Lennard-Jones cosine squared energy */
66inline double ljcos2_pair_energy(IA_parameters const &ia_params, double dist) {
67 if (dist < (ia_params.ljcos2.cut + ia_params.ljcos2.offset)) {
68 auto const r_off = dist - ia_params.ljcos2.offset;
69 if (r_off < ia_params.ljcos2.rchange) {
70 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos2.sig / r_off);
71 return 4. * ia_params.ljcos2.eps * (Utils::sqr(frac6) - frac6);
72 }
73 if (r_off < (ia_params.ljcos2.rchange + ia_params.ljcos2.w)) {
74 return -ia_params.ljcos2.eps / 2. *
75 (cos(std::numbers::pi * (r_off - ia_params.ljcos2.rchange) /
76 ia_params.ljcos2.w) +
77 1.);
78 }
79 }
80 return 0.;
81}
82
83#endif /* ifdef LJCOS2 */
84#endif
This file contains the defaults for ESPResSo.
double ljcos2_pair_energy(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine squared energy.
Definition ljcos2.hpp:66
double ljcos2_pair_force_factor(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine squared force factor.
Definition ljcos2.hpp:46
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.