pytanksim.classes.storagetankclasses

Contains classes which store the properties of the storage tanks.

The StorageTank and SorbentTank classes are part of this module.

Classes

StorageTank

Stores the properties of the storage tank.

SorbentTank

Stores properties of a fluid storage tank filled with sorbents.

Module Contents

class pytanksim.classes.storagetankclasses.StorageTank(stored_fluid, aluminum_mass=0, carbon_fiber_mass=0, steel_mass=0, vent_pressure=None, min_supply_pressure=100000.0, thermal_resistance=0, surface_area=0, heat_transfer_coefficient=0, volume=None, set_capacity=None, full_pressure=None, empty_pressure=None, full_temperature=None, empty_temperature=None, full_quality=1, empty_quality=1)

Stores the properties of the storage tank.

It also has methods to calculate useful quantities such as tank dormancy given a constant heat leakage rate, the internal energy of the fluid being stored at various conditions, etc.

volume

Internal volume of the storage tank (m^3).

Type:

float

stored_fluid

Object to calculate the thermophysical properties of the fluid being stored.

Type:

StoredFluid

aluminum_mass

The mass of aluminum making up the tank walls (kg). The default is 0.

Type:

float, optional

carbon_fiber_mass

The mass of carbon fiber making up the tank walls (kg). The default is 0.

Type:

float, optional

steel_mass

The mass of steel making up the tank walls (kg). The default is 0.

Type:

float, optional

vent_pressure

The pressure (Pa) at which the fluid being stored must be vented. The default is None. If None, the value will be taken as the maximum value where the CoolProp backend can calculate the properties of the fluid being stored.

Type:

float, optional

min_supply_pressure

The minimum supply pressure (Pa) for discharging simulations.The default is 1E5.

Type:

float, optional

thermal_resistance

The thermal resistance of the tank walls (K/W). The default is 0. If 0, the value will not be considered in simulations.

Type:

Callable, optional

surface_area

The surface area of the tank that is in contact with the environment (m^2). The default is 0.

Type:

float, optional

heat_transfer_coefficient

The heat transfer coefficient of the tank surface (W/(m^2 K)). The default is 0.

Type:

Callable, optional

Initialize a StorageTank object.

Parameters:
  • stored_fluid (StoredFluid) – Object to calculate the thermophysical properties of the fluid being stored.

  • aluminum_mass (float, optional) – The mass of aluminum making up the tank walls (kg). The default is 0.

  • carbon_fiber_mass (float, optional) – The mass of carbon fiber making up the tank walls (kg). The default is 0.

  • steel_mass (float, optional) – The mass of steel making up the tank walls (kg). The default is 0.

  • vent_pressure (float, optional) – The pressure (Pa) at which the fluid being stored must be vented. The default is None. If None, the value will be taken as the maximum value where the CoolProp backend can calculate the properties of the fluid being stored.

  • min_supply_pressure (float, optional) – The minimum supply pressure (Pa) for discharging simulations.The default is 1E5.

  • thermal_resistance (Callable or float, optional) –

    A function which returns the thermal resistance of the tank walls (K/W) as a function of tank pressure (Pa), tank temperature (K), time (s), and temperature of surroundings (K). The default is 0. If a float is provided, it will be converted to a function which returns that value everywhere. If both this and the arguments ‘surface_area’ and ‘heat_transfer_coefficient’ are passed, two values of thermal resistance will be calculated and the highest value between the two will be taken at each time step. Thus, to avoid confusion, one should either: (a) use the other two arguments together, or (b) use this one, but not both at the same time.

    If a callable is passed, it must have the signature:

    def tr_function(p, T, time, env_temp):
        # 'p' is tank pressure (Pa)
        # 'T' is tank temperature (K)
        # 'time' is the time elapsed within the simulation (s)
        # 'env_temp' is the temperature of surroundings (K)
        ....
        # Returned is the thermal resistance (K/W)
        return tr_value
    

  • surface_area (float, optional) – The surface area of the tank that is in contact with the environment (m^2). The default is 0.

  • heat_transfer_coefficient (Callable or float, optional) –

    A function which returns the heat transfer coefficient of the tank walls (W/(m^2 K)) as a function of tank pressure (Pa), tank temperature (K), time (s), and temperature of surroundings (K). The default is 0. If a float is provided, it will be converted to a function which returns that value everywhere.

    If a callable is passed, it must have the signature:

    def htc_function(p, T, time, env_temp):
        # 'p' is tank pressure (Pa)
        # 'T' is tank temperature (K)
        # 'time' is the time elapsed within the simulation (s)
        # 'env_temp' is the temperature of surroundings (K)
        ....
        # Returned is the heat transfer coefficient (W/(m^2 K))
        return heat_transfer_coef
    

  • volume (float, optional) – Internal volume of the storage tank (m^3). The default is None. This value is required unless the set capacity and operating conditions are defined, in which case the volume is calculated from the capacity and operating conditions.

  • set_capacity (float, optional) – Set internal capacity of the storage tank (mol). The default is None. If specified, this will override the user-specified tank volume.

  • full_pressure (float, optional) – Pressure (Pa) of the tank when it is considered full. The default is None.

  • empty_pressure (float, optional) – Pressure (Pa) of the tank when it is considered empty. The default is None.

  • full_temperature (float, optional) – Temperature (K) of the tank when it is considered full. The default is None.

  • empty_temperature (float, optional) – Temperature (K) of the tank when it is considered empty. The default is None.

  • full_quality (float, optional) – Vapor quality of the tank when it is considered full. The default is 1 (Gas).

  • empty_quality (float, optional) – Vapor quality of the tank when it is considered empty. The default is 1 (Gas).

