PDSim.flow package¶
Submodules¶
PDSim.flow.fanno module¶
- PDSim.flow.fanno.Fanno_Ma_nondimLength(double Lparam, double gamma) double¶
Fanno flow analysis inverted calculation to get mach number from nondim. length
For the given length parameter (4*f_F*L_{1-2}/D_h), find the Mach number by doing a solve using the secant method
- PDSim.flow.fanno.p_pstar(double Ma, double gamma) double¶
Return
p/pstar, given by\[\]rac{p}{p^*} = rac{1}{Ma}left( rac{(gamma+1)}{2} ight)^{1/2}*left(1+ rac{(gamma-1)}{2}Ma^2 ight)^{-1/2}
PDSim.flow.flow module¶
- class PDSim.flow.flow.FlowPath(key1='', key2='', MdotFcn=None, MdotFcn_kwargs={}, Nflows=1)¶
Bases:
object- Parameters:
key1 (string) – The key for the first flow node connected to this path
key2 (string) – The key for the second flow node connected to this path
MdotFcn (function) –
Two options, either an instance of
FlowFunction, or a function with a prototype likef(double A,FlowPath FP, **kwargs). See alsoFlowFunction.Any function passed in for
MdotFcnwill be wrapped into an instance ofFlowFunction. Using an instance ofFlowFunctionis more computationally efficient because the Cython code doesn’t need to pass back through the python level and can all stay at the C/C++ level.MdotFcn_kwargs (dictionary) – A dictionary of terms that will be passed along to the call to
MdotFcnwhen it is calledNflows (int) – The number of flows that are to be calculated for the flow path (by default 1)
- MdotFcn¶
PDSim.flow.flow_models.FlowFunction
The function that will return the mass flow rate
- Type:
- MdotFcn_str¶
bytes
- Type:
- State_down¶
CoolProp.CoolProp.State
The downstream state
- Type:
- calculate(self)¶
Calculate the flow path
- key1¶
The string key corresponding to the first node
- key1_exists¶
‘bool’
- Type:
- key2¶
The string key corresponding to the second node
- key2_exists¶
‘bool’
- Type:
- key_down¶
The string key corresponding to the downstream node
- key_down_Index¶
‘long’
- Type:
- key_down_exists¶
‘bool’
- Type:
- key_up¶
The string key corresponding to the upstream node
- key_up_Index¶
‘long’
- Type:
- key_up_exists¶
‘bool’
- Type:
- class PDSim.flow.flow.FlowPathCollection(iterable=(), /)¶
Bases:
list- calculate(self)¶
Run the code for each flow path to calculate the flow rates
- get_deepcopy(self)¶
Using this method, the link to the mass flow function is broken
- sumterms(self, arraym summerdT, arraym summerdm)¶
Sum all the mass flow and mdot*h for each CV in existence at a given step for the derivatives in the ODE solver
Meant to be called by PDSimCore.derivs()
- update_existence(self, Core)¶
A function to update the pointers for the flow path as well as check existence of the states on either end of the path
This is required whenever the existence of any of the CV or tubes changes. Calling this function will update the pointers to the states
- Parameters:
Core (
PDSimCoreinstance or derived class thereof)
- PDSim.flow.flow.rebuildFlowPath(d)¶
- PDSim.flow.flow.sumterms_given_CV(key, list Flows) tuple¶
A function to sum all the mdot terms for a given control volume
Searches the list of flows and for each element in the flows, checks whether the key matches one of upstream or downstream key
- Parameters:
key (string)
Flows (
FlowPathCollectioninstance)
PDSim.flow.flow_models module¶
- class PDSim.flow.flow_models.FlowFunction(Nvalues=1)¶
Bases:
objectA wrapper to contain the function that will be called
- Two methods are provided, call(FP) and __call__(FP). The special method
__call__(FP) allows an instance of FlowFunction to be called directly like:
FFW = FlowFunction() FFW(FP)
or you can call the call() method like:
FFW.call(FP)
Having both methods allows cython functions to stay at the C++ layer since they can call the .call() function with defined argument types and not need to come back to python layer for speed
See also PyFlowFunctionWrapper
- Returns:
- mdotfloat
The mass flow rate in kg/s
- call(self, FlowPath FP) double¶
- resize(self, int Nflows)¶
Resize the storage arraym
- PDSim.flow.flow_models.FrictionCorrectedIsentropicNozzle(double A, State State_up, State State_down, double delta, int Type, double t=-1.0, double ro=-1.0) double¶
Frictionally-corrected nozzle model - the so-called hybrid leakage model
- Parameters:
A (float) – Flow area at the minimum area [\(m^2\)], equal to \(\delta_{flank}h\) for flank, and \(s_r\delta_{radial}\) for radial leakage. Intended for scroll compressor, but can be used with other compressors
State_up (
Stateinstance) – The State instance corresponding to the upstream side of the flow pathState_down (
Stateinstance) – The State instance corresponding to the downstream side of the flow pathdelta (float) – Gap width in meters
Type (int) – One of
flow_models.TYPE_RADIALorflow_models.TYPE_FLANKt (float) – Scroll wrap thickness in m
ro (float) – Orbiting radius in m
Notes
If Type is
flow_models.TYPE_RADIAL, t must be providedIf Type is
flow_models.TYPE_FLANK, ro must be providedImplements the frictionally-corrected method of Bell, I, Groll, E, Braun, J. E, & W. Travis, H. (in press, 2013). A computationally efficient hybrid leakage model for positive displacement compressors and expanders. International Journal of Refrigeration.
- PDSim.flow.flow_models.IsentropicNozzle(double A, State State_up, State State_down, int other_output=-1) double¶
The mass flow rate is calculated by using isentropic flow model
- Parameters:
A – double Throat area of the nozzle [m\(^2\)]
State_up –
Stateinstance UpstreamStateinstanceState_down –
Stateinstance DownstreamStateinstanceother_output – int Default is to return the mass flow rate, can over-ride by passing
flow_models.OUTPUT_VELOCITYorflow_models.OUTPUT_MAinstead
- Returns:
- double
Default is to return the mass flow rate, can over-ride by passing flags in the other_output variable
- Return type:
out
- class PDSim.flow.flow_models.IsentropicNozzleWrapper¶
Bases:
FlowFunctionA wrapper that can be added to call the isentropic nozzle model if the flow area is constant
- call(self, FlowPath FP) double¶
Returns the mass flow rate from the isentropic nozzle model
- PDSim.flow.flow_models.IsothermalWallTube(mdot, State1, State2, fixed, L, ID, OD=None, HTModel='Twall', Tmean=None, T_wall=None, Q_add=0.0, alpha=None)¶
In this tube model, one of the nodes is known (fixed), but the other is calculated based on heat transfer and pressure drop for a given mass flow rate
Assumes flow is turbulent and fully developed. The flow is almost certainly fully turbulent, but it is unlikely to be truly fully developed
- Parameters:
mdot (float) – mass flow rate [kg/s]
State1 (
Stateinstance) – State number 1 for the TubeState2 (
Stateinstance) – State number 2 for the Tubefixed (int,
1or2) – Which node is fixedL (float) – Length of tube [m]
ID (float) – Internal diameter of tube [m]
OD (float, optional) – Outer diameter of tube [m], not used if fixed wall temperature
HTModel (‘Twall’ or [other models] , optional) – Key for what type of model is used for the heat transfer
Tmean (float, optional) – Mean fluid temperature for evaluation of fluid properties [K]
T_wall (float, optional) – Temperature of wall [K]
Q_add (float, optional) – Additional amount of heat that will be added to the fluid in the tube [kW] This term is not added to the amount of heat transfer returned from this function
alpha (float, optional) – The heat transfer coefficient [kW/m2/K]. If not provided, calculated from correlations
- Returns:
Q – The amount of heat transfer [W], not including
Q_add- Return type:
- class PDSim.flow.flow_models.PyFlowFunctionWrapper(Function, kwargs, Nflows=1)¶
Bases:
FlowFunctionThis class is defined in order to wrap python functions for ease-of-use.
In this way, functions defined at the python level can still be used by the Cython code
- call(self, FlowPath FP) double¶
Call the flow path function, and store the flows that are calculated in the values arraym instance
- class PDSim.flow.flow_models.ValveModel(double d_valve, double d_port, double C_D, double rho_valve, double x_stopper, double m_eff, double k_valve, double x_tr, key_up, key_down)¶
Bases:
object(
Source code,png,hires.png,pdf)
Pressure-dominant Regime
\[M_{valve}\ddot x_{valve}+k_{valve}x_{valve} = (p_{high}-p_{low}) A_{valve}+\frac{1}{2}C_D\rho (V-\dot x_{valve})^2A_{valve}\]Two variables are \(x_2=\dot x_{valve}\) and \(x_1=x_{valve}\) where \(\ddot x_{valve}=\frac{d}{dt}[\dot x_{valve}]\) or \(\ddot x_{valve}=\dot x_2\). Thus the system of derivatives is
\[\begin{split}\mathbf f_{valves}=\frac{d}{dt}\left[ \begin{array}{c} \dot x_{valve} \\ x_{valve} \end{array} \right]=\left[ \begin{array}{c} \frac{d}{dt}[\dot x_{valve}] \\ \frac{d}{dt}[x_{valve}] \end{array} \right]\end{split}\]Thus the system of equations is given by
\[ \begin{align}\begin{aligned}\dot x_1 = x_2\\M_{valve}\dot x_2+k_{valve}x_1 = (p_{high}-p_{low}) A_{valve}+\frac{1}{2}C_D\rho (V-x_2)^2A_{valve}\end{aligned}\end{align} \]which yields the solution for the derivatives of \(x_1\) and \(x_2\) of
\[ \begin{align}\begin{aligned}\dot x_1 = x_2\\\dot x_2 = \dfrac{(p_{high}-p_{low}) A_{valve}+\frac{1}{2}C_D\rho (V-x_2)^2A_{valve}-k_{valve}x_1}{M_{valve}}\end{aligned}\end{align} \](
Source code,png,hires.png,pdf)
And if mass-flux-dominated, force balance given by
\[M_{valve}\ddot x_{valve}+k_{valve}x_{valve} = \frac{1}{2}C_D\rho (\mathbf V-\dot x_{valve})^2 A_{valve}+\rho (\mathbf V-\dot x_{valve})^2 A_{port}\]Which yields the solution for the system of derivatives of
\[ \begin{align}\begin{aligned}\dot x_1 = x_2\\\dot x_2= \dfrac{\frac{1}{2}C_D\rho (\mathbf V-x_2)^2 A_{valve}+\rho (\mathbf V-x_2)^2 A_{port}-k_{valve}x_1}{M_{valve}}\end{aligned}\end{align} \]- A(self) double¶
- State_down¶
CoolProp.CoolProp.State
- Type:
- flow_velocity(self, State State_up, State State_down) double¶
For a given set of states, and a known valve lift, first check whether it is within the valve lift range, and then calculate the flow velocity
- get_States(self, Core)¶
Core is the main model core, it contains information that is needed for the flow models
- set_xv(self, arraym xv)¶
- PDSim.flow.flow_models.makeIsentropicNozzleWrapper(kwds)¶
- PDSim.flow.flow_models.makePyFlowFunctionWrapper(kwds)¶
- PDSim.flow.flow_models.pow(double x, double y) double¶
- PDSim.flow.flow_models.rebuildValveModel(d)¶