NREL / GEOPHIRES-X

MIT License
26 stars 21 forks source link

JEDI Geothermal Implementation #221

Open softwareengineerprogrammer opened 1 month ago

softwareengineerprogrammer commented 1 month ago

Parent issue: https://github.com/NREL/GEOPHIRES-X/issues/169


Implementation being handled by @aimiktena & @natakokota (I can't assign them directly because they are not added as collaborators on this repo)


  1. Download a fresh copy of 01d-jedi-geothermal-model-rel-gt12-23-16.xlsm and open it in Excel (other programs such as Google Sheets or Numbers on Mac may also work, although Excel is recommended to reduce chances of compatibility issues affecting formulas). It is strongly recommended that you DO NOT REUSE the same original file repeatedly in order to reduce the risk of accidentally editing it. You should be careful to avoid editing the sheet at all throughout this entire process, as it will be hard to catch and correct alterations.

  2. Pick an initial output to calculate from the Summary Results sheet, i.e. Jobs (FTE) Total Impacts in cell B28: image

  3. Add the output to JediGeothermalResult, suffixed with units, i.e. operating_years_annual_earnings_MUSD: https://github.com/NREL/GEOPHIRES-X/blob/94ddec5e699f3b2915a365333514134abd2dc67e/src/jedi_geothermal/__init__.py#L18-L28

  4. Using Excel, follow & write down the formulas that calculate that output until you get back to inputs

  5. Add the required inputs to JediGeothermalInputParameters (if not already present), i.e. resource_depth_m: https://github.com/NREL/GEOPHIRES-X/blob/94ddec5e699f3b2915a365333514134abd2dc67e/src/jedi_geothermal/__init__.py#L31-L40

  6. Add a python function to src/jedi_geothermal/__init__.py that implements the formula you wrote down, calculating the output from the inputs, i.e.

    def get_operating_years_annual_earnings_MUSD(resource_depth_m):
    return resource_depth_m * 5 # dummy example formula, obviously =]
  7. Call the function in get_jedi_geothermal_result using input values from input_params and setting the corresponding output on JediGeothermalResult, i.e.

    
    class JediGeothermalClient:
    def __init__(self):
        self._logger = _logger
    
    def get_jedi_geothermal_result(self, input_params: JediGeothermalInputParameters) -> JediGeothermalResult:
        self._logger.info(f'Calculating JEDI result for: {input_params}')
        result: JediGeothermalResult = JediGeothermalResult
        result.operating_years_annual_earnings_MUSD = get_operating_years_annual_earnings_MUSD(input_params.resource_depth_m)
    
      # [... other calculations ...]
    
       return result
8. Write one or more tests in [`tests/jedi_geothermal_tests/test_jedi_geothermal.py`](https://github.com/NREL/GEOPHIRES-X/blob/94ddec5e699f3b2915a365333514134abd2dc67e/tests/jedi_geothermal_tests/test_jedi_geothermal.py) i.e.
```python
def test_calculate_operating_years_annual_earnings():
    self.assertEqual(500, get_operating_years_annual_earnings_MUSD(100))