Raises:
  • ValueError – If any of the mass values provided are less than 0.

  • ValueError – If the vent pressure set is higher than what can be calculated by ‘CoolProp’.

  • ValueError – If neither the volume nor the complete capacity and the pressure and temperature swing conditions were provided.

Returns:

A storage tank object which can be passed as arguments to dynamic simulations and can calculate certain properties on its own.

Return type:

StorageTank

capacity(p, T, q=0, unit='mol')

Return the amount of fluid stored in the tank at given conditions.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. Can vary between 0 and 1. The default is 0.

  • unit (str, optional) – Unit of the capacity to be returned. Valid units are “mol” and “kg”. The default is “mol”.

Returns:

Amount of fluid stored.

Return type:

float

capacity_bulk(p, T, q=0, unit='mol')

Calculate the amount of bulk fluid in the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. Can vary between 0 and 1. The default is 0.

  • unit (str, optional) – Unit of the capacity to be returned. Valid units are “mol” and “kg”. The default is “mol”.

Returns:

Amount of bulk fluid stored.

Return type:

float

find_quality_at_saturation_capacity(T, capacity)

Find vapor quality at the given temperature and capacity.

Parameters:
  • T (float) – Temperature (K)

  • capacity (float) – Amount of fluid in the tank (moles).

Returns:

Vapor quality of the fluid being stored. This is assuming that the fluid is on the saturation line.

Return type:

float

internal_energy(p, T, q=1)

Calculate the internal energy of the fluid inside of the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. The default is 1.

Returns:

Internal energy of the fluid being stored (J).

Return type:

float

conditions_at_capacity_temperature(cap, T, p_guess, q_guess)

Find conditions corresponding to a given capacity and temperature.

Parameters:
  • cap (float) – Amount of fluid inside the tank (moles).

  • T (float) – Temperature (K).

  • p_guess (float) – Initial guess for pressure value (Pa) to be optimized.

  • q_guess (float) – Initial guess for vaport quality value to be optimized.

Returns:

The optimization result represented as a OptimizeResult object. The relevant attribute for this method is x, the solution array. x[0] contains the pressure value and x[1] contains the vapor quality value.

Return type:

OptimizeResult

conditions_at_capacity_pressure(cap, p, T_guess, q_guess)

Find conditions corresponding to a given capacity and temperature.

Parameters:
  • cap (float) – Amount of fluid inside the tank (moles).

  • P (float) – Pressure (Pa).

  • T_guess (float) – Initial guess for temperature value (K) to be optimized.

  • q_guess (float) – Initial guess for vaport quality value to be optimized.

Returns:

The optimization result represented as a OptimizeResult object. The relevant attribute for this package is x, the solution array. x[0] contains the temperature value and x[1] contains the vapor quality value.

Return type:

scipy.optimize.OptimizeResult

calculate_dormancy(p, T, heating_power, q=0)

Calculate dormancy time given a constant heating rate.

Parameters:
  • p (float) – Initial tank pressure (Pa).

  • T (float) – Initial tank temperature (K).

  • heating_power (float) – The heating power going into the tank during parking (W).

  • q (float, optional) – Initial vapor quality of the tank. The default is 0 (pure liquid).

Returns:

Pandas dataframe containing calculation conditions and results. Each key stores a floating point number. The dictionary keys and their respective values are:

  • ”init pressure”: initial pressure

  • ”init temperature”: initial temperature

  • ”init quality”: initial vapor quality

  • ”dormancy time”: time until tank needs to be vented in seconds

  • ”final temperature”: temperature of the tank as venting begins

  • ”final quality”: vapor quality at the time of venting

  • ”final pressure”: pressure at the time of venting

  • ”capacity error”: error between final and initial capacity

  • ”total energy change”: difference in internal energy between the initial and final conditions

  • ”solid heat capacity contribution”: the amount of heat absorbed by the tank walls

