code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
donor_pairs = []
data = namedtuple('hbonddonor', 'd d_orig_atom d_orig_idx h type')
for donor in [a for a in all_atoms if a.OBAtom.IsHbondDonor() and a.idx not in self.altconf]:
in_ring = False
if not in_ring:
for adj_atom in [a for a in pybel.ob.... | def find_hbd(self, all_atoms, hydroph_atoms) | Find all possible strong and weak hydrogen bonds donors (all hydrophobic C-H pairings) | 2.660446 | 2.603281 | 1.021959 |
data = namedtuple('aromatic_ring', 'atoms orig_atoms atoms_orig_idx normal obj center type')
rings = []
aromatic_amino = ['TYR', 'TRP', 'HIS', 'PHE']
ring_candidates = mol.OBMol.GetSSSR()
write_message("Number of aromatic ring candidates: %i\n" % len(ring_candidates), mt... | def find_rings(self, mol, all_atoms) | Find rings and return only aromatic.
Rings have to be sufficiently planar OR be detected by OpenBabel as aromatic. | 4.870939 | 4.61577 | 1.055282 |
unpaired_hba, unpaired_hbd, unpaired_hal = [], [], []
# Unpaired hydrogen bond acceptors/donors in ligand (not used for hydrogen bonds/water, salt bridges/mcomplex)
involved_atoms = [hbond.a.idx for hbond in self.hbonds_pdon] + [hbond.d.idx for hbond in self.hbonds_ldon]
[[invol... | def find_unpaired_ligand(self) | Identify unpaired functional in groups in ligands, involving H-Bond donors, acceptors, halogen bond donors. | 3.276624 | 3.187936 | 1.02782 |
sel = {}
# 1. Rings interacting via stacking can't have additional hydrophobic contacts between each other.
for pistack, h in itertools.product(pistacks, all_h):
h1, h2 = h.bsatom.idx, h.ligatom.idx
brs, lrs = [p1.idx for p1 in pistack.proteinring.atoms], [p2.id... | def refine_hydrophobic(self, all_h, pistacks) | Apply several rules to reduce the number of hydrophobic interactions. | 3.046341 | 3.027519 | 1.006217 |
i_set = {}
for hbond in all_hbonds:
i_set[hbond] = False
for salt in salt_pneg:
protidx, ligidx = [at.idx for at in salt.negative.atoms], [at.idx for at in salt.positive.atoms]
if hbond.d.idx in ligidx and hbond.a.idx in protidx:
... | def refine_hbonds_ldon(self, all_hbonds, salt_lneg, salt_pneg) | Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds. | 2.424083 | 2.398301 | 1.01075 |
i_set = []
for picat in all_picat:
exclude = False
for stack in stacks:
if whichrestype(stack.proteinring.atoms[0]) == 'HIS' and picat.ring.obj == stack.ligandring.obj:
exclude = True
if not exclude:
i_set.a... | def refine_pi_cation_laro(self, all_picat, stacks) | Just important for constellations with histidine involved. If the histidine ring is positioned in stacking
position to an aromatic ring in the ligand, there is in most cases stacking and pi-cation interaction reported
as histidine also carries a positive charge in the ring. For such cases, only report s... | 6.023558 | 5.042306 | 1.194604 |
donor_atoms_hbonds = [hb.d.idx for hb in hbonds_ldon + hbonds_pdon]
wb_dict = {}
wb_dict2 = {}
omega = 110.0
# Just one hydrogen bond per donor atom
for wbridge in [wb for wb in wbridges if wb.d.idx not in donor_atoms_hbonds]:
if (wbridge.water.idx, ... | def refine_water_bridges(self, wbridges, hbonds_ldon, hbonds_pdon) | A donor atom already forming a hydrogen bond is not allowed to form a water bridge. Each water molecule
can only be donor for two water bridges, selecting the constellation with the omega angle closest to 110 deg. | 2.144624 | 2.024281 | 1.05945 |
data = namedtuple('hal_acceptor', 'o o_orig_idx y y_orig_idx')
a_set = []
# All oxygens, nitrogen, sulfurs with neighboring carbon, phosphor, nitrogen or sulfur
for a in [at for at in atoms if at.atomicnum in [8, 7, 16]]:
n_atoms = [na for na in pybel.ob.OBAtomAtomIt... | def find_hal(self, atoms) | Look for halogen bond acceptors (Y-{O|P|N|S}, with Y=C,P,S) | 3.694729 | 3.316266 | 1.114123 |
data = namedtuple('pcharge', 'atoms atoms_orig_idx type center restype resnr reschain')
a_set = []
# Iterate through all residue, exclude those in chains defined as peptides
for res in [r for r in pybel.ob.OBResidueIter(mol.OBMol) if not r.GetChain() in config.PEPTIDES]:
... | def find_charged(self, mol) | Looks for positive charges in arginine, histidine or lysine, for negative in aspartic and glutamic acid. | 2.648996 | 2.538769 | 1.043418 |
data = namedtuple('metal_binding', 'atom atom_orig_idx type restype resnr reschain location')
a_set = []
for res in pybel.ob.OBResidueIter(mol.OBMol):
restype, reschain, resnr = res.GetName().upper(), res.GetChain(), res.GetNum()
if restype in ['ASP', 'GLU', 'SER... | def find_metal_binding(self, mol) | Looks for atoms that could possibly be involved in chelating a metal ion.
This can be any main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids | 1.844639 | 1.798853 | 1.025453 |
n_atoms = [a_neighbor.GetAtomicNum() for a_neighbor in pybel.ob.OBAtomAtomIter(atom.OBAtom)]
if group in ['quartamine', 'tertamine'] and atom.atomicnum == 7: # Nitrogen
# It's a nitrogen, so could be a protonated amine or quaternary ammonium
if '1' not in n_atoms and l... | def is_functional_group(self, atom, group) | Given a pybel atom, look up if it belongs to a function group | 2.890684 | 2.873008 | 1.006152 |
data = namedtuple('hal_donor', 'x orig_x x_orig_idx c c_orig_idx')
a_set = []
for a in atoms:
if self.is_functional_group(a, 'halocarbon'):
n_atoms = [na for na in pybel.ob.OBAtomAtomIter(a.OBAtom) if na.GetAtomicNum() == 6]
x_orig_idx = self.... | def find_hal(self, atoms) | Look for halogen bond donors (X-C, with X=F, Cl, Br, I) | 3.756134 | 3.520526 | 1.066924 |
single_sites = []
for member in ligand.members:
single_sites.append(':'.join([str(x) for x in member]))
site = ' + '.join(single_sites)
site = site if not len(site) > 20 else site[:20] + '...'
longname = ligand.longname if not len(ligand.longname) > 20 else ... | def characterize_complex(self, ligand) | Handles all basic functions for characterizing the interactions for one ligand | 4.272356 | 4.252169 | 1.004747 |
return [obres.GetIdx() for obres in resis if self.res_belongs_to_bs(obres, cutoff, ligcentroid)] | def extract_bs(self, cutoff, ligcentroid, resis) | Return list of ids from residues belonging to the binding site | 6.687406 | 5.280663 | 1.266395 |
rescentroid = centroid([(atm.x(), atm.y(), atm.z()) for atm in pybel.ob.OBResidueAtomIter(res)])
# Check geometry
near_enough = True if euclidean3d(rescentroid, ligcentroid) < cutoff else False
# Check chain membership
restricted_chain = True if res.GetChain() in config.... | def res_belongs_to_bs(self, res, cutoff, ligcentroid) | Check for each residue if its centroid is within a certain distance to the ligand centroid.
Additionally checks if a residue belongs to a chain restricted by the user (e.g. by defining a peptide chain) | 6.303313 | 5.61337 | 1.122911 |
return {
'MEDIA_URL' : core_settings.MEDIA_URL,
'STATIC_URL': core_settings.STATIC_URL,
'VERSION' : core_settings.VERSION,
'SERVER_INFO' : core_settings.SERVER_INFO,
'SITE_NAME' : current_site_name,
'CURRENT_SITE': current_site,
} | def url_info(request) | Make MEDIA_URL and current HttpRequest object
available in template code. | 3.153004 | 2.841515 | 1.109621 |
# never cache headers + ETag
add_never_cache_headers(response)
if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache:
# We don't need to update the cache, just return.
return response
if request.method != 'GET':
#... | def process_response(self, request, response) | Sets the cache, if needed. | 5.445839 | 5.378323 | 1.012553 |
if self.cache_anonymous_only:
assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' ... | def process_request(self, request) | Checks whether the page is already cached and returns the cached
version if available. | 3.545065 | 3.533456 | 1.003285 |
collected = []
for func in finder_funcs:
gathered = func(obj, count, collected, *args, **kwargs)
if gathered:
collected += gathered
if len(collected) >= count:
return collected[:count]
return collected | def collect_related(self, finder_funcs, obj, count, *args, **kwargs) | Collects objects related to ``obj`` using a list of ``finder_funcs``.
Stops when required count is collected or the function list is
exhausted. | 2.849141 | 2.893735 | 0.98459 |
return self.collect_related(self._get_finders(finder), obj, count, mods, only_from_same_site) | def get_related_for_object(self, obj, count, finder=None, mods=[], only_from_same_site=True) | Returns at most ``count`` publishable objects related to ``obj`` using
named related finder ``finder``.
If only specific type of publishable is prefered, use ``mods`` attribute
to list required classes.
Finally, use ``only_from_same_site`` if you don't want cross-site
content.
... | 4.329672 | 6.044493 | 0.7163 |
assert offset >= 0, "Offset must be a positive integer"
assert count >= 0, "Count must be a positive integer"
if not count:
return []
limit = offset + count
qset = self.get_listing_queryset(category, children, content_types, date_range, exclude, **kwargs)
... | def get_listing(self, category=None, children=ListingHandler.NONE, count=10, offset=0, content_types=[], date_range=(), exclude=None, **kwargs) | Get top objects for given category and potentionally also its child categories.
Params:
category - Category object to list objects for. None if any category will do
count - number of objects to output, defaults to 10
offset - starting with object number... 1-based
... | 4.386189 | 4.454028 | 0.984769 |
tname, context = _do_paginator(context, adjacent_pages, template_name)
return render_to_string(tname, context) | def paginator(context, adjacent_pages=2, template_name=None) | Renders a ``inclusion_tags/paginator.html`` or ``inc/paginator.html``
template with additional pagination context. To be used in conjunction
with the ``object_list`` generic
view.
If ``TEMPLATE_NAME`` parameter is given,
``inclusion_tags/paginator_TEMPLATE_NAME.html`` or
``inc/paginator_TEMPLA... | 4.747203 | 9.955762 | 0.47683 |
contents = token.split_contents()
if len(contents) not in [5, 7]:
raise template.TemplateSyntaxError('%r tag requires 4 or 6 arguments.' % contents[0])
elif len(contents) == 5:
tag, obj_var, count, fill, var_name = contents
return AuthorListingNode(obj_var, count, var_name)
... | def do_author_listing(parser, token) | Get N listing objects that were published by given author recently and optionally
omit a publishable object in results.
**Usage**::
{% author_listing <author> <limit> as <result> [omit <obj>] %}
**Parameters**::
================================== =========================================... | 3.076631 | 3.339848 | 0.921189 |
def f(T):
pw = _Region1(T, P)
gw = pw["h"]-T*pw["s"]
pv = _Region2(T, P)
gv = pv["h"]-T*pv["s"]
ps = SeaWater._saline(T, P, S)
return -ps["g"]+S*ps["gs"]-gw+gv
Tb = fsolve(f, 300)[0]
return Tb | def _Tb(P, S) | Procedure to calculate the boiling temperature of seawater
Parameters
----------
P : float
Pressure, [MPa]
S : float
Salinity, [kg/kg]
Returns
-------
Tb : float
Boiling temperature, [K]
References
----------
IAPWS, Advisory Note No. 5: Industrial Calc... | 6.78319 | 8.059806 | 0.841607 |
def f(T):
T = float(T)
pw = _Region1(T, P)
gw = pw["h"]-T*pw["s"]
gih = _Ice(T, P)["g"]
ps = SeaWater._saline(T, P, S)
return -ps["g"]+S*ps["gs"]-gw+gih
Tf = fsolve(f, 300)[0]
return Tf | def _Tf(P, S) | Procedure to calculate the freezing temperature of seawater
Parameters
----------
P : float
Pressure, [MPa]
S : float
Salinity, [kg/kg]
Returns
-------
Tf : float
Freezing temperature, [K]
References
----------
IAPWS, Advisory Note No. 5: Industrial Ca... | 10.562848 | 11.660273 | 0.905883 |
def f(parr):
T, P = parr
pw = _Region1(T, P)
gw = pw["h"]-T*pw["s"]
pv = _Region2(T, P)
gv = pv["h"]-T*pv["s"]
gih = _Ice(T, P)["g"]
ps = SeaWater._saline(T, P, S)
return -ps["g"]+S*ps["gs"]-gw+gih, -ps["g"]+S*ps["gs"]-gw+gv
Tt, Pt = fsolv... | def _Triple(S) | Procedure to calculate the triple point pressure and temperature for
seawater
Parameters
----------
S : float
Salinity, [kg/kg]
Returns
-------
prop : dict
Dictionary with the triple point properties:
* Tt: Triple point temperature, [K]
* Pt: Triple... | 7.484588 | 6.413662 | 1.166976 |
pw = _Region1(T, P)
gw = pw["h"]-T*pw["s"]
def f(Posm):
pw2 = _Region1(T, P+Posm)
gw2 = pw2["h"]-T*pw2["s"]
ps = SeaWater._saline(T, P+Posm, S)
return -ps["g"]+S*ps["gs"]-gw+gw2
Posm = fsolve(f, 0)[0]
return Posm | def _OsmoticPressure(T, P, S) | Procedure to calculate the osmotic pressure of seawater
Parameters
----------
T : float
Tmperature, [K]
P : float
Pressure, [MPa]
S : float
Salinity, [kg/kg]
Returns
-------
Posm : float
Osmotic pressure, [MPa]
References
----------
IAPWS, ... | 6.472671 | 7.133564 | 0.907355 |
# Check input parameters
if T < 273.15 or T > 523.15 or P < 0 or P > 140 or S < 0 or S > 0.17:
raise NotImplementedError("Incoming out of bound")
# Eq 4
a1 = -7.180891e-5+1.831971e-7*P
a2 = 1.048077e-3-4.494722e-6*P
# Eq 5
b1 = 1.463375e-1+9.208586e-4*P
b2 = -3.086908e-3+1... | def _ThCond_SeaWater(T, P, S) | Equation for the thermal conductivity of seawater
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
S : float
Salinity, [kg/kg]
Returns
-------
k : float
Thermal conductivity excess relative to that of the pure water, [W/mK]
... | 3.974284 | 3.841416 | 1.034588 |
# Check input parameters
if T < 523.15 or T > 623.15 or mH2SO4 < 0 or mH2SO4 > 0.75 or \
mNaCl < 0 or mNaCl > 2.25:
raise NotImplementedError("Incoming out of bound")
A00 = -0.8085987*T+81.4613752+0.10537803*T*log(T)
A10 = 3.4636364*T-281.63322-0.46779874*T*log(T)
A20 = -6.... | def _solNa2SO4(T, mH2SO4, mNaCl) | Equation for the solubility of sodium sulfate in aqueous mixtures of
sodium chloride and sulfuric acid
Parameters
----------
T : float
Temperature, [K]
mH2SO4 : float
Molality of sufuric acid, [mol/kg(water)]
mNaCl : float
Molality of sodium chloride, [mol/kg(water)]
... | 3.608943 | 3.538986 | 1.019768 |
# Check input parameters
if x < 0 or x > 0.12:
raise NotImplementedError("Incoming out of bound")
T1 = Tc*(1 + 2.3e1*x - 3.3e2*x**1.5 - 1.8e3*x**2)
T2 = Tc*(1 + 1.757e1*x - 3.026e2*x**1.5 + 2.838e3*x**2 - 1.349e4*x**2.5 +
3.278e4*x**3 - 3.674e4*x**3.5 + 1.437e4*x**4)
f1 = ... | def _critNaCl(x) | Equation for the critical locus of aqueous solutions of sodium chloride
Parameters
----------
x : float
Mole fraction of NaCl, [-]
Returns
-------
prop : dict
A dictionary withe the properties:
* Tc: critical temperature, [K]
* Pc: critical pressure, [M... | 3.376898 | 3.296753 | 1.02431 |
T = self.kwargs["T"]
P = self.kwargs["P"]
S = self.kwargs["S"]
self.m = S/(1-S)/Ms
if self.kwargs["fast"] and T <= 313.15:
pw = self._waterSupp(T, P)
elif self.kwargs["IF97"]:
pw = self._waterIF97(T, P)
else:
pw = self... | def calculo(self) | Calculate procedure | 3.890736 | 3.866103 | 1.006372 |
water = IAPWS95(P=P, T=T)
prop = {}
prop["g"] = water.h-T*water.s
prop["gt"] = -water.s
prop["gp"] = 1./water.rho
prop["gtt"] = -water.cp/T
prop["gtp"] = water.betas*water.cp/T
prop["gpp"] = -1e6/(water.rho*water.w)**2-water.betas**2*1e3*water.cp/... | def _water(cls, T, P) | Get properties of pure water, Table4 pag 8 | 4.756545 | 4.729024 | 1.00582 |
fir = 0
# Polinomial terms
nr1 = coef.get("nr1", [])
d1 = coef.get("d1", [])
t1 = coef.get("t1", [])
for n, d, t in zip(nr1, d1, t1):
fir += n*delta**d*tau**t
# Exponential terms
nr2 = coef.get("nr2", [])
d2 = coef.get("d2", [])
g2 = coef.get("gamma2", [])
t2 =... | def _phir(tau, delta, coef) | Residual contribution to the adimensional free Helmholtz energy
Parameters
----------
tau : float
Inverse reduced temperature Tc/T, [-]
delta : float
Reduced density rho/rhoc, [-]
coef : dict
Dictionary with equation of state parameters
Returns
-------
fir : flo... | 2.154863 | 2.197437 | 0.980626 |
def decorator(f):
# __doc__ is only writable in python3.
# The doc build must be done with python3 so this snnippet do the work
py_version = platform.python_version()
if py_version[0] == "3":
doc = f.__doc__.split(os.linesep)
try:
ind = do... | def mainClassDoc() | Function decorator used to automatic adiction of base class MEoS in
subclass __doc__ | 4.506114 | 3.953447 | 1.139794 |
self._mode = ""
if self.kwargs["T"] and self.kwargs["P"]:
self._mode = "TP"
elif self.kwargs["T"] and self.kwargs["rho"]:
self._mode = "Trho"
elif self.kwargs["T"] and self.kwargs["h"] is not None:
self._mode = "Th"
elif self.kwargs["T... | def calculable(self) | Check if inputs are enough to define state | 1.370251 | 1.342476 | 1.02069 |
return deriv_H(self, z, x, y, fase) | def derivative(self, z, x, y, fase) | Wrapper derivative for custom derived properties
where x, y, z can be: P, T, v, rho, u, h, s, g, a | 6.776799 | 6.217253 | 1.089999 |
rhoc = self._constants.get("rhoref", self.rhoc)
Tc = self._constants.get("Tref", self.Tc)
if T > Tc:
T = Tc
tau = Tc/T
rhoLo = self._Liquid_Density(T)
rhoGo = self._Vapor_Density(T)
def f(parr):
rhol, rhog = parr
del... | def _saturation(self, T) | Saturation calculation for two phase search | 3.153778 | 3.15834 | 0.998556 |
if isinstance(rho, ndarray):
rho = rho[0]
if isinstance(T, ndarray):
T = T[0]
if rho < 0:
rho = 1e-20
if T < 50:
T = 50
rhoc = self._constants.get("rhoref", self.rhoc)
Tc = self._constants.get("Tref", self.Tc)
... | def _Helmholtz(self, rho, T) | Calculated properties from helmholtz free energy and derivatives
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
prop : dict
Dictionary with calculated properties:
... | 3.391468 | 2.946372 | 1.151066 |
rhoc = self._constants.get("rhoref", self.rhoc)
Tc = self._constants.get("Tref", self.Tc)
delta = rho/rhoc
tau = Tc/T
ideal = self._phi0(tau, delta)
fio = ideal["fio"]
fiot = ideal["fiot"]
fiott = ideal["fiott"]
propiedades = _fase()
... | def _prop0(self, rho, T) | Ideal gas properties | 4.84067 | 4.644521 | 1.042232 |
Fi0 = self.Fi0
fio = Fi0["ao_log"][0]*log(delta)+Fi0["ao_log"][1]*log(tau)
fiot = +Fi0["ao_log"][1]/tau
fiott = -Fi0["ao_log"][1]/tau**2
fiod = 1/delta
fiodd = -1/delta**2
fiodt = 0
for n, t in zip(Fi0["ao_pow"], Fi0["pow"]):
fio +=... | def _phi0(self, tau, delta) | Ideal gas Helmholtz free energy and derivatives
Parameters
----------
tau : float
Inverse reduced temperature Tc/T, [-]
delta : float
Reduced density rho/rhoc, [-]
Returns
-------
prop : dictionary with ideal adimensional helmholtz energy... | 3.180475 | 2.913843 | 1.091505 |
if not rho:
prop = {}
prop["fir"] = 0
prop["firt"] = 0
prop["fird"] = 0
prop["firtt"] = 0
prop["firdt"] = 0
prop["firdd"] = 0
return prop
R = self._constants.get("R")/self._constants.get("M", self.M... | def _derivDimensional(self, rho, T) | Calcule the dimensional form or Helmholtz free energy derivatives
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
prop : dict
Dictionary with residual helmholtz energy and derivati... | 2.858429 | 2.479547 | 1.152803 |
tau = 1-T/self.Tc
sigma = 0
for n, t in zip(self._surf["sigma"], self._surf["exp"]):
sigma += n*tau**t
return sigma | def _surface(self, T) | Generic equation for the surface tension
Parameters
----------
T : float
Temperature, [K]
Returns
-------
σ : float
Surface tension, [N/m]
Notes
-----
Need a _surf dict in the derived class with the parameters keys:
... | 7.078767 | 5.866027 | 1.20674 |
Tita = 1-T/cls.Tc
suma = 0
for n, x in zip(cls._Pv["ao"], cls._Pv["exp"]):
suma += n*Tita**x
Pr = exp(cls.Tc/T*suma)
Pv = Pr*cls.Pc
return Pv | def _Vapor_Pressure(cls, T) | Auxiliary equation for the vapour pressure
Parameters
----------
T : float
Temperature, [K]
Returns
-------
Pv : float
Vapour pressure, [Pa]
References
----------
IAPWS, Revised Supplementary Release on Saturation Propert... | 7.195637 | 9.690859 | 0.742518 |
eq = cls._rhoL["eq"]
Tita = 1-T/cls.Tc
if eq == 2:
Tita = Tita**(1./3)
suma = 0
for n, x in zip(cls._rhoL["ao"], cls._rhoL["exp"]):
suma += n*Tita**x
Pr = suma+1
rho = Pr*cls.rhoc
return rho | def _Liquid_Density(cls, T) | Auxiliary equation for the density of saturated liquid
Parameters
----------
T : float
Temperature, [K]
Returns
-------
rho : float
Saturated liquid density, [kg/m³]
References
----------
IAPWS, Revised Supplementary Rele... | 6.495708 | 8.308781 | 0.781788 |
eq = cls._rhoG["eq"]
Tita = 1-T/cls.Tc
if eq == 4:
Tita = Tita**(1./3)
suma = 0
for n, x in zip(cls._rhoG["ao"], cls._rhoG["exp"]):
suma += n*Tita**x
Pr = exp(suma)
rho = Pr*cls.rhoc
return rho | def _Vapor_Density(cls, T) | Auxiliary equation for the density of saturated vapor
Parameters
----------
T : float
Temperature, [K]
Returns
-------
rho : float
Saturated vapor density, [kg/m³]
References
----------
IAPWS, Revised Supplementary Releas... | 6.248743 | 8.06592 | 0.774709 |
Tita = 1-T/cls.Tc
suma1 = 0
suma2 = 0
for n, x in zip(cls._Pv["ao"], cls._Pv["exp"]):
suma1 -= n*x*Tita**(x-1)/cls.Tc
suma2 += n*Tita**x
Pr = (cls.Tc*suma1/T-cls.Tc/T**2*suma2)*exp(cls.Tc/T*suma2)
dPdT = Pr*cls.Pc
return dPdT | def _dPdT_sat(cls, T) | Auxiliary equation for the dP/dT along saturation line
Parameters
----------
T : float
Temperature, [K]
Returns
-------
dPdT : float
dPdT, [MPa/K]
References
----------
IAPWS, Revised Supplementary Release on Saturation P... | 5.442887 | 6.440501 | 0.845103 |
# Check input parameters
if T < 193 or T > 473 or P < 0 or P > 5 or x < 0 or x > 1:
raise(NotImplementedError("Input not in range of validity"))
R = 8.314462 # J/molK
# Virial coefficients
vir = _virial(T)
# Eq 3
beta = x*(2-x)*vir["Bww"]+(1-x)**2*(2*vir["Baw"]-vir["Baa"])
... | def _fugacity(T, P, x) | Fugacity equation for humid air
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
x : float
Mole fraction of water-vapor, [-]
Returns
-------
fv : float
fugacity coefficient, [MPa]
Notes
------
Raise :class:`NotImple... | 3.882554 | 3.540165 | 1.096715 |
c = cls._blend["bubble"]
Tj = cls._blend["Tj"]
Pj = cls._blend["Pj"]
Tita = 1-T/Tj
suma = 0
for i, n in zip(c["i"], c["n"]):
suma += n*Tita**(i/2.)
P = Pj*exp(Tj/T*suma)
return P | def _bubbleP(cls, T) | Using ancillary equation return the pressure of bubble point | 6.226317 | 5.809285 | 1.071787 |
self._mode = ""
if self.kwargs["T"] and self.kwargs["P"]:
self._mode = "TP"
elif self.kwargs["T"] and self.kwargs["rho"]:
self._mode = "Trho"
elif self.kwargs["P"] and self.kwargs["rho"]:
self._mode = "Prho"
# Composition definition
... | def calculable(self) | Check if inputs are enough to define state | 2.862986 | 2.639065 | 1.084848 |
T = self.kwargs["T"]
rho = self.kwargs["rho"]
P = self.kwargs["P"]
# Composition alternate definition
if self._composition == "A":
A = self.kwargs["A"]
elif self._composition == "xa":
xa = self.kwargs["xa"]
A = xa/(1-(1-xa)*(1... | def calculo(self) | Calculate procedure | 3.560818 | 3.511506 | 1.014043 |
if T <= 273.16:
ice = _Ice(T, P)
gw = ice["g"]
else:
water = IAPWS95(T=T, P=P)
gw = water.g
def f(parr):
rho, a = parr
if a > 1:
a = 1
fa = self._fav(T, rho, a)
muw = fa["fir... | def _eq(self, T, P) | Procedure for calculate the composition in saturation state
Parameters
----------
T : float
Temperature [K]
P : float
Pressure [MPa]
Returns
-------
Asat : float
Saturation mass fraction of dry air in humid air [kg/kg] | 7.666501 | 7.445586 | 1.029671 |
prop = {}
prop["P"] = rho**2*fav["fird"]/1000 # Eq T1
prop["s"] = -fav["firt"] # Eq T2
prop["cp"] = -T*fav["firtt"]+T*rho*fav["firdt"]**2/( # Eq T3
2*fav["fird"]+rho*fav["firdd"])
p... | def _prop(self, T, rho, fav) | Thermodynamic properties of humid air
Parameters
----------
T : float
Temperature, [K]
rho : float
Density, [kg/m³]
fav : dict
dictionary with helmholtz energy and derivatives
Returns
-------
prop : dict
Di... | 3.395459 | 2.842951 | 1.194343 |
prop = {}
prop["mu"] = fav["fira"]
prop["muw"] = fav["fir"]+rho*fav["fird"]-A*fav["fira"]
prop["M"] = 1/((1-A)/Mw+A/Ma)
prop["HR"] = 1/A-1
prop["xa"] = A*Mw/Ma/(1-A*(1-Mw/Ma))
prop["xw"] = 1-prop["xa"]
return prop | def _coligative(self, rho, A, fav) | Miscelaneous properties of humid air
Parameters
----------
rho : float
Density, [kg/m³]
A : float
Mass fraction of dry air in humid air, [kg/kg]
fav : dict
dictionary with helmholtz energy and derivatives
Returns
-------
... | 7.57799 | 4.485359 | 1.689495 |
if 50 <= T <= 273.16:
Tita = T/Tt
suma = 0
a = [-0.212144006e2, 0.273203819e2, -0.61059813e1]
expo = [0.333333333e-2, 1.20666667, 1.70333333]
for ai, expi in zip(a, expo):
suma += ai*Tita**expi
return exp(suma/Tita)*Pt
else:
raise NotImple... | def _Sublimation_Pressure(T) | Sublimation Pressure correlation
Parameters
----------
T : float
Temperature, [K]
Returns
-------
P : float
Pressure at sublimation line, [MPa]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* 50 ≤ T ≤ 273.16
Examples
---... | 6.337557 | 6.001661 | 1.055967 |
if ice == "Ih" and 251.165 <= T <= 273.16:
# Ice Ih
Tref = Tt
Pref = Pt
Tita = T/Tref
a = [0.119539337e7, 0.808183159e5, 0.33382686e4]
expo = [3., 0.2575e2, 0.10375e3]
suma = 1
for ai, expi in zip(a, expo):
suma += ai*(1-Tita**expi)
... | def _Melting_Pressure(T, ice="Ih") | Melting Pressure correlation
Parameters
----------
T : float
Temperature, [K]
ice: string
Type of ice: Ih, III, V, VI, VII.
Below 273.15 is a mandatory input, the ice Ih is the default value.
Above 273.15, the ice type is unnecesary.
Returns
-------
P : floa... | 3.553023 | 3.335039 | 1.065362 |
if 248.15 <= T <= Tc:
Tr = T/Tc
return 1e-3*(235.8*(1-Tr)**1.256*(1-0.625*(1-Tr)))
else:
raise NotImplementedError("Incoming out of bound") | def _Tension(T) | Equation for the surface tension
Parameters
----------
T : float
Temperature, [K]
Returns
-------
σ : float
Surface tension, [N/m]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* 248.15 ≤ T ≤ 647
* Estrapolate to -25ºC in... | 8.94697 | 9.01015 | 0.992988 |
# Check input parameters
if T < 238 or T > 1200:
raise NotImplementedError("Incoming out of bound")
k = 1.380658e-23
Na = 6.0221367e23
alfa = 1.636e-40
epsilon0 = 8.854187817e-12
mu = 6.138e-30
d = rho/rhoc
Tr = Tc/T
I = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10, None]
... | def _Dielectric(rho, T) | Equation for the Dielectric constant
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
epsilon : float
Dielectric constant, [-]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
... | 5.268328 | 5.425134 | 0.971096 |
# Check input parameters
if rho < 0 or rho > 1060 or T < 261.15 or T > 773.15 or l < 0.2 or l > 1.1:
raise NotImplementedError("Incoming out of bound")
Lir = 5.432937
Luv = 0.229202
d = rho/1000.
Tr = T/273.15
L = l/0.589
a = [0.244257733, 0.974634476e-2, -0.373234996e-2, 0... | def _Refractive(rho, T, l=0.5893) | Equation for the refractive index
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
l : float, optional
Light Wavelength, [μm]
Returns
-------
n : float
Refractive index, [-]
Notes
------
Raise :class:`NotImplemen... | 4.932283 | 4.487862 | 1.099027 |
# Check input parameters
if rho < 0 or rho > 1250 or T < 273.15 or T > 1073.15:
raise NotImplementedError("Incoming out of bound")
# The internal method of calculation use rho in g/cm³
d = rho/1000.
# Water molecular weight different
Mw = 18.015268
gamma = [6.1415e-1, 4.82513... | def _Kw(rho, T) | Equation for the ionization constant of ordinary water
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
pKw : float
Ionization constant in -log10(kw), [-]
Notes
------
Raise :class:`NotImplementedError` if in... | 7.975711 | 7.087572 | 1.125309 |
# FIXME: Dont work
rho_ = rho/1000
kw = 10**-_Kw(rho, T)
A = [1850., 1410., 2.16417e-6, 1.81609e-7, -1.75297e-9, 7.20708e-12]
B = [16., 11.6, 3.26e-4, -2.3e-6, 1.1e-8]
t = T-273.15
Loo = A[0]-1/(1/A[1]+sum([A[i+2]*t**(i+1) for i in range(4)])) # Eq 5
rho_h = B[0]-1/(1/B[1]+su... | def _Conductivity(rho, T) | Equation for the electrolytic conductivity of liquid and dense
supercrítical water
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
K : float
Electrolytic conductivity, [S/m]
Notes
------
Raise :class:`No... | 4.976099 | 5.236702 | 0.950235 |
Tr = T/643.847
rhor = rho/358.0
no = [1.0, 0.940695, 0.578377, -0.202044]
fi0 = Tr**0.5/sum([n/Tr**i for i, n in enumerate(no)])
Li = [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 2, 5, 0, 1, 2, 3, 0, 1, 3,
5, 0, 1, 5, 3]
Lj = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, ... | def _D2O_Viscosity(rho, T) | Equation for the Viscosity of heavy water
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
μ : float
Viscosity, [Pa·s]
Examples
--------
>>> _D2O_Viscosity(998, 298.15)
0.0008897351001498108
>>> _D2O_... | 4.256696 | 4.47804 | 0.950571 |
rhor = rho/358
Tr = T/643.847
tau = Tr/(abs(Tr-1.1)+1.1)
no = [1.0, 37.3223, 22.5485, 13.0465, 0.0, -2.60735]
Lo = sum([Li*Tr**i for i, Li in enumerate(no)])
nr = [483.656, -191.039, 73.0358, -7.57467]
Lr = -167.31*(1-exp(-2.506*rhor))+sum(
[Li*rhor**(i+1) for i, Li in enumera... | def _D2O_ThCond(rho, T) | Equation for the thermal conductivity of heavy water
Parameters
----------
rho : float
Density, [kg/m³]
T : float
Temperature, [K]
Returns
-------
k : float
Thermal conductivity, [W/mK]
Examples
--------
>>> _D2O_ThCond(998, 298.15)
0.60771286758806... | 6.593382 | 7.057851 | 0.934191 |
if 210 <= T <= 276.969:
Tita = T/276.969
suma = 0
ai = [-0.1314226e2, 0.3212969e2]
ti = [-1.73, -1.42]
for a, t in zip(ai, ti):
suma += a*(1-Tita**t)
return exp(suma)*0.00066159
else:
raise NotImplementedError("Incoming out of bound") | def _D2O_Sublimation_Pressure(T) | Sublimation Pressure correlation for heavy water
Parameters
----------
T : float
Temperature, [K]
Returns
-------
P : float
Pressure at sublimation line, [MPa]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* 210 ≤ T ≤ 276.969
... | 7.09549 | 6.185174 | 1.147177 |
if ice == "Ih" and 254.415 <= T <= 276.969:
# Ice Ih, Eq 9
Tita = T/276.969
ai = [-0.30153e5, 0.692503e6]
ti = [5.5, 8.2]
suma = 1
for a, t in zip(ai, ti):
suma += a*(1-Tita**t)
P = suma*0.00066159
elif ice == "III" and 254.415 < T <= 258.... | def _D2O_Melting_Pressure(T, ice="Ih") | Melting Pressure correlation for heavy water
Parameters
----------
T : float
Temperature, [K]
ice: string
Type of ice: Ih, III, V, VI, VII.
Below 276.969 is a mandatory input, the ice Ih is the default value.
Above 276.969, the ice type is unnecesary.
Returns
--... | 3.522918 | 3.214339 | 1.096001 |
# Avoid round problem
P = round(P, 8)
T = round(T, 8)
if P > Pc and T > Tc:
phase = "Supercritical fluid"
elif T > Tc:
phase = "Gas"
elif P > Pc:
phase = "Compressible liquid"
elif P == Pc and T == Tc:
phase = "Critical point"
elif region == 4 and x =... | def getphase(Tc, Pc, T, P, x, region) | Return fluid phase string name
Parameters
----------
Tc : float
Critical temperature, [K]
Pc : float
Critical pressure, [MPa]
T : float
Temperature, [K]
P : float
Pressure, [MPa]
x : float
Quality, [-]
region: int
Region number, used only ... | 2.808192 | 2.821534 | 0.995272 |
r
# We use the relation between rho and v and his partial derivative
# ∂v/∂b|c = -1/ρ² ∂ρ/∂b|c
# ∂a/∂v|c = -ρ² ∂a/∂ρ|c
mul = 1
if z == "rho":
mul = -fase.rho**2
z = "v"
if x == "rho":
mul = -1/fase.rho**2
x = "v"
if y == "rho":
y = "v"
dT = {"... | def deriv_H(state, z, x, y, fase) | r"""Calculate generic partial derivative
:math:`\left.\frac{\partial z}{\partial x}\right|_{y}` from a fundamental
helmholtz free energy equation of state
Parameters
----------
state : any python object
Only need to define P and T properties, non phase specific properties
z : str
... | 3.072343 | 2.67836 | 1.147099 |
r
mul = 1
if z == "rho":
mul = -fase.rho**2
z = "v"
if x == "rho":
mul = -1/fase.rho**2
x = "v"
dT = {"P": 0,
"T": 1,
"v": fase.v*fase.alfav,
"u": fase.cp-state.P*1000*fase.v*fase.alfav,
"h": fase.cp,
"s": fase.cp/sta... | def deriv_G(state, z, x, y, fase) | r"""Calculate generic partial derivative
:math:`\left.\frac{\partial z}{\partial x}\right|_{y}` from a fundamental
Gibbs free energy equation of state
Parameters
----------
state : any python object
Only need to define P and T properties, non phase specific properties
z : str
Na... | 2.917101 | 2.572085 | 1.134139 |
# Check input parameters
if s < 3.397782955 or s > 3.77828134:
raise NotImplementedError("Incoming out of bound")
sigma = s/3.8
I = [0, 1, 1, 3, 5, 6]
J = [0, -2, 2, -12, -4, -3]
n = [0.913965547600543, -0.430944856041991e-4, 0.603235694765419e2,
0.117518273082168e-17, 0.2... | def _h13_s(s) | Define the boundary between Region 1 and 3, h=f(s)
Parameters
----------
s : float
Specific entropy, [kJ/kgK]
Returns
-------
h : float
Specific enthalpy, [kJ/kg]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* s(100MPa,623.15K) ... | 6.54667 | 6.978097 | 0.938174 |
# Check input parameters
if T < 273.15 or T > Tc:
raise NotImplementedError("Incoming out of bound")
n = [0, 0.11670521452767E+04, -0.72421316703206E+06, -0.17073846940092E+02,
0.12020824702470E+05, -0.32325550322333E+07, 0.14915108613530E+02,
-0.48232657361591E+04, 0.4051134... | def _PSat_T(T) | Define the saturated line, P=f(T)
Parameters
----------
T : float
Temperature, [K]
Returns
-------
P : float
Pressure, [MPa]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* 273.15 ≤ T ≤ 647.096
References
----------
... | 4.676261 | 4.955167 | 0.943714 |
# Check input parameters
if P < 611.212677/1e6 or P > 22.064:
raise NotImplementedError("Incoming out of bound")
n = [0, 0.11670521452767E+04, -0.72421316703206E+06, -0.17073846940092E+02,
0.12020824702470E+05, -0.32325550322333E+07, 0.14915108613530E+02,
-0.48232657361591E+0... | def _TSat_P(P) | Define the saturated line, T=f(P)
Parameters
----------
P : float
Pressure, [MPa]
Returns
-------
T : float
Temperature, [K]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* 0.00061121 ≤ P ≤ 22.064
References
----------
... | 4.969 | 5.102876 | 0.973765 |
# Check input parameters
hmin_Ps3 = _Region1(623.15, Ps_623)["h"]
hmax_Ps3 = _Region2(623.15, Ps_623)["h"]
if h < hmin_Ps3 or h > hmax_Ps3:
raise NotImplementedError("Incoming out of bound")
nu = h/2600
I = [0, 1, 1, 1, 1, 5, 7, 8, 14, 20, 22, 24, 28, 36]
J = [0, 1, 3, 4, 36, 3... | def _PSat_h(h) | Define the saturated line, P=f(h) for region 3
Parameters
----------
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
P : float
Pressure, [MPa]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* h'(623.15K) ≤ h ≤ h''(623.15K)
... | 5.35286 | 5.428909 | 0.985992 |
# Check input parameters
smin_Ps3 = _Region1(623.15, Ps_623)["s"]
smax_Ps3 = _Region2(623.15, Ps_623)["s"]
if s < smin_Ps3 or s > smax_Ps3:
raise NotImplementedError("Incoming out of bound")
sigma = s/5.2
I = [0, 1, 1, 4, 12, 12, 16, 24, 28, 32]
J = [0, 1, 32, 7, 4, 14, 36, 10,... | def _PSat_s(s) | Define the saturated line, P=f(s) for region 3
Parameters
----------
s : float
Specific entropy, [kJ/kgK]
Returns
-------
P : float
Pressure, [MPa]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
* s'(623.15K) ≤ s ≤ s''(623.15K)
... | 5.639427 | 5.718071 | 0.986246 |
I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6]
J = [0, 1, 2, 6, 22, 32, 0, 1, 2, 3, 4, 10, 32, 10, 32, 10, 32, 32, 32, 32]
n = [-0.23872489924521e3, 0.40421188637945e3, 0.11349746881718e3,
-0.58457616048039e1, -0.15285482413140e-3, -0.10866707695377e-5,
-0.1339174487... | def _Backward1_T_Ph(P, h) | Backward equation for region 1, T=f(P,h)
Parameters
----------
P : float
Pressure, [MPa]
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
T : float
Temperature, [K]
References
----------
IAPWS, Revised Release on the IAPWS Industrial Formulation 199... | 4.390492 | 4.483884 | 0.979172 |
I = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 5]
J = [0, 1, 2, 4, 5, 6, 8, 14, 0, 1, 4, 6, 0, 1, 10, 4, 1, 4, 0]
n = [-0.691997014660582, -0.183612548787560e2, -0.928332409297335e1,
0.659639569909906e2, -0.162060388912024e2, 0.450620017338667e3,
0.854680678224170e3, 0.607... | def _Backward1_P_hs(h, s) | Backward equation for region 1, P=f(h,s)
Parameters
----------
h : float
Specific enthalpy, [kJ/kg]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
P : float
Pressure, [MPa]
References
----------
IAPWS, Revised Supplementary Release on Backward Equ... | 4.66144 | 4.835889 | 0.963926 |
Jo = [0, 1, -5, -4, -3, -2, -1, 2, 3]
no = [-0.96927686500217E+01, 0.10086655968018E+02, -0.56087911283020E-02,
0.71452738081455E-01, -0.40710498223928E+00, 0.14240819171444E+01,
-0.43839511319450E+01, -0.28408632460772E+00, 0.21268463753307E-01]
go = log(Pr)
gop = Pr**-1
go... | def Region2_cp0(Tr, Pr) | Ideal properties for Region 2
Parameters
----------
Tr : float
Reduced temperature, [-]
Pr : float
Reduced pressure, [-]
Returns
-------
prop : array
Array with ideal Gibbs energy partial derivatives:
* g: Ideal Specific Gibbs energy [kJ/kg]
... | 5.046224 | 5.06741 | 0.995819 |
smin = _Region2(_TSat_P(4), 4)["s"]
smax = _Region2(1073.15, 4)["s"]
if s < smin:
h = 0
elif s > smax:
h = 5000
else:
h = -0.349898083432139e4 + 0.257560716905876e4*s - \
0.421073558227969e3*s**2+0.276349063799944e2*s**3
return h | def _hab_s(s) | Define the boundary between Region 2a and 2b, h=f(s)
Parameters
----------
s : float
Specific entropy, [kJ/kgK]
Returns
-------
h : float
Specific enthalpy, [kJ/kg]
References
----------
IAPWS, Revised Supplementary Release on Backward Equations for Pressure
as... | 6.952011 | 7.081943 | 0.981653 |
if P <= 4:
T = _Backward2a_T_Ph(P, h)
elif 4 < P <= 6.546699678:
T = _Backward2b_T_Ph(P, h)
else:
hf = _hbc_P(P)
if h >= hf:
T = _Backward2b_T_Ph(P, h)
else:
T = _Backward2c_T_Ph(P, h)
if P <= 22.064:
Tsat = _TSat_P(P)
... | def _Backward2_T_Ph(P, h) | Backward equation for region 2, T=f(P,h)
Parameters
----------
P : float
Pressure, [MPa]
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
T : float
Temperature, [K] | 3.356407 | 3.377023 | 0.993895 |
if P <= 4:
T = _Backward2a_T_Ps(P, s)
elif s >= 5.85:
T = _Backward2b_T_Ps(P, s)
else:
T = _Backward2c_T_Ps(P, s)
if P <= 22.064:
Tsat = _TSat_P(P)
T = max(Tsat, T)
return T | def _Backward2_T_Ps(P, s) | Backward equation for region 2, T=f(P,s)
Parameters
----------
P : float
Pressure, [MPa]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
T : float
Temperature, [K] | 3.35488 | 3.512495 | 0.955127 |
sfbc = 5.85
hamin = _hab_s(s)
if h <= hamin:
P = _Backward2a_P_hs(h, s)
elif s >= sfbc:
P = _Backward2b_P_hs(h, s)
else:
P = _Backward2c_P_hs(h, s)
return P | def _Backward2_P_hs(h, s) | Backward equation for region 2, P=f(h,s)
Parameters
----------
h : float
Specific enthalpy, [kJ/kg]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
P : float
Pressure, [MPa] | 4.059367 | 4.321452 | 0.939353 |
I = [0, 1, 2, -1, -2]
n = [0.154793642129415e4, -0.187661219490113e3, 0.213144632222113e2,
-0.191887498864292e4, 0.918419702359447e3]
Pr = P/1
T = 0
for i, ni in zip(I, n):
T += ni * log(Pr)**i
return T | def _tab_P(P) | Define the boundary between Region 3a-3b, T=f(P)
Parameters
----------
P : float
Pressure, [MPa]
Returns
-------
T : float
Temperature, [K]
References
----------
IAPWS, Revised Supplementary Release on Backward Equations for Specific
Volume as a Function of Pre... | 6.275052 | 6.959684 | 0.901629 |
hf = _h_3ab(P)
if h <= hf:
return _Backward3a_v_Ph(P, h)
else:
return _Backward3b_v_Ph(P, h) | def _Backward3_v_Ph(P, h) | Backward equation for region 3, v=f(P,h)
Parameters
----------
P : float
Pressure, [MPa]
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
v : float
Specific volume, [m³/kg] | 3.790452 | 5.228876 | 0.724908 |
hf = _h_3ab(P)
if h <= hf:
T = _Backward3a_T_Ph(P, h)
else:
T = _Backward3b_T_Ph(P, h)
return T | def _Backward3_T_Ph(P, h) | Backward equation for region 3, T=f(P,h)
Parameters
----------
P : float
Pressure, [MPa]
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
T : float
Temperature, [K] | 3.811208 | 4.788145 | 0.795967 |
if s <= sc:
return _Backward3a_v_Ps(P, s)
else:
return _Backward3b_v_Ps(P, s) | def _Backward3_v_Ps(P, s) | Backward equation for region 3, v=f(P,s)
Parameters
----------
P : float
Pressure, [MPa]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
v : float
Specific volume, [m³/kg] | 3.05034 | 4.506558 | 0.676867 |
sc = 4.41202148223476
if s <= sc:
T = _Backward3a_T_Ps(P, s)
else:
T = _Backward3b_T_Ps(P, s)
return T | def _Backward3_T_Ps(P, s) | Backward equation for region 3, T=f(P,s)
Parameters
----------
P : float
Pressure, [MPa]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
T : float
Temperature, [K] | 4.419693 | 5.088648 | 0.86854 |
sc = 4.41202148223476
if s <= sc:
return _Backward3a_P_hs(h, s)
else:
return _Backward3b_P_hs(h, s) | def _Backward3_P_hs(h, s) | Backward equation for region 3, P=f(h,s)
Parameters
----------
h : float
Specific enthalpy, [kJ/kg]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
P : float
Pressure, [MPa] | 4.515633 | 5.601849 | 0.806097 |
if x == 0:
if P < 19.00881189:
region = "c"
elif P < 21.0434:
region = "s"
elif P < 21.9316:
region = "u"
else:
region = "y"
else:
if P < 20.5:
region = "t"
elif P < 21.0434:
region = "r"... | def _Backward3_sat_v_P(P, T, x) | Backward equation for region 3 for saturated state, vs=f(P,x)
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
x : integer
Vapor quality, [-]
Returns
-------
v : float
Specific volume, [m³/kg]
Notes
-----
The vapor ... | 3.438508 | 3.846781 | 0.893867 |
T = _TSat_P(P)
if T > 623.15:
rhol = 1./_Backward3_sat_v_P(P, T, 0)
P1 = _Region3(rhol, T)
rhov = 1./_Backward3_sat_v_P(P, T, 1)
P2 = _Region3(rhov, T)
else:
P1 = _Region1(T, P)
P2 = _Region2(T, P)
propiedades = {}
propiedades["T"] = T
propie... | def _Region4(P, x) | Basic equation for region 4
Parameters
----------
P : float
Pressure, [MPa]
x : float
Vapor quality, [-]
Returns
-------
prop : dict
Dict with calculated properties. The available properties are:
* T: Saturated temperature, [K]
* P: Saturate... | 2.565558 | 2.630445 | 0.975332 |
region = None
if 1073.15 < T <= 2273.15 and Pmin <= P <= 50:
region = 5
elif Pmin <= P <= Ps_623:
Tsat = _TSat_P(P)
if 273.15 <= T <= Tsat:
region = 1
elif Tsat < T <= 1073.15:
region = 2
elif Ps_623 < P <= 100:
T_b23 = _t_P(P)
... | def _Bound_TP(T, P) | Region definition for input T and P
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
Returns
-------
region : float
IAPWS-97 region code
References
----------
Wagner, W; Kretzschmar, H-J: International Steam Tables: Properties ... | 2.897358 | 3.075604 | 0.942045 |
region = None
if Pmin <= P <= Ps_623:
h14 = _Region1(_TSat_P(P), P)["h"]
h24 = _Region2(_TSat_P(P), P)["h"]
h25 = _Region2(1073.15, P)["h"]
hmin = _Region1(273.15, P)["h"]
hmax = _Region5(2273.15, P)["h"]
if hmin <= h <= h14:
region = 1
el... | def _Bound_Ph(P, h) | Region definition for input P y h
Parameters
----------
P : float
Pressure, [MPa]
h : float
Specific enthalpy, [kJ/kg]
Returns
-------
region : float
IAPWS-97 region code
References
----------
Wagner, W; Kretzschmar, H-J: International Steam Tables: Pro... | 1.948719 | 2.025245 | 0.962214 |
region = None
if Pmin <= P <= Ps_623:
smin = _Region1(273.15, P)["s"]
s14 = _Region1(_TSat_P(P), P)["s"]
s24 = _Region2(_TSat_P(P), P)["s"]
s25 = _Region2(1073.15, P)["s"]
smax = _Region5(2273.15, P)["s"]
if smin <= s <= s14:
region = 1
el... | def _Bound_Ps(P, s) | Region definition for input P and s
Parameters
----------
P : float
Pressure, [MPa]
s : float
Specific entropy, [kJ/kgK]
Returns
-------
region : float
IAPWS-97 region code
References
----------
Wagner, W; Kretzschmar, H-J: International Steam Tables: P... | 1.933741 | 1.969425 | 0.981881 |
if T <= 1073.15:
Tr = 540/T
Pr = P/1.
go, gop, gopp, got, gott, gopt = Region2_cp0(Tr, Pr)
else:
Tr = 1000/T
Pr = P/1.
go, gop, gopp, got, gott, gopt = Region5_cp0(Tr, Pr)
prop0 = {}
prop0["v"] = Pr*gop*R*T/P/1000
prop0["h"] = Tr*got*R*T
prop... | def prop0(T, P) | Ideal gas properties
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
Returns
-------
prop : dict
Dict with calculated properties. The available properties are:
* v: Specific volume, [m³/kg]
* h: Specific enthalpy, ... | 4.411794 | 4.11308 | 1.072626 |
self._thermo = ""
if self.kwargs["T"] and self.kwargs["P"]:
self._thermo = "TP"
elif self.kwargs["P"] and self.kwargs["h"] is not None:
self._thermo = "Ph"
elif self.kwargs["P"] and self.kwargs["s"] is not None:
self._thermo = "Ps"
# T... | def calculable(self) | Check if class is calculable by its kwargs | 2.137002 | 2.017005 | 1.059493 |
return deriv_G(self, z, x, y, fase) | def derivative(self, z, x, y, fase) | Wrapper derivative for custom derived properties
where x, y, z can be: P, T, v, u, h, s, g, a | 6.853547 | 6.316701 | 1.084988 |
if 0 <= x <= 0.33367:
Ttr = 273.16*(1-0.3439823*x-1.3274271*x**2-274.973*x**3)
elif 0.33367 < x <= 0.58396:
Ttr = 193.549*(1-4.987368*(x-0.5)**2)
elif 0.58396 < x <= 0.81473:
Ttr = 194.38*(1-4.886151*(x-2/3)**2+10.37298*(x-2/3)**3)
elif 0.81473 < x <= 1:
Ttr = 195.49... | def Ttr(x) | Equation for the triple point of ammonia-water mixture
Parameters
----------
x : float
Mole fraction of ammonia in mixture, [mol/mol]
Returns
-------
Ttr : float
Triple point temperature, [K]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
... | 4.058699 | 4.282547 | 0.94773 |
# FIXME: The values are good, bad difer by 1%, a error I can find
# In Pressure happen and only use fird
M = (1-x)*IAPWS95.M + x*NH3.M
R = 8.314471/M
phio = self._phi0(rho, T, x)
fio = phio["fio"]
tau0 = phio["tau"]
fiot = phio["fiot"]
f... | def _prop(self, rho, T, x) | Thermodynamic properties of ammonia-water mixtures
Parameters
----------
T : float
Temperature [K]
rho : float
Density [kg/m³]
x : float
Mole fraction of ammonia in mixture [mol/mol]
Returns
-------
prop : dict
... | 4.817029 | 4.144177 | 1.162361 |
def func_wrapper(ds):
return grid_attrs_to_aospy_names(func(ds, **kwargs), grid_attrs)
return func_wrapper | def _preprocess_and_rename_grid_attrs(func, grid_attrs=None, **kwargs) | Call a custom preprocessing method first then rename grid attrs.
This wrapper is needed to generate a single function to pass to the
``preprocesss`` of xr.open_mfdataset. It makes sure that the
user-specified preprocess function is called on the loaded Dataset before
aospy's is applied. An example fo... | 8.340243 | 3.777884 | 2.207649 |
if grid_attrs is None:
grid_attrs = {}
# Override GRID_ATTRS with entries in grid_attrs
attrs = GRID_ATTRS.copy()
for k, v in grid_attrs.items():
if k not in attrs:
raise ValueError(
'Unrecognized internal name, {!r}, specified for a custom '
... | def grid_attrs_to_aospy_names(data, grid_attrs=None) | Rename grid attributes to be consistent with aospy conventions.
Search all of the dataset's coords and dims looking for matches to known
grid attribute names; any that are found subsequently get renamed to the
aospy name as specified in ``aospy.internal_names.GRID_ATTRS``.
Also forces any renamed grid... | 3.736628 | 3.733676 | 1.000791 |
grid_attrs_in_ds = set(GRID_ATTRS.keys()).intersection(
set(ds.coords) | set(ds.data_vars))
ds = ds.set_coords(grid_attrs_in_ds)
return ds | def set_grid_attrs_as_coords(ds) | Set available grid attributes as coordinates in a given Dataset.
Grid attributes are assumed to have their internal aospy names. Grid
attributes are set as coordinates, such that they are carried by all
selected DataArrays with overlapping index dimensions.
Parameters
----------
ds : Dataset
... | 3.298058 | 4.712453 | 0.69986 |
if da.dtype == np.float32:
logging.warning('Datapoints were stored using the np.float32 datatype.'
'For accurate reduction operations using bottleneck, '
'datapoints are being cast to the np.float64 datatype.'
' For more informatio... | def _maybe_cast_to_float64(da) | Cast DataArrays to np.float64 if they are of type np.float32.
Parameters
----------
da : xr.DataArray
Input DataArray
Returns
-------
DataArray | 5.302079 | 5.850239 | 0.906301 |
for name in var.names:
try:
da = ds[name].rename(var.name)
if upcast_float32:
return _maybe_cast_to_float64(da)
else:
return da
except KeyError:
pass
msg = '{0} not found among names: {1} in\n{2}'.format(var, va... | def _sel_var(ds, var, upcast_float32=True) | Select the specified variable by trying all possible alternative names.
Parameters
----------
ds : Dataset
Dataset possibly containing var
var : aospy.Var
Variable to find data for
upcast_float32 : bool (default True)
Whether to cast a float32 DataArray up to float64
Re... | 3.696808 | 3.202641 | 1.1543 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.