OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Enge.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Chris Rogers
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * 1. Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright notice,
9  * this list of conditions and the following disclaimer in the documentation
10  * and/or other materials provided with the distribution.
11  * 3. Neither the name of STFC nor the names of its contributors may be used to
12  * endorse or promote products derived from this software without specific
13  * prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ENDFIELDMODEL_ENGE_H_
29 #define ENDFIELDMODEL_ENGE_H_
30 
31 #include <iostream>
32 #include <vector>
33 
35 
36 namespace endfieldmodel {
37 
38 class Enge : public EndFieldModel {
39  public:
41  Enge() : _a(), _lambda(0.) {SetEngeDiffIndices(10);}
49  Enge(const std::vector<double> a, double x0, double lambda, int max_index)
50  : _a(a), _lambda(lambda), _x0(x0) {SetEngeDiffIndices(max_index);}
52  ~Enge() {}
53 
55  Enge* Clone() const;
56 
58  std::vector<double> GetEngeParameters() const {return _a;}
59 
61  void SetEngeParameters(std::vector<double> a) {_a = a;}
62 
64  inline double GetLambda() const {return _lambda;}
65 
67  inline void SetLambda(double lambda) {_lambda = lambda;}
68 
70  inline double GetX0() const {return _x0;}
71 
73  inline void SetX0(double x0) {_x0 = x0;}
74 
79  double GetEnge(double x, int n) const;
80 
82  inline double GetDoubleEnge(double x, int n) const;
83 
89  double HN(double x, int n) const;
90 
96  double GN(double x, int n) const;
97 
103  static void SetEngeDiffIndices(size_t n);
104 
106  inline static std::vector< std::vector<int> > GetQIndex(int n);
107 
109  inline static std::vector< std::vector<int> > GetHIndex(int n);
110  private:
111  std::vector<double> _a;
112  double _lambda, _x0;
113 
115  static std::vector< std::vector< std::vector<int> > > _q;
117  static std::vector< std::vector< std::vector<int> > > _h;
118 };
119 
120 std::vector< std::vector<int> > Enge::GetQIndex(int n) {
122  return _q[n];
123 }
124 
125 std::vector< std::vector<int> > Enge::GetHIndex(int n) {
127  return _h[n];
128 }
129 
130 double Enge::GetDoubleEnge(double x, int n) const {
131  if (n == 0) {
132  return (GetEnge(x-_x0, n)+GetEnge(-x-_x0, n))-1.;
133  } else {
134  if (n%2 != 0) return GetEnge(x-_x0, n)-GetEnge(-x-_x0, n);
135  else return GetEnge(x-_x0, n)+GetEnge(-x-_x0, n);
136  }
137 }
138 
139 }
140 
141 #endif
void SetLambda(double lambda)
Definition: Enge.h:67
Enge(const std::vector< double > a, double x0, double lambda, int max_index)
Definition: Enge.h:49
Enge * Clone() const
double GetDoubleEnge(double x, int n) const
Definition: Enge.h:130
void SetX0(double x0)
Definition: Enge.h:73
static std::vector< std::vector< std::vector< int > > > _q
Definition: Enge.h:115
double HN(double x, int n) const
Definition: Enge.cpp:59
double _lambda
Definition: Enge.h:112
std::vector< double > GetEngeParameters() const
Definition: Enge.h:58
void SetEngeParameters(std::vector< double > a)
Definition: Enge.h:61
static std::vector< std::vector< int > > GetHIndex(int n)
Definition: Enge.h:125
static std::vector< std::vector< int > > GetQIndex(int n)
Definition: Enge.h:120
double GetX0() const
Definition: Enge.h:70
double GN(double x, int n) const
Definition: Enge.cpp:71
static void SetEngeDiffIndices(size_t n)
Definition: Enge.cpp:93
std::vector< double > _a
Definition: Enge.h:111
static std::vector< std::vector< std::vector< int > > > _h
Definition: Enge.h:117
double GetEnge(double x, int n) const
Definition: Enge.cpp:40
double GetLambda() const
Definition: Enge.h:64