Skip to content

objectives

Objective function routine

objective_function(i_figure_merit, data)

Calculate the specified objective function

Parameters:

Name Type Description Default
i_figure_merit int

the ID and sign of the figure of merit to evaluate. A negative value indicates maximisation. A positive value indicates minimisation. * 1: Major radius * 3: Neutron wall load * 4: TF coil + PF coil power * 5: Fusion gain * 6: Cost of electricity * 7: Direct/constructed/capital cost * 8: Aspect ratio * 9: Divertor heat load * 10: Toroidal field on axis * 11: Injected power * 14: Pulse length * 15: Plant availability * 16: Major radius/burn time * 17: Net electrical output * 18: NULL, f(x) = 1 * 19: Major radius/burn time

required
data DataStructure

data structure object for providing data to the objective function

required

Raises:

Type Description
ProcessValueError

If i_figure_merit=15 not used with i_plant_availability=1

Source code in process/core/solver/objectives.py
 11
 12
 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
 45
 46
 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
103
104
105
106
107
def objective_function(i_figure_merit: int, data: DataStructure) -> float:
    """Calculate the specified objective function

    Parameters
    ----------
    i_figure_merit : int
        the ID and sign of the figure of merit to evaluate.
        A negative value indicates maximisation.
        A positive value indicates minimisation.
        * 1: Major radius
        * 3: Neutron wall load
        * 4: TF coil + PF coil power
        * 5: Fusion gain
        * 6: Cost of electricity
        * 7: Direct/constructed/capital cost
        * 8: Aspect ratio
        * 9: Divertor heat load
        * 10: Toroidal field on axis
        * 11: Injected power
        * 14: Pulse length
        * 15: Plant availability
        * 16: Major radius/burn time
        * 17: Net electrical output
        * 18: NULL, f(x) = 1
        * 19: Major radius/burn time
    data: DataStructure
        data structure object for providing data to the
        objective function

    Raises
    ------
    ProcessValueError
        If i_figure_merit=15 not used with i_plant_availability=1
    """
    try:
        figure_of_merit = FiguresOfMerit(abs(i_figure_merit))
    except ValueError as err:
        raise ProcessValueError(
            f"Invalid i_figure_merit value: {i_figure_merit}"
        ) from err

    # -1 = maximise
    # +1 = minimise
    objective_sign = np.sign(i_figure_merit)
    match FiguresOfMerit(figure_of_merit):
        case FiguresOfMerit.MAJOR_RADIUS:
            objective_metric = 0.2 * data.physics.rmajor
        case FiguresOfMerit.NEUTRON_WALL_LOAD:
            objective_metric = data.physics.pflux_fw_neutron_mw
        case FiguresOfMerit.P_TF_PLUS_P_PF:
            objective_metric = (data.tfcoil.tfcmw + 1e-3 * data.pf_power.srcktpm) / 10.0
        case FiguresOfMerit.FUSION_GAIN_Q:
            objective_metric = data.current_drive.big_q_plasma
        case FiguresOfMerit.COST_OF_ELECTRICITY:
            objective_metric = data.costs.coe / 100.0
        case FiguresOfMerit.CAPITAL_COST:
            objective_metric = (
                data.costs.cdirt / 1.0e3
                if data.costs.ireactor == 0
                else data.costs.concost / 1.0e4
            )
        case FiguresOfMerit.ASPECT_RATIO:
            objective_metric = data.physics.aspect
        case FiguresOfMerit.DIVERTOR_HEAT_LOAD:
            objective_metric = data.divertor.pflux_div_heat_load_mw
        case FiguresOfMerit.TOROIDAL_FIELD:
            objective_metric = data.physics.b_plasma_toroidal_on_axis
        case FiguresOfMerit.TOTAL_INJECTED_POWER:
            objective_metric = data.current_drive.p_hcd_injected_total_mw
        case FiguresOfMerit.PULSE_LENGTH:
            objective_metric = data.times.t_plant_pulse_burn / 2.0e4
        case FiguresOfMerit.PLANT_AVAILABILITY_FACTOR:
            if (
                AvailabilityModel(data.costs.i_plant_availability)
                == AvailabilityModel.USER_INPUT
            ):
                raise ProcessValueError(
                    "i_figure_merit=15 requires `f_t_plant_available` to be calculated, "
                    "not user input"
                )
            objective_metric = data.costs.f_t_plant_available
        case FiguresOfMerit.MIN_R0_MAX_TAU_BURN:
            objective_metric = 0.95 * (data.physics.rmajor / 9.0) - 0.05 * (
                data.times.t_plant_pulse_burn / 7200.0
            )
        case FiguresOfMerit.NET_ELECTRICAL_OUTPUT:
            objective_metric = data.heat_transport.p_plant_electric_net_mw / 500.0
        case FiguresOfMerit.NULL_FIGURE_OF_MERIT:
            objective_metric = 1.0
        case FiguresOfMerit.MAX_Q_MAX_T_PLANT_PULSE_BURN:
            objective_metric = -0.5 * (data.current_drive.big_q_plasma / 20.0) - 0.5 * (
                data.times.t_plant_pulse_burn / 7200.0
            )
        case _:
            raise ProcessValueError(f"Unknown figure_of_merit: {figure_of_merit}")

    return objective_sign * objective_metric