77from pathlib import Path
88from typing import Any
99
10+ import numpy as np
11+
12+ # noinspection PyProtectedMember
13+ from geophires_x .EconomicsSam import _cash_flow_profile_row
1014from geophires_x .OptionList import PlantType
1115from geophires_x .OptionList import WellDrillingCostCorrelation
1216from geophires_x_client import GeophiresXClient
1317from geophires_x_client import GeophiresXResult
18+
19+ # noinspection PyProtectedMember
1420from geophires_x_client import _get_logger
1521from geophires_x_client .geophires_input_parameters import EndUseOption
1622from geophires_x_client .geophires_input_parameters import GeophiresInputParameters
@@ -1306,7 +1312,9 @@ def test_royalty_rate(self):
13061312 from_file_path = self ._get_test_file_path (
13071313 'geophires_x_tests/generic-egs-case-2_sam-single-owner-ppa.txt'
13081314 ),
1309- params = {'Royalty Rate' : royalty_rate },
1315+ params = {
1316+ 'Royalty Rate' : royalty_rate ,
1317+ },
13101318 )
13111319 )
13121320 opex_result = result .result ['OPERATING AND MAINTENANCE COSTS (M$/yr)' ]
@@ -1332,7 +1340,22 @@ def test_royalty_rate(self):
13321340
13331341 if royalty_rate > 0.0 :
13341342 self .assertEqual (58.88 , opex_result [royalties_output_name ]['value' ])
1335- self .assertGreater (royalty_holder_npv_MUSD , 0 ) # FIXME WIP
1336- else :
1343+ self .assertGreater (royalty_holder_npv_MUSD , 0 )
1344+
1345+ royalties_cash_flow_MUSD = [
1346+ it * 1e-6
1347+ for it in _cash_flow_profile_row (
1348+ result .result ['SAM CASH FLOW PROFILE' ], 'O&M production-based expense ($)'
1349+ )
1350+ ]
1351+
1352+ self .assertAlmostEqual (
1353+ np .average (royalties_cash_flow_MUSD [1 :]), opex_result [royalties_output_name ]['value' ], places = 1
1354+ )
1355+
1356+ if royalty_rate == 0.1 :
1357+ self .assertAlmostEqual (708.07 , royalty_holder_npv_MUSD , places = 2 )
1358+
1359+ if royalty_rate == 0.0 :
13371360 self .assertEqual (0 , opex_result [royalties_output_name ]['value' ])
13381361 self .assertEqual (0 , royalty_holder_npv_MUSD )
0 commit comments