tscw_module package

Submodules

tscw_module.tscw_DataClassesInput module

class tscw_module.tscw_DataClassesInput.FieldData(n_fluid, tvd, delta_z, medium_type, medium_id)[source]

Bases: object

Class to create a field data file (*_gaca.fd.txt) as input for TSWC-GACA. Later on the following methods need to be performed for each instance of the class. For each step the according methods will check for correct inputs and prevent error in the exported txt-file.

Workflow for Generating field data.

—- 1. BOREHOLE —-
  1. ‘add_boreholeVector’

  2. ‘add_radialComment’ (optional)

  3. ‘add_boreholeInclination’

  4. ‘add_materialProperty’ (depending on vertical discretisation)

  5. ‘add_temperature’ - borehole

—- 2. CAVNERN —-
  1. ‘add_cavernVector’

  2. ‘add_temperature’ - cavern

  3. ‘add_cavernCharacteristics’

—- The last step is to export the field data to an txt-file with the method ‘export_fieldData’. —-

add_boreholeInclination(inclination)[source]

Add inclination for borehole

Parameters:

inclination (array [1xp_borehole] oder 'vertical') – either array [1 x p_borehole] with deg data or ‘vertical’

add_boreholeVector(radial_vector, aggregate_state)[source]

Adds a radial vector within the borehole [m] and respective aggregate states (‘FLUID’ or ‘SOLID’).

Parameters:
  • radial_vector (list or array [m]) – must be strictly increasing, will define self.m_borehole [int].

  • aggregate_state (string array) – list of strings either ‘FLUID’ or ‘SOLID’. Does not need to have the same length as radial_vector. Remaining values will be filled with ‘SOLID’.

add_element(starting_coor, end_coor, material_data, name=None)[source]

Add material properties of an element to the borehole model.

Parameters:
  • starting_coor (tuple) – (z0, x0) - Top coordinates of element at the top left corner.

  • end_coor (tuple) – (z1, x1) - Bottom coordinates of element at the bottom right corner.

  • material_data (dict) – for example: {‘rho’: 1000, ‘cp’: 4180,’lambda’: 0.6} Units respt. in [kg/m3], [J/kg*K], [W/(m*K)],

  • name (_type_, optional) – Name, defaults to None

add_formation(top, bottom, material_data, name=None)[source]

Add Formation elements after having initilised formation.

Parameters:
  • top (float) – start of layer [m]

  • bottom (float) – end of layer [m]

  • material_data (dict) – for example: {‘rho’: 1000, ‘cp’: 4180,’lambda’: 0.6} Units respt. in [kg/m3], [J/kg*K], [W/(m*K)],

  • name (str, optional) – _description_, defaults to None

add_materialProperty(top, bottom, heat_capacity, thermal_conductivity, name=None)[source]

Adds material properties to the borehole. The value for the center of gravity of the layer is then modeled, with indication in relation to the bottom edge of the layer. Hierarchical; new values overwrite respective old values at the same intervals.

Parameters:
  • top (int or float) – start of layer [m]

  • bottom (int or float) – end of layer [m]

  • heat_capacity (array [1 x m_borehole]) – [MJ/(m3K)]

  • thermal_conductivity ([W/(m K)]) – [1 x m_borehole]

  • name (str, optional) – Name of the layer, will be displayed in .txt file when exported, defaults to None

add_radialComment(radialComment)[source]

Add comments for radial borehole vector. Will be displayed lather in txt file (OPTIONAL - for overview purpose only). If the array has a length of e.g. 5, then the comment is valid for the first five radial elements.

Parameters:

radialComment (array) – E.g. [‘ID 858’,’OD 858’,’ID 1134’, ‘ZEMENT’, ‘FORMATION’]

add_temperature(temperature, mode)[source]

Adds temperature data to the borehole or cavern.

Parameters:
  • temperature (_type_) – (p_borehole x m_borehole) array for ‘borehole or (m_cavern) for cavern

  • mode (str) – either ‘borehole’, ‘cavern’, ‘reservoir’

define_fluid_space(indices)[source]

Define which elements of radial_borehole_vector are not ‘SOLID’-

Parameters:
  • indices (int or float) – If integer -> index, if float -> search for closest match in radial_borehole_vector

  • names (string) – either ‘FLUID’ or ???

initialise_formation(radial_vector_formation)[source]

Initilise radial points for formation

Parameters:

radial_vector_formation (array) – radial points

plot_geometry(xlimits=None, export_folder=None)[source]

Plots geometry.

Parameters:
  • xlimits (list, optional) – start and end value of radial range, defaults to None

  • export_folder (str, optional) – Export plot data into folder, defaults to None

Returns:

Two figures for heat capacity * rho and lambda

Return type:

fig_cp, fig_lambda

class tscw_module.tscw_DataClassesInput.GacaFieldData(n_boreholes, n_fluid, tvd, delta_z, medium_type_cavern, medium_id_cavern)[source]

Bases: FieldData

add_cavernCharacteristics(refdepth_cavern, density_salt, specific_heat_capacity_salt, heat_conductivity_salt, height_cavern, volume_brine_equivalent, radius_brine_level, pressure_cavern, temperature_brine_equivalent=None)[source]

Add cavern characteristics:

Parameters:
  • refdepth_cavern (float) – reference depth for cavern pressure and modeling [m]

  • density_salt (float) – [kg/m3]

  • specific_heat_capacity_salt (float) – [J/kgK]

  • heat_conductivity_salt (float) – [W/mK]

  • height_cavern (float) – consists of H_zy + 2*rad_cav [m]

  • volume_brine_equivalent (float) – [m3]

  • radius_brine_level (float) – [m]

  • pressure_cavern (float) – [MPa]

  • temperature_brine_equivalent (float, optional) – [°C], defaults to None

add_cavernVector(radial_vector)[source]

Adds a radial vector within the cavern. The first element is the cavern radius.

Parameters:

radial_vector (list or array [m]) – must be strictly increasing, will define self.m_cavern [int].

export_fieldData(save_folder, project_name, is_binary_export=False)[source]

Exports TSCW konform txt-File with suffix “_gaca.fd.txt”.

Args:

save_folder (Path): Folder where the project is located. project_name (str): Project name (this will be a subfolder in save_folder) is_binary_export (bool, optional): Export an additional *.pickle file which can be later loaded into python. Defaults to False.

class tscw_module.tscw_DataClassesInput.ProcessData(description, coupled_annuli, medium_type, medium_id, tscw_module='gaca')[source]

Bases: object

MAP_MODULE_TO_FILE_EXT = {'gaca': '_gaca.pd.txt', 'tscl': '_tscl.pd.txt', 'tsgf': '_tsgf.pd.txt'}
add_stage(stage_data)[source]

Erlaubt flexibles hinzufügen von stages. Stages werden chronologisch hinzugefügt. WICHTIG: Schlüsselnamen aus dict müssen mit Variablenname von TSWC übereinstimmen, erlaubt sind folgende Namen:

  • ‘TERMINATION_ID’,

  • ‘TERMINATION_QUANTITY’,

  • ‘DT_MAX’,

  • ‘FLOW_RATE’,

  • ‘P_BOUNDARY_CONDITION’,

  • ‘BOUNDARY_PRESSURE’,

  • ‘T_BOUNDARY_CONDITION’,

  • ‘BOUNDARY_TEMPERATURE’,

  • ‘K_S’

‘TERMINATION_ID’ und ‘TERMINATION_QUANTITY’ müssen eingegeben werden!

Parameters:

stage_data (dict) – Enthält alle erforderlichen Parameter in der Form {Schlüssel: Wert}

export_processData(save_folder, project_name, subfolder='')[source]

Exports class to a txt-File with the suffix depending on tscw_module. Will will be exported to a folder named (path, project_name, suffix). If it does not exist, it will be created.

Parameters:
  • save_folder (str) – _description_

  • project_name (str) – _description_

  • subfolder (str, optional) – defaults to ‘’

class tscw_module.tscw_DataClassesInput.TsclFieldData(n_fluid, tvd, delta_z, medium_type_cavern, medium_id_cavern)[source]

Bases: FieldData

add_cavernCharacteristics(cavern_net_volume_0, medium_type_cavern, medium_id_cavern, depth_cavern, dr_max_cavern, dr_1_cavern, dr_1_saltrock, f_dr, r_max_cavern, temperature_cavern, temperature_salt, density_salt, specific_heat_capacity_salt, heat_conductivity_salt, height_cavern, conductance_weight_factor)[source]

Add cavern charistics

Args:

cavern_net_volume_0 (float): _description_ medium_type_cavern (str): _description_ medium_id_cavern (int): _description_ depth_cavern (float): _description_ dr_max_cavern (float): _description_ dr_1_cavern (float): _description_ dr_1_saltrock (float): _description_ f_dr (float): _description_ r_max_cavern (float): _description_ temperature_cavern (float): _description_ temperature_salt (float): _description_ density_salt (float): _description_ specific_heat_capacity_salt (float): _description_ heat_conductivity_salt (float): _description_ height_cavern (float): _description_ conductance_weight_factor (float): _description_

export_fieldData(save_folder, project_name, is_binary_export=False)[source]

Exports TSCW konform txt-File with suffix “_tscl.fd.txt”.

Args:

save_folder (Path): Folder where the project is located. project_name (str): Project name (this will be a subfolder in save_folder) is_binary_export (bool, optional): Export an additional *.pickle file which can be later loaded into python. Defaults to False.

class tscw_module.tscw_DataClassesInput.TsgfFieldData(n_fluid, tvd, delta_z, medium_type_cavern, medium_id_cavern)[source]

Bases: FieldData

add_reservoirCharacteristics(refdepth_reservoir, pressure_reservoir, minsky_A, minsky_B)[source]

Adds reservoir characteristics.

Parameters:
  • refdepth_reservoir (float) – reference depth for reservoir pressure and modeling [m]

  • pressure_reservoir (float) – reservoir pressure [MPa]

  • minsky_A (float) – Filtration coefficient A

  • minsky_B (float) – Filtration coefficient B

export_fieldData(save_folder, project_name, is_binary_export=False)[source]

Exports TSCW konform txt-File with suffix “_tsgf.fd.txt”.

Args:

save_folder (Path): Folder where the project is located. project_name (str): Project name (this will be a subfolder in save_folder) is_binary_export (bool, optional): Export an additional *.pickle file which can be later loaded into python. Defaults to False.

tscw_module.tscw_DataClassesOutput module

class tscw_module.tscw_DataClassesOutput.TSCW_TBHC(path)[source]

Bases: TSCW_Output

Reads data from Projektname_i_pTBHC.txt Important attributes: self.sr_df: - meta data self.vertT_df: - temperature data self.vertP_df: - pressure data

calculate_axial_forces(meta_data, z_ref, T0, is_export=False, p_RR=3)[source]

Calculates resulting axial forces

Parameters:
  • meta_data (dict) – dictionary containing meta data.

  • z_ref (_type_) – reference depth, temperature and pressure array will be calculated by the mean at z_ref and z0 = 0m.

  • T0 (float, optional) – Initial temperature for reference in delta_T

  • is_export (bool, optional) – _description_, defaults to False

  • p_RR (float) – float, anulus pressure for calculating Fz_ges_rr in MPa.

Returns:

pandas dataframe containing forces

Return type:

pd.Dataframe

export_csv(depths)[source]

Exports data to a xlsx- file.

Parameters:

depths (list) – which depths to export (alogrithm looks for closest match)

extract_max_force(i_etappe, mode, min_time=0)[source]

Extracts min or max Fz_ges for a selected Stage.

Parameters:
  • i_etappe (int) – Stage number

  • mode (str) – either ‘min’ or ‘max’

  • min_time (float, optional) – float - minimum time that has passed after the value is selected, put in +inf to select end of stage, 0 by default, defaults to 0

Returns:

pd.Dataframe containing relevant parameters, respective index in self.df

Return type:

_type_

plot_axial_forces(is_export=False)[source]

Plots axial forces of forces_df.

Parameters:

is_export (bool, optional) – Export as png, defaults to False

Return type:

figure

plot_cavern_pt_development(is_export=False)[source]

Plots cavern pressure - temperature development over time.

Parameters:

is_export (bool, optional) – defaults to False

plot_forces_difference(depths, save_folder, xlimits, *args)[source]

Plot difference between calculated forces. Pass other TSWC_TBHC instances as input (comma separated).

Args: :type depths: :param depths: depths to plot :type depths: list :type save_folder: Path :param save_folder: Folder or Path where to save figure. :type save_folder: Path :type xlimits: :param xlimits: set xlimits for Plot. :type xlimits: List (x1, x2) :type args: :param args: Other instances of TSWC_TBHC. :type args: list of TSWC_TBHC instances.

Returns: _type_: Figure

Return type:

figure

plot_pt_difference(depths, save_folder, xlimits, *args)[source]

_summary_

Args: :type depths: :param depths: depths to plot :type depths: list :type save_folder: Path :param save_folder: Folder or Path where to save figure. :type save_folder: Path :type xlimits: :param xlimits: set xlimits for Plot. :type xlimits: List (x1, x2) :type args: :param args: Other instances of TSWC_TBHC. :type args: list of TSWC_TBHC instances.

Returns: _type_: Figure

Return type:

figure

plot_tp_vs_depth(time_t=None, time_p=None, is_export=False)[source]

Plots borehole temperature - pressure development over depth.

Parameters:
  • depth_t (_type_, optional) – which time intervals for Temperature, by default all

  • depth_p (_type_, optional) – which time intervals for Pressure, by default all

  • is_export (bool, optional) – defaults to False

plot_tp_vs_time(depth_t=None, depth_p=None, is_export=False)[source]

_summary_

Parameters:
  • depth_t (_type_, optional) – which depth intervals for Temperature, by default all

  • depth_p (which depth intervals for Pressure, by default all) – _description_, defaults to None

  • is_export (bool, optional) – defaults to False

