wall

Input representing first wall and other plasma facing components.

Wall input is used in simulations to check intersections between a marker trajectory and physical components like first wall of fast-ion-loss detector. It is also used in BBNBI5 to estimate shinethrough and in ASCOT-BMC.

Wall models can also be used to mimic LCFS to catch markers that escape plasma. This could prove more detailed information than just using the MAXRHO end condition.

a5py.ascot5io.wall.wall_2D

Contour in Rz-plane that represents an axisymmetric wall.

a5py.ascot5io.wall.wall_3D

Triangle mesh that represents a 3D wall.

class a5py.ascot5io.wall.wall_2D(root, path, **kwargs)

Bases: DataGroup

Contour in Rz-plane that represents an axisymmetric wall.

This wall is simple and fast in simulations, but it does not allow evaluation of wall loads. For those, use 3D wall instead.

The wall doesn’t have to form a closed loop but it prevents markers from escaping the computational domain.

area(normal=False, data=None)

Calculate the corresponsing area for revolving each strip of the 2D wall around the z-axis. Note: the normal vector is returned with only R and z components.

Parameters:
normalbool, optional

If True, calculate and return the surface normal vectors as well.

datadict, optional

Dictionary with the wall data. If None, the data is read from the file.

Returns:
areaarray_like, (nelement,)

Surface areas of the wall elements.

nvecarray_like, (nelement,3)

Normal vectors of the wall elements in (R, z, 0)

Note that the direction of the normal vector is not specified (it can point either inside or outside).

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.

getnormedline()

Return the length of each strip of the 2D wall.

Returns:
dataarray_like, (N-1)

lenghts of each strip

getwallcontour(phi=unyt_quantity(0, 'degree'))

Return a cross section of the wall with a given poloidal plane.

Parameters:
phifloat

Toroidal angle of the plane.

Returns:
linesarray_like (n,2,2)

Line segments [[[r1,z1], [r2,z2]], …] that form the cross section.

getwalloutline(phigrid)

Return minimum and maximum wall R-coordinates as a function of phi.

Parameters:
phigridarray_like

Toroidal coordinates.

Returns:
rminarray_like, (nphi,)

Minimum R-coordinate at each toroidal angle.

rmaxarray_like, (nphi,)

Maximum R-coordinate at each toroidal angle.

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, nelements, r, z, desc=None)

Write input data to the HDF5 file.

First vertex shouldn’t correspond to the last vertex, i.e., don’t give (R,z) coordinates that make a closed loop.

Parameters:
fnstr

Full path to the HDF5 file.

nelementsint

Number of wall segments.

rarray_like (nelements,1)

R coordinates of wall segment vertices [m].

zarray_like (nelements,1)

z coordinates of wall segment vertices [m].

descstr, optional

Input description.

Returns:
namestr

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

Raises:
ValueError

If the input is inconsistent.

class a5py.ascot5io.wall.wall_3D(root, path, **kwargs)

Triangle mesh that represents a 3D wall.

This wall model can be obtained easily from a STEP file or from a CAD model with a little effort. If 3D model of the wall is not available, consider using the mock-up 3D wall generated by “rotating” the 2D wall contour toroidally in steps.

3D wall model allows estimating the wall loads, but keep in mind that smaller triangles means more markers are required in simulation to gain sufficient statistics. On the other hand, too coarse model means that important details on wall load distribution could be missed.

This wall doesn’t have to form a closed “waterproof” structure, and one can use this to model FILD.

append(newWall, data=None)

Returns the wall with newWall[“x1x2x3], newWall[“y1y2y3”], newWall[“z1z2z3”], newWall[“flag”] to the existing triangles. If data=None (or not given) reads the old triangles from file.

area(normal=False, data=None)

Calculate wall element area.

Parameters:
normalbool, optional

If True, calculate and return the surface normal vectors as well.

datadict, optional

Dictionary with the wall data. If None, the data is read from the file.

Returns:
areaarray_like, (nelement,)

Surface areas of the wall elements.

