Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plumed AlphaFold
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Kurečka
Plumed AlphaFold
Commits
33a1f03a
There was an error fetching the commit references. Please try again later.
Commit
33a1f03a
authored
13 years ago
by
Giovanni Bussi
Browse files
Options
Downloads
Patches
Plain Diff
Missing file sorry!
parent
3836349e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/SwitchingFunction.h
+77
-0
77 additions, 0 deletions
src/SwitchingFunction.h
with
77 additions
and
0 deletions
src/SwitchingFunction.h
0 → 100644
+
77
−
0
View file @
33a1f03a
#ifndef __PLUMED_SwitchingFunction_h
#define __PLUMED_SwitchingFunction_h
#include
<cassert>
#include
<cmath>
namespace
PLMD
{
/// Small class to compure switching functions.
/// In the future we might extend it so as to be set using
/// a string:
/// void set(std::string);
/// which can then be parsed for more complex stuff, e.g. exponentials
/// tabulated functions from file, matheval, etc...
class
SwitchingFunction
{
bool
init
;
int
nn
,
mm
;
double
r_0
,
d_0
;
double
epsilon
;
double
threshold
;
public:
SwitchingFunction
();
void
set
(
int
nn
,
int
mm
,
double
r_0
,
double
d_0
);
double
calculate
(
double
x
,
double
&
df
)
const
;
};
inline
SwitchingFunction
::
SwitchingFunction
()
:
init
(
false
){
}
inline
void
SwitchingFunction
::
set
(
int
nn
,
int
mm
,
double
r_0
,
double
d_0
){
init
=
true
;
this
->
nn
=
nn
;
this
->
mm
=
mm
;
this
->
r_0
=
r_0
;
this
->
d_0
=
d_0
;
epsilon
=
1e-10
;
threshold
=
pow
(
0.00001
,
1.
/
(
nn
-
mm
));
}
inline
double
SwitchingFunction
::
calculate
(
double
distance
,
double
&
dfunc
)
const
{
assert
(
init
);
const
double
rdist
=
(
distance
-
d_0
)
/
r_0
;
double
result
=
0.
;
if
(
rdist
<=
0.
){
result
+=
1.
;
dfunc
=
0.
;
}
else
if
(
rdist
>
(
1.
-
epsilon
)
&&
rdist
<
(
1
+
epsilon
)){
result
+=
nn
/
mm
;
dfunc
=
0.5
*
nn
*
(
nn
-
mm
)
/
mm
;
}
else
if
(
rdist
>
threshold
){
dfunc
=
0.
;
}
else
{
double
rNdist
=
rdist
;
double
rMdist
=
rdist
;
// this is a naive optimization
// we probably have to implement some generic, fast pow(double,int)
if
(
nn
>
2
)
for
(
int
i
=
0
;
i
<
nn
-
2
;
i
++
)
rNdist
*=
rdist
;
else
rNdist
=
pow
(
rdist
,
nn
-
1
);
if
(
mm
>
2
)
for
(
int
i
=
0
;
i
<
mm
-
2
;
i
++
)
rMdist
*=
rdist
;
else
rMdist
=
pow
(
rdist
,
mm
-
1
);
double
num
=
1.
-
rNdist
*
rdist
;
double
iden
=
1.
/
(
1.
-
rMdist
*
rdist
);
double
func
=
num
*
iden
;
result
+=
func
;
dfunc
=
((
-
nn
*
rNdist
*
iden
)
+
(
func
*
(
iden
*
mm
)
*
rMdist
))
/
(
distance
*
r_0
);
}
return
result
;
}
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment