reV.SAM.generation.Geothermal

class Geothermal(resource, meta, sam_sys_inputs, site_sys_inputs=None, output_request=None, drop_leap=False)[source]

Bases: AbstractSamGenerationFromWeatherFile

reV-SAM geothermal generation.

As of 12/20/2022, the resource potential input in SAM is only used to calculate the number of well replacements during the lifetime of a geothermal plant. It was decided that reV would not model well replacements. Therefore, reV sets the resource potential to match (or be just above) the gross potential so that SAM does not throw any errors.

Also as of 12/20/2022, the SAM GETEM module requires a weather file, but does not actually require any weather data to run. Therefore, reV currently generates an empty weather file to pass to SAM. This behavior can be easily updated in the future should the SAM GETEM module start using weather data.

See the PySAM Geothermal documentation for the configuration keys required in the sam_sys_inputs config. Some notable keys include (non-exhaustive):

  • resource_type : Integer flag representing either Hydrothermal (0) or EGS (1) resource. Only values of 0 or 1 allowed.

  • resource_potential : Total resource potential at location (in MW).

    Important

    reV automatically sets the resource potential to match the gross potential (see documentation above), so this key should be left out of the config (it will be overridden in any case).

  • resource_temp : Temperature of resource (in C).

    Important

    This value is set by reV based on the user’s geothermal resource data input. To override this behavior, users may specify their own resource_temp value (either a single value for all sites in the SAM geothermal config or a site-dependent value in the project points CSV). In this case, the resource temperature from the input data will be ignored completely, and the temperature at each location will be determined solely from this input.

  • resource_depth : Depth to geothermal resource (in m).

  • analysis_type : Integer flag representing the plant configuration. If the nameplate input is to be used to specify the plant capacity, then this flag should be set to 0 (this is the default reV assumption). Otherwise, if the num_wells input is to be used to specify the plant site, then this flag should be set to 1. Only values of 0 or 1 allowed.

  • nameplate : Geothermal plant size (in kW). Only affects the output if analysis_type=0.

    Important

    Unlike wind or solar, reV geothermal dynamically sets the size of a geothermal plant. In particular, the plant capacity is set to match the resource potential (obtained from the input data) for each site. For this to work, users must leave out the nameplate key from the SAM config.

    Alternatively, users may specify their own nameplate capacity value (either a single value for all sites in the SAM geothermal config or a site-dependent value in the project points CSV). In this case, the resource potential from the input data will be ignored completely, and the capacity at each location will be determined solely from this input.

  • num_wells : Number of wells at each plant. This value is used to determined plant capacity if analysis_type=1. Otherwise this input has no effect.

  • num_wells_getem : Number of wells assumed at each plant for power block calculations. Only affects power block outputs if analysis_type=0 (otherwise the num_wells input is used in power block calculations).

    Note

    reV does not currently adjust this value based on the resource input (as it probably should). If any power block outputs are required in the future, there may need to be extra development to set this value based on the dynamically calculated plant size.

  • conversion_type : Integer flag representing the conversion plant type. Either Binary (0) or Flash (1). Only values of 0 or 1 allowed.

  • design_temp : EGS plant design temperature (in C). Only affects EGS runs. This value may be adjusted internally by ``reV under the following conditions:

    • The design temperature is larger than the resource temperature

    • The design temperature is lower than the resource temperature by a factor of MAX_RT_TO_EGS_RATIO

    If either of these conditions are true, the design_temp is adjusted to match the resource temperature input in order to avoid SAM errors.

  • set_EGS_PDT_to_RT : Boolean flag to set EGS design temperature to match the resource temperature input. If this is True, the design_temp input is ignored. This helps avoid SAM/GETEM errors when the plant design temperature is too high/low compared to the resource temperature.

  • geotherm.cost.inj_prod_well_ratio : Fraction representing the injection to production well ratio (0-1). SAM GUI defaults to 0.5 for this value, but it is recommended to set this to the GETEM default of 0.75.

You may also include the following reV-specific keys:

  • num_confirmation_wells : Number of confirmation wells that can also be used as production wells. This number is used to determined to total number of wells required at each plant, and therefore the total drilling costs. This value defaults to 2 (to match the SAM GUI as of 8/1/2023). However, the default value can lead to negative costs if the plant size is small (e.g. only 1 production well is needed, so the costs equal -1 * drill_cost_per_well). This is a limitation of the SAM calculations (as of 8/1/2023), and it is therefore useful to set num_confirmation_wells=0 when performing reV runs for small plant sizes.

  • capital_cost_per_kw : Capital cost values in $/kW. If this value is specified in the config, reV calculates and overrides the total capital_cost value based on the geothermal plant size (capacity) at each location.

  • fixed_operating_cost : Fixed operating cost values in $/kW. If this value is specified in the config, reV calculates and overrides the total fixed_operating_cost value based on the geothermal plant size (capacity) at each location.

  • drill_cost_per_well : Drilling cost per well, in $. If this value is specified in the config, reV calculates the total drilling costs based on the number of wells that need to be drilled at each location. The drilling costs are added to the total capital_cost at each location.

  • reV_outages : Specification for reV-scheduled stochastic outage losses. For example:

    outage_info = [
        {
            'count': 6,
            'duration': 24,
            'percentage_of_capacity_lost': 100,
            'allowed_months': ['January', 'March'],
            'allow_outage_overlap': True
        },
        {
            'count': 10,
            'duration': 1,
            'percentage_of_capacity_lost': 10,
            'allowed_months': ['January'],
            'allow_outage_overlap': False
        },
        ...
    ]
    

    See the description of add_scheduled_losses() or the reV losses demo notebook for detailed instructions on how to specify this input.

  • reV_outages_seed : Integer value used to seed the RNG used to compute stochastic outage losses.

  • time_index_step : Integer representing the step size used to sample the time_index in the resource data. This can be used to reduce temporal resolution (i.e. for 30 minute NSRDB input data, time_index_step=1 yields the full 30 minute time series as output, while time_index_step=2 yields hourly output, and so forth).

Initialize a SAM generation object.

Parameters:
  • resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)

  • meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.

  • sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.

  • site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.

  • output_request (list) – Requested SAM outputs (e.g., ‘cf_mean’, ‘annual_energy’, ‘cf_profile’, ‘gen_profile’, ‘energy_yield’, ‘ppa_price’, ‘lcoe_fcr’).

  • drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.

Methods

add_scheduled_losses([resource])

Add stochastically scheduled losses to SAM config file.

annual_energy()

Get annual energy generation value in kWh from SAM.

assign_inputs()

Assign the self.sam_sys_inputs attribute to the PySAM object.

cf_mean()

Get mean capacity factor (fractional) from SAM.

cf_profile()

Get hourly capacity factor (frac) profile in local timezone.

check_resource_data(resource)

Check resource dataframe for NaN values

collect_outputs([output_lookup])

Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.

default()

Get the executed default PySAM Geothermal object.

drop_leap(resource)

Drop Feb 29th from resource df with time index.

energy_yield()

Get annual energy yield value in kwh/kw from SAM.

ensure_res_len(arr, time_index)

Ensure time_index has a constant time-step and only covers 365 days (no leap days).

execute()

Call the PySAM execute method.

gen_profile()

Get power generation profile (local timezone) in kW.

get_sam_res(*args, **kwargs)

Get the SAM resource iterator object (single year, single file).

get_time_interval(time_index)

Get the time interval.

make_datetime(series)

Ensure that pd series is a datetime series with dt accessor

outputs_to_utc_arr()

Convert array-like SAM outputs to UTC np.ndarrays

reV_run(points_control, res_file, site_df[, ...])

Execute SAM generation based on a reV points control instance.

run()

Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.

run_gen_and_econ()

Run SAM generation and possibility follow-on econ analysis.

set_resource_data(resource, meta)

Generate the weather file and set the path as an input.

tz_elev_check(sam_sys_inputs, ...)

Check timezone+elevation input and use json config timezone+elevation if not in resource meta.

Attributes

DIR

IGNORE_ATTRS

MAX_RT_TO_EGS_RATIO

Max value of resource_temperature/EGS_plan_design_temperature

MODULE

OUTAGE_CONFIG_KEY

Specify outage information in the config file using this key.

OUTAGE_SEED_CONFIG_KEY

Specify a randomizer seed in the config file using this key.

PYSAM_WEATHER_TAG

WF_META_DROP_COLS

attr_dict

Get the heirarchical PySAM object attribute dictionary.

