From 4422c12155c110feaa3c5e1e078ff954ce2d103f Mon Sep 17 00:00:00 2001 From: ocean Date: Mon, 26 Jan 2026 14:49:42 +0000 Subject: [PATCH 1/4] Fixed negativity in sqrt in costs.py by np.clip. --- process/costs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/process/costs.py b/process/costs.py index f1aa09dc79..c5fe104d5e 100644 --- a/process/costs.py +++ b/process/costs.py @@ -3026,7 +3026,8 @@ def coelc(self): # Annual cost of operation and maintenance annoam = cost_variables.ucoam[cost_variables.lsa - 1] * np.sqrt( - heat_transport_variables.p_plant_electric_net_mw / 1200.0e0 + np.clip(heat_transport_variables.p_plant_electric_net_mw, 0, np.inf) + / 1200.0e0 ) # Additional cost due to pulsed reactor thermal storage @@ -3097,7 +3098,8 @@ def coelc(self): # Annual cost of waste disposal annwst = cost_variables.ucwst[cost_variables.lsa - 1] * np.sqrt( - heat_transport_variables.p_plant_electric_net_mw / 1200.0e0 + np.clip(heat_transport_variables.p_plant_electric_net_mw, 0, np.inf) + / 1200.0e0 ) # Cost of electricity due to waste disposal From f0b4ac4266a4fbcc32d36f3aa4246b3cc8f0cd02 Mon Sep 17 00:00:00 2001 From: ocean Date: Thu, 12 Feb 2026 10:09:36 +0000 Subject: [PATCH 2/4] Introduced a local variable sqrt_p_plant_electric_net_mw in the scope of the method coelc to warn in case p_plant_electric_net_mw is negative. Also caught a third place where sqrt_p_plant_electric_net_mw is needed .(missed earlier as it was commented out) --- process/costs.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/process/costs.py b/process/costs.py index c5fe104d5e..a0955fbf64 100644 --- a/process/costs.py +++ b/process/costs.py @@ -1,3 +1,5 @@ +import logging + import numpy as np from process import constants @@ -22,6 +24,8 @@ ) from process.exceptions import ProcessValueError +logger = logging.getLogger(__name__) + class Costs: def __init__(self): @@ -3025,8 +3029,18 @@ def coelc(self): # Annual cost of operation and maintenance - annoam = cost_variables.ucoam[cost_variables.lsa - 1] * np.sqrt( - np.clip(heat_transport_variables.p_plant_electric_net_mw, 0, np.inf) + if heat_transport_variables.p_plant_electric_net_mw < 0: + sqrt_p_plant_electric_net_mw = 0.0 + logger.warning( + "p_plant_electric_net_mw has gone negative!Clamping it to 0 now." + ) + else: + sqrt_p_plant_electric_net_mw = np.sqrt( + heat_transport_variables.p_plant_electric_net_mw + ) + annoam = ( + cost_variables.ucoam[cost_variables.lsa - 1] + * sqrt_p_plant_electric_net_mw / 1200.0e0 ) @@ -3044,7 +3058,7 @@ def coelc(self): # # Scale with net electric power # - # annoam1 = annoam1 * heat_transport_variables.p_plant_electric_net_mw/1200.0e0 + # annoam1 = annoam1 * sqrt_p_plant_electric_net_mw/1200.0e0 # # It is necessary to convert from 1992 pounds to 1990 dollars # Reasonable guess for the exchange rate + inflation factor @@ -3097,8 +3111,9 @@ def coelc(self): # Annual cost of waste disposal - annwst = cost_variables.ucwst[cost_variables.lsa - 1] * np.sqrt( - np.clip(heat_transport_variables.p_plant_electric_net_mw, 0, np.inf) + annwst = ( + cost_variables.ucwst[cost_variables.lsa - 1] + * sqrt_p_plant_electric_net_mw / 1200.0e0 ) From c65b013b3f14da95c4741744460dc49d127d3a03 Mon Sep 17 00:00:00 2001 From: Ocean Date: Thu, 12 Feb 2026 10:27:41 +0000 Subject: [PATCH 3/4] Update process/costs.py Clarified what's the purpose of the calculation inside the warning. Co-authored-by: Timothy <75321887+timothy-nunn@users.noreply.github.com> --- process/costs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/costs.py b/process/costs.py index a0955fbf64..dd735e74ea 100644 --- a/process/costs.py +++ b/process/costs.py @@ -3032,7 +3032,7 @@ def coelc(self): if heat_transport_variables.p_plant_electric_net_mw < 0: sqrt_p_plant_electric_net_mw = 0.0 logger.warning( - "p_plant_electric_net_mw has gone negative!Clamping it to 0 now." + "p_plant_electric_net_mw has gone negative! Clamping it to 0 for the calculation of annoam and annwst (cost of maintenance and cost of waste)." ) else: sqrt_p_plant_electric_net_mw = np.sqrt( From 0f6eb3a3c8a8281c79c52c5ff36145567b77e5d1 Mon Sep 17 00:00:00 2001 From: ocean Date: Thu, 12 Feb 2026 13:02:44 +0000 Subject: [PATCH 4/4] Bug fixes so regression test passes - Undid the comment line change (previously over-corrected) --- process/costs.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/process/costs.py b/process/costs.py index dd735e74ea..3ae2606b34 100644 --- a/process/costs.py +++ b/process/costs.py @@ -3030,18 +3030,17 @@ def coelc(self): # Annual cost of operation and maintenance if heat_transport_variables.p_plant_electric_net_mw < 0: - sqrt_p_plant_electric_net_mw = 0.0 + sqrt_p_plant_electric_net_mw_1200 = 0.0 logger.warning( "p_plant_electric_net_mw has gone negative! Clamping it to 0 for the calculation of annoam and annwst (cost of maintenance and cost of waste)." ) else: - sqrt_p_plant_electric_net_mw = np.sqrt( - heat_transport_variables.p_plant_electric_net_mw + sqrt_p_plant_electric_net_mw_1200 = np.sqrt( + heat_transport_variables.p_plant_electric_net_mw / 1200.0e0 ) annoam = ( cost_variables.ucoam[cost_variables.lsa - 1] - * sqrt_p_plant_electric_net_mw - / 1200.0e0 + * sqrt_p_plant_electric_net_mw_1200 ) # Additional cost due to pulsed reactor thermal storage @@ -3058,7 +3057,7 @@ def coelc(self): # # Scale with net electric power # - # annoam1 = annoam1 * sqrt_p_plant_electric_net_mw/1200.0e0 + # annoam1 = annoam1 * heat_transport_variables.p_plant_electric_net_mw/1200.0e0 # # It is necessary to convert from 1992 pounds to 1990 dollars # Reasonable guess for the exchange rate + inflation factor @@ -3113,8 +3112,7 @@ def coelc(self): annwst = ( cost_variables.ucwst[cost_variables.lsa - 1] - * sqrt_p_plant_electric_net_mw - / 1200.0e0 + * sqrt_p_plant_electric_net_mw_1200 ) # Cost of electricity due to waste disposal