File indexing completed on 2024-04-06 12:22:35
0001 #ifndef rz_harm_poly_h
0002 #define rz_harm_poly_h
0003
0004 #include <cmath>
0005 #include "poly2d_base.h"
0006
0007
0008
0009
0010
0011
0012
0013
0014 namespace magfieldparam {
0015 struct trig_pair {
0016 double CosPhi;
0017 double SinPhi;
0018
0019 trig_pair() : CosPhi(1.), SinPhi(0.) {}
0020 trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
0021 trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
0022
0023
0024 trig_pair Add(const trig_pair &tp) {
0025 return trig_pair(this->CosPhi * tp.CosPhi - this->SinPhi * tp.SinPhi,
0026 this->SinPhi * tp.CosPhi + this->CosPhi * tp.SinPhi);
0027 }
0028 };
0029
0030
0031
0032
0033
0034
0035
0036
0037 class rz_harm_poly : public poly2d_base {
0038 private:
0039 unsigned L;
0040 int M;
0041
0042 static unsigned Cnt;
0043 static double phival;
0044 static bool phi_set;
0045 static unsigned MaxM;
0046
0047 static unsigned TASize;
0048 static trig_pair *TrigArr;
0049
0050 static void SetTrigArrSize(const unsigned N);
0051 static void FillTrigArr(const double phi);
0052
0053 void PrintLM(std::ostream &out = std::cout) {
0054 out << "L=" << std::setw(3) << std::left << L << ", M=" << std::setw(3) << std::left << M << "; ";
0055 }
0056
0057 public:
0058 static int GetMaxM();
0059 static unsigned ParentCount() { return poly2d_base::Count(); }
0060 static unsigned Count() { return Cnt; }
0061 static void SetPhi(const double phi);
0062 static void SetPoint(const double r, const double z, const double phi) {
0063 poly2d_base::SetPoint(r, z);
0064 SetPhi(phi);
0065 }
0066
0067 rz_harm_poly() : poly2d_base(), L(0), M(0) { ++Cnt; }
0068 rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) { ++Cnt; }
0069 rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) { ++Cnt; }
0070 rz_harm_poly(const unsigned N);
0071 ~rz_harm_poly() override;
0072
0073 bool IsPhiSet() { return phi_set; }
0074
0075 rz_harm_poly GetDiff(int nvar) {
0076 rz_harm_poly R(*this);
0077 R.Diff(nvar);
0078 return R;
0079 }
0080 rz_harm_poly GetInt(int nvar) {
0081 rz_harm_poly R(*this);
0082 R.Int(nvar);
0083 return R;
0084 }
0085 rz_harm_poly GetIncPow(int nvar) {
0086 rz_harm_poly R(*this);
0087 R.IncPow(nvar);
0088 return R;
0089 }
0090 rz_harm_poly GetDecPow(int nvar) {
0091 rz_harm_poly R(*this);
0092 R.DecPow(nvar);
0093 return R;
0094 }
0095
0096 rz_harm_poly LadderUp();
0097 rz_harm_poly LadderDwn();
0098
0099 unsigned GetL() { return L; }
0100 int GetM() { return M; }
0101
0102
0103
0104
0105 double GetCos() { return TrigArr[M].CosPhi; }
0106 double GetSin() { return TrigArr[M].SinPhi; }
0107
0108 void CheatL(const unsigned newL) { L = newL; }
0109 void Print(std::ostream &out = std::cout, const std::streamsize prec = 5) {
0110 PrintLM(out);
0111 poly2d_base::Print(out, prec);
0112 }
0113
0114 static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
0115
0116 };
0117 }
0118
0119 #endif