ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ljcos.cpp
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/** \file
22 *
23 * Implementation of \ref ljcos.hpp
24 */
25#include "ljcos.hpp"
26
27#ifdef LJCOS
29
30#include <utils/constants.hpp>
31#include <utils/math/sqr.hpp>
32
33#include <stdexcept>
34
35LJcos_Parameters::LJcos_Parameters(double epsilon, double sigma, double cutoff,
36 double offset)
37 : eps{epsilon}, sig{sigma}, cut{cutoff}, offset{offset} {
38 if (epsilon < 0.) {
39 throw std::domain_error("LJcos parameter 'epsilon' has to be >= 0");
40 }
41 if (sigma < 0.) {
42 throw std::domain_error("LJcos parameter 'sigma' has to be >= 0");
43 }
44 if (cutoff < 0.) {
45 throw std::domain_error("LJcos parameter 'cutoff' has to be >= 0");
46 }
47 auto const facsq = Utils::cbrt_2() * Utils::sqr(sig);
48
49 rmin = sqrt(Utils::cbrt_2()) * sig;
50 alfa = Utils::pi() / (Utils::sqr(cut) - facsq);
51 beta = Utils::pi() * (1. - (1. / (Utils::sqr(cut) / facsq - 1.)));
52}
53
54#endif // LJCOS
Routines to calculate the Lennard-Jones+cosine potential between particle pairs.
DEVICE_QUALIFIER constexpr T cbrt_2()
Cube root of 2.
Definition constants.hpp:71
DEVICE_QUALIFIER constexpr T pi()
Ratio of diameter and circumference of a circle.
Definition constants.hpp:36
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:26
Various procedures concerning interactions between particles.
LJcos_Parameters()=default