Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarmonicFunc.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/core/scoring/constraints/HarmonicFunc.hh
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author James Thompson
13 
14 
16 
17 #include <core/types.hh>
18 
19 #include <utility/pointer/ReferenceCount.hh>
20 
21 // AUTO-REMOVED #include <numeric/angle.functions.hh>
22 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
23 // AUTO-REMOVED #include <basic/Tracer.hh>
24 
25 #include <sstream>
26 
27 
28 // C++ Headers
29 
30 
31 namespace core {
32 namespace scoring {
33 namespace constraints {
34 
35 FuncOP
37 {
38  return new HarmonicFunc( x0_, sd_ );
39 }
40 
41 Real
42 HarmonicFunc::func( Real const x ) const
43 {
44  Real const z = ( x-x0_ )/sd_;
45  return z * z;
46 }
47 
48 Real
49 HarmonicFunc::dfunc( Real const x ) const
50 {
51  return 2 * (x-x0_) / ( sd_ * sd_ );
52 }
53 
54 void
55 HarmonicFunc::read_data( std::istream& in ) {
56  in >> x0_ >> sd_;
57 }
58 
59 void
60 HarmonicFunc::show_definition( std::ostream &out ) const {
61  out << "HARMONIC " << x0_ << " " << sd_ << std::endl;
62 }
63 
64 Size
65 HarmonicFunc::show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold) const {
66  if (verbose_level > 100 ) {
67  out << "HARM " << ( x - x0_ )/sd_ << std::endl;
68  } else if (verbose_level > 70 ) {
69  if ( x < x0_ && ( this->func(x) > threshold ) ) out << "-";
70  else if ( x > x0_ && ( this->func(x) > threshold )) out << "+";
71  else out << ".";
72  }
73  return Func::show_violations( out, x, verbose_level, threshold);
74 }
75 
76 } // namespace constraints
77 } // namespace scoring
78 } // namespace core
79