2121 _ppa_pricing_model ,
2222 _get_fed_and_state_tax_rates ,
2323)
24- from geophires_x .GeoPHIRESUtils import sig_figs
24+ from geophires_x .GeoPHIRESUtils import sig_figs , quantity
2525
2626# noinspection PyProtectedMember
2727from geophires_x .EconomicsSamCashFlow import _clean_profile , _is_category_row_label , _is_designator_row_label
@@ -559,7 +559,8 @@ def _accrued_financing(_r: GeophiresXResult) -> float:
559559 # 'Inflation Rate': 0.04769,
560560 # }
561561 # r3: GeophiresXResult = self._get_result(
562- # params3, file_path=self._get_test_file_path('generic-egs-case-3_no-inflation-rate-during-construction.txt')
562+ # params3,
563+ # file_path=self._get_test_file_path('generic-egs-case-3_no-inflation-rate-during-construction.txt')
563564 # )
564565 # self.assertEqual(15.0, _accrued_financing(r3))
565566 #
@@ -568,18 +569,22 @@ def _accrued_financing(_r: GeophiresXResult) -> float:
568569 # 'Inflation Rate During Construction': 0.15,
569570 # }
570571 # r4: GeophiresXResult = self._get_result(
571- # params4, file_path=self._get_test_file_path('generic-egs-case-3_no-inflation-rate-during-construction.txt')
572+ # params4,
573+ # file_path=self._get_test_file_path('generic-egs-case-3_no-inflation-rate-during-construction.txt')
572574 # )
573575 # self.assertEqual(15.0, _accrued_financing(r4))
574576
575577 def test_add_ons (self ):
576- add_ons_result = self ._get_result (
577- {'Do AddOn Calculations' : True }, file_path = self ._get_test_file_path ('egs-sam-em-add-ons.txt' )
578- )
579578 no_add_ons_result = self ._get_result (
580579 {'Do AddOn Calculations' : False }, file_path = self ._get_test_file_path ('egs-sam-em-add-ons.txt' )
581580 )
581+ self ._assert_capex_line_items_sum_to_total (no_add_ons_result )
582+
583+ add_ons_result = self ._get_result (
584+ {'Do AddOn Calculations' : True }, file_path = self ._get_test_file_path ('egs-sam-em-add-ons.txt' )
585+ )
582586 self .assertIsNotNone (add_ons_result )
587+ self ._assert_capex_line_items_sum_to_total (add_ons_result )
583588
584589 self .assertGreater (
585590 add_ons_result .result ['SUMMARY OF RESULTS' ]['Total CAPEX' ]['value' ],
@@ -613,6 +618,26 @@ def test_add_ons(self):
613618 file_path = self ._get_test_file_path ('egs-sam-em-add-ons.txt' ),
614619 )
615620
621+ def _assert_capex_line_items_sum_to_total (self , r : GeophiresXResult ):
622+ capex_line_items = {key : value for key , value in r .result ['CAPITAL COSTS (M$)' ].items () if value is not None }
623+
624+ total_capex_unit = capex_line_items ['Total CAPEX' ]['unit' ]
625+ total_capex = quantity (capex_line_items ['Total CAPEX' ]['value' ], total_capex_unit )
626+
627+ capex_line_item_sum = 0
628+ for line_item_name , capex_line_item in capex_line_items .items ():
629+ if line_item_name not in [
630+ 'Total CAPEX' ,
631+ 'Total surface equipment costs' ,
632+ 'Drilling and completion costs per well' ,
633+ 'Drilling and completion costs per vertical production well' ,
634+ 'Drilling and completion costs per vertical injection well' ,
635+ 'Drilling and completion costs per non-vertical section' ,
636+ ]:
637+ capex_line_item_sum += quantity (capex_line_item ['value' ], capex_line_item ['unit' ]).to (total_capex_unit )
638+
639+ self .assertEqual (total_capex , capex_line_item_sum )
640+
616641 @staticmethod
617642 def _new_model (input_file : Path , additional_params : dict [str , Any ] | None = None , read_and_calculate = True ) -> Model :
618643 if additional_params is not None :
0 commit comments