nbi

Input data representing NBI.

Neutral beam injectors are used by BBNBI to generate NBI-ion source and calculate shinethrough.

a5py.ascot5io.nbi.NBI

Object representing a bundle of injectors used as an input in BBNBI.

class a5py.ascot5io.nbi.NBI(root, path, **kwargs)

Bases: DataGroup

Object representing a bundle of injectors used as an input in BBNBI.

An injector bundle means that the particles generated from those with BBNBI are not separable. If your work requires that the different NBI sources are kept separate, then use different bundles for those (a bundle can consists of a single injector). Otherwise it is more convenient to combine injectors in a single bundle since it then produces a single BBNBI output.

static create_dummy()

Create dummy data that has correct format and is valid, but can be non-sensical.

This method is intended for testing purposes or to provide data whose presence is needed but which is not actually used in simulation.

The dummy output is a very large rectangular wall.

Returns:
datadict

Input data that can be passed to write_hdf5 method of a corresponding type.

static generate(r, phi, z, tanrad, focallen, dgrid, nbeamlet, anum, znum, mass, energy, efrac, power, div, tilt=None, tanz=None, divhalofrac=None, divhalo=None, ids=1, desc=None)

Generate a generic injector.

The injector grid can be either circular or rectangular, and will be randomly populated with beamlets with a common focus point.

The contents of this function can be used as a template for implementing machine-specific injectors with an actual geometry.

Parameters:
rfloat

Injector center point R-coordinate [m].

phifloat

Injector center point phi-coordinate [deg].

zfloat

Injector center point z-coordinate [m].

tanradfloat

Tangency radius of the injector centerline [m].

focallenfloat

Distance to the focus point from the center of the grid

dgridfloat or array_like (2,)

Diameter of circular grid or width and height of rectangular grid

nbeamletint

Number of beamlets in this injector

anumint

Mass number of injected species

znumint

Nuclear charge number of injected species

massfloat

Mass of the injected species [amu]

energyfloat

Full injection energy [eV]

efracarray_like (3,)

Particle fractions for full, 1/2 and 1/3 energies

powerfloat

Injected power [W]

divarray_like (2,)

Horizontal and vertical divergences [rad]

tiltfloat, optional

Vertical tilt angle of the beam centerline [deg]

tanzfloat, optional

Vertical shift of the tangency radius point [m]

divhalofracfloat, optional

Fraction of particles with halo divergence

divhalofloat, optional

Horizontal and vertical divergences [rad]

idsint, optional

Unique numerical identifier for this injector.

Returns:
injInjector

A single injector.

read()

Read data from HDF5 file.

Returns:
datadict

Data read from HDF5 stored in the same format as is passed to write_hdf5().

static write_hdf5(fn, ninj, injectors, desc=None)

Write input data to the HDF5 file.

Parameters:
fnstr

Full path to the HDF5 file.

ninjint

Number of injectors.

injectorsarray of Injector

Array of injectors used in this bundle.

descstr, optional

Input description.

Returns:
namestr

Name, i.e. “<type>_<qid>”, of the new input that was written.

class a5py.ascot5io.nbi.Injector(ids, anum, znum, mass, energy, efrac, power, divh, divv, divhalofrac, divhaloh, divhalov, nbeamlet, beamletx, beamlety, beamletz, beamletdx, beamletdy, beamletdz)

Bases: object

A single injector made up of beamlets

Attributes:
idsint

Numerical identifier for this injector which should be unique in an input bundle.

anumint

Mass number of injected species.

znumint

Nuclear charge number of injected species.

massfloat

Mass of the injected species [amu].

energyfloat

Full injection energy [eV].

efracarray_like (3,)

Particle fractions for full, 1/2 and 1/3 energies.

powerfloat

Injected power [W].

divhfloat

Horizontal divergence [rad].

divvfloat

Vertical divergence [rad].

divhalofracfloat

Fraction of particles with halo divergence.

divhalohfloat

Horizontal divergence in halo [rad].

divhalovfloat

Vertical divergence in halo [rad].

nbeamletint

Number of beamlets.

beamletxarray_like, (nbeamlet,)

x coordinates of beamlets [m].

beamletyarray_like, (nbeamlet,)

y coordinates of beamlets [m].

beamletzarray_like, (nbeamlet,)

z coordinates of beamlets [m].

beamletdxarray_like, (nbeamlet,)

x components of the unit direction vector of beamlets.

beamletdyarray_like, (nbeamlet,)

y components of the unit direction vector of beamlets.

beamletdzarray_like, (nbeamlet,)

z components of the unit direction vector of beamlets.

plotbeamlets(view='3d', direction=True, axes=None)

Plot the beamlets of this injector.

Parameters:
view{“rz”, “xy”, “3d”}, optional

Control whether the plot is shown in (R,z) or (x,y) plane or in 3D.

directionbool, optional

Flag for showing the beam direction with arrows originating from beamlets.

If False, only the beamlet locations are shown.

axesAxes, optional

The axes where figure is plotted or otherwise new figure is created.