repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
CalebBell/fluids | fluids/core.py | Peclet_heat | def Peclet_heat(V, L, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity
`V`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha}
Inputs either of a... | python | def Peclet_heat(V, L, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity
`V`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha}
Inputs either of a... | [
"def",
"Peclet_heat",
"(",
"V",
",",
"L",
",",
"rho",
"=",
"None",
",",
"Cp",
"=",
"None",
",",
"k",
"=",
"None",
",",
"alpha",
"=",
"None",
")",
":",
"r",
"if",
"rho",
"and",
"Cp",
"and",
"k",
":",
"alpha",
"=",
"k",
"/",
"(",
"rho",
"*",
... | r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity
`V`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha}
Inputs either of any of the following sets:
* V, L, density `rho`, heat capacit... | [
"r",
"Calculates",
"heat",
"transfer",
"Peclet",
"number",
"or",
"Pe",
"for",
"a",
"specified",
"velocity",
"V",
"characteristic",
"length",
"L",
"and",
"specified",
"properties",
"for",
"the",
"given",
"fluid",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L187-L246 | train |
CalebBell/fluids | fluids/core.py | Fourier_heat | def Fourier_heat(t, L, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates heat transfer Fourier number or `Fo` for a specified time
`t`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2}
Inputs either... | python | def Fourier_heat(t, L, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates heat transfer Fourier number or `Fo` for a specified time
`t`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2}
Inputs either... | [
"def",
"Fourier_heat",
"(",
"t",
",",
"L",
",",
"rho",
"=",
"None",
",",
"Cp",
"=",
"None",
",",
"k",
"=",
"None",
",",
"alpha",
"=",
"None",
")",
":",
"r",
"if",
"rho",
"and",
"Cp",
"and",
"k",
":",
"alpha",
"=",
"k",
"/",
"(",
"rho",
"*",... | r'''Calculates heat transfer Fourier number or `Fo` for a specified time
`t`, characteristic length `L`, and specified properties for the given
fluid.
.. math::
Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2}
Inputs either of any of the following sets:
* t, L, density `rho`, heat cap... | [
"r",
"Calculates",
"heat",
"transfer",
"Fourier",
"number",
"or",
"Fo",
"for",
"a",
"specified",
"time",
"t",
"characteristic",
"length",
"L",
"and",
"specified",
"properties",
"for",
"the",
"given",
"fluid",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L288-L348 | train |
CalebBell/fluids | fluids/core.py | Graetz_heat | def Graetz_heat(V, D, x, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates Graetz number or `Gz` for a specified velocity
`V`, diameter `D`, axial distance `x`, and specified properties for the
given fluid.
.. math::
Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha}
Inp... | python | def Graetz_heat(V, D, x, rho=None, Cp=None, k=None, alpha=None):
r'''Calculates Graetz number or `Gz` for a specified velocity
`V`, diameter `D`, axial distance `x`, and specified properties for the
given fluid.
.. math::
Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha}
Inp... | [
"def",
"Graetz_heat",
"(",
"V",
",",
"D",
",",
"x",
",",
"rho",
"=",
"None",
",",
"Cp",
"=",
"None",
",",
"k",
"=",
"None",
",",
"alpha",
"=",
"None",
")",
":",
"r",
"if",
"rho",
"and",
"Cp",
"and",
"k",
":",
"alpha",
"=",
"k",
"/",
"(",
... | r'''Calculates Graetz number or `Gz` for a specified velocity
`V`, diameter `D`, axial distance `x`, and specified properties for the
given fluid.
.. math::
Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha}
Inputs either of any of the following sets:
* V, D, x, density `rho... | [
"r",
"Calculates",
"Graetz",
"number",
"or",
"Gz",
"for",
"a",
"specified",
"velocity",
"V",
"diameter",
"D",
"axial",
"distance",
"x",
"and",
"specified",
"properties",
"for",
"the",
"given",
"fluid",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L390-L454 | train |
CalebBell/fluids | fluids/core.py | Schmidt | def Schmidt(D, mu=None, nu=None, rho=None):
r'''Calculates Schmidt number or `Sc` for a fluid with the given
parameters.
.. math::
Sc = \frac{\mu}{D\rho} = \frac{\nu}{D}
Inputs can be any of the following sets:
* Diffusivity, dynamic viscosity, and density
* Diffusivity and kinematic ... | python | def Schmidt(D, mu=None, nu=None, rho=None):
r'''Calculates Schmidt number or `Sc` for a fluid with the given
parameters.
.. math::
Sc = \frac{\mu}{D\rho} = \frac{\nu}{D}
Inputs can be any of the following sets:
* Diffusivity, dynamic viscosity, and density
* Diffusivity and kinematic ... | [
"def",
"Schmidt",
"(",
"D",
",",
"mu",
"=",
"None",
",",
"nu",
"=",
"None",
",",
"rho",
"=",
"None",
")",
":",
"r",
"if",
"rho",
"and",
"mu",
":",
"return",
"mu",
"/",
"(",
"rho",
"*",
"D",
")",
"elif",
"nu",
":",
"return",
"nu",
"/",
"D",
... | r'''Calculates Schmidt number or `Sc` for a fluid with the given
parameters.
.. math::
Sc = \frac{\mu}{D\rho} = \frac{\nu}{D}
Inputs can be any of the following sets:
* Diffusivity, dynamic viscosity, and density
* Diffusivity and kinematic viscosity
Parameters
----------
D :... | [
"r",
"Calculates",
"Schmidt",
"number",
"or",
"Sc",
"for",
"a",
"fluid",
"with",
"the",
"given",
"parameters",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L457-L512 | train |
CalebBell/fluids | fluids/core.py | Lewis | def Lewis(D=None, alpha=None, Cp=None, k=None, rho=None):
r'''Calculates Lewis number or `Le` for a fluid with the given parameters.
.. math::
Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D}
Inputs can be either of the following sets:
* Diffusivity and Thermal diffusivity
* Diffusivity, heat... | python | def Lewis(D=None, alpha=None, Cp=None, k=None, rho=None):
r'''Calculates Lewis number or `Le` for a fluid with the given parameters.
.. math::
Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D}
Inputs can be either of the following sets:
* Diffusivity and Thermal diffusivity
* Diffusivity, heat... | [
"def",
"Lewis",
"(",
"D",
"=",
"None",
",",
"alpha",
"=",
"None",
",",
"Cp",
"=",
"None",
",",
"k",
"=",
"None",
",",
"rho",
"=",
"None",
")",
":",
"r",
"if",
"k",
"and",
"Cp",
"and",
"rho",
":",
"alpha",
"=",
"k",
"/",
"(",
"rho",
"*",
"... | r'''Calculates Lewis number or `Le` for a fluid with the given parameters.
.. math::
Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D}
Inputs can be either of the following sets:
* Diffusivity and Thermal diffusivity
* Diffusivity, heat capacity, thermal conductivity, and density
Parameters
... | [
"r",
"Calculates",
"Lewis",
"number",
"or",
"Le",
"for",
"a",
"fluid",
"with",
"the",
"given",
"parameters",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L515-L574 | train |
CalebBell/fluids | fluids/core.py | Confinement | def Confinement(D, rhol, rhog, sigma, g=g):
r'''Calculates Confinement number or `Co` for a fluid in a channel of
diameter `D` with liquid and gas densities `rhol` and `rhog` and surface
tension `sigma`, under the influence of gravitational force `g`.
.. math::
\text{Co}=\frac{\left[\frac{\sig... | python | def Confinement(D, rhol, rhog, sigma, g=g):
r'''Calculates Confinement number or `Co` for a fluid in a channel of
diameter `D` with liquid and gas densities `rhol` and `rhog` and surface
tension `sigma`, under the influence of gravitational force `g`.
.. math::
\text{Co}=\frac{\left[\frac{\sig... | [
"def",
"Confinement",
"(",
"D",
",",
"rhol",
",",
"rhog",
",",
"sigma",
",",
"g",
"=",
"g",
")",
":",
"r",
"return",
"(",
"sigma",
"/",
"(",
"g",
"*",
"(",
"rhol",
"-",
"rhog",
")",
")",
")",
"**",
"0.5",
"/",
"D"
] | r'''Calculates Confinement number or `Co` for a fluid in a channel of
diameter `D` with liquid and gas densities `rhol` and `rhog` and surface
tension `sigma`, under the influence of gravitational force `g`.
.. math::
\text{Co}=\frac{\left[\frac{\sigma}{g(\rho_l-\rho_g)}\right]^{0.5}}{D}
Para... | [
"r",
"Calculates",
"Confinement",
"number",
"or",
"Co",
"for",
"a",
"fluid",
"in",
"a",
"channel",
"of",
"diameter",
"D",
"with",
"liquid",
"and",
"gas",
"densities",
"rhol",
"and",
"rhog",
"and",
"surface",
"tension",
"sigma",
"under",
"the",
"influence",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L666-L720 | train |
CalebBell/fluids | fluids/core.py | Morton | def Morton(rhol, rhog, mul, sigma, g=g):
r'''Calculates Morton number or `Mo` for a liquid and vapor with the
specified properties, under the influence of gravitational force `g`.
.. math::
Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3}
Parameters
----------
rhol : f... | python | def Morton(rhol, rhog, mul, sigma, g=g):
r'''Calculates Morton number or `Mo` for a liquid and vapor with the
specified properties, under the influence of gravitational force `g`.
.. math::
Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3}
Parameters
----------
rhol : f... | [
"def",
"Morton",
"(",
"rhol",
",",
"rhog",
",",
"mul",
",",
"sigma",
",",
"g",
"=",
"g",
")",
":",
"r",
"mul2",
"=",
"mul",
"*",
"mul",
"return",
"g",
"*",
"mul2",
"*",
"mul2",
"*",
"(",
"rhol",
"-",
"rhog",
")",
"/",
"(",
"rhol",
"*",
"rho... | r'''Calculates Morton number or `Mo` for a liquid and vapor with the
specified properties, under the influence of gravitational force `g`.
.. math::
Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3}
Parameters
----------
rhol : float
Density of liquid phase, [kg/m^3... | [
"r",
"Calculates",
"Morton",
"number",
"or",
"Mo",
"for",
"a",
"liquid",
"and",
"vapor",
"with",
"the",
"specified",
"properties",
"under",
"the",
"influence",
"of",
"gravitational",
"force",
"g",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L723-L767 | train |
CalebBell/fluids | fluids/core.py | Prandtl | def Prandtl(Cp=None, k=None, mu=None, nu=None, rho=None, alpha=None):
r'''Calculates Prandtl number or `Pr` for a fluid with the given
parameters.
.. math::
Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k}
Inputs can be any of the following sets:
* Heat capacity, dynam... | python | def Prandtl(Cp=None, k=None, mu=None, nu=None, rho=None, alpha=None):
r'''Calculates Prandtl number or `Pr` for a fluid with the given
parameters.
.. math::
Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k}
Inputs can be any of the following sets:
* Heat capacity, dynam... | [
"def",
"Prandtl",
"(",
"Cp",
"=",
"None",
",",
"k",
"=",
"None",
",",
"mu",
"=",
"None",
",",
"nu",
"=",
"None",
",",
"rho",
"=",
"None",
",",
"alpha",
"=",
"None",
")",
":",
"r",
"if",
"k",
"and",
"Cp",
"and",
"mu",
":",
"return",
"Cp",
"*... | r'''Calculates Prandtl number or `Pr` for a fluid with the given
parameters.
.. math::
Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k}
Inputs can be any of the following sets:
* Heat capacity, dynamic viscosity, and thermal conductivity
* Thermal diffusivity and kinem... | [
"r",
"Calculates",
"Prandtl",
"number",
"or",
"Pr",
"for",
"a",
"fluid",
"with",
"the",
"given",
"parameters",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L811-L876 | train |
CalebBell/fluids | fluids/core.py | Grashof | def Grashof(L, beta, T1, T2=0, rho=None, mu=None, nu=None, g=g):
r'''Calculates Grashof number or `Gr` for a fluid with the given
properties, temperature difference, and characteristic length.
.. math::
Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2}
= \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^... | python | def Grashof(L, beta, T1, T2=0, rho=None, mu=None, nu=None, g=g):
r'''Calculates Grashof number or `Gr` for a fluid with the given
properties, temperature difference, and characteristic length.
.. math::
Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2}
= \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^... | [
"def",
"Grashof",
"(",
"L",
",",
"beta",
",",
"T1",
",",
"T2",
"=",
"0",
",",
"rho",
"=",
"None",
",",
"mu",
"=",
"None",
",",
"nu",
"=",
"None",
",",
"g",
"=",
"g",
")",
":",
"r",
"if",
"rho",
"and",
"mu",
":",
"nu",
"=",
"mu",
"/",
"r... | r'''Calculates Grashof number or `Gr` for a fluid with the given
properties, temperature difference, and characteristic length.
.. math::
Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2}
= \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^2}
Inputs either of any of the following sets:
* L, beta, T... | [
"r",
"Calculates",
"Grashof",
"number",
"or",
"Gr",
"for",
"a",
"fluid",
"with",
"the",
"given",
"properties",
"temperature",
"difference",
"and",
"characteristic",
"length",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L879-L946 | train |
CalebBell/fluids | fluids/core.py | Froude | def Froude(V, L, g=g, squared=False):
r'''Calculates Froude number `Fr` for velocity `V` and geometric length
`L`. If desired, gravity can be specified as well. Normally the function
returns the result of the equation below; Froude number is also often
said to be defined as the square of the equation be... | python | def Froude(V, L, g=g, squared=False):
r'''Calculates Froude number `Fr` for velocity `V` and geometric length
`L`. If desired, gravity can be specified as well. Normally the function
returns the result of the equation below; Froude number is also often
said to be defined as the square of the equation be... | [
"def",
"Froude",
"(",
"V",
",",
"L",
",",
"g",
"=",
"g",
",",
"squared",
"=",
"False",
")",
":",
"r",
"Fr",
"=",
"V",
"/",
"(",
"L",
"*",
"g",
")",
"**",
"0.5",
"if",
"squared",
":",
"Fr",
"*=",
"Fr",
"return",
"Fr"
] | r'''Calculates Froude number `Fr` for velocity `V` and geometric length
`L`. If desired, gravity can be specified as well. Normally the function
returns the result of the equation below; Froude number is also often
said to be defined as the square of the equation below.
.. math::
Fr = \frac{V}{... | [
"r",
"Calculates",
"Froude",
"number",
"Fr",
"for",
"velocity",
"V",
"and",
"geometric",
"length",
"L",
".",
"If",
"desired",
"gravity",
"can",
"be",
"specified",
"as",
"well",
".",
"Normally",
"the",
"function",
"returns",
"the",
"result",
"of",
"the",
"e... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1028-L1077 | train |
CalebBell/fluids | fluids/core.py | Stokes_number | def Stokes_number(V, Dp, D, rhop, mu):
r'''Calculates Stokes Number for a given characteristic velocity `V`,
particle diameter `Dp`, characteristic diameter `D`, particle density
`rhop`, and fluid viscosity `mu`.
.. math::
\text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D}
Parameters
----... | python | def Stokes_number(V, Dp, D, rhop, mu):
r'''Calculates Stokes Number for a given characteristic velocity `V`,
particle diameter `Dp`, characteristic diameter `D`, particle density
`rhop`, and fluid viscosity `mu`.
.. math::
\text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D}
Parameters
----... | [
"def",
"Stokes_number",
"(",
"V",
",",
"Dp",
",",
"D",
",",
"rhop",
",",
"mu",
")",
":",
"r",
"return",
"rhop",
"*",
"V",
"*",
"(",
"Dp",
"*",
"Dp",
")",
"/",
"(",
"18.0",
"*",
"mu",
"*",
"D",
")"
] | r'''Calculates Stokes Number for a given characteristic velocity `V`,
particle diameter `Dp`, characteristic diameter `D`, particle density
`rhop`, and fluid viscosity `mu`.
.. math::
\text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D}
Parameters
----------
V : float
Characteristic... | [
"r",
"Calculates",
"Stokes",
"Number",
"for",
"a",
"given",
"characteristic",
"velocity",
"V",
"particle",
"diameter",
"Dp",
"characteristic",
"diameter",
"D",
"particle",
"density",
"rhop",
"and",
"fluid",
"viscosity",
"mu",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1644-L1688 | train |
CalebBell/fluids | fluids/core.py | Suratman | def Suratman(L, rho, mu, sigma):
r'''Calculates Suratman number, `Su`, for a fluid with the given
characteristic length, density, viscosity, and surface tension.
.. math::
\text{Su} = \frac{\rho\sigma L}{\mu^2}
Parameters
----------
L : float
Characteristic length [m]
rho :... | python | def Suratman(L, rho, mu, sigma):
r'''Calculates Suratman number, `Su`, for a fluid with the given
characteristic length, density, viscosity, and surface tension.
.. math::
\text{Su} = \frac{\rho\sigma L}{\mu^2}
Parameters
----------
L : float
Characteristic length [m]
rho :... | [
"def",
"Suratman",
"(",
"L",
",",
"rho",
",",
"mu",
",",
"sigma",
")",
":",
"r",
"return",
"rho",
"*",
"sigma",
"*",
"L",
"/",
"(",
"mu",
"*",
"mu",
")"
] | r'''Calculates Suratman number, `Su`, for a fluid with the given
characteristic length, density, viscosity, and surface tension.
.. math::
\text{Su} = \frac{\rho\sigma L}{\mu^2}
Parameters
----------
L : float
Characteristic length [m]
rho : float
Density of fluid, [kg/... | [
"r",
"Calculates",
"Suratman",
"number",
"Su",
"for",
"a",
"fluid",
"with",
"the",
"given",
"characteristic",
"length",
"density",
"viscosity",
"and",
"surface",
"tension",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1828-L1878 | train |
CalebBell/fluids | fluids/core.py | nu_mu_converter | def nu_mu_converter(rho, mu=None, nu=None):
r'''Calculates either kinematic or dynamic viscosity, depending on inputs.
Used when one type of viscosity is known as well as density, to obtain
the other type. Raises an error if both types of viscosity or neither type
of viscosity is provided.
.. math:... | python | def nu_mu_converter(rho, mu=None, nu=None):
r'''Calculates either kinematic or dynamic viscosity, depending on inputs.
Used when one type of viscosity is known as well as density, to obtain
the other type. Raises an error if both types of viscosity or neither type
of viscosity is provided.
.. math:... | [
"def",
"nu_mu_converter",
"(",
"rho",
",",
"mu",
"=",
"None",
",",
"nu",
"=",
"None",
")",
":",
"r",
"if",
"(",
"nu",
"and",
"mu",
")",
"or",
"not",
"rho",
"or",
"(",
"not",
"nu",
"and",
"not",
"mu",
")",
":",
"raise",
"Exception",
"(",
"'Input... | r'''Calculates either kinematic or dynamic viscosity, depending on inputs.
Used when one type of viscosity is known as well as density, to obtain
the other type. Raises an error if both types of viscosity or neither type
of viscosity is provided.
.. math::
\nu = \frac{\mu}{\rho}
.. math::
... | [
"r",
"Calculates",
"either",
"kinematic",
"or",
"dynamic",
"viscosity",
"depending",
"on",
"inputs",
".",
"Used",
"when",
"one",
"type",
"of",
"viscosity",
"is",
"known",
"as",
"well",
"as",
"density",
"to",
"obtain",
"the",
"other",
"type",
".",
"Raises",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L2158-L2199 | train |
CalebBell/fluids | fluids/core.py | Engauge_2d_parser | def Engauge_2d_parser(lines, flat=False):
'''Not exposed function to read a 2D file generated by engauge-digitizer;
for curve fitting.
'''
z_values = []
x_lists = []
y_lists = []
working_xs = []
working_ys = []
new_curve = True
for line in lines:
if line.strip() == '... | python | def Engauge_2d_parser(lines, flat=False):
'''Not exposed function to read a 2D file generated by engauge-digitizer;
for curve fitting.
'''
z_values = []
x_lists = []
y_lists = []
working_xs = []
working_ys = []
new_curve = True
for line in lines:
if line.strip() == '... | [
"def",
"Engauge_2d_parser",
"(",
"lines",
",",
"flat",
"=",
"False",
")",
":",
"z_values",
"=",
"[",
"]",
"x_lists",
"=",
"[",
"]",
"y_lists",
"=",
"[",
"]",
"working_xs",
"=",
"[",
"]",
"working_ys",
"=",
"[",
"]",
"new_curve",
"=",
"True",
"for",
... | Not exposed function to read a 2D file generated by engauge-digitizer;
for curve fitting. | [
"Not",
"exposed",
"function",
"to",
"read",
"a",
"2D",
"file",
"generated",
"by",
"engauge",
"-",
"digitizer",
";",
"for",
"curve",
"fitting",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L2869-L2910 | train |
CalebBell/fluids | fluids/compressible.py | isothermal_work_compression | def isothermal_work_compression(P1, P2, T, Z=1):
r'''Calculates the work of compression or expansion of a gas going through
an isothermal process.
.. math::
W = zRT\ln\left(\frac{P_2}{P_1}\right)
Parameters
----------
P1 : float
Inlet pressure, [Pa]
P2 : float
Outle... | python | def isothermal_work_compression(P1, P2, T, Z=1):
r'''Calculates the work of compression or expansion of a gas going through
an isothermal process.
.. math::
W = zRT\ln\left(\frac{P_2}{P_1}\right)
Parameters
----------
P1 : float
Inlet pressure, [Pa]
P2 : float
Outle... | [
"def",
"isothermal_work_compression",
"(",
"P1",
",",
"P2",
",",
"T",
",",
"Z",
"=",
"1",
")",
":",
"r",
"return",
"Z",
"*",
"R",
"*",
"T",
"*",
"log",
"(",
"P2",
"/",
"P1",
")"
] | r'''Calculates the work of compression or expansion of a gas going through
an isothermal process.
.. math::
W = zRT\ln\left(\frac{P_2}{P_1}\right)
Parameters
----------
P1 : float
Inlet pressure, [Pa]
P2 : float
Outlet pressure, [Pa]
T : float
Temperature of... | [
"r",
"Calculates",
"the",
"work",
"of",
"compression",
"or",
"expansion",
"of",
"a",
"gas",
"going",
"through",
"an",
"isothermal",
"process",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L38-L102 | train |
CalebBell/fluids | fluids/compressible.py | isentropic_T_rise_compression | def isentropic_T_rise_compression(T1, P1, P2, k, eta=1):
r'''Calculates the increase in temperature of a fluid which is compressed
or expanded under isentropic, adiabatic conditions assuming constant
Cp and Cv. The polytropic model is the same equation; just provide `n`
instead of `k` and use a polytro... | python | def isentropic_T_rise_compression(T1, P1, P2, k, eta=1):
r'''Calculates the increase in temperature of a fluid which is compressed
or expanded under isentropic, adiabatic conditions assuming constant
Cp and Cv. The polytropic model is the same equation; just provide `n`
instead of `k` and use a polytro... | [
"def",
"isentropic_T_rise_compression",
"(",
"T1",
",",
"P1",
",",
"P2",
",",
"k",
",",
"eta",
"=",
"1",
")",
":",
"r",
"dT",
"=",
"T1",
"*",
"(",
"(",
"P2",
"/",
"P1",
")",
"**",
"(",
"(",
"k",
"-",
"1.0",
")",
"/",
"k",
")",
"-",
"1.0",
... | r'''Calculates the increase in temperature of a fluid which is compressed
or expanded under isentropic, adiabatic conditions assuming constant
Cp and Cv. The polytropic model is the same equation; just provide `n`
instead of `k` and use a polytropic efficienty for `eta` instead of a
isentropic efficien... | [
"r",
"Calculates",
"the",
"increase",
"in",
"temperature",
"of",
"a",
"fluid",
"which",
"is",
"compressed",
"or",
"expanded",
"under",
"isentropic",
"adiabatic",
"conditions",
"assuming",
"constant",
"Cp",
"and",
"Cv",
".",
"The",
"polytropic",
"model",
"is",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L212-L264 | train |
CalebBell/fluids | fluids/compressible.py | isentropic_efficiency | def isentropic_efficiency(P1, P2, k, eta_s=None, eta_p=None):
r'''Calculates either isentropic or polytropic efficiency from the other
type of efficiency.
.. math::
\eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1}
{(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1}
.. math::
\eta_p = \frac{\left(k - 1\ri... | python | def isentropic_efficiency(P1, P2, k, eta_s=None, eta_p=None):
r'''Calculates either isentropic or polytropic efficiency from the other
type of efficiency.
.. math::
\eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1}
{(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1}
.. math::
\eta_p = \frac{\left(k - 1\ri... | [
"def",
"isentropic_efficiency",
"(",
"P1",
",",
"P2",
",",
"k",
",",
"eta_s",
"=",
"None",
",",
"eta_p",
"=",
"None",
")",
":",
"r",
"if",
"eta_s",
"is",
"None",
"and",
"eta_p",
":",
"return",
"(",
"(",
"P2",
"/",
"P1",
")",
"**",
"(",
"(",
"k"... | r'''Calculates either isentropic or polytropic efficiency from the other
type of efficiency.
.. math::
\eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1}
{(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1}
.. math::
\eta_p = \frac{\left(k - 1\right) \log{\left (\frac{P_{2}}{P_{1}}
\right )}}{k \log{\le... | [
"r",
"Calculates",
"either",
"isentropic",
"or",
"polytropic",
"efficiency",
"from",
"the",
"other",
"type",
"of",
"efficiency",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L267-L320 | train |
CalebBell/fluids | fluids/compressible.py | P_isothermal_critical_flow | def P_isothermal_critical_flow(P, fd, D, L):
r'''Calculates critical flow pressure `Pcf` for a fluid flowing
isothermally and suffering pressure drop caused by a pipe's friction factor.
.. math::
P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW}
{\left (- e^{\frac{1}{D} \le... | python | def P_isothermal_critical_flow(P, fd, D, L):
r'''Calculates critical flow pressure `Pcf` for a fluid flowing
isothermally and suffering pressure drop caused by a pipe's friction factor.
.. math::
P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW}
{\left (- e^{\frac{1}{D} \le... | [
"def",
"P_isothermal_critical_flow",
"(",
"P",
",",
"fd",
",",
"D",
",",
"L",
")",
":",
"r",
"lambert_term",
"=",
"float",
"(",
"lambertw",
"(",
"-",
"exp",
"(",
"(",
"-",
"D",
"-",
"L",
"*",
"fd",
")",
"/",
"D",
")",
",",
"-",
"1",
")",
".",... | r'''Calculates critical flow pressure `Pcf` for a fluid flowing
isothermally and suffering pressure drop caused by a pipe's friction factor.
.. math::
P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW}
{\left (- e^{\frac{1}{D} \left(- D - L f_d\right)} \right )} + 1\right)
... | [
"r",
"Calculates",
"critical",
"flow",
"pressure",
"Pcf",
"for",
"a",
"fluid",
"flowing",
"isothermally",
"and",
"suffering",
"pressure",
"drop",
"caused",
"by",
"a",
"pipe",
"s",
"friction",
"factor",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L452-L499 | train |
CalebBell/fluids | fluids/compressible.py | P_upstream_isothermal_critical_flow | def P_upstream_isothermal_critical_flow(P, fd, D, L):
'''Not part of the public API. Reverses `P_isothermal_critical_flow`.
Examples
--------
>>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185,
... L=1000., D=0.5)
1000000.0000000001
'''
lambertw_term = float(lambert... | python | def P_upstream_isothermal_critical_flow(P, fd, D, L):
'''Not part of the public API. Reverses `P_isothermal_critical_flow`.
Examples
--------
>>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185,
... L=1000., D=0.5)
1000000.0000000001
'''
lambertw_term = float(lambert... | [
"def",
"P_upstream_isothermal_critical_flow",
"(",
"P",
",",
"fd",
",",
"D",
",",
"L",
")",
":",
"lambertw_term",
"=",
"float",
"(",
"lambertw",
"(",
"-",
"exp",
"(",
"-",
"(",
"fd",
"*",
"L",
"+",
"D",
")",
"/",
"D",
")",
",",
"-",
"1",
")",
"... | Not part of the public API. Reverses `P_isothermal_critical_flow`.
Examples
--------
>>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185,
... L=1000., D=0.5)
1000000.0000000001 | [
"Not",
"part",
"of",
"the",
"public",
"API",
".",
"Reverses",
"P_isothermal_critical_flow",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L502-L512 | train |
CalebBell/fluids | fluids/compressible.py | is_critical_flow | def is_critical_flow(P1, P2, k):
r'''Determines if a flow of a fluid driven by pressure gradient
P1 - P2 is critical, for a fluid with the given isentropic coefficient.
This function calculates critical flow pressure, and checks if this is
larger than P2. If so, the flow is critical and choked.
Par... | python | def is_critical_flow(P1, P2, k):
r'''Determines if a flow of a fluid driven by pressure gradient
P1 - P2 is critical, for a fluid with the given isentropic coefficient.
This function calculates critical flow pressure, and checks if this is
larger than P2. If so, the flow is critical and choked.
Par... | [
"def",
"is_critical_flow",
"(",
"P1",
",",
"P2",
",",
"k",
")",
":",
"r",
"Pcf",
"=",
"P_critical_flow",
"(",
"P1",
",",
"k",
")",
"return",
"Pcf",
">",
"P2"
] | r'''Determines if a flow of a fluid driven by pressure gradient
P1 - P2 is critical, for a fluid with the given isentropic coefficient.
This function calculates critical flow pressure, and checks if this is
larger than P2. If so, the flow is critical and choked.
Parameters
----------
P1 : float... | [
"r",
"Determines",
"if",
"a",
"flow",
"of",
"a",
"fluid",
"driven",
"by",
"pressure",
"gradient",
"P1",
"-",
"P2",
"is",
"critical",
"for",
"a",
"fluid",
"with",
"the",
"given",
"isentropic",
"coefficient",
".",
"This",
"function",
"calculates",
"critical",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L515-L554 | train |
CalebBell/fluids | fluids/friction.py | one_phase_dP | def one_phase_dP(m, rho, mu, D, roughness=0, L=1, Method=None):
r'''Calculates single-phase pressure drop. This is a wrapper
around other methods.
Parameters
----------
m : float
Mass flow rate of fluid, [kg/s]
rho : float
Density of fluid, [kg/m^3]
mu : float
Viscos... | python | def one_phase_dP(m, rho, mu, D, roughness=0, L=1, Method=None):
r'''Calculates single-phase pressure drop. This is a wrapper
around other methods.
Parameters
----------
m : float
Mass flow rate of fluid, [kg/s]
rho : float
Density of fluid, [kg/m^3]
mu : float
Viscos... | [
"def",
"one_phase_dP",
"(",
"m",
",",
"rho",
",",
"mu",
",",
"D",
",",
"roughness",
"=",
"0",
",",
"L",
"=",
"1",
",",
"Method",
"=",
"None",
")",
":",
"r",
"D2",
"=",
"D",
"*",
"D",
"V",
"=",
"m",
"/",
"(",
"0.25",
"*",
"pi",
"*",
"D2",
... | r'''Calculates single-phase pressure drop. This is a wrapper
around other methods.
Parameters
----------
m : float
Mass flow rate of fluid, [kg/s]
rho : float
Density of fluid, [kg/m^3]
mu : float
Viscosity of fluid, [Pa*s]
D : float
Diameter of pipe, [m]
... | [
"r",
"Calculates",
"single",
"-",
"phase",
"pressure",
"drop",
".",
"This",
"is",
"a",
"wrapper",
"around",
"other",
"methods",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/friction.py#L3874-L3918 | train |
CalebBell/fluids | fluids/flow_meter.py | discharge_coefficient_to_K | def discharge_coefficient_to_K(D, Do, C):
r'''Converts a discharge coefficient to a standard loss coefficient,
for use in computation of the actual pressure drop of an orifice or other
device.
.. math::
K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2
Parameters
... | python | def discharge_coefficient_to_K(D, Do, C):
r'''Converts a discharge coefficient to a standard loss coefficient,
for use in computation of the actual pressure drop of an orifice or other
device.
.. math::
K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2
Parameters
... | [
"def",
"discharge_coefficient_to_K",
"(",
"D",
",",
"Do",
",",
"C",
")",
":",
"r",
"beta",
"=",
"Do",
"/",
"D",
"beta2",
"=",
"beta",
"*",
"beta",
"beta4",
"=",
"beta2",
"*",
"beta2",
"return",
"(",
"(",
"1.0",
"-",
"beta4",
"*",
"(",
"1.0",
"-",... | r'''Converts a discharge coefficient to a standard loss coefficient,
for use in computation of the actual pressure drop of an orifice or other
device.
.. math::
K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2
Parameters
----------
D : float
Upstream inte... | [
"r",
"Converts",
"a",
"discharge",
"coefficient",
"to",
"a",
"standard",
"loss",
"coefficient",
"for",
"use",
"in",
"computation",
"of",
"the",
"actual",
"pressure",
"drop",
"of",
"an",
"orifice",
"or",
"other",
"device",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/flow_meter.py#L438-L484 | train |
CalebBell/fluids | fluids/particle_size_distribution.py | ParticleSizeDistributionContinuous.dn | def dn(self, fraction, n=None):
r'''Computes the diameter at which a specified `fraction` of the
distribution falls under. Utilizes a bounded solver to search for the
desired diameter.
Parameters
----------
fraction : float
Fraction of the distribution which... | python | def dn(self, fraction, n=None):
r'''Computes the diameter at which a specified `fraction` of the
distribution falls under. Utilizes a bounded solver to search for the
desired diameter.
Parameters
----------
fraction : float
Fraction of the distribution which... | [
"def",
"dn",
"(",
"self",
",",
"fraction",
",",
"n",
"=",
"None",
")",
":",
"r",
"if",
"fraction",
"==",
"1.0",
":",
"fraction",
"=",
"1.0",
"-",
"epsilon",
"if",
"fraction",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Fraction must be more than 0'",
... | r'''Computes the diameter at which a specified `fraction` of the
distribution falls under. Utilizes a bounded solver to search for the
desired diameter.
Parameters
----------
fraction : float
Fraction of the distribution which should be under the calculated
... | [
"r",
"Computes",
"the",
"diameter",
"at",
"which",
"a",
"specified",
"fraction",
"of",
"the",
"distribution",
"falls",
"under",
".",
"Utilizes",
"a",
"bounded",
"solver",
"to",
"search",
"for",
"the",
"desired",
"diameter",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1360-L1417 | train |
CalebBell/fluids | fluids/particle_size_distribution.py | ParticleSizeDistribution.fit | def fit(self, x0=None, distribution='lognormal', n=None, **kwargs):
'''Incomplete method to fit experimental values to a curve. It is very
hard to get good initial guesses, which are really required for this.
Differential evolution is promissing. This API is likely to change in
the futur... | python | def fit(self, x0=None, distribution='lognormal', n=None, **kwargs):
'''Incomplete method to fit experimental values to a curve. It is very
hard to get good initial guesses, which are really required for this.
Differential evolution is promissing. This API is likely to change in
the futur... | [
"def",
"fit",
"(",
"self",
",",
"x0",
"=",
"None",
",",
"distribution",
"=",
"'lognormal'",
",",
"n",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"dist",
"=",
"{",
"'lognormal'",
":",
"PSDLognormal",
",",
"'GGS'",
":",
"PSDGatesGaudinSchuhman",
",",
"'... | Incomplete method to fit experimental values to a curve. It is very
hard to get good initial guesses, which are really required for this.
Differential evolution is promissing. This API is likely to change in
the future. | [
"Incomplete",
"method",
"to",
"fit",
"experimental",
"values",
"to",
"a",
"curve",
".",
"It",
"is",
"very",
"hard",
"to",
"get",
"good",
"initial",
"guesses",
"which",
"are",
"really",
"required",
"for",
"this",
".",
"Differential",
"evolution",
"is",
"promi... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1881-L1905 | train |
CalebBell/fluids | fluids/particle_size_distribution.py | ParticleSizeDistribution.Dis | def Dis(self):
'''Representative diameters of each bin.
'''
return [self.di_power(i, power=1) for i in range(self.N)] | python | def Dis(self):
'''Representative diameters of each bin.
'''
return [self.di_power(i, power=1) for i in range(self.N)] | [
"def",
"Dis",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"di_power",
"(",
"i",
",",
"power",
"=",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"N",
")",
"]"
] | Representative diameters of each bin. | [
"Representative",
"diameters",
"of",
"each",
"bin",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1908-L1911 | train |
CalebBell/fluids | fluids/geometry.py | SA_tank | def SA_tank(D, L, sideA=None, sideB=None, sideA_a=0,
sideB_a=0, sideA_f=None, sideA_k=None, sideB_f=None, sideB_k=None,
full_output=False):
r'''Calculates the surface are of a cylindrical tank with optional heads.
In the degenerate case of being provided with only `D` and `L`, provides... | python | def SA_tank(D, L, sideA=None, sideB=None, sideA_a=0,
sideB_a=0, sideA_f=None, sideA_k=None, sideB_f=None, sideB_k=None,
full_output=False):
r'''Calculates the surface are of a cylindrical tank with optional heads.
In the degenerate case of being provided with only `D` and `L`, provides... | [
"def",
"SA_tank",
"(",
"D",
",",
"L",
",",
"sideA",
"=",
"None",
",",
"sideB",
"=",
"None",
",",
"sideA_a",
"=",
"0",
",",
"sideB_a",
"=",
"0",
",",
"sideA_f",
"=",
"None",
",",
"sideA_k",
"=",
"None",
",",
"sideB_f",
"=",
"None",
",",
"sideB_k",... | r'''Calculates the surface are of a cylindrical tank with optional heads.
In the degenerate case of being provided with only `D` and `L`, provides
the surface area of a cylinder.
Parameters
----------
D : float
Diameter of the cylindrical section of the tank, [m]
L : float
Lengt... | [
"r",
"Calculates",
"the",
"surface",
"are",
"of",
"a",
"cylindrical",
"tank",
"with",
"optional",
"heads",
".",
"In",
"the",
"degenerate",
"case",
"of",
"being",
"provided",
"with",
"only",
"D",
"and",
"L",
"provides",
"the",
"surface",
"area",
"of",
"a",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1192-L1287 | train |
CalebBell/fluids | fluids/geometry.py | pitch_angle_solver | def pitch_angle_solver(angle=None, pitch=None, pitch_parallel=None,
pitch_normal=None):
r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and
`pitch_normal` and calculate the other two. This is useful for applications
with tube banks, as in shell and tube heat exchang... | python | def pitch_angle_solver(angle=None, pitch=None, pitch_parallel=None,
pitch_normal=None):
r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and
`pitch_normal` and calculate the other two. This is useful for applications
with tube banks, as in shell and tube heat exchang... | [
"def",
"pitch_angle_solver",
"(",
"angle",
"=",
"None",
",",
"pitch",
"=",
"None",
",",
"pitch_parallel",
"=",
"None",
",",
"pitch_normal",
"=",
"None",
")",
":",
"r",
"if",
"angle",
"is",
"not",
"None",
"and",
"pitch",
"is",
"not",
"None",
":",
"pitch... | r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and
`pitch_normal` and calculate the other two. This is useful for applications
with tube banks, as in shell and tube heat exchangers or air coolers and
allows for a wider range of user input.
.. math::
\text{pitch normal} = \t... | [
"r",
"Utility",
"to",
"take",
"any",
"two",
"of",
"angle",
"pitch",
"pitch_parallel",
"and",
"pitch_normal",
"and",
"calculate",
"the",
"other",
"two",
".",
"This",
"is",
"useful",
"for",
"applications",
"with",
"tube",
"banks",
"as",
"in",
"shell",
"and",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3030-L3113 | train |
CalebBell/fluids | fluids/geometry.py | A_hollow_cylinder | def A_hollow_cylinder(Di, Do, L):
r'''Returns the surface area of a hollow cylinder.
.. math::
A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4}
- 2\cdot \frac{\pi D_i^2}{4}
Parameters
----------
Di : float
Diameter of the hollow in the cylinder, [m]
Do : float
... | python | def A_hollow_cylinder(Di, Do, L):
r'''Returns the surface area of a hollow cylinder.
.. math::
A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4}
- 2\cdot \frac{\pi D_i^2}{4}
Parameters
----------
Di : float
Diameter of the hollow in the cylinder, [m]
Do : float
... | [
"def",
"A_hollow_cylinder",
"(",
"Di",
",",
"Do",
",",
"L",
")",
":",
"r",
"side_o",
"=",
"pi",
"*",
"Do",
"*",
"L",
"side_i",
"=",
"pi",
"*",
"Di",
"*",
"L",
"cap_circle",
"=",
"pi",
"*",
"Do",
"**",
"2",
"/",
"4",
"*",
"2",
"cap_removed",
"... | r'''Returns the surface area of a hollow cylinder.
.. math::
A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4}
- 2\cdot \frac{\pi D_i^2}{4}
Parameters
----------
Di : float
Diameter of the hollow in the cylinder, [m]
Do : float
Diameter of the exterior of the ... | [
"r",
"Returns",
"the",
"surface",
"area",
"of",
"a",
"hollow",
"cylinder",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3285-L3315 | train |
CalebBell/fluids | fluids/geometry.py | A_multiple_hole_cylinder | def A_multiple_hole_cylinder(Do, L, holes):
r'''Returns the surface area of a cylinder with multiple holes.
Calculation will naively return a negative value or other impossible
result if the number of cylinders added is physically impossible.
Holes may be of different shapes, but must be perpendicular t... | python | def A_multiple_hole_cylinder(Do, L, holes):
r'''Returns the surface area of a cylinder with multiple holes.
Calculation will naively return a negative value or other impossible
result if the number of cylinders added is physically impossible.
Holes may be of different shapes, but must be perpendicular t... | [
"def",
"A_multiple_hole_cylinder",
"(",
"Do",
",",
"L",
",",
"holes",
")",
":",
"r",
"side_o",
"=",
"pi",
"*",
"Do",
"*",
"L",
"cap_circle",
"=",
"pi",
"*",
"Do",
"**",
"2",
"/",
"4",
"*",
"2",
"A",
"=",
"cap_circle",
"+",
"side_o",
"for",
"Di",
... | r'''Returns the surface area of a cylinder with multiple holes.
Calculation will naively return a negative value or other impossible
result if the number of cylinders added is physically impossible.
Holes may be of different shapes, but must be perpendicular to the
axis of the cylinder.
.. math::
... | [
"r",
"Returns",
"the",
"surface",
"area",
"of",
"a",
"cylinder",
"with",
"multiple",
"holes",
".",
"Calculation",
"will",
"naively",
"return",
"a",
"negative",
"value",
"or",
"other",
"impossible",
"result",
"if",
"the",
"number",
"of",
"cylinders",
"added",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3346-L3384 | train |
CalebBell/fluids | fluids/geometry.py | TANK.V_from_h | def V_from_h(self, h, method='full'):
r'''Method to calculate the volume of liquid in a fully defined tank
given a specified height `h`. `h` must be under the maximum height.
If the method is 'chebyshev', and the coefficients have not yet been
calculated, they are created by calling `se... | python | def V_from_h(self, h, method='full'):
r'''Method to calculate the volume of liquid in a fully defined tank
given a specified height `h`. `h` must be under the maximum height.
If the method is 'chebyshev', and the coefficients have not yet been
calculated, they are created by calling `se... | [
"def",
"V_from_h",
"(",
"self",
",",
"h",
",",
"method",
"=",
"'full'",
")",
":",
"r",
"if",
"method",
"==",
"'full'",
":",
"return",
"V_from_h",
"(",
"h",
",",
"self",
".",
"D",
",",
"self",
".",
"L",
",",
"self",
".",
"horizontal",
",",
"self",... | r'''Method to calculate the volume of liquid in a fully defined tank
given a specified height `h`. `h` must be under the maximum height.
If the method is 'chebyshev', and the coefficients have not yet been
calculated, they are created by calling `set_chebyshev_approximators`.
Parameter... | [
"r",
"Method",
"to",
"calculate",
"the",
"volume",
"of",
"liquid",
"in",
"a",
"fully",
"defined",
"tank",
"given",
"a",
"specified",
"height",
"h",
".",
"h",
"must",
"be",
"under",
"the",
"maximum",
"height",
".",
"If",
"the",
"method",
"is",
"chebyshev"... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1713-L1744 | train |
CalebBell/fluids | fluids/geometry.py | TANK.h_from_V | def h_from_V(self, V, method='spline'):
r'''Method to calculate the height of liquid in a fully defined tank
given a specified volume of liquid in it `V`. `V` must be under the
maximum volume. If the method is 'spline', and the interpolation table
is not yet defined, creates it by callin... | python | def h_from_V(self, V, method='spline'):
r'''Method to calculate the height of liquid in a fully defined tank
given a specified volume of liquid in it `V`. `V` must be under the
maximum volume. If the method is 'spline', and the interpolation table
is not yet defined, creates it by callin... | [
"def",
"h_from_V",
"(",
"self",
",",
"V",
",",
"method",
"=",
"'spline'",
")",
":",
"r",
"if",
"method",
"==",
"'spline'",
":",
"if",
"not",
"self",
".",
"table",
":",
"self",
".",
"set_table",
"(",
")",
"return",
"float",
"(",
"self",
".",
"interp... | r'''Method to calculate the height of liquid in a fully defined tank
given a specified volume of liquid in it `V`. `V` must be under the
maximum volume. If the method is 'spline', and the interpolation table
is not yet defined, creates it by calling the method set_table. If the
method is... | [
"r",
"Method",
"to",
"calculate",
"the",
"height",
"of",
"liquid",
"in",
"a",
"fully",
"defined",
"tank",
"given",
"a",
"specified",
"volume",
"of",
"liquid",
"in",
"it",
"V",
".",
"V",
"must",
"be",
"under",
"the",
"maximum",
"volume",
".",
"If",
"the... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1746-L1779 | train |
CalebBell/fluids | fluids/geometry.py | TANK.set_table | def set_table(self, n=100, dx=None):
r'''Method to set an interpolation table of liquids levels versus
volumes in the tank, for a fully defined tank. Normally run by the
h_from_V method, this may be run prior to its use with a custom
specification. Either the number of points on the tabl... | python | def set_table(self, n=100, dx=None):
r'''Method to set an interpolation table of liquids levels versus
volumes in the tank, for a fully defined tank. Normally run by the
h_from_V method, this may be run prior to its use with a custom
specification. Either the number of points on the tabl... | [
"def",
"set_table",
"(",
"self",
",",
"n",
"=",
"100",
",",
"dx",
"=",
"None",
")",
":",
"r",
"if",
"dx",
":",
"self",
".",
"heights",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"self",
".",
"h_max",
",",
"int",
"(",
"self",
".",
"h_max",
"/"... | r'''Method to set an interpolation table of liquids levels versus
volumes in the tank, for a fully defined tank. Normally run by the
h_from_V method, this may be run prior to its use with a custom
specification. Either the number of points on the table, or the
vertical distance between s... | [
"r",
"Method",
"to",
"set",
"an",
"interpolation",
"table",
"of",
"liquids",
"levels",
"versus",
"volumes",
"in",
"the",
"tank",
"for",
"a",
"fully",
"defined",
"tank",
".",
"Normally",
"run",
"by",
"the",
"h_from_V",
"method",
"this",
"may",
"be",
"run",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1781-L1802 | train |
CalebBell/fluids | fluids/geometry.py | TANK._V_solver_error | def _V_solver_error(self, Vtarget, D, L, horizontal, sideA, sideB, sideA_a,
sideB_a, sideA_f, sideA_k, sideB_f, sideB_k,
sideA_a_ratio, sideB_a_ratio):
'''Function which uses only the variables given, and the TANK
class itself, to determine how far from the ... | python | def _V_solver_error(self, Vtarget, D, L, horizontal, sideA, sideB, sideA_a,
sideB_a, sideA_f, sideA_k, sideB_f, sideB_k,
sideA_a_ratio, sideB_a_ratio):
'''Function which uses only the variables given, and the TANK
class itself, to determine how far from the ... | [
"def",
"_V_solver_error",
"(",
"self",
",",
"Vtarget",
",",
"D",
",",
"L",
",",
"horizontal",
",",
"sideA",
",",
"sideB",
",",
"sideA_a",
",",
"sideB_a",
",",
"sideA_f",
",",
"sideA_k",
",",
"sideB_f",
",",
"sideB_k",
",",
"sideA_a_ratio",
",",
"sideB_a_... | Function which uses only the variables given, and the TANK
class itself, to determine how far from the desired volume, Vtarget,
the volume produced by the specified parameters in a new TANK instance
is. Should only be used by solve_tank_for_V method. | [
"Function",
"which",
"uses",
"only",
"the",
"variables",
"given",
"and",
"the",
"TANK",
"class",
"itself",
"to",
"determine",
"how",
"far",
"from",
"the",
"desired",
"volume",
"Vtarget",
"the",
"volume",
"produced",
"by",
"the",
"specified",
"parameters",
"in"... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1843-L1856 | train |
CalebBell/fluids | fluids/geometry.py | PlateExchanger.plate_exchanger_identifier | def plate_exchanger_identifier(self):
'''Method to create an identifying string in format 'L' + wavelength +
'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and
amplitude are specified in units of mm and rounded to two decimal places.
'''
s = ('L' + str(round(se... | python | def plate_exchanger_identifier(self):
'''Method to create an identifying string in format 'L' + wavelength +
'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and
amplitude are specified in units of mm and rounded to two decimal places.
'''
s = ('L' + str(round(se... | [
"def",
"plate_exchanger_identifier",
"(",
"self",
")",
":",
"s",
"=",
"(",
"'L'",
"+",
"str",
"(",
"round",
"(",
"self",
".",
"wavelength",
"*",
"1000",
",",
"2",
")",
")",
"+",
"'A'",
"+",
"str",
"(",
"round",
"(",
"self",
".",
"amplitude",
"*",
... | Method to create an identifying string in format 'L' + wavelength +
'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and
amplitude are specified in units of mm and rounded to two decimal places. | [
"Method",
"to",
"create",
"an",
"identifying",
"string",
"in",
"format",
"L",
"+",
"wavelength",
"+",
"A",
"+",
"amplitude",
"+",
"B",
"+",
"chevron",
"angle",
"-",
"chevron",
"angle",
".",
"Wavelength",
"and",
"amplitude",
"are",
"specified",
"in",
"units... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L2163-L2171 | train |
CalebBell/fluids | fluids/numerics/__init__.py | linspace | def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None):
'''Port of numpy's linspace to pure python. Does not support dtype, and
returns lists of floats.
'''
num = int(num)
start = start * 1.
stop = stop * 1.
if num <= 0:
return []
if endpoint:
if nu... | python | def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None):
'''Port of numpy's linspace to pure python. Does not support dtype, and
returns lists of floats.
'''
num = int(num)
start = start * 1.
stop = stop * 1.
if num <= 0:
return []
if endpoint:
if nu... | [
"def",
"linspace",
"(",
"start",
",",
"stop",
",",
"num",
"=",
"50",
",",
"endpoint",
"=",
"True",
",",
"retstep",
"=",
"False",
",",
"dtype",
"=",
"None",
")",
":",
"num",
"=",
"int",
"(",
"num",
")",
"start",
"=",
"start",
"*",
"1.",
"stop",
... | Port of numpy's linspace to pure python. Does not support dtype, and
returns lists of floats. | [
"Port",
"of",
"numpy",
"s",
"linspace",
"to",
"pure",
"python",
".",
"Does",
"not",
"support",
"dtype",
"and",
"returns",
"lists",
"of",
"floats",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L361-L392 | train |
CalebBell/fluids | fluids/numerics/__init__.py | derivative | def derivative(func, x0, dx=1.0, n=1, args=(), order=3):
'''Reimplementation of SciPy's derivative function, with more cached
coefficients and without using numpy. If new coefficients not cached are
needed, they are only calculated once and are remembered.
'''
if order < n + 1:
raise ValueEr... | python | def derivative(func, x0, dx=1.0, n=1, args=(), order=3):
'''Reimplementation of SciPy's derivative function, with more cached
coefficients and without using numpy. If new coefficients not cached are
needed, they are only calculated once and are remembered.
'''
if order < n + 1:
raise ValueEr... | [
"def",
"derivative",
"(",
"func",
",",
"x0",
",",
"dx",
"=",
"1.0",
",",
"n",
"=",
"1",
",",
"args",
"=",
"(",
")",
",",
"order",
"=",
"3",
")",
":",
"if",
"order",
"<",
"n",
"+",
"1",
":",
"raise",
"ValueError",
"if",
"order",
"%",
"2",
"=... | Reimplementation of SciPy's derivative function, with more cached
coefficients and without using numpy. If new coefficients not cached are
needed, they are only calculated once and are remembered. | [
"Reimplementation",
"of",
"SciPy",
"s",
"derivative",
"function",
"with",
"more",
"cached",
"coefficients",
"and",
"without",
"using",
"numpy",
".",
"If",
"new",
"coefficients",
"not",
"cached",
"are",
"needed",
"they",
"are",
"only",
"calculated",
"once",
"and"... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L547-L561 | train |
CalebBell/fluids | fluids/numerics/__init__.py | polyder | def polyder(c, m=1, scl=1, axis=0):
'''not quite a copy of numpy's version because this was faster to implement.
'''
c = list(c)
cnt = int(m)
if cnt == 0:
return c
n = len(c)
if cnt >= n:
c = c[:1]*0
else:
for i in range(cnt):
n = n - 1
c... | python | def polyder(c, m=1, scl=1, axis=0):
'''not quite a copy of numpy's version because this was faster to implement.
'''
c = list(c)
cnt = int(m)
if cnt == 0:
return c
n = len(c)
if cnt >= n:
c = c[:1]*0
else:
for i in range(cnt):
n = n - 1
c... | [
"def",
"polyder",
"(",
"c",
",",
"m",
"=",
"1",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"list",
"(",
"c",
")",
"cnt",
"=",
"int",
"(",
"m",
")",
"if",
"cnt",
"==",
"0",
":",
"return",
"c",
"n",
"=",
"len",
"(",
... | not quite a copy of numpy's version because this was faster to implement. | [
"not",
"quite",
"a",
"copy",
"of",
"numpy",
"s",
"version",
"because",
"this",
"was",
"faster",
"to",
"implement",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L620-L640 | train |
CalebBell/fluids | fluids/numerics/__init__.py | horner_log | def horner_log(coeffs, log_coeff, x):
'''Technically possible to save one addition of the last term of
coeffs is removed but benchmarks said nothing was saved'''
tot = 0.0
for c in coeffs:
tot = tot*x + c
return tot + log_coeff*log(x) | python | def horner_log(coeffs, log_coeff, x):
'''Technically possible to save one addition of the last term of
coeffs is removed but benchmarks said nothing was saved'''
tot = 0.0
for c in coeffs:
tot = tot*x + c
return tot + log_coeff*log(x) | [
"def",
"horner_log",
"(",
"coeffs",
",",
"log_coeff",
",",
"x",
")",
":",
"tot",
"=",
"0.0",
"for",
"c",
"in",
"coeffs",
":",
"tot",
"=",
"tot",
"*",
"x",
"+",
"c",
"return",
"tot",
"+",
"log_coeff",
"*",
"log",
"(",
"x",
")"
] | Technically possible to save one addition of the last term of
coeffs is removed but benchmarks said nothing was saved | [
"Technically",
"possible",
"to",
"save",
"one",
"addition",
"of",
"the",
"last",
"term",
"of",
"coeffs",
"is",
"removed",
"but",
"benchmarks",
"said",
"nothing",
"was",
"saved"
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L679-L685 | train |
CalebBell/fluids | fluids/numerics/__init__.py | implementation_optimize_tck | def implementation_optimize_tck(tck):
'''Converts 1-d or 2-d splines calculated with SciPy's `splrep` or
`bisplrep` to a format for fastest computation - lists in PyPy, and numpy
arrays otherwise.
Only implemented for 3 and 5 length `tck`s.
'''
if IS_PYPY:
return tck
else:
... | python | def implementation_optimize_tck(tck):
'''Converts 1-d or 2-d splines calculated with SciPy's `splrep` or
`bisplrep` to a format for fastest computation - lists in PyPy, and numpy
arrays otherwise.
Only implemented for 3 and 5 length `tck`s.
'''
if IS_PYPY:
return tck
else:
... | [
"def",
"implementation_optimize_tck",
"(",
"tck",
")",
":",
"if",
"IS_PYPY",
":",
"return",
"tck",
"else",
":",
"if",
"len",
"(",
"tck",
")",
"==",
"3",
":",
"tck",
"[",
"0",
"]",
"=",
"np",
".",
"array",
"(",
"tck",
"[",
"0",
"]",
")",
"tck",
... | Converts 1-d or 2-d splines calculated with SciPy's `splrep` or
`bisplrep` to a format for fastest computation - lists in PyPy, and numpy
arrays otherwise.
Only implemented for 3 and 5 length `tck`s. | [
"Converts",
"1",
"-",
"d",
"or",
"2",
"-",
"d",
"splines",
"calculated",
"with",
"SciPy",
"s",
"splrep",
"or",
"bisplrep",
"to",
"a",
"format",
"for",
"fastest",
"computation",
"-",
"lists",
"in",
"PyPy",
"and",
"numpy",
"arrays",
"otherwise",
".",
"Only... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L870-L889 | train |
CalebBell/fluids | fluids/numerics/__init__.py | py_bisect | def py_bisect(f, a, b, args=(), xtol=_xtol, rtol=_rtol, maxiter=_iter,
ytol=None, full_output=False, disp=True):
'''Port of SciPy's C bisect routine.
'''
fa = f(a, *args)
fb = f(b, *args)
if fa*fb > 0.0:
raise ValueError("f(a) and f(b) must have different signs")
elif fa =... | python | def py_bisect(f, a, b, args=(), xtol=_xtol, rtol=_rtol, maxiter=_iter,
ytol=None, full_output=False, disp=True):
'''Port of SciPy's C bisect routine.
'''
fa = f(a, *args)
fb = f(b, *args)
if fa*fb > 0.0:
raise ValueError("f(a) and f(b) must have different signs")
elif fa =... | [
"def",
"py_bisect",
"(",
"f",
",",
"a",
",",
"b",
",",
"args",
"=",
"(",
")",
",",
"xtol",
"=",
"_xtol",
",",
"rtol",
"=",
"_rtol",
",",
"maxiter",
"=",
"_iter",
",",
"ytol",
"=",
"None",
",",
"full_output",
"=",
"False",
",",
"disp",
"=",
"Tru... | Port of SciPy's C bisect routine. | [
"Port",
"of",
"SciPy",
"s",
"C",
"bisect",
"routine",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L1058-L1089 | train |
CalebBell/fluids | fluids/control_valve.py | is_choked_turbulent_l | def is_choked_turbulent_l(dP, P1, Psat, FF, FL=None, FLP=None, FP=None):
r'''Calculates if a liquid flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 liquid valve sizing calculations.
Either FL may be provided or FLP and FP, depending on the calculation
process.
.. math::
... | python | def is_choked_turbulent_l(dP, P1, Psat, FF, FL=None, FLP=None, FP=None):
r'''Calculates if a liquid flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 liquid valve sizing calculations.
Either FL may be provided or FLP and FP, depending on the calculation
process.
.. math::
... | [
"def",
"is_choked_turbulent_l",
"(",
"dP",
",",
"P1",
",",
"Psat",
",",
"FF",
",",
"FL",
"=",
"None",
",",
"FLP",
"=",
"None",
",",
"FP",
"=",
"None",
")",
":",
"r",
"if",
"FLP",
"and",
"FP",
":",
"return",
"dP",
">=",
"(",
"FLP",
"/",
"FP",
... | r'''Calculates if a liquid flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 liquid valve sizing calculations.
Either FL may be provided or FLP and FP, depending on the calculation
process.
.. math::
\Delta P > F_L^2(P_1 - F_F P_{sat})
.. math::
\Delta P >= \l... | [
"r",
"Calculates",
"if",
"a",
"liquid",
"flow",
"in",
"IEC",
"60534",
"calculations",
"is",
"critical",
"or",
"not",
"for",
"use",
"in",
"IEC",
"60534",
"liquid",
"valve",
"sizing",
"calculations",
".",
"Either",
"FL",
"may",
"be",
"provided",
"or",
"FLP",... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L259-L310 | train |
CalebBell/fluids | fluids/control_valve.py | is_choked_turbulent_g | def is_choked_turbulent_g(x, Fgamma, xT=None, xTP=None):
r'''Calculates if a gas flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 gas valve sizing calculations.
Either xT or xTP must be provided, depending on the calculation process.
.. math::
x \ge F_\gamma x_T
.. m... | python | def is_choked_turbulent_g(x, Fgamma, xT=None, xTP=None):
r'''Calculates if a gas flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 gas valve sizing calculations.
Either xT or xTP must be provided, depending on the calculation process.
.. math::
x \ge F_\gamma x_T
.. m... | [
"def",
"is_choked_turbulent_g",
"(",
"x",
",",
"Fgamma",
",",
"xT",
"=",
"None",
",",
"xTP",
"=",
"None",
")",
":",
"r",
"if",
"xT",
":",
"return",
"x",
">=",
"Fgamma",
"*",
"xT",
"elif",
"xTP",
":",
"return",
"x",
">=",
"Fgamma",
"*",
"xTP",
"el... | r'''Calculates if a gas flow in IEC 60534 calculations is critical or
not, for use in IEC 60534 gas valve sizing calculations.
Either xT or xTP must be provided, depending on the calculation process.
.. math::
x \ge F_\gamma x_T
.. math::
x \ge F_\gamma x_{TP}
Parameters
-----... | [
"r",
"Calculates",
"if",
"a",
"gas",
"flow",
"in",
"IEC",
"60534",
"calculations",
"is",
"critical",
"or",
"not",
"for",
"use",
"in",
"IEC",
"60534",
"gas",
"valve",
"sizing",
"calculations",
".",
"Either",
"xT",
"or",
"xTP",
"must",
"be",
"provided",
"d... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L313-L360 | train |
CalebBell/fluids | fluids/control_valve.py | Reynolds_valve | def Reynolds_valve(nu, Q, D1, FL, Fd, C):
r'''Calculates Reynolds number of a control valve for a liquid or gas
flowing through it at a specified Q, for a specified D1, FL, Fd, C, and
with kinematic viscosity `nu` according to IEC 60534 calculations.
.. math::
Re_v = \frac{N_4 F_d Q}{\nu \sqrt{... | python | def Reynolds_valve(nu, Q, D1, FL, Fd, C):
r'''Calculates Reynolds number of a control valve for a liquid or gas
flowing through it at a specified Q, for a specified D1, FL, Fd, C, and
with kinematic viscosity `nu` according to IEC 60534 calculations.
.. math::
Re_v = \frac{N_4 F_d Q}{\nu \sqrt{... | [
"def",
"Reynolds_valve",
"(",
"nu",
",",
"Q",
",",
"D1",
",",
"FL",
",",
"Fd",
",",
"C",
")",
":",
"r",
"return",
"N4",
"*",
"Fd",
"*",
"Q",
"/",
"nu",
"/",
"(",
"C",
"*",
"FL",
")",
"**",
"0.5",
"*",
"(",
"FL",
"**",
"2",
"*",
"C",
"**... | r'''Calculates Reynolds number of a control valve for a liquid or gas
flowing through it at a specified Q, for a specified D1, FL, Fd, C, and
with kinematic viscosity `nu` according to IEC 60534 calculations.
.. math::
Re_v = \frac{N_4 F_d Q}{\nu \sqrt{C F_L}}\left(\frac{F_L^2 C^2}
{N_2D^4}... | [
"r",
"Calculates",
"Reynolds",
"number",
"of",
"a",
"control",
"valve",
"for",
"a",
"liquid",
"or",
"gas",
"flowing",
"through",
"it",
"at",
"a",
"specified",
"Q",
"for",
"a",
"specified",
"D1",
"FL",
"Fd",
"C",
"and",
"with",
"kinematic",
"viscosity",
"... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L363-L403 | train |
CalebBell/fluids | fluids/control_valve.py | Reynolds_factor | def Reynolds_factor(FL, C, d, Rev, full_trim=True):
r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds
number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery
factor `FL`, and with either full or reduced trim, all according to
IEC 60534 calculations.
If f... | python | def Reynolds_factor(FL, C, d, Rev, full_trim=True):
r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds
number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery
factor `FL`, and with either full or reduced trim, all according to
IEC 60534 calculations.
If f... | [
"def",
"Reynolds_factor",
"(",
"FL",
",",
"C",
",",
"d",
",",
"Rev",
",",
"full_trim",
"=",
"True",
")",
":",
"r",
"if",
"full_trim",
":",
"n1",
"=",
"N2",
"/",
"(",
"min",
"(",
"C",
"/",
"d",
"**",
"2",
",",
"0.04",
")",
")",
"**",
"2",
"F... | r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds
number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery
factor `FL`, and with either full or reduced trim, all according to
IEC 60534 calculations.
If full trim:
.. math::
F_{R,1a} = 1 + \left(\f... | [
"r",
"Calculates",
"the",
"Reynolds",
"number",
"factor",
"FR",
"for",
"a",
"valve",
"with",
"a",
"Reynolds",
"number",
"Rev",
"diameter",
"d",
"flow",
"coefficient",
"C",
"liquid",
"pressure",
"recovery",
"factor",
"FL",
"and",
"with",
"either",
"full",
"or... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L461-L547 | train |
CalebBell/fluids | fluids/units.py | func_args | def func_args(func):
'''Basic function which returns a tuple of arguments of a function or
method.
'''
try:
return tuple(inspect.signature(func).parameters)
except:
return tuple(inspect.getargspec(func).args) | python | def func_args(func):
'''Basic function which returns a tuple of arguments of a function or
method.
'''
try:
return tuple(inspect.signature(func).parameters)
except:
return tuple(inspect.getargspec(func).args) | [
"def",
"func_args",
"(",
"func",
")",
":",
"try",
":",
"return",
"tuple",
"(",
"inspect",
".",
"signature",
"(",
"func",
")",
".",
"parameters",
")",
"except",
":",
"return",
"tuple",
"(",
"inspect",
".",
"getargspec",
"(",
"func",
")",
".",
"args",
... | Basic function which returns a tuple of arguments of a function or
method. | [
"Basic",
"function",
"which",
"returns",
"a",
"tuple",
"of",
"arguments",
"of",
"a",
"function",
"or",
"method",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/units.py#L51-L58 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | cast_scalar | def cast_scalar(method):
"""
Cast scalars to constant interpolating objects
"""
@wraps(method)
def new_method(self, other):
if np.isscalar(other):
other = type(self)([other],self.domain())
return method(self, other)
return new_method | python | def cast_scalar(method):
"""
Cast scalars to constant interpolating objects
"""
@wraps(method)
def new_method(self, other):
if np.isscalar(other):
other = type(self)([other],self.domain())
return method(self, other)
return new_method | [
"def",
"cast_scalar",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"new_method",
"(",
"self",
",",
"other",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"other",
")",
":",
"other",
"=",
"type",
"(",
"self",
")",
"(",
"[",
"oth... | Cast scalars to constant interpolating objects | [
"Cast",
"scalars",
"to",
"constant",
"interpolating",
"objects"
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L75-L84 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | dct | def dct(data):
"""
Compute DCT using FFT
"""
N = len(data)//2
fftdata = fftpack.fft(data, axis=0)[:N+1]
fftdata /= N
fftdata[0] /= 2.
fftdata[-1] /= 2.
if np.isrealobj(data):
data = np.real(fftdata)
else:
data = fftdata
return data | python | def dct(data):
"""
Compute DCT using FFT
"""
N = len(data)//2
fftdata = fftpack.fft(data, axis=0)[:N+1]
fftdata /= N
fftdata[0] /= 2.
fftdata[-1] /= 2.
if np.isrealobj(data):
data = np.real(fftdata)
else:
data = fftdata
return data | [
"def",
"dct",
"(",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
")",
"//",
"2",
"fftdata",
"=",
"fftpack",
".",
"fft",
"(",
"data",
",",
"axis",
"=",
"0",
")",
"[",
":",
"N",
"+",
"1",
"]",
"fftdata",
"/=",
"N",
"fftdata",
"[",
"0",
"]",... | Compute DCT using FFT | [
"Compute",
"DCT",
"using",
"FFT"
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L637-L650 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Polyfun._cutoff | def _cutoff(self, coeffs, vscale):
"""
Compute cutoff index after which the coefficients are deemed negligible.
"""
bnd = self._threshold(vscale)
inds = np.nonzero(abs(coeffs) >= bnd)
if len(inds[0]):
N = inds[0][-1]
else:
N = 0
re... | python | def _cutoff(self, coeffs, vscale):
"""
Compute cutoff index after which the coefficients are deemed negligible.
"""
bnd = self._threshold(vscale)
inds = np.nonzero(abs(coeffs) >= bnd)
if len(inds[0]):
N = inds[0][-1]
else:
N = 0
re... | [
"def",
"_cutoff",
"(",
"self",
",",
"coeffs",
",",
"vscale",
")",
":",
"bnd",
"=",
"self",
".",
"_threshold",
"(",
"vscale",
")",
"inds",
"=",
"np",
".",
"nonzero",
"(",
"abs",
"(",
"coeffs",
")",
">=",
"bnd",
")",
"if",
"len",
"(",
"inds",
"[",
... | Compute cutoff index after which the coefficients are deemed negligible. | [
"Compute",
"cutoff",
"index",
"after",
"which",
"the",
"coefficients",
"are",
"deemed",
"negligible",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L203-L213 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Polyfun.same_domain | def same_domain(self, fun2):
"""
Returns True if the domains of two objects are the same.
"""
return np.allclose(self.domain(), fun2.domain(), rtol=1e-14, atol=1e-14) | python | def same_domain(self, fun2):
"""
Returns True if the domains of two objects are the same.
"""
return np.allclose(self.domain(), fun2.domain(), rtol=1e-14, atol=1e-14) | [
"def",
"same_domain",
"(",
"self",
",",
"fun2",
")",
":",
"return",
"np",
".",
"allclose",
"(",
"self",
".",
"domain",
"(",
")",
",",
"fun2",
".",
"domain",
"(",
")",
",",
"rtol",
"=",
"1e-14",
",",
"atol",
"=",
"1e-14",
")"
] | Returns True if the domains of two objects are the same. | [
"Returns",
"True",
"if",
"the",
"domains",
"of",
"two",
"objects",
"are",
"the",
"same",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L241-L245 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Polyfun.restrict | def restrict(self,subinterval):
"""
Return a Polyfun that matches self on subinterval.
"""
if (subinterval[0] < self._domain[0]) or (subinterval[1] > self._domain[1]):
raise ValueError("Can only restrict to subinterval")
return self.from_function(self, subinterval) | python | def restrict(self,subinterval):
"""
Return a Polyfun that matches self on subinterval.
"""
if (subinterval[0] < self._domain[0]) or (subinterval[1] > self._domain[1]):
raise ValueError("Can only restrict to subinterval")
return self.from_function(self, subinterval) | [
"def",
"restrict",
"(",
"self",
",",
"subinterval",
")",
":",
"if",
"(",
"subinterval",
"[",
"0",
"]",
"<",
"self",
".",
"_domain",
"[",
"0",
"]",
")",
"or",
"(",
"subinterval",
"[",
"1",
"]",
">",
"self",
".",
"_domain",
"[",
"1",
"]",
")",
":... | Return a Polyfun that matches self on subinterval. | [
"Return",
"a",
"Polyfun",
"that",
"matches",
"self",
"on",
"subinterval",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L395-L401 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.basis | def basis(self, n):
"""
Chebyshev basis functions T_n.
"""
if n == 0:
return self(np.array([1.]))
vals = np.ones(n+1)
vals[1::2] = -1
return self(vals) | python | def basis(self, n):
"""
Chebyshev basis functions T_n.
"""
if n == 0:
return self(np.array([1.]))
vals = np.ones(n+1)
vals[1::2] = -1
return self(vals) | [
"def",
"basis",
"(",
"self",
",",
"n",
")",
":",
"if",
"n",
"==",
"0",
":",
"return",
"self",
"(",
"np",
".",
"array",
"(",
"[",
"1.",
"]",
")",
")",
"vals",
"=",
"np",
".",
"ones",
"(",
"n",
"+",
"1",
")",
"vals",
"[",
"1",
":",
":",
"... | Chebyshev basis functions T_n. | [
"Chebyshev",
"basis",
"functions",
"T_n",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L435-L443 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.sum | def sum(self):
"""
Evaluate the integral over the given interval using
Clenshaw-Curtis quadrature.
"""
ak = self.coefficients()
ak2 = ak[::2]
n = len(ak2)
Tints = 2/(1-(2*np.arange(n))**2)
val = np.sum((Tints*ak2.T).T, axis=0)
a_, b_ = self... | python | def sum(self):
"""
Evaluate the integral over the given interval using
Clenshaw-Curtis quadrature.
"""
ak = self.coefficients()
ak2 = ak[::2]
n = len(ak2)
Tints = 2/(1-(2*np.arange(n))**2)
val = np.sum((Tints*ak2.T).T, axis=0)
a_, b_ = self... | [
"def",
"sum",
"(",
"self",
")",
":",
"ak",
"=",
"self",
".",
"coefficients",
"(",
")",
"ak2",
"=",
"ak",
"[",
":",
":",
"2",
"]",
"n",
"=",
"len",
"(",
"ak2",
")",
"Tints",
"=",
"2",
"/",
"(",
"1",
"-",
"(",
"2",
"*",
"np",
".",
"arange",... | Evaluate the integral over the given interval using
Clenshaw-Curtis quadrature. | [
"Evaluate",
"the",
"integral",
"over",
"the",
"given",
"interval",
"using",
"Clenshaw",
"-",
"Curtis",
"quadrature",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L449-L460 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.integrate | def integrate(self):
"""
Return the object representing the primitive of self over the domain. The
output starts at zero on the left-hand side of the domain.
"""
coeffs = self.coefficients()
a,b = self.domain()
int_coeffs = 0.5*(b-a)*poly.chebyshev.chebint(coeffs)... | python | def integrate(self):
"""
Return the object representing the primitive of self over the domain. The
output starts at zero on the left-hand side of the domain.
"""
coeffs = self.coefficients()
a,b = self.domain()
int_coeffs = 0.5*(b-a)*poly.chebyshev.chebint(coeffs)... | [
"def",
"integrate",
"(",
"self",
")",
":",
"coeffs",
"=",
"self",
".",
"coefficients",
"(",
")",
"a",
",",
"b",
"=",
"self",
".",
"domain",
"(",
")",
"int_coeffs",
"=",
"0.5",
"*",
"(",
"b",
"-",
"a",
")",
"*",
"poly",
".",
"chebyshev",
".",
"c... | Return the object representing the primitive of self over the domain. The
output starts at zero on the left-hand side of the domain. | [
"Return",
"the",
"object",
"representing",
"the",
"primitive",
"of",
"self",
"over",
"the",
"domain",
".",
"The",
"output",
"starts",
"at",
"zero",
"on",
"the",
"left",
"-",
"hand",
"side",
"of",
"the",
"domain",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L462-L471 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.differentiate | def differentiate(self, n=1):
"""
n-th derivative, default 1.
"""
ak = self.coefficients()
a_, b_ = self.domain()
for _ in range(n):
ak = self.differentiator(ak)
return self.from_coeff((2./(b_-a_))**n*ak, domain=self.domain()) | python | def differentiate(self, n=1):
"""
n-th derivative, default 1.
"""
ak = self.coefficients()
a_, b_ = self.domain()
for _ in range(n):
ak = self.differentiator(ak)
return self.from_coeff((2./(b_-a_))**n*ak, domain=self.domain()) | [
"def",
"differentiate",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"ak",
"=",
"self",
".",
"coefficients",
"(",
")",
"a_",
",",
"b_",
"=",
"self",
".",
"domain",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"n",
")",
":",
"ak",
"=",
"self",
".",... | n-th derivative, default 1. | [
"n",
"-",
"th",
"derivative",
"default",
"1",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L473-L481 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.sample_function | def sample_function(self, f, N):
"""
Sample a function on N+1 Chebyshev points.
"""
x = self.interpolation_points(N+1)
return f(x) | python | def sample_function(self, f, N):
"""
Sample a function on N+1 Chebyshev points.
"""
x = self.interpolation_points(N+1)
return f(x) | [
"def",
"sample_function",
"(",
"self",
",",
"f",
",",
"N",
")",
":",
"x",
"=",
"self",
".",
"interpolation_points",
"(",
"N",
"+",
"1",
")",
"return",
"f",
"(",
"x",
")"
] | Sample a function on N+1 Chebyshev points. | [
"Sample",
"a",
"function",
"on",
"N",
"+",
"1",
"Chebyshev",
"points",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L538-L543 | train |
CalebBell/fluids | fluids/optional/pychebfun.py | Chebfun.interpolator | def interpolator(self, x, values):
"""
Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x
"""
# hacking the barycentric interpolator by computing the weights in advance
p = Bary([0.])
N = len(values)
weights = np.... | python | def interpolator(self, x, values):
"""
Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x
"""
# hacking the barycentric interpolator by computing the weights in advance
p = Bary([0.])
N = len(values)
weights = np.... | [
"def",
"interpolator",
"(",
"self",
",",
"x",
",",
"values",
")",
":",
"p",
"=",
"Bary",
"(",
"[",
"0.",
"]",
")",
"N",
"=",
"len",
"(",
"values",
")",
"weights",
"=",
"np",
".",
"ones",
"(",
"N",
")",
"weights",
"[",
"0",
"]",
"=",
".5",
"... | Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x | [
"Returns",
"a",
"polynomial",
"with",
"vector",
"coefficients",
"which",
"interpolates",
"the",
"values",
"at",
"the",
"Chebyshev",
"points",
"x"
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L582-L596 | train |
CalebBell/fluids | fluids/drag.py | drag_sphere | def drag_sphere(Re, Method=None, AvailableMethods=False):
r'''This function handles calculation of drag coefficient on spheres.
Twenty methods are available, all requiring only the Reynolds number of the
sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will
be automatically selected... | python | def drag_sphere(Re, Method=None, AvailableMethods=False):
r'''This function handles calculation of drag coefficient on spheres.
Twenty methods are available, all requiring only the Reynolds number of the
sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will
be automatically selected... | [
"def",
"drag_sphere",
"(",
"Re",
",",
"Method",
"=",
"None",
",",
"AvailableMethods",
"=",
"False",
")",
":",
"r",
"def",
"list_methods",
"(",
")",
":",
"methods",
"=",
"[",
"]",
"for",
"key",
",",
"(",
"func",
",",
"Re_min",
",",
"Re_max",
")",
"i... | r'''This function handles calculation of drag coefficient on spheres.
Twenty methods are available, all requiring only the Reynolds number of the
sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will
be automatically selected if none is specified. The full list of correlations
valid... | [
"r",
"This",
"function",
"handles",
"calculation",
"of",
"drag",
"coefficient",
"on",
"spheres",
".",
"Twenty",
"methods",
"are",
"available",
"all",
"requiring",
"only",
"the",
"Reynolds",
"number",
"of",
"the",
"sphere",
".",
"Most",
"methods",
"are",
"valid... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1028-L1101 | train |
CalebBell/fluids | fluids/drag.py | v_terminal | def v_terminal(D, rhop, rho, mu, Method=None):
r'''Calculates terminal velocity of a falling sphere using any drag
coefficient method supported by `drag_sphere`. The laminar solution for
Re < 0.01 is first tried; if the resulting terminal velocity does not
put it in the laminar regime, a numerical solut... | python | def v_terminal(D, rhop, rho, mu, Method=None):
r'''Calculates terminal velocity of a falling sphere using any drag
coefficient method supported by `drag_sphere`. The laminar solution for
Re < 0.01 is first tried; if the resulting terminal velocity does not
put it in the laminar regime, a numerical solut... | [
"def",
"v_terminal",
"(",
"D",
",",
"rhop",
",",
"rho",
",",
"mu",
",",
"Method",
"=",
"None",
")",
":",
"r",
"v_lam",
"=",
"g",
"*",
"D",
"*",
"D",
"*",
"(",
"rhop",
"-",
"rho",
")",
"/",
"(",
"18",
"*",
"mu",
")",
"Re_lam",
"=",
"Reynolds... | r'''Calculates terminal velocity of a falling sphere using any drag
coefficient method supported by `drag_sphere`. The laminar solution for
Re < 0.01 is first tried; if the resulting terminal velocity does not
put it in the laminar regime, a numerical solution is used.
.. math::
v_t = \sqrt{\fr... | [
"r",
"Calculates",
"terminal",
"velocity",
"of",
"a",
"falling",
"sphere",
"using",
"any",
"drag",
"coefficient",
"method",
"supported",
"by",
"drag_sphere",
".",
"The",
"laminar",
"solution",
"for",
"Re",
"<",
"0",
".",
"01",
"is",
"first",
"tried",
";",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1104-L1185 | train |
CalebBell/fluids | fluids/drag.py | integrate_drag_sphere | def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None,
distance=False):
r'''Integrates the velocity and distance traveled by a particle moving
at a speed which will converge to its terminal velocity.
Performs an integration of the following expression for acceleration:
... | python | def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None,
distance=False):
r'''Integrates the velocity and distance traveled by a particle moving
at a speed which will converge to its terminal velocity.
Performs an integration of the following expression for acceleration:
... | [
"def",
"integrate_drag_sphere",
"(",
"D",
",",
"rhop",
",",
"rho",
",",
"mu",
",",
"t",
",",
"V",
"=",
"0",
",",
"Method",
"=",
"None",
",",
"distance",
"=",
"False",
")",
":",
"r",
"laminar_initial",
"=",
"Reynolds",
"(",
"V",
"=",
"V",
",",
"rh... | r'''Integrates the velocity and distance traveled by a particle moving
at a speed which will converge to its terminal velocity.
Performs an integration of the following expression for acceleration:
.. math::
a = \frac{g(\rho_p-\rho_f)}{\rho_p} - \frac{3C_D \rho_f u^2}{4D \rho_p}
Parameters
... | [
"r",
"Integrates",
"the",
"velocity",
"and",
"distance",
"traveled",
"by",
"a",
"particle",
"moving",
"at",
"a",
"speed",
"which",
"will",
"converge",
"to",
"its",
"terminal",
"velocity",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1260-L1414 | train |
CalebBell/fluids | fluids/fittings.py | bend_rounded_Ito | def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None,
roughness=0.0):
'''Ito method as shown in Blevins. Curved friction factor as given in
Blevins, with minor tweaks to be more accurate to the original methods.
'''
if not rc:
if bend_diameters is None:
... | python | def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None,
roughness=0.0):
'''Ito method as shown in Blevins. Curved friction factor as given in
Blevins, with minor tweaks to be more accurate to the original methods.
'''
if not rc:
if bend_diameters is None:
... | [
"def",
"bend_rounded_Ito",
"(",
"Di",
",",
"angle",
",",
"Re",
",",
"rc",
"=",
"None",
",",
"bend_diameters",
"=",
"None",
",",
"roughness",
"=",
"0.0",
")",
":",
"if",
"not",
"rc",
":",
"if",
"bend_diameters",
"is",
"None",
":",
"bend_diameters",
"=",... | Ito method as shown in Blevins. Curved friction factor as given in
Blevins, with minor tweaks to be more accurate to the original methods. | [
"Ito",
"method",
"as",
"shown",
"in",
"Blevins",
".",
"Curved",
"friction",
"factor",
"as",
"given",
"in",
"Blevins",
"with",
"minor",
"tweaks",
"to",
"be",
"more",
"accurate",
"to",
"the",
"original",
"methods",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/fittings.py#L1193-L1224 | train |
CalebBell/fluids | fluids/design_climate.py | geopy_geolocator | def geopy_geolocator():
'''Lazy loader for geocoder from geopy. This currently loads the
`Nominatim` geocode and returns an instance of it, taking ~2 us.
'''
global geolocator
if geolocator is None:
try:
from geopy.geocoders import Nominatim
except ImportError:
... | python | def geopy_geolocator():
'''Lazy loader for geocoder from geopy. This currently loads the
`Nominatim` geocode and returns an instance of it, taking ~2 us.
'''
global geolocator
if geolocator is None:
try:
from geopy.geocoders import Nominatim
except ImportError:
... | [
"def",
"geopy_geolocator",
"(",
")",
":",
"global",
"geolocator",
"if",
"geolocator",
"is",
"None",
":",
"try",
":",
"from",
"geopy",
".",
"geocoders",
"import",
"Nominatim",
"except",
"ImportError",
":",
"return",
"None",
"geolocator",
"=",
"Nominatim",
"(",
... | Lazy loader for geocoder from geopy. This currently loads the
`Nominatim` geocode and returns an instance of it, taking ~2 us. | [
"Lazy",
"loader",
"for",
"geocoder",
"from",
"geopy",
".",
"This",
"currently",
"loads",
"the",
"Nominatim",
"geocode",
"and",
"returns",
"an",
"instance",
"of",
"it",
"taking",
"~2",
"us",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L86-L98 | train |
CalebBell/fluids | fluids/design_climate.py | heating_degree_days | def heating_degree_days(T, T_base=F2K(65), truncate=True):
r'''Calculates the heating degree days for a period of time.
.. math::
\text{heating degree days} = max(T - T_{base}, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is us... | python | def heating_degree_days(T, T_base=F2K(65), truncate=True):
r'''Calculates the heating degree days for a period of time.
.. math::
\text{heating degree days} = max(T - T_{base}, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is us... | [
"def",
"heating_degree_days",
"(",
"T",
",",
"T_base",
"=",
"F2K",
"(",
"65",
")",
",",
"truncate",
"=",
"True",
")",
":",
"r",
"dd",
"=",
"T",
"-",
"T_base",
"if",
"truncate",
"and",
"dd",
"<",
"0.0",
":",
"dd",
"=",
"0.0",
"return",
"dd"
] | r'''Calculates the heating degree days for a period of time.
.. math::
\text{heating degree days} = max(T - T_{base}, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is used,
other times the average of the lowest and highest t... | [
"r",
"Calculates",
"the",
"heating",
"degree",
"days",
"for",
"a",
"period",
"of",
"time",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L193-L246 | train |
CalebBell/fluids | fluids/design_climate.py | cooling_degree_days | def cooling_degree_days(T, T_base=283.15, truncate=True):
r'''Calculates the cooling degree days for a period of time.
.. math::
\text{cooling degree days} = max(T_{base} - T, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is use... | python | def cooling_degree_days(T, T_base=283.15, truncate=True):
r'''Calculates the cooling degree days for a period of time.
.. math::
\text{cooling degree days} = max(T_{base} - T, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is use... | [
"def",
"cooling_degree_days",
"(",
"T",
",",
"T_base",
"=",
"283.15",
",",
"truncate",
"=",
"True",
")",
":",
"r",
"dd",
"=",
"T_base",
"-",
"T",
"if",
"truncate",
"and",
"dd",
"<",
"0.0",
":",
"dd",
"=",
"0.0",
"return",
"dd"
] | r'''Calculates the cooling degree days for a period of time.
.. math::
\text{cooling degree days} = max(T_{base} - T, 0)
Parameters
----------
T : float
Measured temperature; sometimes an average over a length of time is used,
other times the average of the lowest and highest t... | [
"r",
"Calculates",
"the",
"cooling",
"degree",
"days",
"for",
"a",
"period",
"of",
"time",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L249-L300 | train |
CalebBell/fluids | fluids/design_climate.py | get_station_year_text | def get_station_year_text(WMO, WBAN, year):
'''Basic method to download data from the GSOD database, given a
station identifier and year.
Parameters
----------
WMO : int or None
World Meteorological Organization (WMO) identifiers, [-]
WBAN : int or None
Weather Bureau Army Na... | python | def get_station_year_text(WMO, WBAN, year):
'''Basic method to download data from the GSOD database, given a
station identifier and year.
Parameters
----------
WMO : int or None
World Meteorological Organization (WMO) identifiers, [-]
WBAN : int or None
Weather Bureau Army Na... | [
"def",
"get_station_year_text",
"(",
"WMO",
",",
"WBAN",
",",
"year",
")",
":",
"if",
"WMO",
"is",
"None",
":",
"WMO",
"=",
"999999",
"if",
"WBAN",
"is",
"None",
":",
"WBAN",
"=",
"99999",
"station",
"=",
"str",
"(",
"int",
"(",
"WMO",
")",
")",
... | Basic method to download data from the GSOD database, given a
station identifier and year.
Parameters
----------
WMO : int or None
World Meteorological Organization (WMO) identifiers, [-]
WBAN : int or None
Weather Bureau Army Navy (WBAN) weather station identifier, [-]
year ... | [
"Basic",
"method",
"to",
"download",
"data",
"from",
"the",
"GSOD",
"database",
"given",
"a",
"station",
"identifier",
"and",
"year",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L699-L760 | train |
CalebBell/fluids | fluids/packed_tower.py | _Stichlmair_flood_f | def _Stichlmair_flood_f(inputs, Vl, rhog, rhol, mug, voidage, specific_area,
C1, C2, C3, H):
'''Internal function which calculates the errors of the two Stichlmair
objective functions, and their jacobian.
'''
Vg, dP_irr = float(inputs[0]), float(inputs[1])
dp = 6.0*(1.0 - voi... | python | def _Stichlmair_flood_f(inputs, Vl, rhog, rhol, mug, voidage, specific_area,
C1, C2, C3, H):
'''Internal function which calculates the errors of the two Stichlmair
objective functions, and their jacobian.
'''
Vg, dP_irr = float(inputs[0]), float(inputs[1])
dp = 6.0*(1.0 - voi... | [
"def",
"_Stichlmair_flood_f",
"(",
"inputs",
",",
"Vl",
",",
"rhog",
",",
"rhol",
",",
"mug",
",",
"voidage",
",",
"specific_area",
",",
"C1",
",",
"C2",
",",
"C3",
",",
"H",
")",
":",
"Vg",
",",
"dP_irr",
"=",
"float",
"(",
"inputs",
"[",
"0",
"... | Internal function which calculates the errors of the two Stichlmair
objective functions, and their jacobian. | [
"Internal",
"function",
"which",
"calculates",
"the",
"errors",
"of",
"the",
"two",
"Stichlmair",
"objective",
"functions",
"and",
"their",
"jacobian",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_tower.py#L568-L586 | train |
CalebBell/fluids | fluids/packed_tower.py | Robbins | def Robbins(L, G, rhol, rhog, mul, H=1.0, Fpd=24.0):
r'''Calculates pressure drop across a packed column, using the Robbins
equation.
Pressure drop is given by:
.. math::
\Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4
.. math::
G_f=G[0.075/\rho_g]^{0.... | python | def Robbins(L, G, rhol, rhog, mul, H=1.0, Fpd=24.0):
r'''Calculates pressure drop across a packed column, using the Robbins
equation.
Pressure drop is given by:
.. math::
\Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4
.. math::
G_f=G[0.075/\rho_g]^{0.... | [
"def",
"Robbins",
"(",
"L",
",",
"G",
",",
"rhol",
",",
"rhog",
",",
"mul",
",",
"H",
"=",
"1.0",
",",
"Fpd",
"=",
"24.0",
")",
":",
"r",
"L",
"=",
"L",
"*",
"737.33812",
"G",
"=",
"G",
"*",
"737.33812",
"rhol",
"=",
"rhol",
"*",
"0.062427961... | r'''Calculates pressure drop across a packed column, using the Robbins
equation.
Pressure drop is given by:
.. math::
\Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4
.. math::
G_f=G[0.075/\rho_g]^{0.5}[F_{pd}/20]^{0.5}=986F_s[F_{pd}/20]^{0.5}
.. math:... | [
"r",
"Calculates",
"pressure",
"drop",
"across",
"a",
"packed",
"column",
"using",
"the",
"Robbins",
"equation",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_tower.py#L741-L812 | train |
CalebBell/fluids | fluids/packed_bed.py | dP_packed_bed | def dP_packed_bed(dp, voidage, vs, rho, mu, L=1, Dt=None, sphericity=None,
Method=None, AvailableMethods=False):
r'''This function handles choosing which pressure drop in a packed bed
correlation is used. Automatically select which correlation
to use if none is provided. Returns None if in... | python | def dP_packed_bed(dp, voidage, vs, rho, mu, L=1, Dt=None, sphericity=None,
Method=None, AvailableMethods=False):
r'''This function handles choosing which pressure drop in a packed bed
correlation is used. Automatically select which correlation
to use if none is provided. Returns None if in... | [
"def",
"dP_packed_bed",
"(",
"dp",
",",
"voidage",
",",
"vs",
",",
"rho",
",",
"mu",
",",
"L",
"=",
"1",
",",
"Dt",
"=",
"None",
",",
"sphericity",
"=",
"None",
",",
"Method",
"=",
"None",
",",
"AvailableMethods",
"=",
"False",
")",
":",
"r",
"de... | r'''This function handles choosing which pressure drop in a packed bed
correlation is used. Automatically select which correlation
to use if none is provided. Returns None if insufficient information is
provided.
Preferred correlations are 'Erdim, Akgiray & Demir' when tube
diameter is not provided... | [
"r",
"This",
"function",
"handles",
"choosing",
"which",
"pressure",
"drop",
"in",
"a",
"packed",
"bed",
"correlation",
"is",
"used",
".",
"Automatically",
"select",
"which",
"correlation",
"to",
"use",
"if",
"none",
"is",
"provided",
".",
"Returns",
"None",
... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_bed.py#L994-L1079 | train |
CalebBell/fluids | fluids/two_phase.py | Friedel | def Friedel(m, x, rhol, rhog, mul, mug, sigma, D, roughness=0, L=1):
r'''Calculates two-phase pressure drop with the Friedel correlation.
.. math::
\Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2
.. math::
\phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}}
.. math::
H = \... | python | def Friedel(m, x, rhol, rhog, mul, mug, sigma, D, roughness=0, L=1):
r'''Calculates two-phase pressure drop with the Friedel correlation.
.. math::
\Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2
.. math::
\phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}}
.. math::
H = \... | [
"def",
"Friedel",
"(",
"m",
",",
"x",
",",
"rhol",
",",
"rhog",
",",
"mul",
",",
"mug",
",",
"sigma",
",",
"D",
",",
"roughness",
"=",
"0",
",",
"L",
"=",
"1",
")",
":",
"r",
"v_lo",
"=",
"m",
"/",
"rhol",
"/",
"(",
"pi",
"/",
"4",
"*",
... | r'''Calculates two-phase pressure drop with the Friedel correlation.
.. math::
\Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2
.. math::
\phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}}
.. math::
H = \left(\frac{\rho_l}{\rho_g}\right)^{0.91}\left(\frac{\mu_g}{\mu_l}
... | [
"r",
"Calculates",
"two",
"-",
"phase",
"pressure",
"drop",
"with",
"the",
"Friedel",
"correlation",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/two_phase.py#L204-L324 | train |
CalebBell/fluids | fluids/atmosphere.py | airmass | def airmass(func, angle, H_max=86400.0, R_planet=6.371229E6, RI=1.000276):
r'''Calculates mass of air per square meter in the atmosphere using a
provided atmospheric model. The lowest air mass is calculated straight up;
as the angle is lowered to nearer and nearer the horizon, the air mass
increases, a... | python | def airmass(func, angle, H_max=86400.0, R_planet=6.371229E6, RI=1.000276):
r'''Calculates mass of air per square meter in the atmosphere using a
provided atmospheric model. The lowest air mass is calculated straight up;
as the angle is lowered to nearer and nearer the horizon, the air mass
increases, a... | [
"def",
"airmass",
"(",
"func",
",",
"angle",
",",
"H_max",
"=",
"86400.0",
",",
"R_planet",
"=",
"6.371229E6",
",",
"RI",
"=",
"1.000276",
")",
":",
"r",
"delta0",
"=",
"RI",
"-",
"1.0",
"rho0",
"=",
"func",
"(",
"0.0",
")",
"angle_term",
"=",
"cos... | r'''Calculates mass of air per square meter in the atmosphere using a
provided atmospheric model. The lowest air mass is calculated straight up;
as the angle is lowered to nearer and nearer the horizon, the air mass
increases, and can approach 40x or more the minimum airmass.
.. math::
m(\gamm... | [
"r",
"Calculates",
"mass",
"of",
"air",
"per",
"square",
"meter",
"in",
"the",
"atmosphere",
"using",
"a",
"provided",
"atmospheric",
"model",
".",
"The",
"lowest",
"air",
"mass",
"is",
"calculated",
"straight",
"up",
";",
"as",
"the",
"angle",
"is",
"lowe... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/atmosphere.py#L689-L750 | train |
CalebBell/fluids | fluids/atmosphere.py | ATMOSPHERE_1976._get_ind_from_H | def _get_ind_from_H(H):
r'''Method defined in the US Standard Atmosphere 1976 for determining
the index of the layer a specified elevation is above. Levels are
0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively.
'''
if H <= 0:
return 0
for ind, ... | python | def _get_ind_from_H(H):
r'''Method defined in the US Standard Atmosphere 1976 for determining
the index of the layer a specified elevation is above. Levels are
0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively.
'''
if H <= 0:
return 0
for ind, ... | [
"def",
"_get_ind_from_H",
"(",
"H",
")",
":",
"r",
"if",
"H",
"<=",
"0",
":",
"return",
"0",
"for",
"ind",
",",
"Hi",
"in",
"enumerate",
"(",
"H_std",
")",
":",
"if",
"Hi",
">=",
"H",
":",
"return",
"ind",
"-",
"1",
"return",
"7"
] | r'''Method defined in the US Standard Atmosphere 1976 for determining
the index of the layer a specified elevation is above. Levels are
0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively. | [
"r",
"Method",
"defined",
"in",
"the",
"US",
"Standard",
"Atmosphere",
"1976",
"for",
"determining",
"the",
"index",
"of",
"the",
"layer",
"a",
"specified",
"elevation",
"is",
"above",
".",
"Levels",
"are",
"0",
"11E3",
"20E3",
"32E3",
"47E3",
"51E3",
"71E... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/atmosphere.py#L154-L164 | train |
CalebBell/fluids | fluids/piping.py | gauge_from_t | def gauge_from_t(t, SI=True, schedule='BWG'):
r'''Looks up the gauge of a given wire thickness of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
t : float
Thickness, [m]
SI : bool, optional
If False, requires that the thickness is give... | python | def gauge_from_t(t, SI=True, schedule='BWG'):
r'''Looks up the gauge of a given wire thickness of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
t : float
Thickness, [m]
SI : bool, optional
If False, requires that the thickness is give... | [
"def",
"gauge_from_t",
"(",
"t",
",",
"SI",
"=",
"True",
",",
"schedule",
"=",
"'BWG'",
")",
":",
"r",
"tol",
"=",
"0.1",
"if",
"SI",
":",
"t_inch",
"=",
"round",
"(",
"t",
"/",
"inch",
",",
"9",
")",
"else",
":",
"t_inch",
"=",
"t",
"try",
"... | r'''Looks up the gauge of a given wire thickness of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
t : float
Thickness, [m]
SI : bool, optional
If False, requires that the thickness is given in inches not meters
schedule : str
... | [
"r",
"Looks",
"up",
"the",
"gauge",
"of",
"a",
"given",
"wire",
"thickness",
"of",
"given",
"schedule",
".",
"Values",
"are",
"all",
"non",
"-",
"linear",
"and",
"tabulated",
"internally",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/piping.py#L349-L434 | train |
CalebBell/fluids | fluids/piping.py | t_from_gauge | def t_from_gauge(gauge, SI=True, schedule='BWG'):
r'''Looks up the thickness of a given wire gauge of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
gauge : float-like
Wire Gauge, []
SI : bool, optional
If False, will return a thicknes... | python | def t_from_gauge(gauge, SI=True, schedule='BWG'):
r'''Looks up the thickness of a given wire gauge of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
gauge : float-like
Wire Gauge, []
SI : bool, optional
If False, will return a thicknes... | [
"def",
"t_from_gauge",
"(",
"gauge",
",",
"SI",
"=",
"True",
",",
"schedule",
"=",
"'BWG'",
")",
":",
"r",
"try",
":",
"sch_integers",
",",
"sch_inch",
",",
"sch_SI",
",",
"decreasing",
"=",
"wire_schedules",
"[",
"schedule",
"]",
"except",
":",
"raise",... | r'''Looks up the thickness of a given wire gauge of given schedule.
Values are all non-linear, and tabulated internally.
Parameters
----------
gauge : float-like
Wire Gauge, []
SI : bool, optional
If False, will return a thickness in inches not meters
schedule : str
Gaug... | [
"r",
"Looks",
"up",
"the",
"thickness",
"of",
"a",
"given",
"wire",
"gauge",
"of",
"given",
"schedule",
".",
"Values",
"are",
"all",
"non",
"-",
"linear",
"and",
"tabulated",
"internally",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/piping.py#L437-L493 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_F2 | def API520_F2(k, P1, P2):
r'''Calculates coefficient F2 for subcritical flow for use in API 520
subcritical flow relief valve sizing.
.. math::
F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k}
\left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]}
.. math::
r = \frac{P_2}{P_1}
Par... | python | def API520_F2(k, P1, P2):
r'''Calculates coefficient F2 for subcritical flow for use in API 520
subcritical flow relief valve sizing.
.. math::
F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k}
\left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]}
.. math::
r = \frac{P_2}{P_1}
Par... | [
"def",
"API520_F2",
"(",
"k",
",",
"P1",
",",
"P2",
")",
":",
"r",
"r",
"=",
"P2",
"/",
"P1",
"return",
"(",
"k",
"/",
"(",
"k",
"-",
"1",
")",
"*",
"r",
"**",
"(",
"2.",
"/",
"k",
")",
"*",
"(",
"(",
"1",
"-",
"r",
"**",
"(",
"(",
... | r'''Calculates coefficient F2 for subcritical flow for use in API 520
subcritical flow relief valve sizing.
.. math::
F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k}
\left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]}
.. math::
r = \frac{P_2}{P_1}
Parameters
----------
k :... | [
"r",
"Calculates",
"coefficient",
"F2",
"for",
"subcritical",
"flow",
"for",
"use",
"in",
"API",
"520",
"subcritical",
"flow",
"relief",
"valve",
"sizing",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L130-L173 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_SH | def API520_SH(T1, P1):
r'''Calculates correction due to steam superheat for steam flow for use in
API 520 relief valve sizing. 2D interpolation among a table with 28
pressures and 10 temperatures is performed.
Parameters
----------
T1 : float
Temperature of the fluid entering the valve... | python | def API520_SH(T1, P1):
r'''Calculates correction due to steam superheat for steam flow for use in
API 520 relief valve sizing. 2D interpolation among a table with 28
pressures and 10 temperatures is performed.
Parameters
----------
T1 : float
Temperature of the fluid entering the valve... | [
"def",
"API520_SH",
"(",
"T1",
",",
"P1",
")",
":",
"r",
"if",
"P1",
">",
"20780325.0",
":",
"raise",
"Exception",
"(",
"'For P above 20679 kPag, use the critical flow model'",
")",
"if",
"T1",
">",
"922.15",
":",
"raise",
"Exception",
"(",
"'Superheat cannot be... | r'''Calculates correction due to steam superheat for steam flow for use in
API 520 relief valve sizing. 2D interpolation among a table with 28
pressures and 10 temperatures is performed.
Parameters
----------
T1 : float
Temperature of the fluid entering the valve [K]
P1 : float
... | [
"r",
"Calculates",
"correction",
"due",
"to",
"steam",
"superheat",
"for",
"steam",
"flow",
"for",
"use",
"in",
"API",
"520",
"relief",
"valve",
"sizing",
".",
"2D",
"interpolation",
"among",
"a",
"table",
"with",
"28",
"pressures",
"and",
"10",
"temperature... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L319-L361 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_W | def API520_W(Pset, Pback):
r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in liquid service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolation among a table ... | python | def API520_W(Pset, Pback):
r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in liquid service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolation among a table ... | [
"def",
"API520_W",
"(",
"Pset",
",",
"Pback",
")",
":",
"r",
"gauge_backpressure",
"=",
"(",
"Pback",
"-",
"atm",
")",
"/",
"(",
"Pset",
"-",
"atm",
")",
"*",
"100.0",
"if",
"gauge_backpressure",
"<",
"15.0",
":",
"return",
"1.0",
"return",
"interp",
... | r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in liquid service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolation among a table with
53 backpressures is pe... | [
"r",
"Calculates",
"capacity",
"correction",
"due",
"to",
"backpressure",
"on",
"balanced",
"spring",
"-",
"loaded",
"PRVs",
"in",
"liquid",
"service",
".",
"For",
"pilot",
"operated",
"valves",
"this",
"is",
"always",
"1",
".",
"Applicable",
"up",
"to",
"50... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L383-L421 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_B | def API520_B(Pset, Pback, overpressure=0.1):
r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in vapor service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolati... | python | def API520_B(Pset, Pback, overpressure=0.1):
r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in vapor service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolati... | [
"def",
"API520_B",
"(",
"Pset",
",",
"Pback",
",",
"overpressure",
"=",
"0.1",
")",
":",
"r",
"gauge_backpressure",
"=",
"(",
"Pback",
"-",
"atm",
")",
"/",
"(",
"Pset",
"-",
"atm",
")",
"*",
"100",
"if",
"overpressure",
"not",
"in",
"[",
"0.1",
",... | r'''Calculates capacity correction due to backpressure on balanced
spring-loaded PRVs in vapor service. For pilot operated valves,
this is always 1. Applicable up to 50% of the percent gauge backpressure,
For use in API 520 relief valve sizing. 1D interpolation among a table with
53 backpressures is per... | [
"r",
"Calculates",
"capacity",
"correction",
"due",
"to",
"backpressure",
"on",
"balanced",
"spring",
"-",
"loaded",
"PRVs",
"in",
"vapor",
"service",
".",
"For",
"pilot",
"operated",
"valves",
"this",
"is",
"always",
"1",
".",
"Applicable",
"up",
"to",
"50%... | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L452-L504 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_A_g | def API520_A_g(m, T, Z, MW, k, P1, P2=101325, Kd=0.975, Kb=1, Kc=1):
r'''Calculates required relief valve area for an API 520 valve passing
a gas or a vapor, at either critical or sub-critical flow.
For critical flow:
.. math::
A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}}
For sub-critic... | python | def API520_A_g(m, T, Z, MW, k, P1, P2=101325, Kd=0.975, Kb=1, Kc=1):
r'''Calculates required relief valve area for an API 520 valve passing
a gas or a vapor, at either critical or sub-critical flow.
For critical flow:
.. math::
A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}}
For sub-critic... | [
"def",
"API520_A_g",
"(",
"m",
",",
"T",
",",
"Z",
",",
"MW",
",",
"k",
",",
"P1",
",",
"P2",
"=",
"101325",
",",
"Kd",
"=",
"0.975",
",",
"Kb",
"=",
"1",
",",
"Kc",
"=",
"1",
")",
":",
"r",
"P1",
",",
"P2",
"=",
"P1",
"/",
"1000.",
","... | r'''Calculates required relief valve area for an API 520 valve passing
a gas or a vapor, at either critical or sub-critical flow.
For critical flow:
.. math::
A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}}
For sub-critical flow:
.. math::
A = \frac{17.9m}{F_2K_dK_c}\sqrt{\frac{TZ... | [
"r",
"Calculates",
"required",
"relief",
"valve",
"area",
"for",
"an",
"API",
"520",
"valve",
"passing",
"a",
"gas",
"or",
"a",
"vapor",
"at",
"either",
"critical",
"or",
"sub",
"-",
"critical",
"flow",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L507-L582 | train |
CalebBell/fluids | fluids/safety_valve.py | API520_A_steam | def API520_A_steam(m, T, P1, Kd=0.975, Kb=1, Kc=1):
r'''Calculates required relief valve area for an API 520 valve passing
a steam, at either saturation or superheat but not partially condensed.
.. math::
A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}}
Parameters
----------
m : float
... | python | def API520_A_steam(m, T, P1, Kd=0.975, Kb=1, Kc=1):
r'''Calculates required relief valve area for an API 520 valve passing
a steam, at either saturation or superheat but not partially condensed.
.. math::
A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}}
Parameters
----------
m : float
... | [
"def",
"API520_A_steam",
"(",
"m",
",",
"T",
",",
"P1",
",",
"Kd",
"=",
"0.975",
",",
"Kb",
"=",
"1",
",",
"Kc",
"=",
"1",
")",
":",
"r",
"KN",
"=",
"API520_N",
"(",
"P1",
")",
"KSH",
"=",
"API520_SH",
"(",
"T",
",",
"P1",
")",
"P1",
"=",
... | r'''Calculates required relief valve area for an API 520 valve passing
a steam, at either saturation or superheat but not partially condensed.
.. math::
A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}}
Parameters
----------
m : float
Mass flow rate of steam through the valve, [kg/s]
... | [
"r",
"Calculates",
"required",
"relief",
"valve",
"area",
"for",
"an",
"API",
"520",
"valve",
"passing",
"a",
"steam",
"at",
"either",
"saturation",
"or",
"superheat",
"but",
"not",
"partially",
"condensed",
"."
] | 57f556752e039f1d3e5a822f408c184783db2828 | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L585-L639 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/context.py | pisaContext.getFile | def getFile(self, name, relative=None):
"""
Returns a file name or None
"""
if self.pathCallback is not None:
return getFile(self._getFileDeprecated(name, relative))
return getFile(name, relative or self.pathDirectory) | python | def getFile(self, name, relative=None):
"""
Returns a file name or None
"""
if self.pathCallback is not None:
return getFile(self._getFileDeprecated(name, relative))
return getFile(name, relative or self.pathDirectory) | [
"def",
"getFile",
"(",
"self",
",",
"name",
",",
"relative",
"=",
"None",
")",
":",
"if",
"self",
".",
"pathCallback",
"is",
"not",
"None",
":",
"return",
"getFile",
"(",
"self",
".",
"_getFileDeprecated",
"(",
"name",
",",
"relative",
")",
")",
"retur... | Returns a file name or None | [
"Returns",
"a",
"file",
"name",
"or",
"None"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/context.py#L812-L818 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/context.py | pisaContext.getFontName | def getFontName(self, names, default="helvetica"):
"""
Name of a font
"""
# print names, self.fontList
if type(names) is not ListType:
if type(names) not in six.string_types:
names = str(names)
names = names.strip().split(",")
for n... | python | def getFontName(self, names, default="helvetica"):
"""
Name of a font
"""
# print names, self.fontList
if type(names) is not ListType:
if type(names) not in six.string_types:
names = str(names)
names = names.strip().split(",")
for n... | [
"def",
"getFontName",
"(",
"self",
",",
"names",
",",
"default",
"=",
"\"helvetica\"",
")",
":",
"if",
"type",
"(",
"names",
")",
"is",
"not",
"ListType",
":",
"if",
"type",
"(",
"names",
")",
"not",
"in",
"six",
".",
"string_types",
":",
"names",
"=... | Name of a font | [
"Name",
"of",
"a",
"font"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/context.py#L820-L835 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/parser.py | pisaPreLoop | def pisaPreLoop(node, context, collect=False):
"""
Collect all CSS definitions
"""
data = u""
if node.nodeType == Node.TEXT_NODE and collect:
data = node.data
elif node.nodeType == Node.ELEMENT_NODE:
name = node.tagName.lower()
if name in ("style", "link"):
... | python | def pisaPreLoop(node, context, collect=False):
"""
Collect all CSS definitions
"""
data = u""
if node.nodeType == Node.TEXT_NODE and collect:
data = node.data
elif node.nodeType == Node.ELEMENT_NODE:
name = node.tagName.lower()
if name in ("style", "link"):
... | [
"def",
"pisaPreLoop",
"(",
"node",
",",
"context",
",",
"collect",
"=",
"False",
")",
":",
"data",
"=",
"u\"\"",
"if",
"node",
".",
"nodeType",
"==",
"Node",
".",
"TEXT_NODE",
"and",
"collect",
":",
"data",
"=",
"node",
".",
"data",
"elif",
"node",
"... | Collect all CSS definitions | [
"Collect",
"all",
"CSS",
"definitions"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/parser.py#L440-L476 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/parser.py | pisaParser | def pisaParser(src, context, default_css="", xhtml=False, encoding=None, xml_output=None):
"""
- Parse HTML and get miniDOM
- Extract CSS informations, add default CSS, parse CSS
- Handle the document DOM itself and build reportlab story
- Return Context object
"""
global CSSAttrCache
C... | python | def pisaParser(src, context, default_css="", xhtml=False, encoding=None, xml_output=None):
"""
- Parse HTML and get miniDOM
- Extract CSS informations, add default CSS, parse CSS
- Handle the document DOM itself and build reportlab story
- Return Context object
"""
global CSSAttrCache
C... | [
"def",
"pisaParser",
"(",
"src",
",",
"context",
",",
"default_css",
"=",
"\"\"",
",",
"xhtml",
"=",
"False",
",",
"encoding",
"=",
"None",
",",
"xml_output",
"=",
"None",
")",
":",
"global",
"CSSAttrCache",
"CSSAttrCache",
"=",
"{",
"}",
"if",
"xhtml",
... | - Parse HTML and get miniDOM
- Extract CSS informations, add default CSS, parse CSS
- Handle the document DOM itself and build reportlab story
- Return Context object | [
"-",
"Parse",
"HTML",
"and",
"get",
"miniDOM",
"-",
"Extract",
"CSS",
"informations",
"add",
"default",
"CSS",
"parse",
"CSS",
"-",
"Handle",
"the",
"document",
"DOM",
"itself",
"and",
"build",
"reportlab",
"story",
"-",
"Return",
"Context",
"object"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/parser.py#L703-L760 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Line.doLayout | def doLayout(self, width):
"""
Align words in previous line.
"""
# Calculate dimensions
self.width = width
font_sizes = [0] + [frag.get("fontSize", 0) for frag in self]
self.fontSize = max(font_sizes)
self.height = self.lineHeight = max(frag * self.LINEH... | python | def doLayout(self, width):
"""
Align words in previous line.
"""
# Calculate dimensions
self.width = width
font_sizes = [0] + [frag.get("fontSize", 0) for frag in self]
self.fontSize = max(font_sizes)
self.height = self.lineHeight = max(frag * self.LINEH... | [
"def",
"doLayout",
"(",
"self",
",",
"width",
")",
":",
"self",
".",
"width",
"=",
"width",
"font_sizes",
"=",
"[",
"0",
"]",
"+",
"[",
"frag",
".",
"get",
"(",
"\"fontSize\"",
",",
"0",
")",
"for",
"frag",
"in",
"self",
"]",
"self",
".",
"fontSi... | Align words in previous line. | [
"Align",
"words",
"in",
"previous",
"line",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L276-L293 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Text.splitIntoLines | def splitIntoLines(self, maxWidth, maxHeight, splitted=False):
"""
Split text into lines and calculate X positions. If we need more
space in height than available we return the rest of the text
"""
self.lines = []
self.height = 0
self.maxWidth = self.width = maxWi... | python | def splitIntoLines(self, maxWidth, maxHeight, splitted=False):
"""
Split text into lines and calculate X positions. If we need more
space in height than available we return the rest of the text
"""
self.lines = []
self.height = 0
self.maxWidth = self.width = maxWi... | [
"def",
"splitIntoLines",
"(",
"self",
",",
"maxWidth",
",",
"maxHeight",
",",
"splitted",
"=",
"False",
")",
":",
"self",
".",
"lines",
"=",
"[",
"]",
"self",
".",
"height",
"=",
"0",
"self",
".",
"maxWidth",
"=",
"self",
".",
"width",
"=",
"maxWidth... | Split text into lines and calculate X positions. If we need more
space in height than available we return the rest of the text | [
"Split",
"text",
"into",
"lines",
"and",
"calculate",
"X",
"positions",
".",
"If",
"we",
"need",
"more",
"space",
"in",
"height",
"than",
"available",
"we",
"return",
"the",
"rest",
"of",
"the",
"text"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L330-L415 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Text.dumpLines | def dumpLines(self):
"""
For debugging dump all line and their content
"""
for i, line in enumerate(self.lines):
logger.debug("Line %d:", i)
logger.debug(line.dumpFragments()) | python | def dumpLines(self):
"""
For debugging dump all line and their content
"""
for i, line in enumerate(self.lines):
logger.debug("Line %d:", i)
logger.debug(line.dumpFragments()) | [
"def",
"dumpLines",
"(",
"self",
")",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"self",
".",
"lines",
")",
":",
"logger",
".",
"debug",
"(",
"\"Line %d:\"",
",",
"i",
")",
"logger",
".",
"debug",
"(",
"line",
".",
"dumpFragments",
"(",
... | For debugging dump all line and their content | [
"For",
"debugging",
"dump",
"all",
"line",
"and",
"their",
"content"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L417-L423 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Paragraph.wrap | def wrap(self, availWidth, availHeight):
"""
Determine the rectangle this paragraph really needs.
"""
# memorize available space
self.avWidth = availWidth
self.avHeight = availHeight
logger.debug("*** wrap (%f, %f)", availWidth, availHeight)
if not self... | python | def wrap(self, availWidth, availHeight):
"""
Determine the rectangle this paragraph really needs.
"""
# memorize available space
self.avWidth = availWidth
self.avHeight = availHeight
logger.debug("*** wrap (%f, %f)", availWidth, availHeight)
if not self... | [
"def",
"wrap",
"(",
"self",
",",
"availWidth",
",",
"availHeight",
")",
":",
"self",
".",
"avWidth",
"=",
"availWidth",
"self",
".",
"avHeight",
"=",
"availHeight",
"logger",
".",
"debug",
"(",
"\"*** wrap (%f, %f)\"",
",",
"availWidth",
",",
"availHeight",
... | Determine the rectangle this paragraph really needs. | [
"Determine",
"the",
"rectangle",
"this",
"paragraph",
"really",
"needs",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L458-L481 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Paragraph.split | def split(self, availWidth, availHeight):
"""
Split ourselves in two paragraphs.
"""
logger.debug("*** split (%f, %f)", availWidth, availHeight)
splitted = []
if self.splitIndex:
text1 = self.text[:self.splitIndex]
text2 = self.text[self.splitInd... | python | def split(self, availWidth, availHeight):
"""
Split ourselves in two paragraphs.
"""
logger.debug("*** split (%f, %f)", availWidth, availHeight)
splitted = []
if self.splitIndex:
text1 = self.text[:self.splitIndex]
text2 = self.text[self.splitInd... | [
"def",
"split",
"(",
"self",
",",
"availWidth",
",",
"availHeight",
")",
":",
"logger",
".",
"debug",
"(",
"\"*** split (%f, %f)\"",
",",
"availWidth",
",",
"availHeight",
")",
"splitted",
"=",
"[",
"]",
"if",
"self",
".",
"splitIndex",
":",
"text1",
"=",
... | Split ourselves in two paragraphs. | [
"Split",
"ourselves",
"in",
"two",
"paragraphs",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L483-L502 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/paragraph.py | Paragraph.draw | def draw(self):
"""
Render the content of the paragraph.
"""
logger.debug("*** draw")
if not self.text:
return
canvas = self.canv
style = self.style
canvas.saveState()
# Draw box arround paragraph for debugging
if self.debu... | python | def draw(self):
"""
Render the content of the paragraph.
"""
logger.debug("*** draw")
if not self.text:
return
canvas = self.canv
style = self.style
canvas.saveState()
# Draw box arround paragraph for debugging
if self.debu... | [
"def",
"draw",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"*** draw\"",
")",
"if",
"not",
"self",
".",
"text",
":",
"return",
"canvas",
"=",
"self",
".",
"canv",
"style",
"=",
"self",
".",
"style",
"canvas",
".",
"saveState",
"(",
")",
"... | Render the content of the paragraph. | [
"Render",
"the",
"content",
"of",
"the",
"paragraph",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L504-L573 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/pisa.py | showLogging | def showLogging(debug=False):
"""
Shortcut for enabling log dump
"""
try:
log_level = logging.WARN
log_format = LOG_FORMAT_DEBUG
if debug:
log_level = logging.DEBUG
logging.basicConfig(
level=log_level,
format=log_format)
except:
... | python | def showLogging(debug=False):
"""
Shortcut for enabling log dump
"""
try:
log_level = logging.WARN
log_format = LOG_FORMAT_DEBUG
if debug:
log_level = logging.DEBUG
logging.basicConfig(
level=log_level,
format=log_format)
except:
... | [
"def",
"showLogging",
"(",
"debug",
"=",
"False",
")",
":",
"try",
":",
"log_level",
"=",
"logging",
".",
"WARN",
"log_format",
"=",
"LOG_FORMAT_DEBUG",
"if",
"debug",
":",
"log_level",
"=",
"logging",
".",
"DEBUG",
"logging",
".",
"basicConfig",
"(",
"lev... | Shortcut for enabling log dump | [
"Shortcut",
"for",
"enabling",
"log",
"dump"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/pisa.py#L420-L434 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser.parseFile | def parseFile(self, srcFile, closeFile=False):
"""Parses CSS file-like objects using the current cssBuilder.
Use for external stylesheets."""
try:
result = self.parse(srcFile.read())
finally:
if closeFile:
srcFile.close()
return result | python | def parseFile(self, srcFile, closeFile=False):
"""Parses CSS file-like objects using the current cssBuilder.
Use for external stylesheets."""
try:
result = self.parse(srcFile.read())
finally:
if closeFile:
srcFile.close()
return result | [
"def",
"parseFile",
"(",
"self",
",",
"srcFile",
",",
"closeFile",
"=",
"False",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"parse",
"(",
"srcFile",
".",
"read",
"(",
")",
")",
"finally",
":",
"if",
"closeFile",
":",
"srcFile",
".",
"close",
... | Parses CSS file-like objects using the current cssBuilder.
Use for external stylesheets. | [
"Parses",
"CSS",
"file",
"-",
"like",
"objects",
"using",
"the",
"current",
"cssBuilder",
".",
"Use",
"for",
"external",
"stylesheets",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L427-L436 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser.parse | def parse(self, src):
"""Parses CSS string source using the current cssBuilder.
Use for embedded stylesheets."""
self.cssBuilder.beginStylesheet()
try:
# XXX Some simple preprocessing
src = cssSpecial.cleanupCSS(src)
try:
src, styles... | python | def parse(self, src):
"""Parses CSS string source using the current cssBuilder.
Use for embedded stylesheets."""
self.cssBuilder.beginStylesheet()
try:
# XXX Some simple preprocessing
src = cssSpecial.cleanupCSS(src)
try:
src, styles... | [
"def",
"parse",
"(",
"self",
",",
"src",
")",
":",
"self",
".",
"cssBuilder",
".",
"beginStylesheet",
"(",
")",
"try",
":",
"src",
"=",
"cssSpecial",
".",
"cleanupCSS",
"(",
"src",
")",
"try",
":",
"src",
",",
"stylesheet",
"=",
"self",
".",
"_parseS... | Parses CSS string source using the current cssBuilder.
Use for embedded stylesheets. | [
"Parses",
"CSS",
"string",
"source",
"using",
"the",
"current",
"cssBuilder",
".",
"Use",
"for",
"embedded",
"stylesheets",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L439-L456 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser.parseInline | def parseInline(self, src):
"""Parses CSS inline source string using the current cssBuilder.
Use to parse a tag's 'sytle'-like attribute."""
self.cssBuilder.beginInline()
try:
try:
src, properties = self._parseDeclarationGroup(src.strip(), braces=False)
... | python | def parseInline(self, src):
"""Parses CSS inline source string using the current cssBuilder.
Use to parse a tag's 'sytle'-like attribute."""
self.cssBuilder.beginInline()
try:
try:
src, properties = self._parseDeclarationGroup(src.strip(), braces=False)
... | [
"def",
"parseInline",
"(",
"self",
",",
"src",
")",
":",
"self",
".",
"cssBuilder",
".",
"beginInline",
"(",
")",
"try",
":",
"try",
":",
"src",
",",
"properties",
"=",
"self",
".",
"_parseDeclarationGroup",
"(",
"src",
".",
"strip",
"(",
")",
",",
"... | Parses CSS inline source string using the current cssBuilder.
Use to parse a tag's 'sytle'-like attribute. | [
"Parses",
"CSS",
"inline",
"source",
"string",
"using",
"the",
"current",
"cssBuilder",
".",
"Use",
"to",
"parse",
"a",
"tag",
"s",
"sytle",
"-",
"like",
"attribute",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L459-L474 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser.parseAttributes | def parseAttributes(self, attributes=None, **kwAttributes):
"""Parses CSS attribute source strings, and return as an inline stylesheet.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseSingleAttr
"""
attributes = attributes if attributes is not None e... | python | def parseAttributes(self, attributes=None, **kwAttributes):
"""Parses CSS attribute source strings, and return as an inline stylesheet.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseSingleAttr
"""
attributes = attributes if attributes is not None e... | [
"def",
"parseAttributes",
"(",
"self",
",",
"attributes",
"=",
"None",
",",
"**",
"kwAttributes",
")",
":",
"attributes",
"=",
"attributes",
"if",
"attributes",
"is",
"not",
"None",
"else",
"{",
"}",
"if",
"attributes",
":",
"kwAttributes",
".",
"update",
... | Parses CSS attribute source strings, and return as an inline stylesheet.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseSingleAttr | [
"Parses",
"CSS",
"attribute",
"source",
"strings",
"and",
"return",
"as",
"an",
"inline",
"stylesheet",
".",
"Use",
"to",
"parse",
"a",
"tag",
"s",
"highly",
"CSS",
"-",
"based",
"attributes",
"like",
"font",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L476-L501 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser.parseSingleAttr | def parseSingleAttr(self, attrValue):
"""Parse a single CSS attribute source string, and returns the built CSS expression.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseAttributes
"""
results = self.parseAttributes(temp=attrValue)
if 'temp... | python | def parseSingleAttr(self, attrValue):
"""Parse a single CSS attribute source string, and returns the built CSS expression.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseAttributes
"""
results = self.parseAttributes(temp=attrValue)
if 'temp... | [
"def",
"parseSingleAttr",
"(",
"self",
",",
"attrValue",
")",
":",
"results",
"=",
"self",
".",
"parseAttributes",
"(",
"temp",
"=",
"attrValue",
")",
"if",
"'temp'",
"in",
"results",
"[",
"1",
"]",
":",
"return",
"results",
"[",
"1",
"]",
"[",
"'temp'... | Parse a single CSS attribute source string, and returns the built CSS expression.
Use to parse a tag's highly CSS-based attributes like 'font'.
See also: parseAttributes | [
"Parse",
"a",
"single",
"CSS",
"attribute",
"source",
"string",
"and",
"returns",
"the",
"built",
"CSS",
"expression",
".",
"Use",
"to",
"parse",
"a",
"tag",
"s",
"highly",
"CSS",
"-",
"based",
"attributes",
"like",
"font",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L504-L515 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | CSSParser._parseAtFrame | def _parseAtFrame(self, src):
"""
XXX Proprietary for PDF
"""
src = src[len('@frame '):].lstrip()
box, src = self._getIdent(src)
src, properties = self._parseDeclarationGroup(src.lstrip())
result = [self.cssBuilder.atFrame(box, properties)]
return src.lstr... | python | def _parseAtFrame(self, src):
"""
XXX Proprietary for PDF
"""
src = src[len('@frame '):].lstrip()
box, src = self._getIdent(src)
src, properties = self._parseDeclarationGroup(src.lstrip())
result = [self.cssBuilder.atFrame(box, properties)]
return src.lstr... | [
"def",
"_parseAtFrame",
"(",
"self",
",",
"src",
")",
":",
"src",
"=",
"src",
"[",
"len",
"(",
"'@frame '",
")",
":",
"]",
".",
"lstrip",
"(",
")",
"box",
",",
"src",
"=",
"self",
".",
"_getIdent",
"(",
"src",
")",
"src",
",",
"properties",
"=",
... | XXX Proprietary for PDF | [
"XXX",
"Proprietary",
"for",
"PDF"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L788-L796 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/util.py | ErrorMsg | def ErrorMsg():
"""
Helper to get a nice traceback as string
"""
import traceback
limit = None
_type, value, tb = sys.exc_info()
_list = traceback.format_tb(tb, limit) + \
traceback.format_exception_only(_type, value)
return "Traceback (innermost last):\n" + "%-20s %s" % (
... | python | def ErrorMsg():
"""
Helper to get a nice traceback as string
"""
import traceback
limit = None
_type, value, tb = sys.exc_info()
_list = traceback.format_tb(tb, limit) + \
traceback.format_exception_only(_type, value)
return "Traceback (innermost last):\n" + "%-20s %s" % (
... | [
"def",
"ErrorMsg",
"(",
")",
":",
"import",
"traceback",
"limit",
"=",
"None",
"_type",
",",
"value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"_list",
"=",
"traceback",
".",
"format_tb",
"(",
"tb",
",",
"limit",
")",
"+",
"traceback",
".",
... | Helper to get a nice traceback as string | [
"Helper",
"to",
"get",
"a",
"nice",
"traceback",
"as",
"string"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L119-L131 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/util.py | transform_attrs | def transform_attrs(obj, keys, container, func, extras=None):
"""
Allows to apply one function to set of keys cheching if key is in container,
also trasform ccs key to report lab keys.
extras = Are extra params for func, it will be call like func(*[param1, param2])
obj = frag
keys = [(reportl... | python | def transform_attrs(obj, keys, container, func, extras=None):
"""
Allows to apply one function to set of keys cheching if key is in container,
also trasform ccs key to report lab keys.
extras = Are extra params for func, it will be call like func(*[param1, param2])
obj = frag
keys = [(reportl... | [
"def",
"transform_attrs",
"(",
"obj",
",",
"keys",
",",
"container",
",",
"func",
",",
"extras",
"=",
"None",
")",
":",
"cpextras",
"=",
"extras",
"for",
"reportlab",
",",
"css",
"in",
"keys",
":",
"extras",
"=",
"cpextras",
"if",
"extras",
"is",
"None... | Allows to apply one function to set of keys cheching if key is in container,
also trasform ccs key to report lab keys.
extras = Are extra params for func, it will be call like func(*[param1, param2])
obj = frag
keys = [(reportlab, css), ... ]
container = cssAttr | [
"Allows",
"to",
"apply",
"one",
"function",
"to",
"set",
"of",
"keys",
"cheching",
"if",
"key",
"is",
"in",
"container",
"also",
"trasform",
"ccs",
"key",
"to",
"report",
"lab",
"keys",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L140-L164 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/util.py | copy_attrs | def copy_attrs(obj1, obj2, attrs):
"""
Allows copy a list of attributes from object2 to object1.
Useful for copy ccs attributes to fragment
"""
for attr in attrs:
value = getattr(obj2, attr) if hasattr(obj2, attr) else None
if value is None and isinstance(obj2, dict) and attr in ob... | python | def copy_attrs(obj1, obj2, attrs):
"""
Allows copy a list of attributes from object2 to object1.
Useful for copy ccs attributes to fragment
"""
for attr in attrs:
value = getattr(obj2, attr) if hasattr(obj2, attr) else None
if value is None and isinstance(obj2, dict) and attr in ob... | [
"def",
"copy_attrs",
"(",
"obj1",
",",
"obj2",
",",
"attrs",
")",
":",
"for",
"attr",
"in",
"attrs",
":",
"value",
"=",
"getattr",
"(",
"obj2",
",",
"attr",
")",
"if",
"hasattr",
"(",
"obj2",
",",
"attr",
")",
"else",
"None",
"if",
"value",
"is",
... | Allows copy a list of attributes from object2 to object1.
Useful for copy ccs attributes to fragment | [
"Allows",
"copy",
"a",
"list",
"of",
"attributes",
"from",
"object2",
"to",
"object1",
".",
"Useful",
"for",
"copy",
"ccs",
"attributes",
"to",
"fragment"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L167-L176 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/util.py | set_value | def set_value(obj, attrs, value, _copy=False):
"""
Allows set the same value to a list of attributes
"""
for attr in attrs:
if _copy:
value = copy(value)
setattr(obj, attr, value) | python | def set_value(obj, attrs, value, _copy=False):
"""
Allows set the same value to a list of attributes
"""
for attr in attrs:
if _copy:
value = copy(value)
setattr(obj, attr, value) | [
"def",
"set_value",
"(",
"obj",
",",
"attrs",
",",
"value",
",",
"_copy",
"=",
"False",
")",
":",
"for",
"attr",
"in",
"attrs",
":",
"if",
"_copy",
":",
"value",
"=",
"copy",
"(",
"value",
")",
"setattr",
"(",
"obj",
",",
"attr",
",",
"value",
")... | Allows set the same value to a list of attributes | [
"Allows",
"set",
"the",
"same",
"value",
"to",
"a",
"list",
"of",
"attributes"
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L179-L186 | train |
xhtml2pdf/xhtml2pdf | xhtml2pdf/util.py | getColor | def getColor(value, default=None):
"""
Convert to color value.
This returns a Color object instance from a text bit.
"""
if isinstance(value, Color):
return value
value = str(value).strip().lower()
if value == "transparent" or value == "none":
return default
if value in ... | python | def getColor(value, default=None):
"""
Convert to color value.
This returns a Color object instance from a text bit.
"""
if isinstance(value, Color):
return value
value = str(value).strip().lower()
if value == "transparent" or value == "none":
return default
if value in ... | [
"def",
"getColor",
"(",
"value",
",",
"default",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Color",
")",
":",
"return",
"value",
"value",
"=",
"str",
"(",
"value",
")",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"if",
"va... | Convert to color value.
This returns a Color object instance from a text bit. | [
"Convert",
"to",
"color",
"value",
".",
"This",
"returns",
"a",
"Color",
"object",
"instance",
"from",
"a",
"text",
"bit",
"."
] | 230357a392f48816532d3c2fa082a680b80ece48 | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L190-L214 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.