|
| 1 | +Cherab interface |
| 2 | +================ |
| 3 | + |
| 4 | +Cherab (https://www.cherab.info/) is a python library for forward |
| 5 | +modelling diagnostics based on spectroscopic plasma emission. It is |
| 6 | +based on the Raysect (http://www.raysect.org/) scientific ray-tracing |
| 7 | +framework. |
| 8 | + |
| 9 | +Triangulation |
| 10 | +------------- |
| 11 | + |
| 12 | +Before Cherab can be used, a triangulated mesh must be generated. This |
| 13 | +mesh is stored in an attribute ``cherab_grid``. This can be attached to |
| 14 | +a Dataset or DataArray by calling the ``bout.with_cherab_grid()`` accessor:: |
| 15 | + |
| 16 | + ds = ds.bout.with_cherab_grid() |
| 17 | + |
| 18 | +Following operations will generate a grid if needed, but if this |
| 19 | +attribute is already present then the grid is not |
| 20 | +recalculated. Calling this method on a dataset before performing |
| 21 | +Cherab operations improves efficiency. |
| 22 | + |
| 23 | + |
| 24 | +Wall heat fluxes |
| 25 | +---------------- |
| 26 | + |
| 27 | +To calculate radiation heat fluxes to walls, first create an ``xbout.AxisymmetricWall`` |
| 28 | +object that represents a 2D (R, Z) axisymmetric wall. This can be done by |
| 29 | +reading the wall coordinates from a GEQDSK equilibrium file:: |
| 30 | + |
| 31 | + wall = xbout.wall.read_geqdsk("geqdsk") |
| 32 | + |
| 33 | +Triangulate a grid and attach to the dataset:: |
| 34 | + |
| 35 | + ds = ds.bout.with_cherab_grid() |
| 36 | + |
| 37 | +Extract a data array. This must be 2D (x, y) so select a single time |
| 38 | +slice and toroidal angle e.g. excitation radiation:: |
| 39 | + |
| 40 | + da = -bd['Rd+_ex'].isel(t=1, zeta=0) |
| 41 | + |
| 42 | +Remove potentially invalid data in the guard cells:: |
| 43 | + |
| 44 | + da[:2,:] = 0.0 |
| 45 | + da[-2:,:] = 0.0 |
| 46 | + |
| 47 | +Attach data to the Cherab triangulated mesh, returning an |
| 48 | +``xbout.cherab.TriangularData`` object that Cherab can work with:: |
| 49 | + |
| 50 | + data = da.bout.as_cherab_data() |
| 51 | + |
| 52 | +Calculate the wall heat fluxes:: |
| 53 | + |
| 54 | + result = data.wall_flux(cat_wall, pixel_samples=1000) |
| 55 | + |
| 56 | +This result is a list of dicts, one for each wall element. Those dicts |
| 57 | +contain coordinates "rz1" and "rz2", results "power_density" and |
| 58 | +"total_power". |
| 59 | + |
0 commit comments