8 #ifndef IMPMISC_WORM_LIKE_CHAIN_H
9 #define IMPMISC_WORM_LIKE_CHAIN_H
11 #include <IMP/misc/misc_config.h>
13 #include <IMP/kernel/internal/constants.h>
14 #include <IMP/kernel/internal/units.h>
16 IMPMISC_BEGIN_NAMESPACE
35 <<
"than the total length for this model");
38 virtual DerivativePair evaluate_with_derivative(
double feature)
const;
40 virtual double evaluate(
double feature)
const;
44 void do_show(std::ostream &out)
const;
47 unit::Piconewton cderiv(unit::Angstrom l)
const {
48 unit::Piconewton pn = IMP::internal::KB *
49 IMP::internal::DEFAULT_TEMPERATURE / lp_ *
50 (.25 / square(1.0 - (l / lmax_)) - .25 + (l / lmax_));
54 unit::Picojoule eval(unit::Angstrom m)
const {
56 IMP::internal::KB * IMP::internal::DEFAULT_TEMPERATURE / lp_ *
57 (.25 * square(lmax_) / (lmax_ - m) - m * .25 + .5 * square(m) / lmax_);
61 unit::Angstrom cutoff()
const {
return .99 * lmax_; }
63 unit::Angstrom lmax_, lp_;
67 inline double WormLikeChain::evaluate(
double v)
const {
68 return evaluate_with_derivative(v).first;
71 inline DerivativePair WormLikeChain::evaluate_with_derivative(
double v)
const {
72 static const unit::Picojoule zero = eval(unit::Angstrom(0));
74 if (l < unit::Angstrom(0)) l = unit::Angstrom(0);
77 unit::Piconewton doubled;
79 ret = (eval(l) - zero);
82 unit::Picojoule springterm = (l - cutoff()) * cderiv(cutoff());
83 ret = (eval(cutoff()) + springterm - zero);
84 doubled = cderiv(cutoff());
86 <<
" " << l <<
" " << lmax_ <<
" "
87 << cutoff() << std::endl);
89 unit::YoctoKilocalorie zc = convert_J_to_Cal(ret);
90 double value = (zc * unit::ATOMS_PER_MOL).get_value();
93 unit::YoctoKilocaloriePerAngstrom du = unit::convert_J_to_Cal(doubled);
95 double deriv = (du * unit::ATOMS_PER_MOL).get_value();
97 return std::make_pair(value, deriv);
100 inline void WormLikeChain::do_show(std::ostream &out)
const {
101 out <<
"params " << lmax_ <<
" " << lp_ << std::endl;
105 IMPMISC_END_NAMESPACE
Import IMP/kernel/UnaryFunction.h in the namespace.
Abstract single variable functor class for score functions.
WormLikeChain(Float l_max, Float lp)
Define the energy term.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Worm-like-chain energy for polymer chains.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
double Float
Basic floating-point value (could be float, double...)
#define IMP_LOG_VERBOSE(expr)