Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xray_scattering.hh
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
11 /// @brief
12 /// @author
13 
14 #ifndef INCLUDED_core_scoring_electron_density_xray_scattering_hh
15 #define INCLUDED_core_scoring_electron_density_xray_scattering_hh
16 
17 #include <core/types.hh>
18 
19 #include <cmath>
20 #include <string>
21 
22 
23 #ifdef WIN32
24 
25  #define _USE_MATH_DEFINES
26 
27  #include <math.h>
28 
29 #endif
30 
31 
32 // C++ Headers
33 
34 namespace core {
35 namespace scoring {
36 namespace electron_density {
37 
38 
39 ////////////
40 // 4-gaussian approximation of scattering coefficients
41 class KromerMann {
42 public:
44  a_[0] = a_[1] = a_[2] = a_[3] = 0;
45  b_[0] = b_[1] = b_[2] = b_[3] = 0;
46  c_ = 0;
47  }
48  KromerMann(float c, float a1, float a2, float a3, float a4, float b1, float b2, float b3, float b4) {
49  a_[0] = a1; a_[1] = a2; a_[2] = a3; a_[3] = a4;
50  b_[0] = b1; b_[1] = b2; b_[2] = b3; b_[3] = b4;
51  c_ = c;
52  }
53 
54  // scattering at reciprocal space distance^2
55  inline core::Real f0( core::Real S2 ) {
56  return (c_ + a_[0]*exp(b_[0]*S2/4) + a_[1]*exp(b_[1]*S2/4) + a_[2]*exp(b_[2]*S2/4) + a_[3]*exp(b_[3]*S2/4) );
57  }
58 
59 private:
60  float a_[4];
61  float b_[4];
62  float c_;
63 };
64 
65 ////////////
66 // 1-gaussian real-space approximate scattering
68 public:
70  weight_ = 0;
71  sigma_ = 3.0;
72  }
73  OneGaussianScattering(int w, float s) {
74  sigma_ = s;
75  weight_ = w;
76  }
77 
78  // rho = C*exp(-k*X^2)
79  inline core::Real k( core::Real B, core::Real min_grid ) const {
80  // s <= real-space sigma
81  // sig = sig+B/4; % conv by B
82  // sig = max( sig, (reso).^2 ); % res limit
83  // D2 = (x-atom).^2;
84  // rho_c_alt2(ele,:) = grid * ele * sqrt(pi/sig) * exp(-(pi^2/sig).*D2);
85  core::Real s = std::max( sigma_ + B/4 , 4*(min_grid*min_grid) ) ;
86  return ( M_PI*M_PI/s );
87  }
88 
89  // rho = C*exp(-k*X^2)
90  // get scale factor, given k
91  inline core::Real C( core::Real k ) const {
92  core::Real C = pow(k, 1.5);
93  return ( C*weight_ );
94  }
95 
96  inline int a( ) const {
97  return ( weight_ );
98  }
99 
100 private:
101  float sigma_;
102  int weight_;
103 };
104 
105 
106 ////////////
107 // Precomputed scattering
108 // fpd -- doesn't seem to make calculation much faster
109 //
110 // class AtomScattering {
111 // public:
112 // AtomScattering();
113 //
114 // // mask scattering
115 // AtomScattering( core::Real mask, core::Real reso );
116 //
117 // // atom scattering (single gaussian)
118 // AtomScattering( core::Real a, core::Real B, core::Real mask, core::Real reso );
119 //
120 // // TODO: atom scattering (crystallographic form-factors)
121 // //AtomScattering( KromerMann f0, core::Real mask, core::Real reso );
122 //
123 // // interp at a Cartesian point X
124 // core::Real interp_linear( numeric::xyzVector< core::Real > const & X ) const;
125 //
126 // private:
127 // // common initialization
128 // void init( core::Real mask, core::Real reso );
129 //
130 // ObjexxFCL::FArray3D< double > data;
131 // numeric::xyzVector< core::Real > c2i, i2c; // always construct orthogonal
132 // numeric::xyzVector< core::Size > grid;
133 // core::Real reso;
134 // };
135 
136 
137 // weight from scattering factors
139 
140 // weight from scattering factors
142 
143 // precomputed scattering
144 //const AtomScattering & get_scattering( std::string elt );
145 
146 bool factorsLTE5(int X);
147 bool factorsLTE19(int X);
148 int findSampling(double MINSMP, int NMUL);
149 int findSampling5(double MINSMP, int NMUL);
150 
151 }
152 }
153 }
154 
155 #endif