ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
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
22#pragma once
23
24/** \file
25 * Routines to calculate the Lennard-Jones+cosine potential between
26 * particle pairs.
27 *
28 * Implementation in \ref ljcos.cpp.
29 */
30
31#include "config/config.hpp"
32
33#ifdef ESPRESSO_LJCOS
34
36
38#include <utils/math/sqr.hpp>
39
40#include <cmath>
41
42/** Calculate Lennard-Jones cosine force factor */
44 double dist) {
45 auto fac = 0.0;
46 if (dist < (ia_params.ljcos.cut + ia_params.ljcos.offset)) {
47 auto const r_off = dist - ia_params.ljcos.offset;
48 /* cos part of ljcos potential. */
49 if (dist > ia_params.ljcos.rmin + ia_params.ljcos.offset) {
50 fac = (r_off / dist) * ia_params.ljcos.alfa * ia_params.ljcos.eps *
51 (sin(ia_params.ljcos.alfa * Utils::sqr(r_off) +
52 ia_params.ljcos.beta));
53 }
54 /* Lennard-Jones part of the potential. */
55 else if (dist > 0) {
56 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos.sig / r_off);
57 fac = 48.0 * ia_params.ljcos.eps * frac6 * (frac6 - 0.5) / (r_off * dist);
58 }
59 }
60 return fac;
61}
62
63/** Calculate Lennard-Jones cosine energy */
64inline double ljcos_pair_energy(IA_parameters const &ia_params, double dist) {
65 if (dist < (ia_params.ljcos.cut + ia_params.ljcos.offset)) {
66 auto const r_off = dist - ia_params.ljcos.offset;
67 /* Lennard-Jones part of the potential. */
68 if (dist < (ia_params.ljcos.rmin + ia_params.ljcos.offset)) {
69 auto const frac6 = Utils::int_pow<6>(ia_params.ljcos.sig / r_off);
70 return 4.0 * ia_params.ljcos.eps * (Utils::sqr(frac6) - frac6);
71 }
72 /* cosine part of the potential. */
73 return .5 * ia_params.ljcos.eps *
74 (cos(ia_params.ljcos.alfa * Utils::sqr(r_off) +
75 ia_params.ljcos.beta) -
76 1.);
77 }
78 return 0.0;
79}
80
81#endif // ESPRESSO_LJCOS
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
double ljcos_pair_force_factor(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine force factor.
Definition ljcos.hpp:43
double ljcos_pair_energy(IA_parameters const &ia_params, double dist)
Calculate Lennard-Jones cosine energy.
Definition ljcos.hpp:64
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.