doubleSigmoid.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "doubleSigmoid.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace energyScalingFunctions
34 {
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
39 
41 (
45 );
46 
47 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 
49 scalar doubleSigmoid::sigmoidScale
50  (
51  const scalar r,
52  const scalar shift,
53  const scalar scale
54  ) const
55 {
56  return 1.0 / (1.0 + exp( scale * (r - shift)));
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const dictionary& energyScalingFunctionProperties,
66  const pairPotential& pairPot
67 )
68 :
69  energyScalingFunction(name, energyScalingFunctionProperties, pairPot),
70  doubleSigmoidCoeffs_
71  (
72  energyScalingFunctionProperties.subDict(typeName + "Coeffs")
73  ),
74  shift1_(doubleSigmoidCoeffs_.template lookup<scalar>("shift1")),
75  scale1_(doubleSigmoidCoeffs_.template lookup<scalar>("scale1")),
76  shift2_(doubleSigmoidCoeffs_.template lookup<scalar>("shift2")),
77  scale2_(doubleSigmoidCoeffs_.template lookup<scalar>("scale2"))
78 {}
79 
80 
81 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
82 
83 void doubleSigmoid::scaleEnergy(scalar& e, const scalar r) const
84 {
85  e *= sigmoidScale(r, shift1_, scale1_) * sigmoidScale(r, shift2_, scale2_);
86 }
87 
88 
89 bool doubleSigmoid::read(const dictionary& energyScalingFunctionProperties)
90 {
91  energyScalingFunction::read(energyScalingFunctionProperties);
92 
93  doubleSigmoidCoeffs_ =
94  energyScalingFunctionProperties.subDict(typeName + "Coeffs");
95 
96  doubleSigmoidCoeffs_.lookup("shift1") >> shift1_;
97  doubleSigmoidCoeffs_.lookup("scale1") >> scale1_;
98  doubleSigmoidCoeffs_.lookup("shift2") >> shift2_;
99  doubleSigmoidCoeffs_.lookup("scale2") >> scale2_;
100 
101  return true;
102 }
103 
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace energyScalingFunctions
108 } // End namespace Foam
109 
110 // ************************************************************************* //
void scaleEnergy(scalar &e, const scalar r) const
Definition: doubleSigmoid.C:83
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
defineTypeNameAndDebug(doubleSigmoid, 0)
Macros for easy insertion into run-time selection tables.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:982
dimensionedScalar exp(const dimensionedScalar &ds)
bool read(const dictionary &energyScalingFunctionProperties)
Read dictionary.
Definition: doubleSigmoid.C:89
A class for handling words, derived from string.
Definition: word.H:59
energyScalingFunction(const word &name, const dictionary &energyScalingFunctionProperties, const pairPotential &pairPot)
Construct from components.
addToRunTimeSelectionTable(energyScalingFunction, doubleSigmoid, dictionary)
virtual bool read(const dictionary &energyScalingFunctionProperties)=0
Read energyScalingFunction dictionary.
doubleSigmoid(const word &name, const dictionary &energyScalingFunctionProperties, const pairPotential &pairPot)
Construct from components.
Definition: doubleSigmoid.C:63
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844