ukaea/PROCESS

Inequality constraint for injected power coded with the wrong sign[BUG]

Closed this issue · 2 comments

Describe the bug

In constraint_equations.f90 the constraint residue tmp_cc should be coded such that it will be negative if the constraint is satisfied, although the code is a little confusing:

      cc(i) = tmp_cc
....
    ! Issue 505 Reverse the sign so it works as an inequality constraint (cc(i) > 0)
    ! This will have no effect if it is used as an equality constraint because it will be squared.
    cc = -cc

This seems to have been coded incorrectly for the following case:

   subroutine constraint_eqn_030(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units)
      !! Equation for injection power upper limit
..
      tmp_cc =  1.0D0 - pinjmw / (fpinj * pinjalw)

If the actual value of the injected power pinjmw is smaller than the specified upper limit pinjalw and fpinj=1 (constraint is physically satisfied) then tmp_cc is positive, which is incorrect.

@timothy-nunn @jmorris-uk

Steps to reproduce

See attached output file in comment below. Tim has made this converge by setting fpinj=0.25.

Expected behaviour

tmp_cc should be negative when pinjmw is smaller than the specified upper limit pinjalw and fpinj=1 .

Additional context

This only arises when inequality constraints are used instead of f-values.

The constraint table in OUT.DAT is a little confusing because the constraint residue printed seems to be positive or negative at random, irrespective of whether the constraint is physically an upper or lower limit (indicated by the symbol < or >).

As far as I can see at the moment the injected power limit is the only inequality with this problem, although this should be checked.

Also the symbol is incorrect for the LH threshold power, which is a lower limit but is printed as "<".