Return type:

pd.DataFrame

thermal_res(p, T, time, env_temp)

Calculate the thermal resistance of the tank.

Parameters:
  • p (float) – Pressure (Pa) of fluid inside tank.

  • T (float) – Temperature (K) of fluid inside tank

  • time (float) – Time elapsed in simulation (s).

  • env_temp (float) – Temperature (K) of environment surrounding tank.

Returns:

Thermal resistance of the tank (K/W).

Return type:

float

class pytanksim.classes.storagetankclasses.SorbentTank(sorbent_material, aluminum_mass=0, carbon_fiber_mass=0, steel_mass=0, vent_pressure=None, min_supply_pressure=100000.0, thermal_resistance=0, surface_area=0, heat_transfer_coefficient=0, volume=None, set_capacity=None, full_pressure=None, empty_pressure=None, full_temperature=None, empty_temperature=None, full_quality=1, empty_quality=1, set_sorbent_fill=1)

Bases: StorageTank

Stores properties of a fluid storage tank filled with sorbents.

volume

Internal volume of the storage tank (m^3).

Type:

float

sorbent_material

An object storing the properties of the sorbent material used in the tank.

Type:

SorbentMaterial

aluminum_mass

The mass of aluminum making up the tank walls (kg). The default is 0.

Type:

float, optional

carbon_fiber_mass

The mass of carbon fiber making up the tank walls (kg). The default is 0.

Type:

float, optional

steel_mass

The mass of steel making up the tank walls (kg). The default is 0.

Type:

float, optional

vent_pressure

Maximum pressure at which the tank has to be vented (Pa). The default is None.

Type:

float, optional

min_supply_pressure

The minimum supply pressure (Pa) for discharging simulations. The default is 1E5.

Type:

float, optional

thermal_resistance

The thermal resistance of the tank walls (K/W). The default is 0.

Type:

Callable, optional

surface_area

Outer surface area of the tank in contact with the environment (m^2). The default is 0.

Type:

float, optional

heat_transfer_coefficient

The heat transfer coefficient of the tank surface (W/(m^2 K)). The default is 0.

Type:

Callable, optional

Initialize a SorbentTank object.

Parameters:
  • sorbent_material (SorbentMaterial) – An object storing the properties of the sorbent material used in the tank.

  • aluminum_mass (float, optional) – The mass of aluminum making up the tank walls (kg). The default is 0.

  • carbon_fiber_mass (float, optional) – The mass of carbon fiber making up the tank walls (kg). The default is 0.

  • steel_mass (float, optional) – The mass of steel making up the tank walls (kg). The default is 0.

  • vent_pressure (float, optional) – Maximum pressure at which the tank has to be vented (Pa). The default is None.

  • min_supply_pressure (float, optional) – The minimum supply pressure (Pa) for discharging simulations. The default is 1E5.

  • thermal_resistance (Callable or float, optional) –

    A function which returns the thermal resistance of the tank walls (K/W) as a function of tank pressure (Pa), tank temperature (K), time (s), and temperature of surroundings (K). The default is 0. If a float is provided, it will be converted to a function which returns that value everywhere. If both this and the arguments ‘surface_area’ and ‘heat_transfer_coefficient’ are passed, two values of thermal resistance will be calculated and the highest value between the two will be taken at each time step. Thus, to avoid confusion, one should either: (a) use the other two arguments together, or (b) use this one, but not both at the same time.

    If a callable is passed, it must have the signature:

    def tr_function(p, T, time, env_temp):
        # 'p' is tank pressure (Pa)
        # 'T' is tank temperature (K)
        # 'time' is the time elapsed within the simulation (s)
        # 'env_temp' is the temperature of surroundings (K)
        ....
        # Returned is the thermal resistance (K/W)
        return tr_value
    

  • surface_area (float, optional) – Outer surface area of the tank in contact with the environment (m^2). The default is 0.

  • heat_transfer_coefficient (Callable or float, optional) –

    A function which returns the heat transfer coefficient of the tank walls (W/(m^2 K)) as a function of tank pressure (Pa), tank temperature (K), time (s), and temperature of surroundings (K). The default is 0. If a float is provided, it will be converted to a function which returns that value everywhere.

    If a callable is passed, it must have the signature:

    def htc_function(p, T, time, env_temp):
        # 'p' is tank pressure (Pa)
        # 'T' is tank temperature (K)
        # 'time' is the time elapsed within the simulation (s)
        # 'env_temp' is the temperature of surroundings (K)
        ....
        # Returned is the heat transfer coefficient (W/(m^2 K))
        return heat_transfer_coef
    

  • volume (float, optional) – Internal volume of the storage tank (m^3). The default is None. This value is required unless the set capacity and operating conditions are defined, in which case the volume is calculated from the capacity and operating conditions.

  • set_capacity (float, optional) – Set internal capacity of the storage tank (mol). The default is None. If specified, this will override the user-specified tank volume.

  • full_pressure (float, optional) – Pressure (Pa) of the tank when it is considered full. The default is None.

  • empty_pressure (float, optional) – Pressure (Pa) of the tank when it is considered empty. The default is None.

  • full_temperature (float, optional) – Temperature (K) of the tank when it is considered full. The default is None.

  • empty_temperature (float, optional) – Temperature (K) of the tank when it is considered empty. The default is None.

  • full_quality (float, optional) – Vapor quality of the tank when it is considered full. The default is 1 (Gas).

  • empty_quality (float, optional) – Vapor quality of the tank when it is considered empty. The default is 1 (Gas).

  • set_sorbent_fill (float, optional) – Ratio of tank volume filled with sorbent. The default is 1 (completely filled with sorbent).

