6 #ifndef siesta_quantities_hpp
7 #define siesta_quantities_hpp
103 std::vector<double> temp(100);
105 for (
size_t i = 0; i < 100; i++) {
106 double s =
static_cast<double> (i)/99.0;
122 template<
class GIRD_CLASS>
124 const std::string &name) {
126 int status = nc_open(restart_file.c_str(), NC_NOWRITE, &ncid);
128 std::cout <<
"Failed to open " << restart_file << std::endl;
134 nc_inq_varid(ncid,
"nrad", &varid);
135 nc_get_var(ncid, varid, &nrad);
137 std::vector<double> temp(nrad);
138 nc_inq_varid(ncid, name.c_str(), &varid);
139 nc_get_var(ncid, varid, temp.data());
154 const std::string &name) {
156 int status = nc_open(restart_file.c_str(), NC_NOWRITE, &ncid);
158 std::cout <<
"Failed to open " << restart_file << std::endl;
164 nc_inq_varid(ncid,
"curtor", &varid);
165 nc_get_var(ncid, varid, &temp);
179 template<
class GIRD_CLASS,
class PARITY>
181 const std::string &name) {
183 int status = nc_open(restart_file.c_str(), NC_NOWRITE, &ncid);
185 std::cout <<
"Failed to open " << restart_file << std::endl;
191 nc_inq_varid(ncid,
"nrad", &varid);
192 nc_get_var(ncid, varid, &nrad);
195 nc_inq_varid(ncid,
"mpol", &varid);
196 nc_get_var(ncid, varid, &
mpol);
199 nc_inq_varid(ncid,
"ntor", &varid);
200 nc_get_var(ncid, varid, &
ntor);
202 nc_inq_varid(ncid,
"tor_modes", &varid);
203 std::vector<int> tor_modes(2*
ntor + 1);
204 nc_get_var(ncid, varid, tor_modes.data());
207 nc_inq_varid(ncid,
"nfp", &varid);
208 nc_get_var(ncid, varid, &
nfp);
211 for (
size_t m = 0, em =
mpol; m <= em; m++) {
212 for (
long n = -
ntor, en =
ntor; n <= en; n++) {
213 const size_t ni = n +
ntor;
215 std::vector<double> temp(nrad);
216 nc_inq_varid(ncid, name.c_str(), &varid);
218 const std::array<size_t, 3> start = {0, ni, m};
219 const std::array<size_t, 3> end = {
static_cast<size_t> (nrad), 1, 1};
220 nc_get_vara(ncid, varid,
221 start.data(), end.data(),
226 new_grid.push_back(temp);
227 quantity.push_back(new_grid);
247 template<
class GIRD_CLASS,
class PARITY>
249 const std::string &name) {
251 int status = nc_open(restart_file.c_str(), NC_NOWRITE, &ncid);
253 std::cout <<
"Failed to open " << restart_file << std::endl;
259 nc_inq_varid(ncid,
"nrad", &varid);
260 nc_get_var(ncid, varid, &nrad);
263 nc_inq_varid(ncid,
"mpol", &varid);
264 nc_get_var(ncid, varid, &
mpol);
267 nc_inq_varid(ncid,
"ntor", &varid);
268 nc_get_var(ncid, varid, &
ntor);
270 nc_inq_varid(ncid,
"tor_modes", &varid);
271 std::vector<int> tor_modes(2*
ntor + 1);
272 nc_get_var(ncid, varid, tor_modes.data());
275 nc_inq_varid(ncid,
"nfp", &varid);
276 nc_get_var(ncid, varid, &
nfp);
279 nc_inq_varid(ncid,
"b_factor", &varid);
280 nc_get_var(ncid, varid, &bfactor);
283 for (
size_t m = 0, em =
mpol; m <= em; m++) {
284 for (
long n = -
ntor, en =
ntor; n <= en; n++) {
285 const size_t ni = n +
ntor;
287 std::vector<double> temp(nrad);
288 nc_inq_varid(ncid, name.c_str(), &varid);
290 const std::array<size_t, 3> start = {0, ni, m};
291 const std::array<size_t, 3> end = {
static_cast<size_t> (nrad), 1, 1};
292 nc_get_vara(ncid, varid,
293 start.data(), end.data(),
296 for (
size_t i = 0; i < nrad; i++) {
297 if (m == 0 && n == 0) {
298 temp[i] = temp[i]/bfactor;
300 temp[i] = sqrt(2.0)*temp[i]/bfactor;
306 new_grid.push_back(temp);
307 quantity.push_back(new_grid);
326 template<
class PARITY>
337 half_quanity.push_back(half_slice);
353 template<
class PARITY>
357 for (
size_t m = 0, em =
siesta.mpol; m <= em; m++) {
360 for (
long n = -
siesta.ntor, en =
siesta.ntor; n <= en; n++) {
361 const size_t ni = n +
siesta.ntor;
365 full_quanity.push_back(full_slice);
383 double get_r(
const double s,
const double u,
const double v)
const {
384 return r.
get(s, u, v);
395 double get_r_prime(
const double s,
const double u,
const double v)
const {
407 double get_dr_du(
const double s,
const double u,
const double v)
const {
419 double get_dr_dv(
const double s,
const double u,
const double v)
const {
431 double get_z(
const double s,
const double u,
const double v)
const {
432 return z.
get(s, u, v);
443 double get_z_prime(
const double s,
const double u,
const double v)
const {
455 double get_dz_du(
const double s,
const double u,
const double v)
const {
467 double get_dz_dv(
const double s,
const double u,
const double v)
const {
499 double get_bsups(
const double s,
const double u,
const double v)
const {
511 double get_bsupu(
const double s,
const double u,
const double v)
const {
523 double get_bsupv(
const double s,
const double u,
const double v)
const {
535 double get_bsubs(
const double s,
const double u,
const double v)
const {
547 double get_bsubu(
const double s,
const double u,
const double v)
const {
559 double get_bsubv(
const double s,
const double u,
const double v)
const {
571 double get_jksups(
const double s,
const double u,
const double v)
const {
572 return jksups.
get(s, u, v)/(M_PI*4.0E-7);
583 double get_jksupu(
const double s,
const double u,
const double v)
const {
584 return jksupu.
get(s, u, v)/(M_PI*4.0E-7);
595 double get_jksupv(
const double s,
const double u,
const double v)
const {
596 return jksupv.
get(s, u, v)/(M_PI*4.0E-7);
607 double get_jbsups(
const double s,
const double u,
const double v)
const {
619 double get_jbsupu(
const double s,
const double u,
const double v)
const {
631 double get_jbsupv(
const double s,
const double u,
const double v)
const {
643 double get_jacobian(
const double s,
const double u,
const double v)
const {
701 double get_divb(
const double s,
const double u,
const double v)
const {
713 double get_pressure(
const double s,
const double u,
const double v)
const {
Cosine Parity function interface.
Definition: parity.hpp:62
A full grid quantity.
Definition: grid_quantity.hpp:49
A half grid quantity.
Definition: grid_quantity.hpp:80
double get(const double s, const double u, const double v) const
Get a value at a radial s position.
Definition: grid_quantity.hpp:329
double get_du(const double s, const double u, const double v) const
Get a poloidal derivative at a radial s position.
Definition: grid_quantity.hpp:354
double get_dv(const double s, const double u, const double v) const
Get a toroidal derivative at a radial s position.
Definition: grid_quantity.hpp:379
double get(const double s) const
Get a value at a radial s position.
Definition: grid_quantity.hpp:175
Siesta quantities.
Definition: siesta_quantities.hpp:19
double get_z(const double s, const double u, const double v) const
Get Z quantity.
Definition: siesta_quantities.hpp:431
double get_jacobian(const double s, const double u, const double v) const
Get jacobian.
Definition: siesta_quantities.hpp:643
double get_r_prime(const double s, const double u, const double v) const
Get R' quantity.
Definition: siesta_quantities.hpp:395
const siesta_fourier< full_grid, sine > djbsupsds
dJB^sds
Definition: siesta_quantities.hpp:38
double get_bsups(const double s, const double u, const double v) const
Get bsups quantity.
Definition: siesta_quantities.hpp:499
static siesta_grid< full_grid > make_full()
Factory method to make a test quantity.
Definition: siesta_quantities.hpp:102
double get_jksupv(const double s, const double u, const double v) const
Get jksupv quantity.
Definition: siesta_quantities.hpp:595
const siesta_fourier< full_grid, cosine > jksupv
JK^v.
Definition: siesta_quantities.hpp:60
const siesta_fourier< full_grid, cosine > r
r
Definition: siesta_quantities.hpp:24
double get_jksups(const double s, const double u, const double v) const
Get jksups quantity.
Definition: siesta_quantities.hpp:571
siesta_quantities(const std::string &restart_file)
Siesta quantities.
Definition: siesta_quantities.hpp:73
double get_dr_du(const double s, const double u, const double v) const
Get dRdu quantity.
Definition: siesta_quantities.hpp:407
double get_dr_dv(const double s, const double u, const double v) const
Get dRdv quantity.
Definition: siesta_quantities.hpp:419
const siesta_fourier< full_grid, sine > z
z
Definition: siesta_quantities.hpp:28
static double load_scalar(const std::string &restart_file, const std::string &name)
Factory method to load a scalar siesta quantity.
Definition: siesta_quantities.hpp:153
const siesta_fourier< half_grid, cosine > bsupu
JB^u.
Definition: siesta_quantities.hpp:46
double get_djbsups_ds(const double s, const double u, const double v) const
Get djbsupsds quantity.
Definition: siesta_quantities.hpp:665
const siesta_fourier< full_grid, cosine > jksupu
JK^u.
Definition: siesta_quantities.hpp:58
static siesta_fourier< half_grid, PARITY > to_prime(const siesta_fourier< full_grid, PARITY > siesta)
Convert full grid quantity to half grid primed.
Definition: siesta_quantities.hpp:327
const siesta_grid< full_grid > chipf
Radial derivative of poloidal flux.
Definition: siesta_quantities.hpp:34
double get_jbsups(const double s, const double u, const double v) const
Get jbsups quantity.
Definition: siesta_quantities.hpp:607
const siesta_fourier< half_grid, cosine > bsupv
JB^v.
Definition: siesta_quantities.hpp:48
const siesta_fourier< half_grid, sine > jbsups
JB^s.
Definition: siesta_quantities.hpp:36
double get_chipf(const double s) const
Get chipf quantity.
Definition: siesta_quantities.hpp:487
const siesta_fourier< half_grid, cosine > bsubu
B_u.
Definition: siesta_quantities.hpp:52
double get_divb(const double s, const double u, const double v) const
Get divergence of B.
Definition: siesta_quantities.hpp:701
double get_z_prime(const double s, const double u, const double v) const
Get Z' quantity.
Definition: siesta_quantities.hpp:443
const siesta_fourier< half_grid, cosine > jbsupu
JB^u.
Definition: siesta_quantities.hpp:40
const siesta_fourier< half_grid, cosine > drds
drds
Definition: siesta_quantities.hpp:26
const siesta_fourier< half_grid, sine > dzds
dzds
Definition: siesta_quantities.hpp:30
double get_r(const double s, const double u, const double v) const
Get R quantity.
Definition: siesta_quantities.hpp:383
double get_jksupu(const double s, const double u, const double v) const
Get jksupu quantity.
Definition: siesta_quantities.hpp:583
static siesta_fourier< GIRD_CLASS, PARITY > load_fourier(const std::string &restart_file, const std::string &name)
Factory method to load a fourier siesta quantity.
Definition: siesta_quantities.hpp:180
double get_djbsupv_dv(const double s, const double u, const double v) const
Get djbsupvdv quantity.
Definition: siesta_quantities.hpp:689
double get_bsubv(const double s, const double u, const double v) const
Get bsubv quantity.
Definition: siesta_quantities.hpp:559
double get_pressure(const double s, const double u, const double v) const
Get pressure.
Definition: siesta_quantities.hpp:713
const siesta_fourier< half_grid, cosine > jbsupv
JB^v.
Definition: siesta_quantities.hpp:42
static siesta_fourier< full_grid, PARITY > to_prime(const siesta_fourier< half_grid, PARITY > siesta)
Convert full grid quantity to half grid primed.
Definition: siesta_quantities.hpp:354
const siesta_fourier< half_grid, sine > bsubs
B_s.
Definition: siesta_quantities.hpp:50
double get_bsubs(const double s, const double u, const double v) const
Get bsubs quantity.
Definition: siesta_quantities.hpp:535
const siesta_fourier< full_grid, sine > jksups
JK^s.
Definition: siesta_quantities.hpp:56
const siesta_grid< full_grid > phipf
Radial derivative of toroidal flux.
Definition: siesta_quantities.hpp:32
double get_bsupv(const double s, const double u, const double v) const
Get bsupv quantity.
Definition: siesta_quantities.hpp:523
double get_bsupu(const double s, const double u, const double v) const
Get bsupu quantity.
Definition: siesta_quantities.hpp:511
const siesta_fourier< half_grid, cosine > bsubv
B_v.
Definition: siesta_quantities.hpp:54
double get_phipf(const double s) const
Get phipf quantity.
Definition: siesta_quantities.hpp:477
double get_test(const double s) const
Get test quantity.
Definition: siesta_quantities.hpp:723
const siesta_fourier< half_grid, sine > bsups
JB^s.
Definition: siesta_quantities.hpp:44
double get_jbsupu(const double s, const double u, const double v) const
Get jbsupu quantity.
Definition: siesta_quantities.hpp:619
static siesta_grid< GIRD_CLASS > load(const std::string &restart_file, const std::string &name)
Factory method to load a siesta quantity.
Definition: siesta_quantities.hpp:123
double get_dz_dv(const double s, const double u, const double v) const
Get dZdv quantity.
Definition: siesta_quantities.hpp:467
double get_djbsupu_du(const double s, const double u, const double v) const
Get djbsupudu quantity.
Definition: siesta_quantities.hpp:677
const double curtor
Total toroidal current.
Definition: siesta_quantities.hpp:62
double get_curtor() const
Get total toroidal current.
Definition: siesta_quantities.hpp:653
double get_dz_du(const double s, const double u, const double v) const
Get dZdu quantity.
Definition: siesta_quantities.hpp:455
double get_bsubu(const double s, const double u, const double v) const
Get bsubu quantity.
Definition: siesta_quantities.hpp:547
static siesta_fourier< GIRD_CLASS, PARITY > load_fourier_denorm(const std::string &restart_file, const std::string &name)
Factory method to load a fourier denormalized siesta quantity.
Definition: siesta_quantities.hpp:248
const siesta_grid< full_grid > test_full
test function
Definition: siesta_quantities.hpp:22
const siesta_fourier< half_grid, cosine > p
Pressure.
Definition: siesta_quantities.hpp:64
double get_jbsupv(const double s, const double u, const double v) const
Get jbsupv quantity.
Definition: siesta_quantities.hpp:631
Sine Parity function interface.
Definition: parity.hpp:36
Contains classes to interpolate full and half grid quanities.
std::vector< siesta_grid< GRID_CLASS > > siesta_quantity_1d
Type for siesta fourier quantities for a single dimension.
Definition: grid_quantity.hpp:279
std::vector< siesta_quantity_1d< GRID_CLASS > > siesta_quantity
Type for siesta fourier quantities.
Definition: grid_quantity.hpp:283
program siesta
SIESTA is an ideal MHD equilibrium code that allows for islands and stocastic fields....
Definition: siesta.f90:32