Skip to content

final

Final output at the end of a scan.

finalise(models, data, ifail, non_idempotent_msg=None)

Routine to print out the final point in the scan.

Writes to OUT.DAT and MFILE.DAT.

Parameters:

Name Type Description Default
models Models

physics and engineering model objects

required
data

data structure object to provide data to evaluate the constraints

required
ifail int

error flag

required
non_idempotent_msg None | str

warning about non-idempotent variables, defaults to None

None
Source code in process/core/final.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def finalise(models, data, ifail: int, non_idempotent_msg: str | None = None):
    """Routine to print out the final point in the scan.

    Writes to OUT.DAT and MFILE.DAT.

    Parameters
    ----------
    models : process.main.Models
        physics and engineering model objects
    data: DataStructure
        data structure object to provide data to evaluate the constraints
    ifail : int
        error flag
    non_idempotent_msg : None | str, optional
        warning about non-idempotent variables, defaults to None
    """
    if ifail == 1:
        po.oheadr(constants.NOUT, "Final Feasible Point")
    else:
        po.oheadr(constants.NOUT, "Final UNFEASIBLE Point")

    # Output relevant to no optimisation
    if numerics.ioptimz == -2:
        output_evaluation(data)

    # Print non-idempotence warning to OUT.DAT only
    if non_idempotent_msg:
        po.oheadr(constants.NOUT, "NON-IDEMPOTENT VARIABLES")
        po.ocmmnt(constants.NOUT, non_idempotent_msg)

    # Write output to OUT.DAT and MFILE.DAT
    op.write(models, constants.NOUT)

output_evaluation(data)

Write output for an evaluation run of PROCESS

Parameters:

Name Type Description Default
data

data structure object to provide data to evaluate the constraints

required
Source code in process/core/final.py
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def output_evaluation(data):
    """Write output for an evaluation run of PROCESS

    Parameters
    ----------
    data: DataStructure
        data structure object to provide data to evaluate the constraints
    """
    po.oheadr(constants.NOUT, "Numerics")
    po.ocmmnt(constants.NOUT, "PROCESS has performed an evaluation run.")
    po.oblnkl(constants.NOUT)

    # Evaluate objective function
    norm_objf = objective_function(numerics.minmax)
    po.ovarre(constants.MFILE, "Normalised objective function", "(norm_objf)", norm_objf)

    # Print the residuals of the constraint equations

    residual_error, value, residual, symbols, units = constraints.constraint_eqns(
        numerics.neqns + numerics.nineqns, -1, data
    )

    labels = [
        numerics.lablcc[j]
        for j in [i - 1 for i in numerics.icc[: numerics.neqns + numerics.nineqns]]
    ]
    physical_constraint = [f"{c} {u}" for c, u in zip(value, units, strict=False)]
    physical_residual = [f"{c} {u}" for c, u in zip(residual, units, strict=False)]

    table_data = {
        "Constraint Name": labels,
        "Constraint Type": symbols,
        "Physical constraint": physical_constraint,
        "Constraint residual": physical_residual,
        "Normalised residual": residual_error,
    }

    po.write(constants.NOUT, tabulate(table_data, headers="keys"))

    for i in range(numerics.neqns):
        constraint_id = numerics.icc[i]
        po.ovarre(
            constants.MFILE,
            f"{labels[i]} normalised residue",
            f"(eq_con{constraint_id:03d})",
            residual_error[i],
        )

    for i in range(numerics.nineqns):
        constraint_id = numerics.icc[numerics.neqns + i]
        po.ovarre(
            constants.MFILE,
            f"{labels[numerics.neqns + i]}",
            f"(ineq_con{constraint_id:03d})",
            residual_error[numerics.neqns + i],
        )