Extension: Geometries
#include "dg/geometries/geometries.h"
taylor.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <fstream>
5#include <cmath>
6#include <vector>
7#include <boost/math/special_functions.hpp>
8
9#include "dg/algorithm.h"
10#include "solovev_parameters.h"
11#include "magnetic_field.h"
12
13
19namespace dg
20{
21namespace geo
22{
29namespace taylor
30{
34
41struct Psip : public aCylindricalFunctor<Psip>
42{
47 Psip( solovev::Parameters gp): R0_(gp.R_0), c_(gp.c) {
48 cs_ = sqrt( c_[11]*c_[11]-c_[10]*c_[10]);
49 }
50 double do_compute(double R, double Z) const
51 {
52 double Rn = R/R0_, Zn = Z/R0_;
53 double j1_c12 = boost::math::cyl_bessel_j( 1, c_[11]*Rn);
54 double y1_c12 = boost::math::cyl_neumann( 1, c_[11]*Rn);
55 double j1_cs = boost::math::cyl_bessel_j( 1, cs_*Rn);
56 double y1_cs = boost::math::cyl_neumann( 1, cs_*Rn);
57 return R0_*(
58 1.0*Rn*j1_c12
59 + c_[0]*Rn*y1_c12
60 + c_[1]*Rn*j1_cs*cos(c_[10]*Zn)
61 + c_[2]*Rn*y1_cs*cos(c_[10]*Zn)
62 + c_[3]*cos(c_[11]*sqrt(Rn*Rn+Zn*Zn))
63 + c_[4]*cos(c_[11]*Zn)
64 + c_[5]*Rn*j1_c12*Zn
65 + c_[6]*Rn*y1_c12*Zn
66 + c_[7]*Rn*j1_cs*sin(c_[10]*Zn)
67 + c_[8]*Rn*y1_cs*sin(c_[10]*Zn)
68 + c_[9]*sin(c_[11]*Zn));
69
70 }
71 private:
72 double R0_, cs_;
73 std::vector<double> c_;
74};
75
80struct PsipR: public aCylindricalFunctor<PsipR>
81{
83 PsipR( solovev::Parameters gp): R0_(gp.R_0), c_(gp.c) {
84 cs_=sqrt(c_[11]*c_[11]-c_[10]*c_[10]);
85
86 }
87 double do_compute(double R, double Z) const
88 {
89 double Rn=R/R0_, Zn=Z/R0_;
90 double j1_c12R = boost::math::cyl_bessel_j(1, c_[11]*Rn) + c_[11]/2.*Rn*(
91 boost::math::cyl_bessel_j(0, c_[11]*Rn) - boost::math::cyl_bessel_j(2,c_[11]*Rn));
92 double y1_c12R = boost::math::cyl_neumann(1, c_[11]*Rn) + c_[11]/2.*Rn*(
93 boost::math::cyl_neumann(0, c_[11]*Rn) - boost::math::cyl_neumann(2,c_[11]*Rn));
94 double j1_csR = boost::math::cyl_bessel_j(1, cs_*Rn) + cs_/2.*Rn*(
95 boost::math::cyl_bessel_j(0, cs_*Rn) - boost::math::cyl_bessel_j(2, cs_*Rn));
96 double y1_csR = boost::math::cyl_neumann(1, cs_*Rn) + cs_/2.*Rn*(
97 boost::math::cyl_neumann(0, cs_*Rn) - boost::math::cyl_neumann(2, cs_*Rn));
98 double RZbar = sqrt( Rn*Rn+Zn*Zn);
99 double cosR = -c_[11]*Rn/RZbar*sin(c_[11]*RZbar);
100 return (
101 1.0*j1_c12R
102 + c_[0]*y1_c12R
103 + c_[1]*j1_csR*cos(c_[10]*Zn)
104 + c_[2]*y1_csR*cos(c_[10]*Zn)
105 + c_[3]*cosR
106 + c_[5]*j1_c12R*Zn
107 + c_[6]*y1_c12R*Zn
108 + c_[7]*j1_csR*sin(c_[10]*Zn)
109 + c_[8]*y1_csR*sin(c_[10]*Zn) );
110 }
111 private:
112 double R0_, cs_;
113 std::vector<double> c_;
114};
118struct PsipRR: public aCylindricalFunctor<PsipRR>
119{
121 PsipRR( solovev::Parameters gp ): R0_(gp.R_0), c_(gp.c) {
122 cs_ = sqrt( c_[11]*c_[11]-c_[10]*c_[10]);
123 }
124 double do_compute(double R, double Z) const
125 {
126 double Rn=R/R0_, Zn=Z/R0_;
127 double j1_c12R = c_[11]*(boost::math::cyl_bessel_j(0, c_[11]*Rn) - Rn*c_[11]*boost::math::cyl_bessel_j(1, c_[11]*Rn));
128 double y1_c12R = c_[11]*(boost::math::cyl_neumann( 0, c_[11]*Rn) - Rn*c_[11]*boost::math::cyl_neumann(1, c_[11]*Rn));
129 double j1_csR = cs_*(boost::math::cyl_bessel_j(0, cs_*Rn) - Rn*cs_*boost::math::cyl_bessel_j(1, cs_*Rn));
130 double y1_csR = cs_*(boost::math::cyl_neumann( 0, cs_*Rn) - Rn*cs_*boost::math::cyl_neumann( 1, cs_*Rn));
131 double RZbar = sqrt(Rn*Rn+Zn*Zn);
132 double cosR = -c_[11]/(RZbar*RZbar)*(c_[11]*Rn*Rn*cos(c_[11]*RZbar) +Zn*Zn*sin(c_[11]*RZbar)/RZbar);
133 return 1./R0_*(
134 1.0*j1_c12R
135 + c_[0]*y1_c12R
136 + c_[1]*j1_csR*cos(c_[10]*Zn)
137 + c_[2]*y1_csR*cos(c_[10]*Zn)
138 + c_[3]*cosR
139 + c_[5]*j1_c12R*Zn
140 + c_[6]*y1_c12R*Zn
141 + c_[7]*j1_csR*sin(c_[10]*Zn)
142 + c_[8]*y1_csR*sin(c_[10]*Zn) );
143 }
144 private:
145 double R0_, cs_;
146 std::vector<double> c_;
147};
151struct PsipZ: public aCylindricalFunctor<PsipZ>
152{
154 PsipZ( solovev::Parameters gp ): R0_(gp.R_0), c_(gp.c) {
155 cs_ = sqrt( c_[11]*c_[11]-c_[10]*c_[10]);
156 }
157 double do_compute(double R, double Z) const
158 {
159 double Rn = R/R0_, Zn = Z/R0_;
160 double j1_c12 = boost::math::cyl_bessel_j( 1, c_[11]*Rn);
161 double y1_c12 = boost::math::cyl_neumann( 1, c_[11]*Rn);
162 double j1_cs = boost::math::cyl_bessel_j( 1, cs_*Rn);
163 double y1_cs = boost::math::cyl_neumann( 1, cs_*Rn);
164 return (
165 - c_[1]*Rn*j1_cs*c_[10]*sin(c_[10]*Zn)
166 - c_[2]*Rn*y1_cs*c_[10]*sin(c_[10]*Zn)
167 - c_[3]*c_[11]*Zn/sqrt(Rn*Rn+Zn*Zn)*sin(c_[11]*sqrt(Rn*Rn+Zn*Zn))
168 - c_[4]*c_[11]*sin(c_[11]*Zn)
169 + c_[5]*Rn*j1_c12
170 + c_[6]*Rn*y1_c12
171 + c_[7]*Rn*j1_cs*c_[10]*cos(c_[10]*Zn)
172 + c_[8]*Rn*y1_cs*c_[10]*cos(c_[10]*Zn)
173 + c_[9]*c_[11]*cos(c_[11]*Zn));
174 }
175 private:
176 double R0_,cs_;
177 std::vector<double> c_;
178};
182struct PsipZZ: public aCylindricalFunctor<PsipZZ>
183{
185 PsipZZ( solovev::Parameters gp): R0_(gp.R_0), c_(gp.c) {
186 cs_ = sqrt( c_[11]*c_[11]-c_[10]*c_[10]);
187 }
188 double do_compute(double R, double Z) const
189 {
190 double Rn = R/R0_, Zn = Z/R0_;
191 double j1_cs = boost::math::cyl_bessel_j( 1, cs_*Rn);
192 double y1_cs = boost::math::cyl_neumann( 1, cs_*Rn);
193 double RZbar = sqrt(Rn*Rn+Zn*Zn);
194 double cosZ = -c_[11]/(RZbar*RZbar)*(c_[11]*Zn*Zn*cos(c_[11]*RZbar) +Rn*Rn*sin(c_[11]*RZbar)/RZbar);
195 return 1./R0_*(
196 - c_[1]*Rn*j1_cs*c_[10]*c_[10]*cos(c_[10]*Zn)
197 - c_[2]*Rn*y1_cs*c_[10]*c_[10]*cos(c_[10]*Zn)
198 + c_[3]*cosZ
199 - c_[4]*c_[11]*c_[11]*cos(c_[11]*Zn)
200 - c_[7]*Rn*j1_cs*c_[10]*c_[10]*sin(c_[10]*Zn)
201 - c_[8]*Rn*y1_cs*c_[10]*c_[10]*sin(c_[10]*Zn)
202 - c_[9]*c_[11]*c_[11]*sin(c_[11]*Zn));
203 }
204 private:
205 double R0_, cs_;
206 std::vector<double> c_;
207};
211struct PsipRZ: public aCylindricalFunctor<PsipRZ>
212{
214 PsipRZ( solovev::Parameters gp ): R0_(gp.R_0), c_(gp.c) {
215 cs_ = sqrt( c_[11]*c_[11]-c_[10]*c_[10]);
216 }
217 double do_compute(double R, double Z) const
218 {
219 double Rn=R/R0_, Zn=Z/R0_;
220 double j1_c12R = boost::math::cyl_bessel_j(1, c_[11]*Rn) + c_[11]/2.*Rn*(
221 boost::math::cyl_bessel_j(0, c_[11]*Rn) - boost::math::cyl_bessel_j(2,c_[11]*Rn));
222 double y1_c12R = boost::math::cyl_neumann( 1, c_[11]*Rn) + c_[11]/2.*Rn*(
223 boost::math::cyl_neumann( 0, c_[11]*Rn) - boost::math::cyl_neumann( 2,c_[11]*Rn));
224 double j1_csR = boost::math::cyl_bessel_j(1, cs_*Rn) + cs_/2.*Rn*(
225 boost::math::cyl_bessel_j(0, cs_*Rn) - boost::math::cyl_bessel_j(2, cs_*Rn));
226 double y1_csR = boost::math::cyl_neumann( 1, cs_*Rn) + cs_/2.*Rn*(
227 boost::math::cyl_neumann( 0, cs_*Rn) - boost::math::cyl_neumann(2, cs_*Rn));
228 double RZbar = sqrt(Rn*Rn+Zn*Zn);
229 double cosRZ = -c_[11]*Rn*Zn/(RZbar*RZbar*RZbar)*( c_[11]*RZbar*cos(c_[11]*RZbar) -sin(c_[11]*RZbar) );
230 return 1./R0_*(
231 - c_[1]*j1_csR*c_[10]*sin(c_[10]*Zn)
232 - c_[2]*y1_csR*c_[10]*sin(c_[10]*Zn)
233 + c_[3]*cosRZ
234 + c_[5]*j1_c12R
235 + c_[6]*y1_c12R
236 + c_[7]*j1_csR*c_[10]*cos(c_[10]*Zn)
237 + c_[8]*y1_csR*c_[10]*cos(c_[10]*Zn) );
238 }
239 private:
240 double R0_, cs_;
241 std::vector<double> c_;
242};
243
249struct Ipol: public aCylindricalFunctor<Ipol>
250{
252 Ipol( solovev::Parameters gp ): c12_(gp.c[11]), psip_(gp) { }
253 double do_compute(double R, double Z) const
254 {
255 return c12_*psip_(R,Z);
256
257 }
258 private:
259 double c12_;
260 Psip psip_;
261};
265struct IpolR: public aCylindricalFunctor<IpolR>
266{
268 IpolR( solovev::Parameters gp ): c12_(gp.c[11]), psipR_(gp) { }
269 double do_compute(double R, double Z) const
270 {
271 return c12_*psipR_(R,Z);
272 }
273 private:
274 double c12_;
275 PsipR psipR_;
276};
280struct IpolZ: public aCylindricalFunctor<IpolZ>
281{
283 IpolZ( solovev::Parameters gp ): c12_(gp.c[11]), psipZ_(gp) { }
284 double do_compute(double R, double Z) const
285 {
286 return c12_*psipZ_(R,Z);
287 }
288 private:
289 double c12_;
290 PsipZ psipZ_;
291};
292
294{
295 return CylindricalFunctorsLvl2( Psip(gp), PsipR(gp), PsipZ(gp),PsipRR(gp), PsipRZ(gp), PsipZZ(gp));
296}
298{
299 return CylindricalFunctorsLvl1( Ipol(gp), IpolR(gp), IpolZ(gp));
300}
301
303
304} //namespace taylor
315{
317 equilibrium::solovev, modifier::none, str2description.at( gp.description)};
319}
320} //namespace geo
321
322}//namespace dg
323
@ none
no modification
@ solovev
dg::geo::solovev::Psip
@ taylor
dg::geo::taylor::Psip
static dg::geo::TokamakMagneticField createTaylorField(dg::geo::solovev::Parameters gp)
Create a Taylor Magnetic field.
Definition: taylor.h:314
static CylindricalFunctorsLvl1 createIpol(solovev::Parameters gp)
Definition: taylor.h:297
dg::geo::solovev::Parameters Parameters
bring Parameters into the taylor namespace
Definition: taylor.h:33
static CylindricalFunctorsLvl2 createPsip(solovev::Parameters gp)
Definition: taylor.h:293
This struct bundles a function and its first derivatives.
Definition: fluxfunctions.h:182
This struct bundles a function and its first and second derivatives.
Definition: fluxfunctions.h:219
Meta-data about the magnetic field in particular the flux function.
Definition: magnetic_field.h:91
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
Represent functions written in cylindrical coordinates that are independent of the angle phi serving ...
Definition: fluxfunctions.h:66
Constructs and display geometric parameters for the solovev and taylor fields.
Definition: solovev_parameters.h:46
double R_0
major tokamak radius
Definition: solovev_parameters.h:48
double a
little tokamak radius
Definition: solovev_parameters.h:51
std::string description
Definition: solovev_parameters.h:55
double elongation
elongation of the magnetic surfaces
Definition: solovev_parameters.h:52
double triangularity
triangularity of the magnetic surfaces
Definition: solovev_parameters.h:53
Definition: taylor.h:250
Ipol(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:252
double do_compute(double R, double Z) const
Definition: taylor.h:253
Definition: taylor.h:266
double do_compute(double R, double Z) const
Definition: taylor.h:269
IpolR(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:268
Definition: taylor.h:281
double do_compute(double R, double Z) const
Definition: taylor.h:284
IpolZ(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:283
Definition: taylor.h:42
Psip(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:47
double do_compute(double R, double Z) const
Definition: taylor.h:50
Definition: taylor.h:81
double do_compute(double R, double Z) const
Definition: taylor.h:87
PsipR(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:83
Definition: taylor.h:119
PsipRR(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:121
double do_compute(double R, double Z) const
Definition: taylor.h:124
Definition: taylor.h:212
double do_compute(double R, double Z) const
Definition: taylor.h:217
PsipRZ(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:214
Definition: taylor.h:152
PsipZ(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:154
double do_compute(double R, double Z) const
Definition: taylor.h:157
Definition: taylor.h:183
double do_compute(double R, double Z) const
Definition: taylor.h:188
PsipZZ(solovev::Parameters gp)
Construct from given geometric parameters.
Definition: taylor.h:185