Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.5new_solver
      Class Index
      File List
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
trajectorydiagnostics.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2012 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef TRAJECTORYDIAGNOSTICS_HPP
44 #define TRAJECTORYDIAGNOSTICS_HPP 1
45 
46 
47 #include <vector>
48 #include <limits>
49 #include "histogram.hpp"
50 #include "types.hpp"
51 
52 
62 {
63 
65  std::vector<double> _data;
67 public:
68 
72  : _diag(diag) {}
73 
81  void mirror( coordinate_axis_e axis, double level );
82 
85  void add_data( double x ) {
86  _data.push_back( x );
87  }
88 
91  std::vector<double> &data( void ) { return( _data ); }
92 
95  const std::vector<double> &data( void ) const { return( _data ); }
96 
99  size_t size( void ) const { return( _data.size() ); }
100 
103  trajectory_diagnostic_e diagnostic( void ) const { return( _diag ); }
104 
107  const double &operator()( size_t i ) const { return( _data[i] ); }
108 
111  double &operator()( size_t i ) { return( _data[i] ); }
112 
115  const double &operator[]( size_t i ) const { return( _data[i] ); }
116 
119  double &operator[]( size_t i ) { return( _data[i] ); }
120 };
121 
122 
128 {
129 
130  std::vector<TrajectoryDiagnosticColumn> _column;
132 public:
133 
137 
140  TrajectoryDiagnosticData( std::vector<trajectory_diagnostic_e> diag ) {
141  for( size_t a = 0; a < diag.size(); a++ )
142  _column.push_back( TrajectoryDiagnosticColumn( diag[a] ) );
143  }
144 
147  void mirror( coordinate_axis_e axis, double level ) {
148  for( size_t a = 0; a < _column.size(); a++ )
149  _column[a].mirror( axis, level );
150  }
151 
154  void clear() {
155  _column.clear();
156  }
157 
161  _column.push_back( TrajectoryDiagnosticColumn( diag ) );
162  }
163 
166  size_t diag_size() const {
167  return( _column.size() );
168  }
169 
172  size_t traj_size() const {
173  if( _column.size() > 0 )
174  return( _column[0].size() );
175  return( 0 );
176  }
177 
181  return( _column[i].diagnostic() );
182  }
183 
186  const TrajectoryDiagnosticColumn &operator()( size_t i ) const {
187  return( _column[i] );
188  }
189 
193  return( _column[i] );
194  }
195 
199  const double &operator()( size_t j, size_t i ) const {
200  return( _column[i](j) );
201  }
202 
206  double &operator()( size_t j, size_t i ) {
207  return( _column[i](j) );
208  }
209 
212  void add_data( size_t i, double x ) {
213  _column[i].add_data( x );
214  }
215 
218  void export_data( const std::string &filename );
219 };
220 
221 
242 {
243 protected:
244 
245  double _Isum;
246 
247  double _xave;
248  double _xpave;
249 
250  double _x2;
251  double _xp2;
252  double _xxp;
253 
254  double _alpha;
255  double _beta;
256  double _gamma;
257  double _epsilon;
258 
259  double _angle;
260  double _rmajor;
261  double _rminor;
262 
263 public:
264 
267  Emittance();
268 
272  Emittance( const std::vector<double> &x,
273  const std::vector<double> &xp,
274  const std::vector<double> &I );
275 
279  Emittance( const std::vector<double> &x,
280  const std::vector<double> &xp );
281 
291  Emittance( size_t xsize, size_t xpsize, const double range[4],
292  const std::vector<double> &I );
293 
296  double xave( void ) const { return( _xave ); }
297 
300  double xpave( void ) const { return( _xpave ); }
301 
304  double alpha( void ) const { return( _alpha ); }
305 
308  double beta( void ) const { return( _beta ); }
309 
312  double gamma( void ) const { return( _gamma ); }
313 
316  double epsilon( void ) const { return( _epsilon ); }
317 
320  double angle( void ) const { return( _angle ); }
321 
324  double rmajor( void ) const { return( _rmajor ); }
325 
328  double rminor( void ) const { return( _rminor ); }
329 
332  void debug_print( std::ostream &os ) const;
333 };
334 
335 
336 
339 class EmittanceConv : public Emittance
340 {
341 
342  Histogram2D *_grid;
343 
344 public:
345 
363  EmittanceConv( uint32_t n, uint32_t m,
364  const std::vector<double> &r,
365  const std::vector<double> &rp,
366  const std::vector<double> &ap,
367  const std::vector<double> &I,
368  uint32_t rotn = 100,
369  double xmin = std::numeric_limits<double>::quiet_NaN(),
370  double xpmin = std::numeric_limits<double>::quiet_NaN(),
371  double xmax = std::numeric_limits<double>::quiet_NaN(),
372  double xpmax = std::numeric_limits<double>::quiet_NaN() );
373 
376  ~EmittanceConv();
377 
380  const Histogram2D &histogram( void ) const { return( *_grid ); }
381 
384  void free_histogram( void ) { delete _grid; _grid = NULL; }
385 };
386 
387 
388 #endif
double xave(void) const
Return average position (center location) of emittance distribution.
Definition: trajectorydiagnostics.hpp:296
trajectory_diagnostic_e
Type of diagnostic for trajectories.
Definition: types.hpp:196
TrajectoryDiagnosticData()
Create new empty diagnostic data object.
Definition: trajectorydiagnostics.hpp:136
size_t size(void) const
Get size of diagnostic data vector.
Definition: trajectorydiagnostics.hpp:99
double epsilon(void) const
Return rms emittance.
Definition: trajectorydiagnostics.hpp:316
void mirror(coordinate_axis_e axis, double level)
Mirror data columns along plane at axis = level.
Definition: trajectorydiagnostics.hpp:147
Histogram data handling for 1D and 2D
double beta(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:308
Class for trajectory diagnostic data column.
Definition: trajectorydiagnostics.hpp:61
void clear()
Clear all data and diagnostic types.
Definition: trajectorydiagnostics.hpp:154
trajectory_diagnostic_e diagnostic(void) const
Get diagnostic type.
Definition: trajectorydiagnostics.hpp:103
void free_histogram(void)
Free emittance histogram.
Definition: trajectorydiagnostics.hpp:384
Base types.
void add_data(size_t i, double x)
Add data point to i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:212
void mirror(coordinate_axis_e axis, double level)
Add mirrored trajectory diagnostic data to the column.
Definition: trajectorydiagnostics.cpp:59
Emittance()
Default constructor for emittance statistics.
Definition: trajectorydiagnostics.cpp:140
size_t diag_size() const
Return number of data columns.
Definition: trajectorydiagnostics.hpp:166
Class for emittance statistics.
Definition: trajectorydiagnostics.hpp:241
void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: trajectorydiagnostics.cpp:342
Class for trajectory diagnostic data.
Definition: trajectorydiagnostics.hpp:127
const double & operator()(size_t j, size_t i) const
Return const reference to j:th trajectory data in i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:199
double rminor(void) const
Return minor radius of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:328
std::vector< double > & data(void)
Get a reference to diagnostic data vector.
Definition: trajectorydiagnostics.hpp:91
TrajectoryDiagnosticData(std::vector< trajectory_diagnostic_e > diag)
Create diagnostic data object with diagnostic types defined in vector diag.
Definition: trajectorydiagnostics.hpp:140
size_t traj_size() const
Return number of trajectories in data.
Definition: trajectorydiagnostics.hpp:172
void add_data(double x)
Add diagnostic data point to column.
Definition: trajectorydiagnostics.hpp:85
void add_data_column(trajectory_diagnostic_e diag)
Add data column with type diag.
Definition: trajectorydiagnostics.hpp:160
double xpave(void) const
Return average angle (center location) of emittance distribution.
Definition: trajectorydiagnostics.hpp:300
double & operator[](size_t i)
Get reference to data element i.
Definition: trajectorydiagnostics.hpp:119
Class for 2d histogram type representation of data.
Definition: histogram.hpp:216
double gamma(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:312
coordinate_axis_e
Coordinate axis identifier.
Definition: types.hpp:170
double angle(void) const
Return angle of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:320
double alpha(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:304
Class for emittance conversion from (r,r&#39;) to (x,x&#39;).
Definition: trajectorydiagnostics.hpp:339
void export_data(const std::string &filename)
Export trajectory data as ASCII.
Definition: trajectorydiagnostics.cpp:108
const double & operator()(size_t i) const
Get const reference to data element i.
Definition: trajectorydiagnostics.hpp:107
const double & operator[](size_t i) const
Get const reference to data element i.
Definition: trajectorydiagnostics.hpp:115
const TrajectoryDiagnosticColumn & operator()(size_t i) const
Return i:th diagnostic type.
Definition: trajectorydiagnostics.hpp:186
~EmittanceConv()
Destructor for emittance converter.
Definition: trajectorydiagnostics.cpp:694
trajectory_diagnostic_e diagnostic(size_t i) const
Return i:th diagnostic type.
Definition: trajectorydiagnostics.hpp:180
const Histogram2D & histogram(void) const
Get a const reference to histogram built.
Definition: trajectorydiagnostics.hpp:380
const std::vector< double > & data(void) const
Get a const reference to diagnostic data vector.
Definition: trajectorydiagnostics.hpp:95
TrajectoryDiagnosticColumn & operator()(size_t i)
Return i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:192
EmittanceConv(uint32_t n, uint32_t m, const std::vector< double > &r, const std::vector< double > &rp, const std::vector< double > &ap, const std::vector< double > &I, uint32_t rotn=100, double xmin=std::numeric_limits< double >::quiet_NaN(), double xpmin=std::numeric_limits< double >::quiet_NaN(), double xmax=std::numeric_limits< double >::quiet_NaN(), double xpmax=std::numeric_limits< double >::quiet_NaN())
Constructor for (x,x&#39;) emittance data and statistics from (r,r&#39;) data.
Definition: trajectorydiagnostics.cpp:378
double rmajor(void) const
Return major radius of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:324
double & operator()(size_t j, size_t i)
Return reference to j:th trajectory data in i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:206
double & operator()(size_t i)
Get reference to data element i.
Definition: trajectorydiagnostics.hpp:111
TrajectoryDiagnosticColumn(trajectory_diagnostic_e diag)
Create new diagnostic data column with type diag.
Definition: trajectorydiagnostics.hpp:71


Reference manual for Ion Beam Simulator 1.0.5new_solver
Generated by Doxygen 1.8.5 on Tue May 19 2015 09:15:42.