core icon indicating copy to clipboard operation
core copied to clipboard

BeamCXPEC interface class is missing the donor_metastable attribute used in BeamCXLine

Open vsnever opened this issue 2 years ago • 0 comments

The BeamCXLine model uses the donor_metastable attribute of the BeamCXPEC. https://github.com/cherab/core/blob/9ae5a3e5493632c0d4cc8deef3aa838bb0085275/cherab/core/model/beam/charge_exchange.pyx#L309-L312 However, the interface class of the BeamCXPEC does not have this attribute. https://github.com/cherab/core/blob/9ae5a3e5493632c0d4cc8deef3aa838bb0085275/cherab/core/atomic/rates.pxd#L53-L55 The attribute is added only in the openadas implementation of the BeamCXPEC. https://github.com/cherab/core/blob/9ae5a3e5493632c0d4cc8deef3aa838bb0085275/cherab/openadas/rates/cx.pxd#L23-L29

First, models should not use any attributes/methods that are not in the interface classes of atomic rates.

Second, because NullBeamCXPEC does not have a donor_metastable attribute, running code with missing CX PECs for some species will raise an AttributeError if atomic data is configured with missing_rates_return_null = True.

There are two possible solutions. The first is to add the donor_metastable attribute to the BeamCXPEC interface class, and the second is to update the AtomicData.beam_cx_pec() method to return a list of (donor_metastable, rate) pairs instead of a list of rates. I think the first solution is less invasive and will have less impact on user code.

@jacklovell, @Mateasek, which solution do you like better?

vsnever avatar Apr 12 '23 16:04 vsnever