boutpy.boutdata
– exchanging data to/from BOUT++¶Table of Contents
boutgrid
– More Information about BOUT++ GridField
– Field Classmap_pfile2grid
– Map Experimental Profile to Gridcollect
– collect datarestart
– manipulate restart filesgen_surface
– Flux Surface Generatorpol_slice
– Poloidal Sliceboutgrid
– More Information about BOUT++ Grid¶boutpy.boutdata.
boutgrid
(gridfile)[source]¶BOUT++ grid object based on netcdf grid.
Attributes: |
|
---|
Methods
get_alpha(V0=0, pressure=None) | Return local and global normalized pressure gradient. |
get_magnetic_shear(V0=0) | Return local and global magnetic shear s. |
get_minor_r(method=1) | Return minor radius. |
get_peak_GradP0() | Return peak position of Gradient P0 at outer mid-plane. |
get_psin(yind=None, index=False, verbose=True) | Get normalized psin from gridfile. |
get_xind(psin=0.95) | Return xind of psin at outer mid-plane to the psin . |
get_q(q95=False) | Return Safety Factor q. |
get_volume(V0=0) | Return volume enclosed by flux surface. |
surface_average(var, area=False) | Perform surface average. |
topology() | Check topology of the grid. |
get_alpha
(V0=0, pressure=None)[source]¶Return local and global normalized pressure gradient.
local \(\alpha\) [6]:
global \(\alpha\) [7]:
in which the \(V\) is the volume enclosed by the flux surface.
In BOUT++ grid, it can be expressed as:
where the Jacobian is \(J(\psi, \theta) = J(x, y) = hthe/Bp\). The volume inside the inner boundary \(\psi_{in}\) should be calculated separately:
Parameters: |
|
---|---|
Returns: |
|
References
[6] | P.W. Xi, et. al., Phys. Rev. Lett. 112, 085001 (2014); |
[7] | R.L. Miller, et. al., Physics of Plasmas 5, 973 (1998); |
get_magnetic_shear
(V0=0)[source]¶Return local and global magnetic shear s.
local megnetic shear s [8]:
\[s = \dfrac{r}{q}\dfrac{dp}{dr}\]
global megnetic shear s [9] [10]:
\[\begin{split}s & = \dfrac{2V \partial_\psi q}{\partial_\psi V} \\ & = 2V \dfrac{\partial q(\psi)}{\partial V(\psi)} \\ & \approx \dfrac{r}{q}\dfrac{dp}{dr}\end{split}\]
in which the \(V\) is the volume enclosed by the flux surface.
Returns: |
|
---|
References
[8] | P.W. Xi, et. al., Phys. Rev. Lett. 112, 085001 (2014); |
[9] | R.L. Miller, et. al., Physics of Plasmas 5, 973 (1998); |
[10] | F.M. Levinton, et. al., Phys. Rev. Lett. 75, 4417 (1995); |
get_minor_r
(method=1)[source]¶Retrun minor radius.
Parameters: |
|
---|---|
Returns: |
|
get_peak_GradP0
(pressure=None)[source]¶Return peak position of Gradient P0 at outer mid-plane.
Parameters: |
|
---|---|
Returns: |
|
get_psin
(yind=None, index=False, verbose=False)[source]¶Get normalized psi_n from gridfile
Parameters: |
|
---|---|
Returns: |
|
get_q
(q95=False)[source]¶Return Safety Factor q.
Safety Factor q:
Parameters: |
|
---|---|
Returns: |
|
get_volume
(V0=0)[source]¶Return volume enclosed by flux surface.
Parameters: |
|
---|
get_xind
(psin=0.95)[source]¶Return xind of psin at outer mid-plane nearest to the psin
.
Parameters: |
|
---|---|
Returns: |
|
surface_average
(var, area=False, method=1)[source]¶Perform surface average
Parameters: |
|
---|
Notes
This function is based on IDL function in BOUT_TOP/tools/idllib/surface_average.pro.
Field
– Field Class¶boutpy.boutdata.
Field
[source]¶Methods
moment_xyzt(axis=-1) | return (dc, rms) parts at axis=`axis`. |
dc(axis=-1) | return dc parts at axis=`axis`. |
rms(axis=-1) | return rms parts at axis=`axis`. |
normalize(norm=None) | data normalized by norm if norm is given, otherwise maximum used. |
plot(*arg, **kwargs) | plot line(s) or animated lines for 1D/2D data. |
contourf(*args, **kwargs) | plot (animated) contour/contourf/surface plot for 2D/3D data. |
showdata(*args, **kwargs) | Visualiaztion and animation for 1/2/3D data. |
contourf
(*args, **kwargs)[source]¶Plot (animated) contour/contourf/surface plot for 2D/3D data.
Parameters: |
|
---|---|
Returns: |
|
normalize
(norm=None)[source]¶return normalizaed array.
Parameters: |
|
---|
plot
(*args, **kwargs)[source]¶plot line(s) or animated lines for 1D/2D data
Parameters: |
|
---|---|
Returns: |
|
See also
showdata
(*args, **kwargs)[source]¶Visualisation and animation for 1-3D data.
This function is just a wrapper function for plot and contourf. All args and kwargs are passed to these functions according to the dimension of data and key ‘kind’.
Parameters: |
|
---|
See also
boutpy.boutdata.Field.plot()
boutpy.boutdata.Field.contourf()
map_pfile2grid
– Map Experimental Profile to Grid¶map_1d4grid (x, y, gridfile[, index, ext, …]) |
Map 1D-profile to grid |
map_nc2grid (gridfile, ncfile[, output, Er, …]) |
Map 1D profiles in ncfile to netcdf grid generated by hypnotoad.pro |
map_pfile2grid (gridfile, pfile[, output, …]) |
Map pfile to netcdf grid generated by hypnotoad.pro |
Map 1D experimental profiles to netcdf grid generated by hypernotoad.pro
boutpy.boutdata.map_pfile2grid.
map_1d4grid
(x, y, gridfile, index=None, ext=u'const', kind=u'cubic', sigma=8, mode=u'nearest', wtitle=u'', Er=None, vfilter=None, units=None, smooth=u'1st', w=None, sfactor=None, verbose=False, check_positive=False, **kwargs)[source]¶Map 1D-profile to grid
basic rule: constant in y-direction
map \(E_r\):
- E_r = er*Rxy*Bpxy/(Rxy*Bpxy)_omp,
- E_r = omgeb*Rxy*Bpxy
leg regions
- SOL region: same as the nearest line which has core part
- private flux region: constant values which are same as separatrix
Warning
The smooth method(smooth=gaussian: gaussian_filter1d) will slightly make the gradient at boundary closer to 0.
Parameters: |
|
---|---|
Returns: |
|
boutpy.boutdata.map_pfile2grid.
map_pfile2grid
(gridfile, pfile, output=None, Er=u'omgeb', verbose=False, **kwargs)[source]¶Map pfile to netcdf grid generated by hypnotoad.pro
Parameters: |
|
---|---|
Returns: |
|
boutpy.boutdata.map_pfile2grid.
map_nc2grid
(gridfile, ncfile, output=None, Er=u'omgeb', verbose=False, **kwargs)[source]¶Map 1D profiles in ncfile to netcdf grid generated by hypnotoad.pro
Parameters: |
|
---|---|
Returns: |
|
collect
– collect data¶Function is for collecting data parallelly and more efficiently.
boutpy.boutdata.collect.
collect
(varname, xind=None, yind=None, zind=None, tind=None, path='data', yguards=False, info=False, prefix='BOUT.dmp', nthreads=None, shift=True, checkt=False)[source]¶Collect a variable from a set of BOUT++ outputs in parallel.
Parameters: |
|
---|---|
Returns: |
|
Notes
the shift option is set to True by default, which means it returns the data in [x, y, z, t] order which is different from the previous version in [t, x, y, z] order.
restart
– manipulate restart files¶Routines for manipulating restart files.
boutpy.boutdata.restart.
split
(nxpe, nype, path='data', output='./', informat='nc', outformat=None)[source]¶Split restart files across NXPE x NYPE processors.
Returns True on success
boutpy.boutdata.restart.
expand
(newz, path='data', output='./', informat='nc', outformat=None)[source]¶Increase the number of Z points in restart files
boutpy.boutdata.restart.
create
(averagelast=1, final=-1, path='data', output='./', informat='nc', outformat=None)[source]¶Create restart files from data (dmp) files.
Parameters: |
|
---|
gen_surface
– Flux Surface Generator¶pol_slice
– Poloidal Slice¶Takes a 3D variable, and returns a 2D slice at fixed toroidal angle.
N sets the number of times the data must be repeated for a full torus, e.g. n=2 is half a torus zangle gives the (real) toroidal angle of the result
boutpy.boutdata.pol_slice.
pol_slice
(data3d, 'gridfile', n=1, zangle=0.0)[source]¶data2d = pol_slice(data3d, ‘gridfile’, n=1, zangle=0.0)
Parameters: |
|
---|---|
Returns: |
|
boutpy.boutdata.pol_slice.
polslice
(var3d, gridfile, n=1, zangle=0.0, profile=None)[source]¶Return a 2D slice by interpolation.
Parameters: |
|
---|---|
Returns: |
|