Identifiers¶
The “identifier” structure is used to provide an enumerated list of options.
For a complete reference of all available identifiers, see the IMAS Data Dictionary Identifiers documentation.
Index |
Name |
Description |
|---|---|---|
2 |
NBI |
Source from Neutral Beam Injection |
3 |
EC |
Sources from heating at the electron cyclotron heating and current drive |
4 |
LH |
Sources from lower hybrid heating and current drive |
5 |
IC |
Sources from heating at the ion cyclotron range of frequencies |
6 |
fusion |
Sources from fusion reactions, e.g. alpha particle heating |
Using the identifiers library¶
Use pkg-config to get the required compile and link flags: pkg-config --libs --cflags imas-identifiers-cpp.
Below examples illustrates how to use the identifiers in your Cpp programs.
Cpp example 1: obtain identifier information of coordinate identifier
phi¶// Include the Access Layer
#include "ALClasses.h"
// And the required identifiers header(s)
#include "coordinate_identifier.h"
#include <iostream>
int main(int argc, char *argv[])
{
// Get coordinate identifier information for "phi"
int idx = coordinate_identifier::get_index("phi");
// Display coordinate identifier details
std::cout << "Coordinate Identifier Information for 'phi':" << std::endl;
std::cout << " Index: " << idx << std::endl;
std::cout << " Data type: " << coordinate_identifier::get_name(idx) << std::endl;
std::cout << " Description: " << coordinate_identifier::get_description(idx) << std::endl;
return 0;
}
Cpp example 2: Use the identifier library to fill the
NBI label in the core_sources IDS¶#include "ALClasses.h"
#include "distribution_source_identifier.h"
#include "poloidal_plane_coordinates_identifier.h"
#include <iostream>
using namespace IdsNs;
int main(int argc, char *argv[])
{
IdsNs::IDS ids;
// Configure equilibrium IDS
ids._equilibrium.ids_properties.homogeneous_time = 1;
ids._equilibrium.ids_properties.comment = "Test equilibrium IDS";
// Setup equilibrium time slice and profiles
ids._equilibrium.time_slice.resize(1);
ids._equilibrium.time_slice(0).profiles_2d.resize(1);
// Set grid type identifier for equilibrium profiles
poloidal_plane_coordinates_identifier::set_identifier(
ids._equilibrium.time_slice(0).profiles_2d(0).grid_type,
"rectangular"
);
// Output equilibrium grid type information
std::cout << "Equilibrium Grid Type:" << std::endl;
std::cout << " Name: " << ids._equilibrium.time_slice(0).profiles_2d(0).grid_type.name << std::endl;
std::cout << " Index: " << ids._equilibrium.time_slice(0).profiles_2d(0).grid_type.index << std::endl;
std::cout << " Description: " << ids._equilibrium.time_slice(0).profiles_2d(0).grid_type.description << std::endl;
std::cout << std::endl;
// Configure distribution sources IDS
ids._distribution_sources.ids_properties.homogeneous_time = 1;
ids._distribution_sources.ids_properties.comment = "Test distribution sources IDS";
// Setup distribution sources structure
ids._distribution_sources.source.resize(1);
ids._distribution_sources.source(0).process.resize(1);
// Set distribution source type identifier
distribution_source_identifier::set_identifier(
ids._distribution_sources.source(0).process(0).type,
"NBI"
);
// Output distribution source type information
std::cout << "Distribution Source Type:" << std::endl;
std::cout << " Name: " << ids._distribution_sources.source(0).process(0).type.name << std::endl;
std::cout << " Index: " << ids._distribution_sources.source(0).process(0).type.index << std::endl;
std::cout << " Description: " << ids._distribution_sources.source(0).process(0).type.description << std::endl;
return 0;
}
Cpp example 3: Use the identifier library to fill the type of coordinate system used in the
equilibrium IDS¶#include "ALClasses.h"
#include "materials_identifier.h"
#include <iostream>
using namespace IdsNs;
int main(int argc, char *argv[])
{
IdsNs::IDS ids;
std::string names[5] = {"W", "C", "Be", "Cu", "SS"};
ids._wall.description_ggd.resize(1);
ids._wall.description_ggd(0).material.resize(1);
ids._wall.description_ggd(0).material(0).grid_subset.resize(1) ;
materials_identifier::set_identifier(
ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers, names
);
// Output material information
std::cout << "Number of materials: " << ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers.indices.size() << std::endl;
for (int i = 0; i < ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers.indices.size(); i++) {
std::cout << "Material " << (i + 1) << ":" << std::endl;
std::cout << " Index: " << ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers.indices(i) << std::endl;
std::cout << " Name: \"" << ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers.names(i) << "\"" << std::endl;
std::cout << " Description: \"" << ids._wall.description_ggd(0).material(0).grid_subset(0).identifiers.descriptions(i) << "\"" << std::endl;
}
std::cout << std::endl;
return 0;
}