Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   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,2016,2021 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 "error.hpp"
50 #include "histogram.hpp"
51 #include "types.hpp"
52 
53 
63 {
64 
66  std::vector<double> _data;
68 public:
69 
73  : _diag(diag) {}
74 
82  void mirror( coordinate_axis_e axis, double level );
83 
86  void add_data( double x ) {
87  _data.push_back( x );
88  }
89 
92  std::vector<double> &data( void ) { return( _data ); }
93 
96  const std::vector<double> &data( void ) const { return( _data ); }
97 
100  size_t size( void ) const { return( _data.size() ); }
101 
104  trajectory_diagnostic_e diagnostic( void ) const { return( _diag ); }
105 
108  const double &operator()( size_t i ) const { return( _data[i] ); }
109 
112  double &operator()( size_t i ) { return( _data[i] ); }
113 
116  const double &operator[]( size_t i ) const { return( _data[i] ); }
117 
120  double &operator[]( size_t i ) { return( _data[i] ); }
121 };
122 
123 
129 {
130 
131  std::vector<TrajectoryDiagnosticColumn> _column;
133 public:
134 
138 
141  TrajectoryDiagnosticData( std::vector<trajectory_diagnostic_e> diag ) {
142  for( size_t a = 0; a < diag.size(); a++ )
143  _column.push_back( TrajectoryDiagnosticColumn( diag[a] ) );
144  }
145 
148  void mirror( coordinate_axis_e axis, double level ) {
149  for( size_t a = 0; a < _column.size(); a++ )
150  _column[a].mirror( axis, level );
151  }
152 
155  void clear() {
156  _column.clear();
157  }
158 
162  _column.push_back( TrajectoryDiagnosticColumn( diag ) );
163  }
164 
167  size_t diag_size() const {
168  return( _column.size() );
169  }
170 
173  size_t traj_size() const {
174  if( _column.size() > 0 )
175  return( _column[0].size() );
176  return( 0 );
177  }
178 
182  return( _column[i].diagnostic() );
183  }
184 
187  const TrajectoryDiagnosticColumn &operator()( size_t i ) const {
188  if( i >= _column.size() )
189  throw( ErrorRange( ERROR_LOCATION, i, _column.size() ) );
190  return( _column[i] );
191  }
192 
196  if( i >= _column.size() )
197  throw( ErrorRange( ERROR_LOCATION, i, _column.size() ) );
198  return( _column[i] );
199  }
200 
204  const double &operator()( size_t j, size_t i ) const {
205  if( i >= _column.size() )
206  throw( ErrorRange( ERROR_LOCATION, i, _column.size() ) );
207  return( _column[i](j) );
208  }
209 
213  double &operator()( size_t j, size_t i ) {
214  if( i >= _column.size() )
215  throw( ErrorRange( ERROR_LOCATION, i, _column.size() ) );
216  return( _column[i](j) );
217  }
218 
221  void add_data( size_t i, double x ) {
222  _column[i].add_data( x );
223  }
224 
227  void export_data( const std::string &filename );
228 };
229 
230 
251 {
252 protected:
253 
254  double _Isum;
255 
256  double _xave;
257  double _xpave;
258 
259  double _x2;
260  double _xp2;
261  double _xxp;
262 
263  double _alpha;
264  double _beta;
265  double _gamma;
266  double _epsilon;
267 
268  double _angle;
269  double _rmajor;
270  double _rminor;
271 
272 public:
273 
276  Emittance();
277 
281  Emittance( const std::vector<double> &x,
282  const std::vector<double> &xp,
283  const std::vector<double> &I );
284 
288  Emittance( const std::vector<double> &x,
289  const std::vector<double> &xp );
290 
300  Emittance( size_t xsize, size_t xpsize, const double range[4],
301  const std::vector<double> &I );
302 
309  double current( void ) const { return( _Isum ); }
310 
313  double xave( void ) const { return( _xave ); }
314 
317  double xpave( void ) const { return( _xpave ); }
318 
321  double alpha( void ) const { return( _alpha ); }
322 
325  double beta( void ) const { return( _beta ); }
326 
329  double gamma( void ) const { return( _gamma ); }
330 
333  double epsilon( void ) const { return( _epsilon ); }
334 
337  double angle( void ) const { return( _angle ); }
338 
341  double rmajor( void ) const { return( _rmajor ); }
342 
345  double rminor( void ) const { return( _rminor ); }
346 
349  void debug_print( std::ostream &os ) const;
350 };
351 
352 
353 
356 class EmittanceConv : public Emittance
357 {
358 
359  Histogram2D *_grid;
360 
361 public:
362 
380  EmittanceConv( uint32_t n, uint32_t m,
381  const std::vector<double> &r,
382  const std::vector<double> &rp,
383  const std::vector<double> &ap,
384  const std::vector<double> &I,
385  uint32_t rotn = 100,
386  double xmin = std::numeric_limits<double>::quiet_NaN(),
387  double xpmin = std::numeric_limits<double>::quiet_NaN(),
388  double xmax = std::numeric_limits<double>::quiet_NaN(),
389  double xpmax = std::numeric_limits<double>::quiet_NaN() );
390 
393  ~EmittanceConv();
394 
397  const Histogram2D &histogram( void ) const { return( *_grid ); }
398 
401  void free_histogram( void ) { delete _grid; _grid = NULL; }
402 };
403 
404 
405 #endif
Class for emittance conversion from (r,r') to (x,x').
Definition: trajectorydiagnostics.hpp:357
const Histogram2D & histogram(void) const
Get a const reference to histogram built.
Definition: trajectorydiagnostics.hpp:397
void free_histogram(void)
Free emittance histogram.
Definition: trajectorydiagnostics.hpp:401
~EmittanceConv()
Destructor for emittance converter.
Definition: trajectorydiagnostics.cpp:694
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') emittance data and statistics from (r,r') data.
Definition: trajectorydiagnostics.cpp:378
Class for emittance statistics.
Definition: trajectorydiagnostics.hpp:251
double alpha(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:321
double epsilon(void) const
Return rms emittance.
Definition: trajectorydiagnostics.hpp:333
double current(void) const
Return current of beam trajectories used to calculate the emittance.
Definition: trajectorydiagnostics.hpp:309
double gamma(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:329
double xave(void) const
Return average position (center location) of emittance distribution.
Definition: trajectorydiagnostics.hpp:313
Emittance()
Default constructor for emittance statistics.
Definition: trajectorydiagnostics.cpp:140
double angle(void) const
Return angle of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:337
double rminor(void) const
Return minor radius of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:345
double beta(void) const
Return of emittance distribution.
Definition: trajectorydiagnostics.hpp:325
double rmajor(void) const
Return major radius of fitted rms ellipse.
Definition: trajectorydiagnostics.hpp:341
void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: trajectorydiagnostics.cpp:342
double xpave(void) const
Return average angle (center location) of emittance distribution.
Definition: trajectorydiagnostics.hpp:317
Error class for index range checking errors.
Definition: error.hpp:283
Class for 2d histogram type representation of data.
Definition: histogram.hpp:217
Class for trajectory diagnostic data column.
Definition: trajectorydiagnostics.hpp:63
TrajectoryDiagnosticColumn(trajectory_diagnostic_e diag)
Create new diagnostic data column with type diag.
Definition: trajectorydiagnostics.hpp:72
double & operator()(size_t i)
Get reference to data element i.
Definition: trajectorydiagnostics.hpp:112
void add_data(double x)
Add diagnostic data point to column.
Definition: trajectorydiagnostics.hpp:86
const double & operator()(size_t i) const
Get const reference to data element i.
Definition: trajectorydiagnostics.hpp:108
size_t size(void) const
Get size of diagnostic data vector.
Definition: trajectorydiagnostics.hpp:100
double & operator[](size_t i)
Get reference to data element i.
Definition: trajectorydiagnostics.hpp:120
std::vector< double > & data(void)
Get a reference to diagnostic data vector.
Definition: trajectorydiagnostics.hpp:92
void mirror(coordinate_axis_e axis, double level)
Add mirrored trajectory diagnostic data to the column.
Definition: trajectorydiagnostics.cpp:59
const double & operator[](size_t i) const
Get const reference to data element i.
Definition: trajectorydiagnostics.hpp:116
trajectory_diagnostic_e diagnostic(void) const
Get diagnostic type.
Definition: trajectorydiagnostics.hpp:104
const std::vector< double > & data(void) const
Get a const reference to diagnostic data vector.
Definition: trajectorydiagnostics.hpp:96
Class for trajectory diagnostic data.
Definition: trajectorydiagnostics.hpp:129
void add_data(size_t i, double x)
Add data point to i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:221
void clear()
Clear all data and diagnostic types.
Definition: trajectorydiagnostics.hpp:155
void export_data(const std::string &filename)
Export trajectory data as ASCII.
Definition: trajectorydiagnostics.cpp:108
double & operator()(size_t j, size_t i)
Return reference to j:th trajectory data in i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:213
size_t traj_size() const
Return number of trajectories in data.
Definition: trajectorydiagnostics.hpp:173
trajectory_diagnostic_e diagnostic(size_t i) const
Return i:th diagnostic type.
Definition: trajectorydiagnostics.hpp:181
void mirror(coordinate_axis_e axis, double level)
Mirror data columns along plane at axis = level.
Definition: trajectorydiagnostics.hpp:148
TrajectoryDiagnosticData()
Create new empty diagnostic data object.
Definition: trajectorydiagnostics.hpp:137
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:204
void add_data_column(trajectory_diagnostic_e diag)
Add data column with type diag.
Definition: trajectorydiagnostics.hpp:161
const TrajectoryDiagnosticColumn & operator()(size_t i) const
Return i:th diagnostic type.
Definition: trajectorydiagnostics.hpp:187
TrajectoryDiagnosticData(std::vector< trajectory_diagnostic_e > diag)
Create diagnostic data object with diagnostic types defined in vector diag.
Definition: trajectorydiagnostics.hpp:141
size_t diag_size() const
Return number of data columns.
Definition: trajectorydiagnostics.hpp:167
TrajectoryDiagnosticColumn & operator()(size_t i)
Return i:th diagnostic column.
Definition: trajectorydiagnostics.hpp:195
Error classes and handling
#define ERROR_LOCATION
Macro for setting error location when throwing errors.
Definition: error.hpp:83
Histogram data handling for 1D and 2D
Base types.
coordinate_axis_e
Coordinate axis identifier.
Definition: types.hpp:170
trajectory_diagnostic_e
Type of diagnostic for trajectories.
Definition: types.hpp:196


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.