class tscw_module.tscw_DataClassesOutput.TSCW_TFBH(path)[source]

Bases: TSCW_Output

Reads data from /*_TFBH.TXT (Radial temperature along depth in borehole). Stores data in self.data: - data

create_movie(range_radial=None, is_export=False, n_levels=100, field_data_picklePath=None)[source]

Generates a time lapse of the simulated temperature.

Parameters:
  • range_radial (list, optional) – [x0, x1] range of radial start and end point (no exact match needed), defaults to None

  • is_export (bool, optional) – export movie as .mp4 into the same folder of current instance, defaults to False

  • n_levels (int, optional) – how many levels for plt.contourf, defaults to 150

  • field_data_picklePath (str, optional) – path to (/*.pickle) of FieldData class (if it has been exported). If loaded, the geometry will be displayed in the background., defaults to None

Returns:

animation

Return type:

animation.FuncAnimation

plot_temp_distribution(times, depths=None, range_radial=None, is_colormap=True, n_levels=150, is_export=False, field_data_picklePath=None)[source]

The values given in all input lists do not need to match exactly with the simulation result. The algorithm automatically finds the nearest neighbor.

Parameters:
  • times (list) – which time points

  • depths (list, optional) – which depth points, defaults to None

  • range_radial (list, optional) – [x0, x1] beginning and end of radial range, defaults to None

  • is_colormap (bool, optional) – plot as a colormap or line plot, defaults to True

  • n_levels (int, optional) – how many levels in pcolormesh plot, defaults to 150

  • is_export (bool, optional) – export figure into parent folder of file, defaults to False

  • field_data_picklePath (str) – path to (/*.pickle) of FieldData class (if it has been exported). If loaded, the geometry will be displayed in the background., defaults to None

Return type:

figure

class tscw_module.tscw_DataClassesOutput.TSCW_TFC(path)[source]

Bases: TSCW_Output

Reads data from /*_TFC.TXT (cavern temperature over time) Stores data in self.data: - data

plot_temp_distribution(times, range_radial=None, is_export=False)[source]

Plot radial temperature development in cavern over time.

Parameters:
  • times (list) – which time points

  • range_radial (list, optional) – [x0, x1] beginning and end of radial range, defaults to None

tscw_module.thermreg_DataClasses module

class tscw_module.thermreg_DataClasses.ThermregData(path, n_depths=None)[source]

Bases: TSCW_Output

Read in and process Thermreg output data.

calculate_axial_forces(meta_data, T0=None, vectors=<class 'tuple'>, is_export=False)[source]

Calculates resulting axial forces INPUT: meta_data: dictionary containing meta data. T0: Initial temperature for reference in delta_T vectors: tuple - (temperature, pressure) [K, MPa] is_export: true or false - as a xlsx file OUTPUT Dataframe

export_csv()[source]

Export Thermreg p-T data into a xlsx file.

extract_max_force(i_etappe, mode, min_time=0)[source]

Extracts min or max Fz_ges for a selected Stage. INPUT: i_etappe: int - Stage number mode: either ‘min’ or ‘max’ min_time: float - minimum time that has passed after the value is selected, put in +inf to select end of stage, 0 by default OUTPUT: filtered_df: pd.Dataframe containing relevant parameters df_index: int - index of total Dataframe df of respective class.

interpolate_pt(time_array)[source]

Interpolates pressure and temperature for a new time_array INPUT: time_array: list - new time array OUTPUT thermreg_temp_inter - interpolated temperature array thermreg_pres_inter - interpolated pressure array

plot_all_tempfields(radial_vector=None, x2_limit=None, is_export=False)[source]

_summary_

Parameters:
  • depths (_type_, optional) – self.depths

  • radial_vector (_type_, optional) – _description_, defaults to None

  • x2_limit (float, optional) – _description_, defaults to None

  • is_export (bool, optional) – _description_, defaults to False

plot_axial_forces(is_export=False)[source]

Plots axial forces of forces_df. INPUT: is_export: bool - Export as png [optional] OUTPUT figure

plot_tp_vs_depth(time_t=None, time_p=None, is_export=False)[source]

Plots borehole temperature - pressure development over depth.

Parameters:
  • depth_t (_type_, optional) – which time intervals for Temperature, by default all

  • depth_p (_type_, optional) – which time intervals for Pressure, by default all

  • is_export (bool, optional) – defaults to False

plot_tp_vs_time(depth_t=None, depth_p=None, is_export=False)[source]

_summary_

Parameters:
  • depth_t (_type_, optional) – which depth intervals for Temperature, by default all

  • depth_p (which depth intervals for Pressure, by default all) – _description_, defaults to None

  • is_export (bool, optional) – defaults to False

Module contents