has_timezone

Returns true if instance has a timezone set

input_list

Get the list of lowest level input attribute/variable names.

meta

Get meta data property.

module

Get module property.

outage_seed

A value to use as the seed for the outage losses.

pysam

Get the pysam object.

site

Get the site number for this SAM simulation.

MAX_RT_TO_EGS_RATIO = 1.134324

Max value of resource_temperature/EGS_plan_design_temperature

PYSAM = <module 'PySAM.Geothermal' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/PySAM/Geothermal.cpython-38-x86_64-linux-gnu.so'>
static default()[source]

Get the executed default PySAM Geothermal object.

Returns:

PySAM.Geothermal

cf_profile()[source]

Get hourly capacity factor (frac) profile in local timezone. See self.outputs attribute for collected output data in UTC.

Returns:

cf_profile (np.ndarray) – 1D numpy array of capacity factor profile. Datatype is float32 and array length is 8760*time_interval.

assign_inputs()[source]

Assign the self.sam_sys_inputs attribute to the PySAM object.

set_resource_data(resource, meta)[source]

Generate the weather file and set the path as an input.

The Geothermal PySAM model requires a data file, not raw data. This method generates the weather data, writes it to a file on disk, and then sets the file as an input to the Geothermal generation module. The function run_gen_and_econ() deletes the file on disk after a run is complete.

Parameters:
  • resource (pd.DataFrame) – Time series resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation.

  • meta (pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.

run_gen_and_econ()[source]

Run SAM generation and possibility follow-on econ analysis.

OUTAGE_CONFIG_KEY = 'reV_outages'

Specify outage information in the config file using this key.

OUTAGE_SEED_CONFIG_KEY = 'reV_outages_seed'

Specify a randomizer seed in the config file using this key.

add_scheduled_losses(resource=None)

Add stochastically scheduled losses to SAM config file.

This function reads the information in the reV_outages key of the sam_sys_inputs dictionary and computes stochastically scheduled losses from that input. If the value for reV_outages is a string, it must have been generated by calling json.dumps() on the list of dictionaries containing outage specifications. Otherwise, the outage information is expected to be a list of dictionaries containing outage specifications. See Outage for a description of the specifications allowed for each outage. The scheduled losses are passed to SAM via the hourly key to signify which hourly capacity factors should be adjusted with outage losses. If no outage info is specified in sam_sys_inputs, no scheduled losses are added.

Parameters:

resource (pd.DataFrame, optional) – Time series resource data for a single location with a pandas DatetimeIndex. The year value of the index will be used to seed the stochastically scheduled losses. If None, no yearly seed will be used.

See also

Outage

Single outage specification.

Notes

The scheduled losses are passed to SAM via the hourly key to signify which hourly capacity factors should be adjusted with outage losses. If the user specifies other hourly adjustment factors via the hourly key, the effect is combined. For example, if the user inputs a 33% hourly adjustment factor and reV schedules an outage for 70% of the farm down for the same hour, then the resulting adjustment factor is

This means the generation will be reduced by ~80%, because the user requested 33% losses for the 30% the farm that remained operational during the scheduled outage (i.e. 20% remaining of the original generation).

annual_energy()

Get annual energy generation value in kWh from SAM.

Returns:

output (float) – Annual energy generation (kWh).

property attr_dict

Get the heirarchical PySAM object attribute dictionary.

Returns:

_attr_dict (dict) –

Dictionary with:

keys: variable groups values: lowest level attribute/variable names

cf_mean()

Get mean capacity factor (fractional) from SAM.

Returns:

output (float) – Mean capacity factor (fractional).

check_resource_data(resource)

Check resource dataframe for NaN values

Parameters:

resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)

collect_outputs(output_lookup=None)

Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.

Parameters:

output_lookup (dict | None) – Lookup dictionary mapping output keys to special output methods. None defaults to generation default outputs.

static drop_leap(resource)

Drop Feb 29th from resource df with time index.

Parameters:

resource (pd.DataFrame) – Resource dataframe with an index containing a pandas time index object with month and day attributes.

Returns:

resource (pd.DataFrame) – Resource dataframe with all February 29th timesteps removed.

energy_yield()

Get annual energy yield value in kwh/kw from SAM.

Returns:

output (float) – Annual energy yield (kwh/kw).