nvecarray_like, (nelement,3)

Normal vectors of the wall elements in cartesian basis.

Note that the direction of the normal vector is not specifiec (it can vary between elements and point either inside or outside).

static convert_wall_2D(nphi, **kwargs)

Convert wall_2D input to wall_3D input.

This function repeats the 2D wall contour around the torus at intervals Delta phi = 2 pi / (nphi - 1). Then each (R, z) point is connected to a equivalent point in the adjacent contours by a line segment forming 3D wall made of rectangles. Finally each rectangle is divided into two triangles.

Parameters:
nphiint

Number of toroidal segments to be created.

**kwargs

Arguments passed to wall_2D.write_hdf5() excluding fn and desc.

Returns:
outdict

wall_2D converted as an input for write_hdf5().

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 consists of a single triangle on a poloidal plane.

Returns:
datadict

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

getwallcontour(phi=unyt_quantity(0, 'degree'))

Return a cross section of the wall with a given poloidal plane.

Parameters:
phifloat

Toroidal angle of the plane.

Returns:
linesarray_like (n,2,2)

Line segments [[[r1,z1], [r2,z2]], …] that form the cross section.

getwalloutline(z=0)

Return minimum and maximum wall R-coordinates as a function of phi at the given toroidal plane.

Parameters:
phigridarray_like

Toroidal coordinates.

Returns:
rminarray_like, (nphi,)

Minimum R-coordinate at each toroidal angle.

rmaxarray_like, (nphi,)

Maximum R-coordinate at each toroidal angle.

move_component(movement, direction, component)

@Params: filename Filename where the wall will be saved. movement How much the component is moved in metres direction Which direction the component is moved [x, y, z] component Bool array of the points of a component wall Wall object where the wall is copied from, if left empty active wall from filename will be used

@return the new wall data

noderepresentation(w_indices=None)

Return an array of vertices and indices that define this wall.

Parameters:
w_indicesarray_like, optional

list of of triangle indices for which the node representation is done i.e. [ind1, ind2, …, indn].

Can also be a Boolean array with the same size as the number of wall triangles.

Returns:
verticesfloat, array_like <br>

Triangle vertices in a format [[x1, y1, z1], …, [xn, yn, zn]] where n is 3 x number of triangles.

facesint, array_like <br>

Array of dimension (number of triangles, 4) where each four length array defines a wall elemenet as [number of vertices, i1, i2, i3] where number of vertices is always 3 and i1, i2, and i3 define the indices of the vertices in the vertices array.

read()

Read data from HDF5 file.

Returns:
datadict

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

remove_small_triangles(maximumAreaToRemove=0.0, data=None)

The modification happens in-place. No deep copy is made!

set_flags(names, indexes)

@Params: names list of strings containing names of various flags indexes which flag indexes (zero indexed, last index value not included) correspond to each flag, list of tuples

example with 1000 triangles:

names = [‘foo’,’bar’,’baz’] indexes = [(0,10), (10,100), (100,1000)]

@return the new wall data

static write_hdf5(fn, nelements, x1x2x3, y1y2y3, z1z2z3, flag=None, flagIdList=None, flagIdStrings=None, desc=None)

Write input data to the HDF5 file.

Parameters:
fnstr

Full path to the HDF5 file.

nelementsint

Number of wall triangles

x1x2x3array_like (nelements,3)

Each triangle’s vertices’ x coordinates [m].

y1y2y3array_like (nelements,3)

Each triangle’s vertices’ y coordinates [m].

z1z2z3array_like (nelements,3)

Each triangle’s vertices’ z coordinates [m].

flagarray_like (nelements,1), optional

Integer array depicting the wall component of each triangle.

flagIdListarray_like (nUniqueFlags), optional

List of keys (int) of the flagIdStrings.

flagIdStringsarray_like (nUniqueFlags), optional

List of values (str) of the flagIdStrings.

descstr, optional

Input description.

Returns:
namestr

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

Raises:
ValueError

If the triangle vertices or flags have incorrect shape.