Returns:

Object which stores various properties of a storage tank containing sorbents. It also has some useful methods related to the tank, most notably dormancy calculation.

Return type:

SorbentTank

bulk_fluid_volume(p, T)

Calculate the volume of bulk fluid inside of the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature(K).

Returns:

Bulk fluid volume within the tank (m^3).

Return type:

float

capacity(p, T, q=0)

Return the amount of fluid stored in the tank at given conditions.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. Can vary between 0 and 1. The default is 0.

Returns:

Amount of fluid stored (moles).

Return type:

float

capacity_bulk(p, T, q=0)

Calculate the amount of bulk fluid in the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. Can vary between 0 and 1. The default is 0.

Returns:

Amount of bulk fluid stored (moles).

Return type:

float

internal_energy(p, T, q=1)

Calculate the internal energy of the fluid inside of the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. The default is 1.

Returns:

Internal energy of the fluid being stored (J).

Return type:

float

internal_energy_sorbent(p, T, q=1)

Calculate the internal energy of the adsorbed fluid in the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. The default is 1.

Returns:

Internal energy of the adsorbed fluid in the tank (J).

Return type:

float

internal_energy_bulk(p, T, q=1)

Calculate the internal energy of the bulk fluid in the tank.

Parameters:
  • p (float) – Pressure (Pa).

  • T (float) – Temperature (K).

  • q (float, optional) – Vapor quality of the fluid being stored. The default is 1.

Returns:

Internal energy of the bulk fluid in the tank (J).

Return type:

float

find_quality_at_saturation_capacity(T, capacity)

Find vapor quality at the given temperature and capacity.

Parameters:
  • T (float) – Temperature (K)

  • capacity (float) – Amount of fluid in the tank (moles).

Returns:

Vapor quality of the fluid being stored. This is assuming that the fluid is on the saturation line.

Return type:

float

find_temperature_at_saturation_quality(q, cap)

Find temperature at a given capacity and vapor quality value.

Parameters:
  • q (float) – Vapor quality. Can vary between 0 and 1.

  • cap (float) – Amount of fluid stored in the tank (moles).

Returns:

The optimization result represented as a OptimizeResult object. The relevant attribute for this function is x, the optimized temperature value.

Return type:

scipy.optimize.OptimizeResult

calculate_dormancy(p, T, heating_power, q=0)

Calculate dormancy time given a constant heating rate.

Parameters:
  • p (float) – Initial tank pressure (Pa).

  • T (float) – Initial tank temperature (K).

  • heating_power (float) – The heating power going into the tank during parking (W).

  • q (float, optional) – Initial vapor quality of the tank. The default is 0 (pure liquid).

Returns:

Pandas dataframe containing calculation conditions and results. Each key stores a floating point number. The dictionary keys and their respective values are:

  • ”init pressure”: initial pressure

  • ”init temperature”: initial temperature

  • ”init quality”: initial vapor quality

  • ”dormancy time”: time until tank needs to be vented in seconds

  • ”final temperature”: temperature of the tank as venting begins

  • ”final quality”: vapor quality at the time of venting

  • ”final pressure”: pressure at the time of venting

  • ”capacity error”: error between final and initial capacity

  • ”total energy change”: difference in internal energy between the initial and final conditions

  • ”sorbent energy contribution”: the amount of heat taken by the adsorbed phase via desorption

  • ”bulk energy contribution”: the amount of heat absorbed by the bulk phase

  • ”immersion heat contribution”: how much heat has been absorbed by un-immersing the sorbent material in the fluid

  • ”solid heat capacity contribution”: the amount of heat absorbed by the tank walls

Return type:

pd.DataFrame