Skip to content

Errror in calculation of temperature margin [BUG] #3131

@mkovari

Description

@mkovari

A run-time error occurs in the calculation of the superconductor temperature margin, because a negative temperature thelium was sent to itersc in superconductors.py.

There are two different root finders used for calculating temperature margins - we know that neither is reliable. (They are the Newton-Raphson method in supercon in sctfcoil.py and secant_solve in maths_library.py.) It would be best to replace both by a root finder that works within preset bounds - for example scipy.optimize.brentq.

Temporary fix

I have corrected the test in the code, which previously was:

                if ttest <= 0:
                    error_handling.idiags[0] = lap
                    error_handling.fdiags[0] = ttest
                    error_handling.report_error(157)
                    break

to

                if ttest <= delt:
                    error_handling.idiags[0] = lap
                    error_handling.fdiags[0] = ttest
                    error_handling.report_error(157)
                    break

This escapes from the loop when the quantity ttestm = ttest - delt is less than zero, and sometimes allows Process to converge. Funnily enough, the error 157 is then not displayed.

Steps to reproduce

Expected behaviour

The root finder to calculate the temperature margin should never send a negative temperature for evaluation of the superconductor properties.

Evidence

The diagnostic print statement gives thelium and tc0eps.

Line 154 6.261 15.776698285176671
Line 154 0.002806361859818196 15.776698285176671
Line 154 -0.007193638140181804 15.776698285176671
/home/mkovari/PROCESS/process/superconductors.py:170: RuntimeWarning: invalid value encountered in scalar power
  bcrit = bc20eps * (1.0 - t**1.52)
/home/mkovari/PROCESS/process/superconductors.py:187: RuntimeWarning: invalid value encountered in scalar power
  jc2 = (1.0 - t**1.52) * (1.0 - t**2)  # t must be < 1 to avoid NaNs
Line 154 0.012806361859818196 15.776698285176671
Line 154 nan 15.776698285176671

Note that t = min(thelium / tc0eps, 0.9999).

Environment

  • Ubuntu 20.04.6 LTS

Additional context

The temperature margin is the difference between the current-sharing temperature and the operating temperature.
The current-sharing temperature is the temperature at which the critical current equals the operating current, at the operating field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions