~max-mcginley/third-order-lie-map/generator

« back to all changes in this revision

Viewing changes to particle_generation.hh

  • Committer: Max McGinley
  • Date: 2015-08-18 17:13:46 UTC
  • Revision ID: max.mcginley@stfc.ac.uk-20150818171346-ou729otm1b9zmnvo
RK4 method added to integrated interaction 4th order hamiltonian. Relative error around 5e-4 for 10mm x,y and 1Mev px, py. Added missing global and particle generation header files. 2 lattices uploaded for use in tests etc. Documentation to follow.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
static const int plotNumberOfParticles = 33;
 
2
 
 
3
static const double coordVec[8][4] = {{1,0,0,0},{0.70711,0.70711,0,0},{0,1,0,0},{-0.70711,0.70711,0,0},{-1,0,0,0},{-0.70711,-0.70711,0,0},{0,-1,0,0},{0.70711,-0.70711,0,0}};
 
4
 
 
5
double** getInitialCoordinates(double scale = 1.0) {
 
6
        double** particles = new double*[plotNumberOfParticles];
 
7
        for (int i = 0; i < plotNumberOfParticles; i++) {
 
8
                particles[i] = new double[4];
 
9
        }
 
10
        particles[0][0] = 0.;
 
11
        particles[0][1] = 0.;
 
12
        particles[0][2] = 0.;
 
13
        particles[0][3] = 0.;
 
14
        for (int i = 0; i < (plotNumberOfParticles-1)/8; i++) {
 
15
                for (int j = 0; j < 8; j++) {
 
16
                        particles[i*8 + j + 1][0] = coordVec[j][0]*(i+1)*posScale*scale;
 
17
                        particles[i*8 + j + 1][1] = coordVec[j][1]*(i+1)*posScale*scale;
 
18
                        particles[i*8 + j + 1][2] = coordVec[j][2]*(i+1)*momScale*scale;
 
19
                        particles[i*8 + j + 1][3] = coordVec[j][3]*(i+1)*momScale*scale;
 
20
                }
 
21
        }
 
22
        return particles;
 
23
}