static ensure_res_len(arr, time_index)

Ensure time_index has a constant time-step and only covers 365 days (no leap days). If not remove last day

Parameters:
  • arr (ndarray) – Array to truncate if time_index has a leap day

  • time_index (pandas.DatatimeIndex) – Time index associated with arr, used to check time-series frequency and number of days

Returns:

arr (ndarray) – Truncated array of data such that there are 365 days

execute()

Call the PySAM execute method. Raise SAMExecutionError if error. Include the site index if available.

gen_profile()

Get power generation profile (local timezone) in kW. See self.outputs attribute for collected output data in UTC.

Returns:

output (np.ndarray) – 1D array of hourly power generation in kW. Datatype is float32 and array length is 8760*time_interval.

static get_sam_res(*args, **kwargs)

Get the SAM resource iterator object (single year, single file).

classmethod get_time_interval(time_index)

Get the time interval.

Parameters:

time_index (pd.series) – Datetime series. Must have a dt attribute to access datetime properties (added using make_datetime method).

Returns:

time_interval (int:) – This value is the number of indices over which an hour is counted. So if the timestep is 0.5 hours, time_interval is 2.

property has_timezone

Returns true if instance has a timezone set

property input_list

Get the list of lowest level input attribute/variable names.

Returns:

_inputs (list) – List of lowest level input attributes.

static make_datetime(series)

Ensure that pd series is a datetime series with dt accessor

property meta

Get meta data property.

property module

Get module property.

property outage_seed

A value to use as the seed for the outage losses.

Type:

int

outputs_to_utc_arr()

Convert array-like SAM outputs to UTC np.ndarrays

property pysam

Get the pysam object.

classmethod reV_run(points_control, res_file, site_df, lr_res_file=None, output_request=('cf_mean',), drop_leap=False, gid_map=None, nn_map=None, bias_correct=None)

Execute SAM generation based on a reV points control instance.

Parameters:
  • points_control (config.PointsControl) – PointsControl instance containing project points site and SAM config info.

  • res_file (str) – Resource file with full path.

  • site_df (pd.DataFrame) – Dataframe of site-specific input variables. Row index corresponds to site number/gid (via df.loc not df.iloc), column labels are the variable keys that will be passed forward as SAM parameters.

  • lr_res_file (str | None) – Optional low resolution resource file that will be dynamically mapped+interpolated to the nominal-resolution res_file. This needs to be of the same format as resource_file, e.g. they both need to be handled by the same rex Resource handler such as WindResource

  • output_request (list | tuple) – Outputs to retrieve from SAM.

  • drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.

  • gid_map (None | dict) – Mapping of unique integer generation gids (keys) to single integer resource gids (values). This enables the user to input unique generation gids in the project points that map to non-unique resource gids. This can be None or a pre-extracted dict.

  • nn_map (np.ndarray) – Optional 1D array of nearest neighbor mappings associated with the res_file to lr_res_file spatial mapping. For details on this argument, see the rex.MultiResolutionResource docstring.

  • bias_correct (None | pd.DataFrame) – Optional DataFrame or CSV filepath to a wind or solar resource bias correction table. This has columns:

    • gid: GID of site (can be index name of dataframe)

    • method: function name from rex.bias_correction module

    The gid field should match the true resource gid regardless of the optional gid_map input. Only windspeed or GHI + DNI + DHI are corrected, depending on the technology (wind for the former, PV or CSP for the latter). See the functions in the rex.bias_correction module for available inputs for method. Any additional kwargs required for the requested method can be input as additional columns in the bias_correct table e.g., for linear bias correction functions you can include scalar and adder inputs as columns in the bias_correct table on a site-by-site basis. If None, no corrections are applied. By default, None.

Returns:

out (dict) – Nested dictionaries where the top level key is the site index, the second level key is the variable name, second level value is the output variable value.

run()

Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.

property site

Get the site number for this SAM simulation.

static tz_elev_check(sam_sys_inputs, site_sys_inputs, meta)

Check timezone+elevation input and use json config timezone+elevation if not in resource meta.

Parameters:
  • sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.

  • site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.

  • meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.

Returns:

meta (pd.DataFrame | pd.Series) – Dataframe or series for a single site. Will include “timezone” and “elevation” from the sam and site system inputs if found.