8 #ifndef IMPMISC_WORM_LIKE_CHAIN_H
9 #define IMPMISC_WORM_LIKE_CHAIN_H
11 #include <IMP/misc/misc_config.h>
13 #include <IMP/internal/constants.h>
14 #include <IMP/internal/units.h>
16 IMPMISC_BEGIN_NAMESPACE
36 <<
"than the total length for this model");
39 virtual DerivativePair evaluate_with_derivative(
double feature)
const;
41 virtual double evaluate(
double feature)
const;
45 void do_show(std::ostream &out)
const;
48 unit::Piconewton cderiv(unit::Angstrom l)
const {
49 unit::Piconewton pn= IMP::internal::KB*IMP::internal::DEFAULT_TEMPERATURE
50 /lp_*(.25/ square(1.0-(l/lmax_))
55 unit::Picojoule eval(unit::Angstrom m)
const {
58 IMP::internal::DEFAULT_TEMPERATURE/lp_*(.25*square(lmax_)
66 unit::Angstrom cutoff()
const {
70 unit::Angstrom lmax_, lp_;
74 inline double WormLikeChain::evaluate(
double v)
const {
75 return evaluate_with_derivative(v).first;
78 inline DerivativePair WormLikeChain::evaluate_with_derivative(
double v)
const {
79 static const unit::Picojoule zero=eval(unit::Angstrom(0));
81 if (l < unit::Angstrom(0)) l=unit::Angstrom(0);
84 unit::Piconewton doubled;
86 ret= (eval(l) - zero);
89 unit::Picojoule springterm=(l-cutoff())*cderiv(cutoff());
90 ret= (eval(cutoff())+ springterm -zero);
91 doubled= cderiv(cutoff());
93 <<
" " << l <<
" " << lmax_ <<
" " << cutoff()
96 unit::YoctoKilocalorie zc= convert_J_to_Cal(ret);
97 double value=(zc*unit::ATOMS_PER_MOL).get_value();
100 unit::YoctoKilocaloriePerAngstrom du= unit::convert_J_to_Cal(doubled);
102 double deriv = (du*unit::ATOMS_PER_MOL).get_value();
104 return std::make_pair(value, deriv);
107 inline void WormLikeChain::do_show(std::ostream &out)
const {
108 out <<
"params " << lmax_ <<
" " << lp_ << std::endl;
112 IMPMISC_END_NAMESPACE