3
3
import os
4
4
import sys
5
5
from pathlib import Path
6
+ from typing import Any
6
7
7
8
from tabulate import tabulate
8
9
11
12
# ruff: noqa: I001 # Successful module initialization is dependent on this specific import order.
12
13
from geophires_x .Model import Model
13
14
15
+ # noinspection PyProtectedMember
14
16
from geophires_x .EconomicsSam import calculate_sam_economics , _sig_figs , _SAM_CASH_FLOW_PROFILE_KEY
17
+
18
+ # noinspection PyProtectedMember
15
19
from geophires_x .EconomicsSamCashFlow import _clean_profile
16
20
from geophires_x_client import GeophiresInputParameters
17
21
from geophires_x_client import GeophiresXClient
@@ -70,10 +74,10 @@ def test_cash_flow(self):
70
74
self .assertEqual (22 , len (cash_flow [0 ]))
71
75
72
76
def get_row (name : str ) -> list [float ]:
73
- return next ( r for r in cash_flow if r [ 0 ] == name )[ 1 :]
77
+ return EconomicsSamTestCase . _get_cash_flow_row ( cash_flow , name )
74
78
75
79
def get_single_value (name : str ) -> list [float ]:
76
- return get_row ( name )[0 ]
80
+ return EconomicsSamTestCase . _get_cash_flow_row ( cash_flow , name )[0 ]
77
81
78
82
self .assertListEqual (get_row ('PPA revenue ($)' ), get_row ('Total revenue ($)' ))
79
83
@@ -87,6 +91,29 @@ def get_single_value(name: str) -> list[float]:
87
91
m .economics .LCOE .value , get_single_value ('LCOE Levelized cost of energy nominal (cents/kWh)' ), places = 2
88
92
)
89
93
94
+ @staticmethod
95
+ def _get_cash_flow_row (cash_flow , name ):
96
+ return next (r for r in cash_flow if r [0 ] == name )[1 :]
97
+
98
+ def test_property_tax_rate (self ):
99
+ pt_rate = 0.01
100
+ m : Model = EconomicsSamTestCase ._new_model (
101
+ self ._egs_test_file_path (), additional_params = {'Property Tax Rate' : pt_rate }
102
+ )
103
+ m .read_parameters ()
104
+ m .Calculate ()
105
+
106
+ sam_econ = calculate_sam_economics (m )
107
+ cash_flow = sam_econ [_SAM_CASH_FLOW_PROFILE_KEY ]
108
+
109
+ def get_row (name : str ):
110
+ return EconomicsSamTestCase ._get_cash_flow_row (cash_flow , name )
111
+
112
+ ptv_row = get_row ('Property tax net assessed value ($)' )
113
+ pte_row = get_row ('Property tax expense ($)' )
114
+ self .assertIsNotNone (pte_row ) # FIXME WIP
115
+ self .assertAlmostEqual (ptv_row [1 ] * pt_rate , pte_row [1 ], places = 0 ) # Assumes 100% property tax basis
116
+
90
117
def test_only_electricity_end_use_supported (self ):
91
118
with self .assertRaises (RuntimeError ):
92
119
self ._get_result ({'End-Use Option' : 2 })
@@ -119,7 +146,11 @@ def test_sig_figs(self):
119
146
self .assertListEqual (_sig_figs ((1.14 , 2.24 ), 2 ), [1.1 , 2.2 ])
120
147
121
148
@staticmethod
122
- def _new_model (input_file : Path ) -> Model :
149
+ def _new_model (input_file : Path , additional_params : dict [str , Any ] | None = None ) -> Model :
150
+ if additional_params is not None :
151
+ params = GeophiresInputParameters (from_file_path = input_file , params = additional_params )
152
+ input_file = params .as_file_path ()
153
+
123
154
stash_cwd = Path .cwd ()
124
155
stash_sys_argv = sys .argv
125
156
0 commit comments