pytanksim.classes package

Contains the various classes making up pytanksim.

Submodules

pytanksim.classes.basesimclass module

Contains classes related exclusively to the dynamic simulations.

This includes SimParams, BoundaryFlux, and BaseSimulation.

class pytanksim.classes.basesimclass.BaseSimulation(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: object

An abstract base class for dynamic simulations.

Other simulation classes inherit some attributes and methods from this class.

sim_type

Type of simulation (default, heated discharge, cooled refuel, etc.)

Type:

str

sim_phase

1 or 2 phases.

Type:

int

simulation_params

Object which stores simulation parameters.

Type:

SimParams

storage_tank

Object which stores the properties of the tank being simulated.

Type:

StorageTank

boundary_flux

Object which stores the amount of energy entering and exiting the tank.

Type:

BoundaryFlux

stop_reason

A string stating the reason for the simulation to have stopped. It will be passed to the SimResults object once the simulation finishes.

Type:

str

enthalpy_in_calc(p: float, T: float, time: float) float

Calculate the enthalpy (J/mol) of fluid going into the tank.

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

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

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

Returns:

Enthalpy of the fluid going into the tank (J/mol).

Return type:

float

enthalpy_out_calc(fluid_property_dict: Dict[str, float], p: float, T: float, time: float) float

Calculate the enthalpy (J/mol) of fluid going out of the tank.

Parameters:
  • fluid_property_dict (Dict[str,float]) – A dictionary of properties of the fluid being stored inside of the tank. In the case of the two phase simulation, it is the properties of the gas and not the liquid. For this function, this dictionary must return an enthalpy (J/mol) value given the key “hf”.

  • p (float) – Pressure inside of the tank (Pa)

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

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

Returns:

Enthalpy of the fluid going out of the tank (J/mol).

Return type:

float

heat_leak_in(T: float) float

Calculate the heat leakage rate from the environment into the tank.

Parameters:

T (float) – Temperature (K) of the storage tank.

Returns:

The rate of heat leakage into the tank from the environment (W).

Return type:

float

run()

Abstract function which will be defined in the child classes.

Raises:

NotImplementedError – Raises an error since it is not implemented in this abstract base class.

Return type:

None.

sim_phase = None
sim_type = None
stop_reason = None
class pytanksim.classes.basesimclass.BoundaryFlux(mass_flow_in: Callable[[float, float, float], float] | float = 0.0, mass_flow_out: Callable[[float, float, float], float] | float = 0.0, heating_power: Callable[[float, float, float], float] | float = 0.0, cooling_power: Callable[[float, float, float], float] | float = 0.0, pressure_in: Callable[[float, float, float], float] | float | None = None, temperature_in: Callable[[float, float, float], float] | float | None = None, environment_temp: float = 0, enthalpy_in: Callable[[float, float, float], float] | float | None = None, enthalpy_out: Callable[[float, float, float], float] | float | None = None)

Bases: object

Stores information of the mass and energy fluxes on the tank boundaries.

mass_flow_in

A function which returns mass flow into the tank (kg/s) as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is a function which returns 0 everywhere.

Type:

Callable[[float, float, float], float], optional

mass_flow_out

A function which returns mass flow exiting the tank (kg/s) as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is a function which returns 0 everywhere.

Type:

Callable[[float, float, float], float], optional

heating_power

A function which returns heating power added to the tank (W) as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is a function which returns 0 everywhere.

Type:

Callable[[float, float, float], float], optional

cooling_power

A function which returns cooling power added to the tank (W) as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is a function which returns 0 everywhere.

Type:

Callable[[float, float, float], float], optional

pressure_in

A function which returns the pressure (Pa) of the fluid being inserted into the tank as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is None.

Type:

Callable[[float, float, float], float], optional

temperature_in

A function which returns the temperature (K) of the fluid being inserted into the tank as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is None.

Type:

Callable[[float, float, float], float], optional

environment_temp

The temperature (K) of the environment surrounding the tank. This value is used in the dynamic simulation to calculate heat leakage into the tank. The default is 0, in which case heat leakage into the tank is not considered.

Type:

float, optional

enthalpy_in

A function which returns the enthalpy (J/mol) of the fluid being inserted into the tank as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is None.

Type:

Callable[[float, float, float], float], optional

enthalpy_out

A function which returns the enthalpy (J/mol) of the fluid exiting the tank as a function of tank pressure (Pa), tank temperature (K), and time (s). The default is None.

Type:

Callable[[float, float, float], float], optional

class pytanksim.classes.basesimclass.SimParams(init_temperature: float, final_time: float, init_time: float = 0, init_pressure: float = 100000.0, displayed_points: int = 200, target_temp: float = 0, target_pres: float = 0, stop_at_target_pressure: bool = False, stop_at_target_temp: bool = False, target_capacity: float = 0, init_ng: float = 0, init_nl: float = 0, init_q: float | None = None, inserted_amount: float = 0, vented_amount: float = 0, cooling_required: float = 0, heating_required: float = 0, vented_energy: float = 0, flow_energy_in: float = 0, cooling_additional: float = 0, heating_additional: float = 0, heat_leak_in: float = 0, verbose: bool = True)

Bases: object

A class to store simulation parameters.

This data class stores the parameters of the tank at the start of the simulation as well as the conditions specified to stop the simulation. Additionally, it also stores the setting for the number of data points to be reported at the end of the simulation.

init_temperature

The temperature (K) of the tank being simulated at the beginning of the simulation.

Type:

float

init_pressure

The pressure of the tank being simulated (Pa) at the beginning of the simulation. The default value is 1E5. This parameter was made optional as the two-phase simulations did not require it to be filled, rather pytanksim will automatically calculate the saturation pressure given a starting temperature.

Type:

float, optional

final_time

The time (seconds) at which the simulation is to be stopped.

Type:

float

init_time

The time (seconds) at which the beginning of the simulation is set to. The default value is set to 0 seconds.

Type:

float, optional

displayed_points

The number of data points to be reported at the end of the simulation. The default is 200.

Type:

int, optional

target_temp

The target temperature (K) at which the simulation is to be stopped. The default value is 0, which effectively means the simulation does not have a set temperature at which the simulation is stopped.

Type:

float, optional

target_pres

The target pressure (Pa) at which the simulation is to be stopped. The default value is 0, which effectively means the simulation does not have a set pressure at which the simulation is stopped.

Type:

float, optional

stop_at_target_pressure

If True, it will stop the simulation when the target pressure is met. The default is False.

Type:

bool, optional

stop_at_target_temp

If True, it will stop the simulation when the target temperature is met. The default is False.

Type:

bool, optional

target_capacity

The amount of fluid (moles) stored in the tank at which the simulation is to be stopped. The default is 0.

Type:

float, optional

init_ng

The initial amount of gas (moles) stored in the tank at the beginning of the simulation. The default value is 0.

Type:

float, optional

init_nl

The initial amount of liquid (moles) stored in the tank at the beginning of the simulation. The default value is 0.

Type:

float, optional

init_q

The initial quality of the fluid being stored. It can vary between 0 and 1. The default is None.

Type:

float, optional

Parameters:
  • inserted_amount (float, optional) – The amount of fluid which has been previously inserted into the tank (moles) at the beginning of the simulation. Used to track refueling processes across multiple simulations. The default value is 0.

  • vented_amount (float, optional) – The amount of fluid which has been previously vented from the tank (moles) at the beginning of the simulation. Used to track discharging and boil-off processes across multiple simulations. The default value is 0.

  • cooling_required (float, optional) – The cumulative amount of required cooling (J) to maintain a constant pressure prior to the start of a simulation. The default value is 0. Useful when restarting a stopped cooled refuel simulation.

  • heating_required (float, optional) – The cumulative amount of required heating (J) to maintain a constant pressure prior to the start of a simulation. The default value is 0. Useful when restarting a stopped heated discharge simulation.

  • vented_energy (float, optional) – Cumulative amount of enthaloy (J) contained in the fluid vented prior to the start of the simulation. The default is 0. Useful when stopping and restarting discharge simulations.

  • flow_energy_in (float, optional) – Cumulative amount of enthalpy (J) contained in the fluid inserted prior to the start of the simulation. The default is 0. Useful when stopping and restarting refueling simulations.

  • cooling_additional (float, optional) – The cumulative amount of user-specified cooling (J) prior to the start of a simulation. The default value is 0. Useful when stopping and restarting simulations with user-specified cooling.

  • heating_additional (float, optional) – The cumulative amount of user-specified cooling (J) prior to the start of a simulation. The default value is 0. Useful when stopping and restarting simulations with user-specified heating.

  • heat_leak_in (float, optional) – The cumulative amount of heat (J) which has leaked into the tank prior to the start of a simulation. The default value is 0. Useful when stopping and restarting simulations involving heat leakage.

  • verbose (bool, optional) – Whether or not the simulation will print out its progress bars and give a notification once it has finished. The default value is True.

cooling_additional: float = 0
cooling_required: float = 0
displayed_points: int = 200
final_time: float
flow_energy_in: float = 0
classmethod from_SimResults(sim_results: SimResults, displayed_points: float | None = None, init_time: float | None = None, final_time: float | None = None, target_pres: float | None = None, target_temp: float | None = None, stop_at_target_pressure: bool | None = None, stop_at_target_temp: bool | None = None, target_capacity: float | None = None, verbose: bool | None = None) SimParams

Take final conditions from a previous simulation as new parameters.

Parameters:
  • sim_results (SimResults) – An object containing previous simulation results.

  • displayed_points (float, optional) – The number of data points to be reported at the end of the simulation. The default is 200.

  • init_time (float, optional) – The time (seconds) at which the beginning of the simulation is set. The default value is None.

  • final_time (float, optional) – The time (seconds) at which the simulation is to be stopped. If None, then the final_time setting from the previous simulation is used. The default is None.

  • target_pres (float, optional) – The target pressure (Pa) at which the simulation is to be stopped. If None, then the target_pres setting from the previous simulation is used. The default is None.

  • target_temp (float, optional) – The target temperature (K) at which the simulation is to be stopped. If None, then the target_temp setting from the previous simulation is used. The default is None.

  • stop_at_target_pressure (bool, optional) – If True, it will stop the simulation when the target pressure is met. If None, then the stop_at_target_pressure setting from the previous simulation is used. The default is None.

  • stop_at_target_temp (bool, optional) – If True, it will stop the simulation when the target temperature is met. If None, then the stop_at_target_temp setting from the previous simulation is used. The default is None.

  • target_capacity (float, optional) – The amount of fluid (moles) stored in the tank at which the simulation is to be stopped. If None, then the target_capacity value from the previous simulation is used. The default is None.

Returns:

A SimParams object containing the final conditions taken from sim_results set as the new starting parameters.

Return type:

SimParams

heat_leak_in: float = 0
heating_additional: float = 0
heating_required: float = 0
init_ng: float = 0
init_nl: float = 0
init_pressure: float = 100000.0
init_q: float = None
init_temperature: float
init_time: float = 0
inserted_amount: float = 0
stop_at_target_pressure: bool = False
stop_at_target_temp: bool = False
target_capacity: float = 0
target_pres: float = 0
target_temp: float = 0
vented_amount: float = 0
vented_energy: float = 0
verbose: bool = True

pytanksim.classes.excessisothermclass module

Contains the ExcessIsotherm class.

class pytanksim.classes.excessisothermclass.ExcessIsotherm(adsorbate: str, sorbent: str, temperature: float, loading: List[float], pressure: List[float])

Bases: object

Stores experimental excess isotherm measurement results.

This class can be provided values directly in Python or it can import the values from a csv file.

adsorbate

Name of the adsorbate gas.

Type:

str

sorbent

Name of the sorbent material.

Type:

str

temperature

Temperature (K) at which the isotherm was measured.

Type:

float

loading

A list of excess adsorption values (mol/kg).

Type:

List[float]

pressure

A list of pressures (Pa) corresponding to points at which the excess adsorption values were measured.

Type:

list[float]

classmethod from_csv(filename: str, adsorbate: str, sorbent: str, temperature: float) ExcessIsotherm

Import loading and pressure data from a csv file.

Parameters:
  • filename (str) – Path leading to the file from which the data is to be imported.

  • adsorbate (str) – Name of adsorbate gas.

  • sorbent (str) – Name of sorbent material.

  • temperature (float) – Temperature (K) at which the data was measured.

Returns:

A class which stores experimental excess adsorption data.

Return type:

ExcessIsotherm

pytanksim.classes.fluidsorbentclasses module

Contains classes related to the fluids and sorbents to be simulated.

More specifically, contains the StoredFluid, SorbentMaterial, ModelIsotherm, and its derivatives.

class pytanksim.classes.fluidsorbentclasses.DAModel(sorbent: str, stored_fluid: StoredFluid, w0: float, f0: float, eps: float, m: float = 2, k: float = 2, rhoa: float | None = None, va: float | None = None, va_mode: str = 'Constant', rhoa_mode: str = 'Constant', f0_mode: str = 'Dubinin')

Bases: ModelIsotherm

A class for the Dubinin-Astakhov model for adsorption in micropores.

sorbent

Name of sorbent material.

Type:

str

stored_fluid

Object containing properties of the adsorbate.

Type:

StoredFluid

w0

The volume of the adsorbed phase at saturation (m^3/kg).

Type:

float

f0

The fugacity at adsorption saturation (Pa).

Type:

float

eps

Characteristic energy of adsorption (J/mol).

Type:

float

m

The empirical heterogeneity parameter for the Dubinin-Astakhov model. The default is 2.

Type:

float, optional

k

The empirical heterogeneity parameter for Dubinin’s approximation of the saturation fugacity above critical temperatures. The default is 2.

Type:

float, optional

rhoa

The density of the adsorbed phase (mol/m^3). The default is None. If None, the value will be taken as the liquid density at 1 bar.

Type:

float, optional

va

The volume of the adsorbed phase (m^3/kg). The default is None. If None and va_mode is “Constant”, the va_mode will be switched to “Excess” and the va will be assumed to be 0.

Type:

float, optional

va_mode

Determines how the adsorbed phase volume is calculated. “Excess” assumes that the adsorbed phase volume is 0, so the model calculates excess adsorption instead of absolute adsorption. “Constant” assumes a constant adsorbed phase volume. “Vary” will assume that the adsorbed phase volume varies according to the pore filling mechanism posited by the Dubinin-Astakhov equation. The default is “Constant”, but if the parameter va is not specified it will switch to “Excess”.

Type:

str, optional

rhoa_mode

Determines how the adsorbed phase density is calculated. “Ozawa” uses Ozawa’s approximation to calculate the adsorbed phase density. “Constant” assumes a constant adsorbed phase volume. The default is “Constant”.

Type:

str, optional

f0_mode

Determines how the fugacity at saturation is calculated. “Dubinin” uses Dubinin’s approximation. “Constant” assumes a constant value for the fugacity at saturation. The default is “Dubinin”.

Type:

str, optional

differential_energy(p, T, q)

Calculate the differential energy of adsorption (J/mol).

The calculation is based on Myers & Monson [1]_.

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

  • T (float) – Temperature (K).

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

Returns:

The differential energy of adsorption (J/mol).

Return type:

float

Notes

differential_energy_na(na, T)
dlnf0_dT(T)
f0_calc(T: float) float

Calculate the fugacity at saturation (Pa) at a given temperature.

Parameters:

T (float) – Temperature (K).

Returns:

Fugacity at saturation (Pa).

Return type:

float

classmethod from_ExcessIsotherms(ExcessIsotherms: List[ExcessIsotherm], stored_fluid: StoredFluid | None = None, sorbent: str | None = None, w0guess: float = 0.001, f0guess: float = 1470000000.0, epsguess: float = 3000, vaguess: float = 0.001, rhoaguess: float | None = None, mguess: float = 2.0, kguess: float = 2.0, rhoa_mode: str = 'Fit', f0_mode: str = 'Fit', m_mode: str = 'Fit', k_mode: str = 'Fit', va_mode: str = 'Excess', pore_volume: float = 0.003, verbose: bool = True) DAModel

Fit the DA model to a list of ExcessIsotherm data.

Parameters:
  • ExcessIsotherms (List[ExcessIsotherm]) – A list containing ExcessIsotherm objects which contain measurement data at various temperatures.

  • stored_fluid (StoredFluid, optional) – Object for calculating the properties of the adsorbate. The default is None. If None, the StoredFluid object inside of one of the ExcessIsotherm objects passed will be used.

  • sorbent (str, optional) – Name of sorbent material. The default is None. If None, name will be taken from one of the ExcessIsotherm objects passed.

  • w0guess (float, optional) – The initial guess for the adsorbed phase volume at saturation (m^3/kg). The default is 0.001.

  • f0guess (float, optional) – The initial guess for the fugacity at saturation (Pa). The default is 1470E6.

  • epsguess (float, optional) – The initial guess for the characteristic energy of adsorption (J/mol). The default is 3000.

  • vaguess (float, optional) – The initial guess for the volume of the adsorbed phase (m^3/kg). The default is 0.001.

  • rhoaguess (float, optional) – The initial guess for the adsorbed phase density (mol/m^3). The default is None. If None, it will be taken as the liquid density at 1 bar.

  • mguess (float, optional) – The initial guess for the heterogeneity parameter of the Dubinin-Astakhov equation. The default is 2.0.

  • kguess (float, optional) – The initial guess for the heterogeneity parameter of Dubinin’s approximation method for saturation fugacity. The default is 2.0.

  • rhoa_mode (str, optional) – Determines how the density of the adsorbed phase (rhoa) is calculated. If “Fit”, rhoa is a constant to be fitted statistically. If “Ozawa”, Ozawa’s approximation is used to calculate rhoa and rhoa is not a fitting parameter. If “Constant”, the user supplied value for rhoaguess is taken as the density. The default is “Fit”.

  • f0_mode (str, optional) – Determines how the fugacity at saturation (f0) is calculated. If “Fit” then f0 is a constant to be statistically fitted to the data. If “Dubinin” then Dubinin’s approximation is used. If “Constant” then the user supplied value for f0guess is used. The default is “Fit”.

  • m_mode (str, optional) – Determines whether the heterogeneity parameter of the Dubinin- Astakhov equation is taken as a user-supplied constant (if “Constant”) or a fitted parameter (if “Fit”). The default is “Fit”.

  • k_mode (str, optional) – Determines whether the heterogeneity parameter of Dubinin’s approximation for the fugacity above the critical temperature is taken as a user-supplied constant value (if “Constant”) or as a statistically fitted parameter (if “Fit”). The default is “Fit”.

  • va_mode (str, optional) – Determines how the volume of the adsorbed phase is calculated. If “Fit”, the value is a statistically fitted constant. If “Constant”, the value is the user defined value vaguess. If “Vary”, the value varies w.r.t. pressure according to the micropore filling mechanism posited by the Dubinin-Astakhov model. The default is “Excess”.

  • pore_volume (float, optional) – The experimentally measured pore volume of the sorbent material (m^3/kg). It serves as the maximum possible physical value for the parameters w0 and va. The default is 0.003.

  • verbose (bool, optional) – Determines whether or not the complete fitting quality report is logged for the user. The default is True.

Returns:

A DAModel object which can calculate excess and absolute adsorption at various conditions as well as the thermophysical properties of the adsorbed phase.

Return type:

DAModel

internal_energy_adsorbed(p: float, T: float, q: float = 1) float

Calculate the molar integral internal energy of adsorption (J/mol).

The calculation is based on Myers & Monson [1]_.

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

  • T (float) – Temperature (K).

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

Returns:

The differential energy of adsorption (J/mol).

Return type:

float

Notes

key_attr = ['sorbent', 'w0', 'f0', 'eps', 'm', 'k', 'rhoa', 'va', 'va_mode', 'rhoa_mode', 'f0_mode']
model_name = 'Dubinin-Astakhov Model'
n_absolute(p: float, T: float) float

Calculate the absolute adsorbed amount at a given condition.

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

  • T (float) – Temperature(K).

Returns:

Absolute adsorbed amount (mol/kg).

Return type:

float

n_excess(p: float, T: float, q: float = 1) float

Calculate the excess adsorbed amount at a given condition.

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

  • T (float) – Temperature (K)

  • q (float, optional) – The vapor quality of the bulk adsorbate. Can vary between 0 and 1. The default is 1.

Returns:

Excess adsorbed amount (mol/kg).

Return type:

float

rhoa_calc(T: float) float

Calculate the density of the adsorbed phase at a given temperature.

Parameters:

T (float) – Temperature (K).

Returns:

The density of the adsorbed phase (mol/m^3).

Return type:

float

v_ads(p: float, T: float) float

Calculate the volume of the adsorbed phase (m^3/kg).

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

  • T (float) – Temperature (K).

Returns:

Volume of the adsorbed phase (m^3/kg).

Return type:

float

class pytanksim.classes.fluidsorbentclasses.MDAModel(sorbent: str, stored_fluid: StoredFluid, nmax: float, f0: float, alpha: float, beta: float, va: float, m: float = 2, k: float = 2, va_mode: str = 'Constant', f0_mode: str = 'Constant')

Bases: ModelIsotherm

A class for the Modified Dubinin-Astakhov model for adsorption.

A key modification compared to the DA model is the use of the enthalpic and entropic factors to calculate the adsorption energy as a function of temperature instead of treating it as a constant.

differential_energy(p, T, q=1)

Calculate the differential energy of adsorption (J/mol).

The calculation is based on Myers & Monson [1]_.

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

  • T (float) – Temperature (K).

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

Returns:

The differential energy of adsorption (J/mol).

Return type:

float

Notes

differential_energy_na(na, T)
dlnf0_dT(T)
f0_fun(T)
classmethod from_ExcessIsotherms(ExcessIsotherms: List[ExcessIsotherm], stored_fluid: StoredFluid | None = None, sorbent: str | None = None, nmaxguess: float = 71.6, f0guess: float = 1470000000.0, alphaguess: float = 3080, betaguess: float = 18.9, vaguess: float = 0.00143, mguess: float = 2.0, kguess: float = 2.0, va_mode: str = 'Fit', f0_mode: str = 'Fit', m_mode: str = 'Fit', k_mode: str = 'Fit', beta_mode: str = 'Fit', pore_volume: float = 0.003, verbose: bool = True) MDAModel

Fit the MDA model from a list of excess adsorption data.

Parameters:
  • ExcessIsotherms (List[ExcessIsotherm]) – A list of ExcessIsotherm objects which contain measurement data at various temperatures.

  • stored_fluid (StoredFluid, optional) – Object for calculating the properties of the adsorbate. The default is None. If None, the StoredFluid object inside of one of the ExcessIsotherm objects passed will be used.

sorbentstr, optional

Name of sorbent material. The default is None. If None, name will be taken from one of the ExcessIsotherm objects passed.

nmaxguessfloat, optional

The initial guess for the maximum adsorbed amount (mol/kg). The default is 71.6.

f0guessfloat, optional

The initial guess for the fugacity at saturation (Pa). The default is 1470E6.

alphaguessfloat, optional

The initial guess for the enthalpy factor determining the characteristic energy of adsorption. The default is 3080.

betaguessfloat, optional

The initial guess for the entropy factor determining the characteristic energy of adsorption. The default is 18.9.

vaguessfloat, optional

Initial guess for the adsorbed phase volume (m^3/kg). The default is 0.00143.

mguessfloat, optional

The initial guess for the heterogeneity parameter of the Dubinin-Astakhov equation. The default is 2.0.

kguessfloat, optional

The initial guess for the heterogeneity parameter of Dubinin’s approximation method for saturation fugacity. The default is 2.0.

va_modestr, optional

Determines how the volume of the adsorbed phase (va) is calculated. If “Fit”, va is a constant to be fitted statistically. If “Ozawa”, Ozawa’s approximation is used to calculate va and va is not a fitting parameter. If “Constant”, the user supplied value for vaguess is taken as the volume. The default is “Fit”.

f0_modestr, optional

Determines how the fugacity at saturation (f0) is calculated. If “Fit” then f0 is a constant to be statistically fitted to the data. If “Dubinin” then Dubinin’s approximation is used. If “Constant” then the user supplied value for f0guess is used. The default is “Fit”.

m_modestr, optional

Determines whether the heterogeneity parameter of the Dubinin- Astakhov equation is taken as a user-supplied constant (if “Constant”) or a fitted parameter (if “Fit”). The default is “Fit”.

k_modestr, optional

Determines whether the heterogeneity parameter of Dubinin’s approximation for the fugacity above the critical temperature is taken as a user-supplied constant value (if “Constant”) or as a statistically fitted parameter (if “Fit”). The default is “Fit”.

beta_modestr, optional

Determines whether the entropic factor determining the characteristic energy of adsorption is taken as a user-supplied constant (if “Constant”) or as a fitted parameter (if “Fit”). The default is “Fit”.

pore_volumefloat, optional

The experimentally measured pore volume of the sorbent material (m^3/kg). It serves as the maximum possible physical value for the parameters w0 and va. The default is 0.003.

verbosebool, optional

Determines whether or not the complete fitting quality report is logged for the user. The default is True.

Returns:

An MDAModel object. It can calculate the excess and absolute adsorbed amounts at various pressures and temperatures, and it can provide thermophysical properties of the adsorbed phase.

Return type:

MDAModel

internal_energy_adsorbed(p: float, T: float, q: float = 1) float

Calculate the molar integral internal energy of adsorption (J/mol).

The calculation is based on Myers & Monson [1]_.

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

  • T (float) – Temperature (K).

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

Returns:

The molar integral energy of adsorption (J/mol).

Return type:

float

Notes

key_attr = ['sorbent', 'nmax', 'f0', 'alpha', 'beta', 'va', 'm', 'k', 'va_mode', 'f0_mode']
model_name = 'Modified Dubinin-Astakhov Model'
n_absolute(p: float, T: float) float

Calculate the absolute adsorbed amount at given conditions.

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

  • T (float) – Temperature (K)

Returns:

Absolute adsorbed amount (mol/kg).

Return type:

float

n_excess(p: float, T: float, q: float = 1) float

Calculate the excess adsorbed amount at the given conditions.

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

  • T (float) – Temperature (K).

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

Returns:

Excess adsorbed amount (mol/kg).

Return type:

float

v_ads(p: float, T: float) float

Calculate the adsorbed phase volume at the given condtions.

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

  • T (float) – Temperature (K).

Returns:

Adsorbed phase volume (m^3/kg)

Return type:

float

class pytanksim.classes.fluidsorbentclasses.SorbentMaterial(skeletal_density: float, bulk_density: float, specific_surface_area: float, model_isotherm: ModelIsotherm, mass: float = 0, molar_mass: float = 0.01201, Debye_temperature: float = 1500, heat_capacity_function: Callable[[float], float] | None = None)

Bases: object

mass

Mass of sorbent (kg).

Type:

float

skeletal_density

Skeletal density of the sorbent (kg/m^3).

Type:

float

bulk_density

Tapped/compacted bulk density of the sorbent (kg/m^3).

Type:

float

specific_surface_area

Specific surface area of the sorbent (m^2/g).

Type:

float

model_isotherm

Model of fluid adsorption on the sorbent.

Type:

ModelIsotherm

molar_mass

Molar mass of the sorbent material in kg/mol. The default is 12.01E-3 which corresponds to carbon materials.

Type:

float, optional

Debye_temperature

The Debye temperature (K) determining the specific heat of the sorbent at various temperatures. The default is 1500, the value for carbon.

Type:

float, optional

heat_capacity_function

A function which takes in the temperature (K) of the sorbent and returns its specific heat capacity (J/(kg K)). If specified, this function will override the Debye model for specific heat calculation. The default is None.

Type:

Callable[[float], float], optional

class pytanksim.classes.fluidsorbentclasses.StoredFluid(fluid_name: str, EOS: str = 'HEOS', mole_fractions: List | None = None)

Bases: object

A class to calculate the properties of the fluid being stored.

fluid_name

The name of the fluid being stored which corresponds to fluid names in the package CoolProp.

Type:

str

EOS

The name of the equation of state to be used for the calculations of fluid properties by the package CoolProp.

Type:

str

backend

The CoolProp backend used for calculation of fluid properties at various conditions.

Type:

CoolProp.AbstractState

determine_phase(p: float, T: float) str

Determine the phase of the fluid being stored.

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

  • T (float) – Temperature (K).

Returns:

String that could either be “Supercritical”, “Gas”, “Liquid”, or “Saturated” depending on the bulk fluid phase.

Return type:

str

fluid_property_dict(p: float, T: float) Dict[str, float]

Generate a dictionary of fluid properties using CoolProp.

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

  • T (float) – Temperature (K)

Returns:

Dictionary containing several fluid properties needed for various calculations in pytanksim. “hf” is the enthalpy (J/mol). “drho_dp” is the first partial derivative of density (mol/m^3) w.r.t. pressure (Pa). “drho_dT” is the first partial derivative of density (mol/m^3) w.r.t. temperature (K). “rhof” is density (mol/m^3). “dh_dp” is the first partial derivative of enthalpy (J/mol) w.r.t. pressure (Pa). “dh_dT” is the first partial derivative of enthalpy (J/mol) w.r.t. temperature (K). “uf” is the internal energy (J/mol). “du_dp” is the first partial derivative of internal energy (J/mol) w.r.t. pressure (Pa). “du_dT” is the first partial derivative of internal energy (J/mol) w.r.t. temperature (K). “MW” is molar mass (kg/mol).

Return type:

Dict[str, float]

saturation_property_dict(T: float, Q: int = 0) Dict[str, float]

Generate a dictionary of fluid properties at saturation.

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

  • Q (float) – Vapor quality of the fluid being stored.

Returns:

A dictionary containing the fluid properties at saturation at a given temperature. “psat” is the saturation vapor pressure (Pa). “dps_dT” is the first derivative of the saturation vapor pressure (Pa) w.r.t. temperature (K). “hf” is the enthalpy (J/mol). “drho_dp” is the first partial derivative of density (mol/m^3) w.r.t. pressure (Pa). “drho_dT” is the first partial derivative of density (mol/m^3) w.r.t. temperature (K). “rhof” is density (mol/m^3). “dh_dp” is the first partial derivative of enthalpy (J/mol) w.r.t. pressure (Pa). “dh_dT” is the first partial derivative of enthalpy (J/mol) w.r.t. temperature (K). “uf” is the internal energy (J/mol). “du_dp” is the first partial derivative of internal energy (J/mol) w.r.t. pressure (Pa). “du_dT” is the first partial derivative of internal energy (J/mol) w.r.t. temperature (K). “MW” is molar mass (kg/mol).

Return type:

Dict[str, float]

pytanksim.classes.onephasefluidsimclasses module

Module for simulating one phase fluid storage tanks without sorbents.

class pytanksim.classes.onephasefluidsimclasses.OnePhaseFluidCooled(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseFluidSim

Simulates a tank being cooled to maintain constant pressure.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Cooled'
solve_differentials(time: float, T: float) ndarray

Solve for the right hand side of the governing ODE.

Parameters:
  • time (float) – Current time step in the simulation (s).

  • T (float) – Current temperature (K).

Returns:

Numpy array containing values for the RHS of the governing ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasefluidsimclasses.OnePhaseFluidDefault(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseFluidSim

Class for simulating fluid storage dynamics in the one phase region.

run() SimResults

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Default'
solve_differentials(time: float, p: float, T: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • time (float) – Current time step (in s).

  • p (float) – Current pressure (Pa).

  • T (float) – Current temperature (K).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasefluidsimclasses.OnePhaseFluidHeatedDischarge(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseFluidSim

Simulates a tank being heated to discharge at a constant pressure.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Heated'
solve_differentials(time: float, T: float) ndarray

Solve for the right hand side of the governing ODE.

Parameters:
  • time (float) – Current time step in the simulation (s).

  • T (float) – Current temperature (K).

Returns:

Numpy array containing values for the RHS of the governing ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasefluidsimclasses.OnePhaseFluidSim(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: BaseSimulation

Base class for one phase fluid simulations.

sim_phase = 'One Phase'
class pytanksim.classes.onephasefluidsimclasses.OnePhaseFluidVenting(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseFluidSim

Simulate the dynamics of a fluid tank venting at constant pressure.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Venting'
solve_differentials(time: float, T: float) ndarray

Solve for the right hand side of the governing ODE.

Parameters:
  • time (float) – Current time step in the simulation (s).

  • T (float) – Current temperature (K).

Returns:

Numpy array containing values for the RHS of the governing ODE.

Return type:

np.ndarray

pytanksim.classes.onephasesorbentsimclasses module

Module for the simulation of sorbent tanks in the one phase region.

class pytanksim.classes.onephasesorbentsimclasses.OnePhaseSorbentCooled(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseSorbentSim

Sorbent tank cooled at constant pressure in the one phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Cooled'
solve_differentials(T: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • T (float) – Current temperature (K).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasesorbentsimclasses.OnePhaseSorbentDefault(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseSorbentSim

Simulates sorbent tanks in the one phase region without constraints.

run() SimResults

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Default'
solve_differentials(p: float, T: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • p (float) – Current pressure (Pa).

  • T (float) – Current temperature (K).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasesorbentsimclasses.OnePhaseSorbentHeatedDischarge(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseSorbentSim

Sorbent tank heated at constant pressure in the one phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Heated'
solve_differentials(T: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • T (float) – Current temperature (K).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.onephasesorbentsimclasses.OnePhaseSorbentSim(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: BaseSimulation

Base class for simulation of sorbent tanks in the one phase region.

It includes functions to calculate the governing ODE

sim_phase = 'One Phase'
class pytanksim.classes.onephasesorbentsimclasses.OnePhaseSorbentVenting(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: OnePhaseSorbentSim

Sorbent tank venting at constant pressure in the one phase region.

run() SimResults

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as hitting the saturation line, or hitting the maximum pressure limit of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Venting'
solve_differentials(T: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • T (float) – Current temperature (K).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

pytanksim.classes.simresultsclass module

Contains the SimResults class.

It is used for storing and post-processing the results of dynamic simulations.

class pytanksim.classes.simresultsclass.SimResults(pressure: List[float] | ndarray, temperature: List[float] | ndarray, time: List[float] | ndarray, moles_adsorbed: List[float] | ndarray, moles_gas: List[float] | ndarray, moles_liquid: List[float] | ndarray, moles_supercritical: List[float] | ndarray, tank_params: StorageTank | SorbentTank, sim_params: SimParams, stop_reason: str, sim_type: str = None, inserted_amount: List[float] | ndarray = 0, flow_energy_in: List[float] | ndarray = 0, cooling_required: List[float] | ndarray = 0, heating_required: List[float] | ndarray = 0, cooling_additional: List[float] | ndarray = 0, heating_additional: List[float] | ndarray = 0, heat_leak_in: List[float] | ndarray = 0, vented_amount: List[float] | ndarray = 0, vented_energy: List[float] | ndarray = 0)

Bases: object

Class for storing the results of dynamic simulations.

It comes with methods for exporting the results to csv, plotting the results, and for combining the results of multiple simulations.

df

A dataframe containing the results of dynamic simulations. See notes for the column names and the variables each column has.

Type:

pd.DataFrame

Notes

Below is a list of the pandas DataFrame column names and a short description of the variable stored inside each series.

  • t: time (seconds)

  • p: pressure (Pa)

  • T: temperature (K)

  • na: amount of fluid adsorbed (moles)

  • ng: amount of fluid in gaseous form (moles)

  • nl: amount of fluid in liquid form (moles)

  • ns: amount of fluid in supercritical form (moles)

  • Qcoolreq: cumulative amount of cooling required (J)

  • Qheatreq: cumulative amount of heating required (J)

  • nout: cumulative amount of fluid vented (moles)

  • Hout: cumulative amount of vented fluid enthalpy (J)

  • nin: cumulative amount of fluid inserted (moles)

  • Hin: cumulative amount of inserted fluid enthalpy (J)

  • Qcooladd: cumulative amount of user specified cooling (J)

  • Qheatadd: cumulative amount of user specified heating (J)

  • Qleak: cumulative amount of heat leakage into the tank (J)

  • ma: mass of fluid adsorbed (kg)

  • mg: mass of fluid in gaseous form (kg)

  • ml: mass of fluid in liquid form (kg)

  • ms: mass of fluid in supercritical form (kg)

  • mout: cumulative mass of fluid vented (kg)

  • min: cumulative mass of fluid inserted (kg)

  • na_dot: the amount of fluid (moles) being adsorbed per second.

  • ng_dot: the first derivative of the amount of fluid in gaseous form w.r.t. time. Its unit is mol/s.

  • nl_dot: the first derivative of the amount of fluid in liquid form w.r.t. time. Its unit is mol/s

  • ns_dot: the first derivative of the amount of fluid in supercritical form w.r.t. time. Its unit is mol/s.

  • Qcoolreq_dot: the cooling power (W) required to maintain a constant pressure during refuel.

  • Qheatreq_dot: the heating power (W) required to maintain a constant pressure during discharge.

  • nout_dot: the rate at which fluid is being vented from the tank (mol/s).

  • Hout_dot: the rate at which enthalpy is taken away by fluid leaving the tank (W).

  • nin_dot: the rate at which fluid is entering the tank (mol/s).

  • Hin_dot: the rate at which enthalpy is added by fluid fluid entering the tank (W).

  • Qcooladd_dot: the user specified cooling power (W).

  • Qheatadd_dot: the user specified heating power (W).

  • Qleak_dot: the rate of heat leakage into the tank (W).

  • ma_dot: the mass of fluid (kg) being adsorbed per second.

  • mg_dot: the first derivative of the mass of fluid in gaseous form w.r.t. time. Its unit is kg/s.

  • ml_dot: the first derivative of the mass of fluid in liquid form w.r.t. time. Its unit is kg/s.

  • ms_dot: the first derivative of the mass of fluid in supercritical form w.r.t. time. Its unit is kg/s.

  • mout_dot: the rate at which fluid is being vented from the tank (kg/s).

  • min_dot: the rate at which fluid is being inserted into the tank (kg/s).

classmethod combine(sim_results_list: List[SimResults]) SimResults

Combine the results of several simulations into a single object.

Parameters:

sim_results_list ("List[SimResults]") – A list of SimResults objects from several different simulations.

Returns:

A single object containing the combined simulation results.

Return type:

SimResults

fancy_colnames_dict = {'cooling_additional': 'Cumulative Additional Cooling Provided (J)', 'cooling_additional_W': 'Additional Cooling Power (W)', 'cooling_required': 'Cumulative Cooling Energy Required (J)', 'cooling_required_W': 'Cooling Power Required (W)', 'flow_energy_in': 'Cumulative Fluid Enthalpy In (J)', 'flow_energy_in_W': 'Rate of Fluid Enthalpy Flow In (W)', 'heat_leak_in': 'Cumulative Heat Leakage (J)', 'heat_leak_in_W': 'Heat Leakage Rate (W)', 'heating_additional': 'Cumulative Additional Heating Provided (J)', 'heating_additional_W': 'Additional Cooling Power (W)', 'heating_required': 'Cumulative Heating Energy Required (J)', 'heating_required_W': 'Heating Power Required (W)', 'inserted_amount': 'Amount Inserted (mol)', 'inserted_amount_per_s': 'Refueling Rate (mol/s)', 'inserted_kg': 'Amount Inserted (kg)', 'inserted_kg_per_s': 'Refueling Rate (kg/s)', 'kg_adsorbed': 'Amount Adsorbed (kg)', 'kg_adsorbed_per_s': 'd(Adsorbed Amount)/dt (kg/s)', 'kg_gas': 'Vapor Amount (kg)', 'kg_gas_per_s': 'd(Vapor Amount)/dt (kg/s)', 'kg_liquid': 'Liquid Amount (kg)', 'kg_liquid_per_s': 'd(Liquid Amount)/dt (kg/s)', 'kg_supercritical': 'Supercritical Amount (kg)', 'kg_supercritical_per_s': 'd(Supercritical Amount)/dt (kg/s)', 'moles_adsorbed': 'Amount Adsorbed (mol)', 'moles_adsorbed_per_s': 'd(Adsorbed Amount)/dt (mol/s)', 'moles_gas': 'Vapor Amount (mol)', 'moles_gas_per_s': 'd(Vapor Amount)/dt (mol/s)', 'moles_liquid': 'Liquid Amount (mol)', 'moles_liquid_per_s': 'd(Liquid Amount)/dt (mol/s)', 'moles_supercritical': 'Supercritical Amount (mol)', 'moles_supercritical_per_s': 'd(Supercritical Amount)/dt (mol/s)', 'pressure': 'Pressure (Pa)', 'temperature': 'Temperature (K)', 'time': 'Time (s)', 'vented_amount': 'Amount Vented (mol)', 'vented_amount_per_s': 'Venting Rate (mol/s)', 'vented_energy': 'Cumulative Fluid Enthalpy Out (J)', 'vented_energy_W': 'Rate of Fluid Enthalpy Flow Out (W)', 'vented_kg': 'Amount Vented (kg)', 'vented_kg_per_s': 'Venting Rate (kg/s)'}
classmethod from_csv(filename: str, import_components: bool = False)

Import simulation results from a csv file.

Parameters:
  • filename (str) – Path to a csv file which was exported by pytanksim.

  • import_components (bool) – If True, this function will return a tuple with contents as follows: SimResults, StorageTank, SimParams. If False, this function will only return the SimResults object. The default option is False.

Returns:

A single object containing the simulation results, or a tuple with SimResults, StorageTank, and SimParams objects.

Return type:

SimResults|Tuple

get_final_conditions(idx: int = -1) dict

Output final tank conditions at the end of the simulation.

Parameters:

idx (int, optional) – The index of the simulation results array from which the values are to be taken. The default is -1 (the last time point in the simulation).

Returns:

A dictionary containing tank conditions at’idx’.

Return type:

dict

interpolate(x_var: str = 't') dict[Callable[[float], float]]

Interpolate simulation results between points.

Parameters:

x_var (str, optional) – Variable to be used as a basis/input for interpolation.The default is “t”.

Returns:

A dictionary containing functions which interpolate each variable in the SimResults object w.r.t. the variable chosen in x_var.

Return type:

“dict[Callable[[float], float]]”

plot(x_axis: str, y_axes: str | List[str], colors: str | List[str] = ['r', 'b', 'g']) ndarray | Axes

Plot the results of the simulation.

Parameters:
  • x_axis (str) – A string specifying what variable should be on the x-axis. See notes for valid inputs.

  • y_axes (Union[str, List[str]]) – A string or a list of strings specifying what is to be plotted on the y-axis. See notes for valid inputs

  • colors (Union[str, List[str]], optional) – A string or a list of strings specifying colors for the lines in the plot. The default is [“r”, “b”, “g”].

Raises:

ValueError – If more than 3 y-variables are specified to be plotted.

Returns:

A matplolib axis or a numpy array of several axes.

Return type:

Union[np.ndarray, plt.Axes]

Notes

Below is a list of valid string inputs for x_axis and y_axes along with the variables they represent.

  • t: time (seconds)

  • p: pressure (Pa)

  • T: temperature (K)

  • na: amount of fluid adsorbed (moles)

  • ng: amount of fluid in gaseous form (moles)

  • nl: amount of fluid in liquid form (moles)

  • ns: amount of fluid in supercritical form (moles)

  • Qcoolreq: cumulative amount of cooling required (J)

  • Qheatreq: cumulative amount of heating required (J)

  • nout: cumulative amount of fluid vented (moles)

  • Hout: cumulative amount of vented fluid enthalpy (J)

  • nin: cumulative amount of fluid inserted (moles)

  • Hin: cumulative amount of inserted fluid enthalpy (J)

  • Qcooladd: cumulative amount of user specified cooling (J)

  • Qheatadd: cumulative amount of user specified heating (J)

  • Qleak: cumulative amount of heat leakage into the tank (J)

  • ma: mass of fluid adsorbed (kg)

  • mg: mass of fluid in gaseous form (kg)

  • ml: mass of fluid in liquid form (kg)

  • ms: mass of fluid in supercritical form (kg)

  • mout: cumulative mass of fluid vented (kg)

  • min: cumulative mass of fluid inserted (kg)

  • na_dot: the amount of fluid (moles) being adsorbed per second.

  • ng_dot: the first derivative of the amount of fluid in gaseous form w.r.t. time. Its unit is mol/s.

  • nl_dot: the first derivative of the amount of fluid in liquid form w.r.t. time. Its unit is mol/s

  • ns_dot: the first derivative of the amount of fluid in supercritical form w.r.t. time. Its unit is mol/s.

  • Qcoolreq_dot: the cooling power (W) required to maintain a constant pressure during refuel.

  • Qheatreq_dot: the heating power (W) required to maintain a constant pressure during discharge.

  • nout_dot: the rate at which fluid is being vented from the tank (mol/s).

  • Hout_dot: the rate at which enthalpy is taken away by fluid leaving the tank (W).

  • nin_dot: the rate at which fluid is entering the tank (mol/s).

  • Hin_dot: the rate at which enthalpy is added by fluid fluid entering the tank (W).

  • Qcooladd_dot: the user specified cooling power (W).

  • Qheatadd_dot: the user specified heating power (W).

  • Qleak_dot: the rate of heat leakage into the tank (W).

  • ma_dot: the mass of fluid (kg) being adsorbed per second.

  • mg_dot: the first derivative of the mass of fluid in gaseous form w.r.t. time. Its unit is kg/s.

  • ml_dot: the first derivative of the mass of fluid in liquid form w.r.t. time. Its unit is kg/s.

  • ms_dot: the first derivative of the mass of fluid in supercritical form w.r.t. time. Its unit is kg/s.

  • mout_dot: the rate at which fluid is being vented from the tank (kg/s).

  • min_dot: the rate at which fluid is being inserted into the tank (kg/s).

short_colnames = {'Hin': 'flow_energy_in', 'Hin_dot': 'flow_energy_in_W', 'Hout': 'vented_energy', 'Hout_dot': 'vented_energy_W', 'Qcooladd': 'cooling_additional', 'Qcooladd_dot': 'cooling_additional_W', 'Qcoolreq': 'cooling_required', 'Qcoolreq_dot': 'cooling_required_W', 'Qheatadd': 'heating_additional', 'Qheatadd_dot': 'heating_additional_W', 'Qheatreq': 'heating_required', 'Qheatreq_dot': 'heating_required_W', 'Qleak': 'heat_leak_in', 'Qleak_dot': 'heat_leak_in_W', 'T': 'temperature', 'ma': 'kg_adsorbed', 'ma_dot': 'kg_adsorbed_per_s', 'mg': 'kg_gas', 'mg_dot': 'kg_gas_per_s', 'min': 'inserted_kg', 'min_dot': 'inserted_kg_per_s', 'ml': 'kg_liquid', 'ml_dot': 'kg_liquid_per_s', 'mout': 'vented_kg', 'mout_dot': 'vented_kg_per_s', 'ms': 'kg_supercritical', 'ms_dot': 'kg_supercritical_per_s', 'na': 'moles_adsorbed', 'na_dot': 'moles_adsorbed_per_s', 'ng': 'moles_gas', 'ng_dot': 'moles_gas_per_s', 'nin': 'inserted_amount', 'nin_dot': 'inserted_amount_per_s', 'nl': 'moles_liquid', 'nl_dot': 'moles_liquid_per_s', 'nout': 'vented_amount', 'nout_dot': 'vented_amount_per_s', 'ns': 'moles_supercritical', 'ns_dot': 'moles_supercritical_per_s', 'p': 'pressure', 't': 'time'}
short_colnames_inv = {'cooling_additional': 'Qcooladd', 'cooling_additional_W': 'Qcooladd_dot', 'cooling_required': 'Qcoolreq', 'cooling_required_W': 'Qcoolreq_dot', 'flow_energy_in': 'Hin', 'flow_energy_in_W': 'Hin_dot', 'heat_leak_in': 'Qleak', 'heat_leak_in_W': 'Qleak_dot', 'heating_additional': 'Qheatadd', 'heating_additional_W': 'Qheatadd_dot', 'heating_required': 'Qheatreq', 'heating_required_W': 'Qheatreq_dot', 'inserted_amount': 'nin', 'inserted_amount_per_s': 'nin_dot', 'inserted_kg': 'min', 'inserted_kg_per_s': 'min_dot', 'kg_adsorbed': 'ma', 'kg_adsorbed_per_s': 'ma_dot', 'kg_gas': 'mg', 'kg_gas_per_s': 'mg_dot', 'kg_liquid': 'ml', 'kg_liquid_per_s': 'ml_dot', 'kg_supercritical': 'ms', 'kg_supercritical_per_s': 'ms_dot', 'moles_adsorbed': 'na', 'moles_adsorbed_per_s': 'na_dot', 'moles_gas': 'ng', 'moles_gas_per_s': 'ng_dot', 'moles_liquid': 'nl', 'moles_liquid_per_s': 'nl_dot', 'moles_supercritical': 'ns', 'moles_supercritical_per_s': 'ns_dot', 'pressure': 'p', 'temperature': 'T', 'time': 't', 'vented_amount': 'nout', 'vented_amount_per_s': 'nout_dot', 'vented_energy': 'Hout', 'vented_energy_W': 'Hout_dot', 'vented_kg': 'mout', 'vented_kg_per_s': 'mout_dot'}
to_csv(filename: str, verbose: bool = True)

Export simulation results to a csv file.

Parameters:
  • filename (str) – The desired filepath for the csv file to be created.

  • verbose (bool, optional) – Whether or nor to report the completion of the export. The default value is True.

pytanksim.classes.storagetankclasses module

Contains classes which store the properties of the storage tanks.

The StorageTank and SorbentTank classes are part of this module.

class pytanksim.classes.storagetankclasses.SorbentTank(sorbent_material: SorbentMaterial, aluminum_mass: float = 0, carbon_fiber_mass: float = 0, steel_mass: float = 0, vent_pressure: float | None = None, min_supply_pressure: float = 100000.0, thermal_resistance: float = 0, surface_area: float = 0, heat_transfer_coefficient: float = 0, volume: float | None = None, set_capacity: float | None = None, full_pressure: float | None = None, empty_pressure: float | None = None, full_temperature: float | None = None, empty_temperature: float | None = None, full_quality: float = 1, empty_quality: float = 1, set_sorbent_fill: float = 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. If 0, the value will not be considered in simulations. If the arguments ‘surface_area’ and ‘heat_transfer’ are passed, ‘thermal_resistance’ will be calculated based on those two arguments as long as the user does not pass a value to ‘thermal_resistance’.

Type:

float, 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:

float, optional

bulk_fluid_volume(p: float, T: float) float

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

calculate_dormancy(p: float, T: float, heating_power: float, q: float = 0) DataFrame

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

capacity(p: float, T: float, q: float = 0) float

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: float, T: float, q: float = 0) float

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

find_quality_at_saturation_capacity(T: float, capacity: float) float

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: float, cap: float) OptimizeResult

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

internal_energy(p: float, T: float, q: float = 1) float

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_bulk(p: float, T: float, q: float = 1) float

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

internal_energy_sorbent(p: float, T: float, q: float = 1) float

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

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

Bases: object

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. If the arguments ‘surface_area’ and ‘heat_transfer’ are passed, ‘thermal_resistance’ will be calculated based on those two arguments as long as the user does not pass a value to ‘thermal_resistance’.

Type:

float, 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:

float, optional

calculate_dormancy(p: float, T: float, heating_power: float, q: float = 0) DataFrame

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

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

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: float, T: float, q: float = 0, unit: str = 'mol') float

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

conditions_at_capacity_pressure(cap: float, p: float, T_guess: float, q_guess: float) OptimizeResult

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

conditions_at_capacity_temperature(cap: float, T: float, p_guess: float, q_guess: float) OptimizeResult

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

find_quality_at_saturation_capacity(T: float, capacity: float) float

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: float, T: float, q: float = 1) float

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

pytanksim.classes.twophasefluidsimclasses module

Module for simulating fluid tanks in the two-phase region.

class pytanksim.classes.twophasefluidsimclasses.TwoPhaseFluidCooled(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseFluidSim

Fluid tank being cooled at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Cooled'
solve_differentials(time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:

time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasefluidsimclasses.TwoPhaseFluidDefault(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseFluidSim

Simulation of fluid tanks in the two-phase region w/o constraints.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Default'
solve_differentials(time: float, ng: float, nl: float, T: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • time (float) – Current time step (in s).

  • ng (float) – Current amount of gas in the tank (moles).

  • nl (float) – Current amount of liquid in the tank (moles).

  • T (float) – Current temperature (K).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasefluidsimclasses.TwoPhaseFluidHeatedDischarge(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseFluidSim

Fluid tank being heated at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Heated'
solve_differentials(time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:

time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasefluidsimclasses.TwoPhaseFluidSim(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: BaseSimulation

Base class for the simulation of fluid tanks in the two-phase region.

Contains functions for calculating the governing ODEs.

sim_phase = 'Two Phase'
class pytanksim.classes.twophasefluidsimclasses.TwoPhaseFluidVenting(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseFluidSim

Fluid tank venting at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Venting'
solve_differentials(time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:

time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

pytanksim.classes.twophasesorbentsimclasses module

Module for simulating sorbent tanks in the two-phase region.

class pytanksim.classes.twophasesorbentsimclasses.TwoPhaseSorbentCooled(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseSorbentSim

Sorbent tank cooled at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Cooled'
solve_differentials(time: float, ng: float, nl: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • time (float) – Current time step (in s).

  • ng (float) – Current amount of gas in the tank (moles).

  • nl (float) – Current amount of liquid in the tank (moles).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasesorbentsimclasses.TwoPhaseSorbentDefault(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseSorbentSim

Simulate sorbent tanks in the two phase region without constraints.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Default'
solve_differentials(ng: float, nl: float, T: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • time (float) – Current time step (in s).

  • ng (float) – Current amount of gas in the tank (moles).

  • nl (float) – Current amount of liquid in the tank (moles).

  • T (float) – Current temperature (K).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasesorbentsimclasses.TwoPhaseSorbentHeatedDischarge(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseSorbentSim

Sorbent tank heated at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Heated'
solve_differentials(time: float, ng: float, nl: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • ng (float) – Current amount of gas in the tank (moles).

  • nl (float) – Current amount of liquid in the tank (moles).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray

class pytanksim.classes.twophasesorbentsimclasses.TwoPhaseSorbentSim(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: BaseSimulation

Base class for sorbent tanks in the two-phase region.

sim_phase = 'Two Phase'
class pytanksim.classes.twophasesorbentsimclasses.TwoPhaseSorbentVenting(simulation_params: SimParams, storage_tank: StorageTank, boundary_flux: BoundaryFlux)

Bases: TwoPhaseSorbentSim

Sorbent tank venting at constant pressure in the two-phase region.

run()

Run the dynamic simulation.

Raises:

TerminateSimulation – Stops the simulation when it detects an event such as the end of the phase change, or if the simulation hits the maximum pressure of the tank.

Returns:

An object for storing and manipulating the results of the dynamic simulation.

Return type:

SimResults

sim_type = 'Venting'
solve_differentials(ng: float, nl: float, time: float) ndarray

Find the right hand side of the governing ODE at a given time step.

Parameters:
  • ng (float) – Current amount of gas in the tank (moles).

  • nl (float) – Current amount of liquid in the tank (moles).

  • time (float) – Current time step (in s).

Returns:

An array containing the right hand side of the ODE.

Return type:

np.ndarray