Function adas.run_adas405

def run_adas405(uid='adas', year=None, elem=None, defyear=89, filter=None, partial=False, mh=1.0, mz=1.0, files=None, te=[0.0], dens=[0.0], unit_te='ev', all=False, tion=[0.0], denh=[0.0], cx=False, logfile=None)

Runs the adas405 equilibrium balance code.

Parameters

uid : str
username of adf11 location. Defaults to 'adas' for central ADAS data.
year : int
year of adf11 data
elem : str
symbol of element
defyear : int
default year of adf11 data if an adf11 file with year does not exist, defaults to 89 if not set
filter : str
filter extension for power files, default is None
partial : boolean
if True the adf11 files, and the calculation, will be metastable-resolved, default is false
mh : float
hydrogen isotope mass, needed for CX
mz : float
element isotope mass, needed for CX
files : dict, optional
replace the adf11 files constructed from uid/year/defyear/elem/partial with fully specified filenames - not all file names are required - just those for replacement.
  'acd' : recombination rates
  'scd' : ionization rates
  'ccd' : charge exchange recombination rates
  'qcd' : metastable cross coupling rates, if partial is True
  'xcd' : parent cross coupling rates, if partial is True
  'prb' : recombination power coefficients
  'prc' : CX recombination power coefficients
  'plt' : line power coefficients
te : float, array
requested temperatures (eV)
dens : float, array
requested densities (cm-3)
unit_te : str, optional
units, eV or K, for temperature, default is 'ev'
all : boolean
if True evaluate as 2D (te,dens), default is False
tion : float, array, optional
requested ion temperatures (eV), needed for CX
denh : float, array, optional
requested densities (cm-3), needed for CX
cx : boolean
if True include thermal CX as a recombination process, default is False
logfile : str
name of log file, defaults to no output file

Returns

frac : dict
fractional abundances
'stage' : labels of ion/metastable descriptors
'ion'   : equilibrium abundances
power : dict
radiated power and its components
 'stage' : labels of ion/metastable descriptors
 'ion'   : stage contribution to power
 'plt'   : line power
 'prb'   : continuum power (recombination + bremsstrahlung)
 'prc'   : CX power
 'total' : total line power

Notes

The required adf11 files can be very succinctly specified by a year token and element name. For metastable resolved calculations and those with thermal CX with H0 as a recombination process, more information is required. Complete flexibility in supplying the adf11 files is via the files dictionary.

In the returned frac and power dictionaries the dimensions are (nte, nstage) where nte is the number of Te/dens pairs or (ndens, nte, nstage) when 2D is requested (ie all=True). Note that nstage includes the fully stripped species (nstage-Z0+1).

Calls a fortran executable code and communicates via a bi-directional pipe connected to stdout.

References

ADAS manual description of adas405: http://www.adas.ac.uk/man/chap4-05.pdf

Version History

  • Martin O'Mullane, 20-08-2012

    • First version
  • Martin O'Mullane, 24-04-2013

    • Dimension ion quantities from the values in the acd file since this is not related to Z for superstage adf11 datasets.
  • Martin O'Mullane, 16-01-2014

    • For python3 compatibility, change print statement to a function and use adas_write_pipe to send the appropriate stream to the bi-directional pipe.
  • Martin O'Mullane, 19-12-2015

    • The line, continuum and CX powers were mis-labelled in the power output dictionary.
  • Martin O'Mullane, 29-06-2017

    • Use datetime.now() rather than datetime.utcnow()
  • Martin O'Mullane, 06-08-2018

    • Change the default uid to 'adas' from None.
    • Fix failure to work with a single input temperature or density.
    • Return stage labels as strings, not byte arrays.
  • Martin O'Mullane, 07-11-2018

    • Correct method for forming resolved names from uid and year.
    • Call adf11_nmeta.py to calculate the number of stages. This works for resolved and un-resolved data.
  • Martin O'Mullane, 08-11-2019

    • Move construction and checking of filenames to a separate routine.
    • Fix reshaping of fractional abundances for 2D (all=True).

Examples

Equilibrium ionization balance of neon using ADAS 96 data - recommended GCR coefficients as a function of temperature in a fixed density.

>>> import adas as adas
>>> import numpy as np
>>> te=np.geomspace(5, 100.0, 4)
>>> dens=np.zeros(4)+1e13
>>> frac, power=adas.run_adas405(elem='ne', year=96, te=te, dens=dens)
>>> print('Ne5+ abundance : ', frac['ion'][:,5])
Ne5+ abundance :  [1.95489282e-17 9.25744325e-03 2.13619828e-01 6.54479754e-06]
>>> print('Total power : ', power['total'])
Total power :  [7.99152304e-28 1.89806312e-26 4.56436214e-26 1.28680171e-27]