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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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”.
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”.
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”.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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’.
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
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.
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.
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’.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.