Extension: Geometries
#include "dg/geometries/geometries.h"
solovev_parameters.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <vector>
4#ifdef JSONCPP_VERSION_STRING
5#include <dg/file/json_utilities.h>
6#endif
11namespace dg
12{
13namespace geo
14{
15namespace solovev
16{
46{
47 double A,
51 a,
54 std::vector<double> c;
55 std::string description;
56#ifdef JSONCPP_VERSION_STRING
66 Parameters( const dg::file::WrappedJsonValue& js) {
67 A = js.get("A", 0).asDouble();
68 pp = js.get("PP", 1).asDouble();
69 pi = js.get("PI", 1).asDouble();
70 c.resize(12);
71 for (unsigned i=0;i<12;i++)
72 c[i] = js["c"].get(i,0.).asDouble();
73
74 R_0 = js.get( "R_0", 0.).asDouble();
75 a = R_0* js.get( "inverseaspectratio", 0.).asDouble();
76 elongation= js.get( "elongation", 1.).asDouble();
77 triangularity= js.get( "triangularity", 0.).asDouble();
78 try{
79 description = js.get( "description", "standardX").asString();
80 } catch ( std::exception& err)
81 {
82 if( isToroidal())
83 description = "none";
84 else if( !hasXpoint())
85 description = "standardO";
86 else
87 description = "standardX";
88 }
89 }
96 Json::Value dump( ) const
97 {
98 // There seems to be a jsoncpp bug where the move assignment is missing
99 // libjsoncpp-dev-1.7.4 from the package sources
100 // Let's for now wait if a later version fixes it
101 Json::Value js;
102 js["A"] = A;
103 js["PP"] = pp;
104 js["PI"] = pi;
105 for (unsigned i=0;i<12;i++) js["c"][i] = c[i];
106 js["R_0"] = R_0;
107 js["inverseaspectratio"] = a/R_0;
108 js["elongation"] = elongation;
109 js["triangularity"] = triangularity;
110 js[ "equilibrium"] = "solovev";
111 js[ "description"] = description;
112 return js;
113 }
114#endif // JSONCPP_VERSION_STRING
124 bool hasXpoint( ) const{
125 bool Xpoint = false;
126 for( int i=7; i<12; i++)
127 if( fabs(c[i]) >= 1e-10)
128 Xpoint = true;
129 return Xpoint;
130 }
136 bool isToroidal() const{
137 if( pp == 0)
138 return true;
139 return false;
140 }
142 void display( std::ostream& os = std::cout ) const
143 {
144 os << "Solovev Geometrical parameters are: \n"
145 <<" A = "<<A<<"\n"
146 <<" Prefactor Psi = "<<pp<<"\n"
147 <<" Prefactor I = "<<pi<<"\n";
148 for( unsigned i=0; i<12; i++)
149 os<<" c"<<i+1<<"\t\t = "<<c[i]<<"\n";
150
151 os <<" R0 = "<<R_0<<"\n"
152 <<" a = "<<a<<"\n"
153 <<" epsilon_a = "<<a/R_0<<"\n"
154 <<" description = "<<description<<"\n"
155 <<" elongation = "<<elongation<<"\n"
156 <<" triangularity = "<<triangularity<<"\n";
157 os << std::flush;
158
159 }
160};
161} //namespace solovev
162} //namespace geo
163} //namespace dg
description
How flux function looks like. Decider on whether and what flux aligned grid to construct.
Definition: magnetic_field.h:48
@ solovev
dg::geo::solovev::Psip
Constructs and display geometric parameters for the solovev and taylor fields.
Definition: solovev_parameters.h:46
double pp
prefactor for Psi_p
Definition: solovev_parameters.h:49
double R_0
major tokamak radius
Definition: solovev_parameters.h:48
double a
little tokamak radius
Definition: solovev_parameters.h:51
double A
A coefficient.
Definition: solovev_parameters.h:47
bool isToroidal() const
True if pp==0.
Definition: solovev_parameters.h:136
Parameters(const dg::file::WrappedJsonValue &js)
Construct from Json dataset.
Definition: solovev_parameters.h:66
std::string description
Definition: solovev_parameters.h:55
std::vector< double > c
12 coefficients for the solovev equilibrium;
Definition: solovev_parameters.h:54
double pi
prefactor for current I
Definition: solovev_parameters.h:50
double elongation
elongation of the magnetic surfaces
Definition: solovev_parameters.h:52
bool hasXpoint() const
True if any coefficient c_i!=0 with 7<=i<12.
Definition: solovev_parameters.h:124
Json::Value dump() const
Put values into a json string.
Definition: solovev_parameters.h:96
double triangularity
triangularity of the magnetic surfaces
Definition: solovev_parameters.h:53
void display(std::ostream &os=std::cout) const
Write variables as a formatted string.
Definition: solovev_parameters.h:142