encomp package¶
Submodules¶
encomp.constants module¶
Contains constants used elsewhere in the library.
- class Constants[source]¶
Bases:
objectCollection of constants. Use a single instance of this class to refer to these constants.
- R = <Quantity(8.3144598, 'kilogram * meter ** 2 / kelvin / mole / second ** 2')>¶
- SIGMA = <Quantity(5.670374419e-08, 'watt / meter ** 2 / kelvin ** 4')>¶
- normal_conditions_pressure = <Quantity(1.0, 'standard_atmosphere')>¶
- normal_conditions_temperature = <Quantity(273.15, 'kelvin')>¶
- standard_conditions_pressure = <Quantity(1.0, 'standard_atmosphere')>¶
- standard_conditions_temperature = <Quantity(288.15, 'kelvin')>¶
encomp.context module¶
- quantity_format(fmt='compact')[source]¶
Context manager version of
encomp.units.set_quantity_format()that resets to the previous value afterwards.- Parameters:
fmt (str) – Unit format string: one of
'~P', '~L', '~H', '~Lx'. Also accepts aliases:'compact': '~P'and'siunitx': '~Lx'.- Return type:
Iterator[None]
- silence_stdout()[source]¶
Context manager that redirects
stdouttoos.devnull. This is used suppress functions that print tostdout.- Return type:
Iterator[None]
encomp.conversion module¶
encomp.fluids module¶
Classes and functions relating to fluid properties. Uses CoolProp as backend.
Note
This module has the same name as the package fluids,
which is also included when installing encomp.
Avoid importing as a standalone module
(from encomp import fluids) to differentiate between these.
- class CoolPropFluid(name, **kwargs)[source]¶
Bases:
ABC,Generic[MT]Base class that represents a fluid (pure or mixture, gas or liquid). Uses CoolProp as backend to determine fluid properties.
This class should not be used directly, since it does not contain a fixed point to determine fluid properties (temperature, pressure, enthalpy, entropy, …). Define a subclass of
encomp.fluids.CoolPropFluidthat implements the__init__method (this method must set instance attributesnameandpoints).Fluid names for pure fluids are not case-sensitive, but the mixture names are. The following fluid names are recognized by CoolProp:
Pure
1-Butene,Acetone,Air,Ammonia,Argon,Benzene,CarbonDioxide,CarbonMonoxide, CarbonylSulfide,CycloHexane,CycloPropane,Cyclopentane,D4,D5,D6,Deuterium, Dichloroethane,DiethylEther,DimethylCarbonate,DimethylEther,Ethane, Ethanol,EthylBenzene,Ethylene,EthyleneOxide,Fluorine,HFE143m,HeavyWater, Helium,Hydrogen,HydrogenChloride,HydrogenSulfide,IsoButane,IsoButene, Isohexane,Isopentane,Krypton,MD2M,MD3M,MD4M,MDM,MM,Methane,Methanol, MethylLinoleate,MethylLinolenate,MethylOleate,MethylPalmitate,MethylStearate, Neon,Neopentane,Nitrogen,NitrousOxide,Novec649,OrthoDeuterium,OrthoHydrogen, Oxygen,ParaDeuterium,ParaHydrogen,Propylene,Propyne,R11,R113,R114,R115, R116,R12,R123,R1233zd(E),R1234yf,R1234ze(E),R1234ze(Z),R124,R1243zf, R125,R13,R134a,R13I1,R14,R141b,R142b,R143a,R152A,R161,R21,R218,R22,R227EA, R23,R236EA,R236FA,R245ca,R245fa,R32,R365MFC,R40,R404A,R407C,R41,R410A, R507A,RC318,SES36,SulfurDioxide,SulfurHexafluoride,Toluene,Water,Xenon, cis-2-Butene,m-Xylene,n-Butane,n-Decane,n-Dodecane,n-Heptane,n-Hexane, n-Nonane,n-Octane,n-Pentane,n-Propane,n-Undecane,o-Xylene,p-Xylene,trans-2-Butene
Incompressible pure
INCOMP::AS10,INCOMP::AS20,INCOMP::AS30,INCOMP::AS40,INCOMP::AS55,INCOMP::DEB, INCOMP::DSF,INCOMP::DowJ,INCOMP::DowJ2,INCOMP::DowQ,INCOMP::DowQ2,INCOMP::HC10, INCOMP::HC20,INCOMP::HC30,INCOMP::HC40,INCOMP::HC50,INCOMP::HCB,INCOMP::HCM, INCOMP::HFE,INCOMP::HFE2,INCOMP::HY20,INCOMP::HY30,INCOMP::HY40,INCOMP::HY45, INCOMP::HY50,INCOMP::NBS,INCOMP::NaK,INCOMP::PBB,INCOMP::PCL,INCOMP::PCR, INCOMP::PGLT,INCOMP::PHE,INCOMP::PHR,INCOMP::PLR,INCOMP::PMR,INCOMP::PMS1, INCOMP::PMS2,INCOMP::PNF,INCOMP::PNF2,INCOMP::S800,INCOMP::SAB,INCOMP::T66, INCOMP::T72,INCOMP::TCO,INCOMP::TD12,INCOMP::TVP1,INCOMP::TVP1869,INCOMP::TX22, INCOMP::TY10,INCOMP::TY15,INCOMP::TY20,INCOMP::TY24,INCOMP::Water,INCOMP::XLT, INCOMP::XLT2,INCOMP::ZS10,INCOMP::ZS25,INCOMP::ZS40,INCOMP::ZS45,INCOMP::ZS55
Incompressible mixtures
INCOMP::FRE,INCOMP::IceEA,INCOMP::IceNA,INCOMP::IcePG,INCOMP::LiBr,INCOMP::MAM, INCOMP::MAM2,INCOMP::MCA,INCOMP::MCA2,INCOMP::MEA,INCOMP::MEA2,INCOMP::MEG, INCOMP::MEG2,INCOMP::MGL,INCOMP::MGL2,INCOMP::MITSW,INCOMP::MKA,INCOMP::MKA2, INCOMP::MKC,INCOMP::MKC2,INCOMP::MKF,INCOMP::MLI,INCOMP::MMA,INCOMP::MMA2, INCOMP::MMG,INCOMP::MMG2,INCOMP::MNA,INCOMP::MNA2,INCOMP::MPG,INCOMP::MPG2, INCOMP::VCA,INCOMP::VKC,INCOMP::VMA,INCOMP::VMG,INCOMP::VNA,INCOMP::AEG, INCOMP::AKF,INCOMP::AL,INCOMP::AN,INCOMP::APG,INCOMP::GKN,INCOMP::PK2, INCOMP::PKL,INCOMP::ZAC,INCOMP::ZFC,INCOMP::ZLC,INCOMP::ZM,INCOMP::ZMC
Mixtures
AIR.MIX,AMARILLO.MIX,Air.mix,Amarillo.mix,EKOFISK.MIX,Ekofisk.mix,GULFCOAST.MIX, GULFCOASTGAS(NIST1).MIX,GulfCoast.mix,GulfCoastGas(NIST1).mix,HIGHCO2.MIX, HIGHN2.MIX,HighCO2.mix,HighN2.mix,NATURALGASSAMPLE.MIX,NaturalGasSample.mix, R401A.MIX,R401A.mix,R401B.MIX,R401B.mix,R401C.MIX,R401C.mix,R402A.MIX,R402A.mix, R402B.MIX,R402B.mix,R403A.MIX,R403A.mix,R403B.MIX,R403B.mix,R404A.MIX,R404A.mix, R405A.MIX,R405A.mix,R406A.MIX,R406A.mix,R407A.MIX,R407A.mix,R407B.MIX,R407B.mix, R407C.MIX,R407C.mix,R407D.MIX,R407D.mix,R407E.MIX,R407E.mix,R407F.MIX,R407F.mix, R408A.MIX,R408A.mix,R409A.MIX,R409A.mix,R409B.MIX,R409B.mix,R410A.MIX,R410A.mix, R410B.MIX,R410B.mix,R411A.MIX,R411A.mix,R411B.MIX,R411B.mix,R412A.MIX,R412A.mix, R413A.MIX,R413A.mix,R414A.MIX,R414A.mix,R414B.MIX,R414B.mix,R415A.MIX,R415A.mix, R415B.MIX,R415B.mix,R416A.MIX,R416A.mix,R417A.MIX,R417A.mix,R417B.MIX,R417B.mix, R417C.MIX,R417C.mix,R418A.MIX,R418A.mix,R419A.MIX,R419A.mix,R419B.MIX,R419B.mix, R420A.MIX,R420A.mix,R421A.MIX,R421A.mix,R421B.MIX,R421B.mix,R422A.MIX,R422A.mix, R422B.MIX,R422B.mix,R422C.MIX,R422C.mix,R422D.MIX,R422D.mix,R422E.MIX,R422E.mix, R423A.MIX,R423A.mix,R424A.MIX,R424A.mix,R425A.MIX,R425A.mix,R426A.MIX,R426A.mix, R427A.MIX,R427A.mix,R428A.MIX,R428A.mix,R429A.MIX,R429A.mix,R430A.MIX,R430A.mix, R431A.MIX,R431A.mix,R432A.MIX,R432A.mix,R433A.MIX,R433A.mix,R433B.MIX,R433B.mix, R433C.MIX,R433C.mix,R434A.MIX,R434A.mix,R435A.MIX,R435A.mix,R436A.MIX,R436A.mix, R436B.MIX,R436B.mix,R437A.MIX,R437A.mix,R438A.MIX,R438A.mix,R439A.MIX,R439A.mix, R440A.MIX,R440A.mix,R441A.MIX,R441A.mix,R442A.MIX,R442A.mix,R443A.MIX,R443A.mix, R444A.MIX,R444A.mix,R444B.MIX,R444B.mix,R445A.MIX,R445A.mix,R446A.MIX,R446A.mix, R447A.MIX,R447A.mix,R448A.MIX,R448A.mix,R449A.MIX,R449A.mix,R449B.MIX,R449B.mix, R450A.MIX,R450A.mix,R451A.MIX,R451A.mix,R451B.MIX,R451B.mix,R452A.MIX,R452A.mix, R453A.MIX,R453A.mix,R454A.MIX,R454A.mix,R454B.MIX,R454B.mix,R500.MIX,R500.mix, R501.MIX,R501.mix,R502.MIX,R502.mix,R503.MIX,R503.mix,R504.MIX,R504.mix,R507A.MIX, R507A.mix,R508A.MIX,R508A.mix,R508B.MIX,R508B.mix,R509A.MIX,R509A.mix,R510A.MIX, R510A.mix,R511A.MIX,R511A.mix,R512A.MIX,R512A.mix,R513A.MIX,R513A.mix, TYPICALNATURALGAS.MIX,TypicalNaturalGas.mix
Refer to the CoolProp documentation for more information:
http://www.coolprop.org/fluid_properties/PurePseudoPure.html#list-of-fluids
http://www.coolprop.org/fluid_properties/Mixtures.html#binary-pairs
http://www.coolprop.org/fluid_properties/Incompressibles.html#the-different-fluids
table-of-inputs-outputs-to-hapropssi
The names
WaterandHEOS::Wateruses the formulation defined by IAPWS-95. Use the nameIF97::Waterto instead use the slightly faster (but less accurate) IAPWS-97 formulation. In most cases, the difference between IAPWS-95 and IAPWS-97 is negligible. Read CoolProp’s introduction about water properties for more information.- Parameters:
name (CName) –
The name of the fluid, same name as is used by CoolProp. Include the
INCOMP::prefix and potential mixing ratio for incompressible mixtures.Examples:
INCOMP::MITSW[0.05]: seawater with 5 mass-percent salt.INCOMP::MPG[0.5]: 50 % ethylene glycolINCOMP::T66: Therminol 66 (https://www.therminol.com/product/71093438)
kwargs (Quantity[UnknownDimensionality] | Quantity[UnknownDimensionality, float])
- ALL_PROPERTIES: set[Annotated[str, 'CoolProp property name']] = {'A', 'C', 'CONDUCTIVITY', 'CP0MASS', 'CP0MOLAR', 'CPMASS', 'CPMOLAR', 'CVMASS', 'CVMOLAR', 'Cp0mass', 'Cp0molar', 'Cpmass', 'Cpmolar', 'Cvmass', 'Cvmolar', 'D', 'DELTA', 'DIPOLE_MOMENT', 'DMASS', 'DMOLAR', 'Delta', 'Dmass', 'Dmolar', 'G', 'GAMES', 'GAS_CONSTANT', 'GMOLAR', 'GMOLAR_RESIDUAL', 'Gmass', 'Gmolar', 'Gmolar_residual', 'H', 'HELMHOLTZMASS', 'HELMHOLTZMOLAR', 'HMASS', 'HMOLAR', 'HMOLAR_RESIDUAL', 'Helmholtzmass', 'Helmholtzmolar', 'Hmass', 'Hmolar', 'Hmolar_residual', 'I', 'ISENTROPIC_EXPANSION_COEFFICIENT', 'ISOBARIC_EXPANSION_COEFFICIENT', 'ISOTHERMAL_COMPRESSIBILITY', 'L', 'M', 'MOLARMASS', 'MOLAR_MASS', 'MOLEMASS', 'O', 'P', 'PCRIT', 'PHASE', 'PMAX', 'PMIN', 'PRANDTL', 'PTRIPLE', 'P_CRITICAL', 'P_MAX', 'P_MIN', 'P_REDUCING', 'P_TRIPLE', 'P_max', 'P_min', 'Pcrit', 'Phase', 'Prandtl', 'Q', 'RHOCRIT', 'RHOMASS_CRITICAL', 'RHOMASS_REDUCING', 'RHOMOLAR_CRITICAL', 'RHOMOLAR_REDUCING', 'S', 'SMASS', 'SMOLAR', 'SMOLAR_RESIDUAL', 'SPEED_OF_SOUND', 'SURFACE_TENSION', 'Smass', 'Smolar', 'Smolar_residual', 'T', 'TAU', 'TCRIT', 'TMAX', 'TMIN', 'TTRIPLE', 'T_CRITICAL', 'T_FREEZE', 'T_MAX', 'T_MIN', 'T_REDUCING', 'T_TRIPLE', 'T_critical', 'T_freeze', 'T_max', 'T_min', 'T_reducing', 'T_triple', 'Tau', 'Tcrit', 'Tmax', 'Tmin', 'Ttriple', 'U', 'UMASS', 'UMOLAR', 'Umass', 'Umolar', 'V', 'VISCOSITY', 'Z', 'conductivity', 'dipole_moment', 'gas_constant', 'isentropic_expansion_coefficient', 'isobaric_expansion_coefficient', 'isothermal_compressibility', 'molar_mass', 'molarmass', 'molemass', 'p_critical', 'p_reducing', 'p_triple', 'pcrit', 'pmax', 'pmin', 'ptriple', 'rhocrit', 'rhomass_critical', 'rhomass_reducing', 'rhomolar_critical', 'rhomolar_reducing', 'speed_of_sound', 'surface_tension', 'viscosity'}¶
- BACKEND: ClassVar[dict[Literal['backend'], Callable[[...], float | ndarray[tuple[int], dtype[float64]]]]] = {'backend': <cyfunction PropsSI>}¶
- COOLPROP_ERROR_MESSAGES = ('is not valid for keyed_output', 'is not valid for trivial_keyed_output', "For now, we don't support", 'is not implemented for this backend', 'is only defined within the two-phase region', 'failed ungracefully', 'value to T_phase_determination_pure_or_pseudopure is invalid', "Brent's method f(b) is NAN", 'do not bracket the root', 'was unable to find a solution for', 'is outside the range of validity')¶
- PHASES: dict[float, str] = {0.0: 'Liquid', 1.0: 'Supercritical fluid', 2.0: 'Supercritical gas', 3.0: 'Supercritical liquid', 5.0: 'Gas', 6.0: 'Two-phase', 8.0: 'Not imposed'}¶
- PROPERTY_MAP: dict[tuple[Annotated[str, 'CoolProp property name'], ...], tuple[Annotated[str, 'Unit string'], str]] = {('A', 'SPEED_OF_SOUND', 'speed_of_sound'): ('m/s', 'Speed of sound'), ('C', 'CPMASS', 'Cpmass'): ('J/kg/K', 'Mass specific constant pressure specific heat'), ('CONDUCTIVITY', 'L', 'conductivity'): ('W/m/K', 'Thermal conductivity'), ('CP0MASS', 'Cp0mass'): ('J/kg/K', 'Ideal gas mass specific constant pressure specific heat'), ('CP0MOLAR', 'Cp0molar'): ('J/mol/K', 'Ideal gas molar specific constant pressure specific heat'), ('CPMOLAR', 'Cpmolar'): ('J/mol/K', 'Molar specific constant pressure specific heat'), ('CVMASS', 'Cvmass', 'O'): ('J/kg/K', 'Mass specific constant volume specific heat'), ('CVMOLAR', 'Cvmolar'): ('J/mol/K', 'Molar specific constant volume specific heat'), ('D', 'DMASS', 'Dmass'): ('kg/m³', 'Mass density'), ('DELTA', 'Delta'): ('dimensionless', 'Reduced density (rho/rhoc)'), ('DIPOLE_MOMENT', 'dipole_moment'): ('C*m', 'Dipole moment'), ('DMOLAR', 'Dmolar'): ('mol/m³', 'Molar density'), ('G', 'GAMES', 'Gmass'): ('J/kg', 'Mass specific Gibbs energy'), ('GAS_CONSTANT', 'gas_constant'): ('J/mol/K', 'Molar gas constant'), ('GMOLAR', 'Gmolar'): ('J/mol', 'Molar specific Gibbs energy'), ('GMOLAR_RESIDUAL', 'Gmolar_residual'): ('J/mol/K', 'Residual molar Gibbs energy'), ('H', 'HMASS', 'Hmass'): ('J/kg', 'Mass specific enthalpy'), ('HELMHOLTZMASS', 'Helmholtzmass'): ('J/kg', 'Mass specific Helmholtz energy'), ('HELMHOLTZMOLAR', 'Helmholtzmolar'): ('J/mol', 'Molar specific Helmholtz energy'), ('HMOLAR', 'Hmolar'): ('J/mol', 'Molar specific enthalpy'), ('HMOLAR_RESIDUAL', 'Hmolar_residual'): ('J/mol/K', 'Residual molar enthalpy'), ('I', 'SURFACE_TENSION', 'surface_tension'): ('N/m', 'Surface tension'), ('ISENTROPIC_EXPANSION_COEFFICIENT', 'isentropic_expansion_coefficient'): ('dimensionless', 'Isentropic expansion coefficient'), ('ISOBARIC_EXPANSION_COEFFICIENT', 'isobaric_expansion_coefficient'): ('1/K', 'Isobaric expansion coefficient'), ('ISOTHERMAL_COMPRESSIBILITY', 'isothermal_compressibility'): ('1/Pa', 'Isothermal compressibility'), ('M', 'MOLARMASS', 'MOLAR_MASS', 'MOLEMASS', 'molar_mass', 'molarmass', 'molemass'): ('kg/mol', 'Molar mass'), ('P',): ('Pa', 'Pressure'), ('PCRIT', 'P_CRITICAL', 'Pcrit', 'p_critical', 'pcrit'): ('Pa', 'Pressure at the critical point'), ('PHASE', 'Phase'): ('dimensionless', 'Phase index as a float'), ('PMAX', 'P_MAX', 'P_max', 'pmax'): ('Pa', 'Maximum pressure limit'), ('PMIN', 'P_MIN', 'P_min', 'pmin'): ('Pa', 'Minimum pressure limit'), ('PRANDTL', 'Prandtl'): ('dimensionless', 'Prandtl number'), ('PTRIPLE', 'P_TRIPLE', 'p_triple', 'ptriple'): ('Pa', 'Pressure at the triple point (pure only)'), ('P_REDUCING', 'p_reducing'): ('Pa', 'Pressure at the reducing point'), ('Q',): ('dimensionless', 'Mass vapor quality'), ('RHOCRIT', 'RHOMASS_CRITICAL', 'rhocrit', 'rhomass_critical'): ('kg/m³', 'Mass density at critical point'), ('RHOMASS_REDUCING', 'rhomass_reducing'): ('kg/m³', 'Mass density at reducing point'), ('RHOMOLAR_CRITICAL', 'rhomolar_critical'): ('mol/m³', 'Molar density at critical point'), ('RHOMOLAR_REDUCING', 'rhomolar_reducing'): ('mol/m³', 'Molar density at reducing point'), ('S', 'SMASS', 'Smass'): ('J/kg/K', 'Mass specific entropy'), ('SMOLAR', 'Smolar'): ('J/mol/K', 'Molar specific entropy'), ('SMOLAR_RESIDUAL', 'Smolar_residual'): ('J/mol/K', 'Residual molar entropy'), ('T',): ('K', 'Temperature'), ('TAU', 'Tau'): ('dimensionless', 'Reciprocal reduced temperature (Tc/T)'), ('TCRIT', 'T_CRITICAL', 'T_critical', 'Tcrit'): ('K', 'Temperature at the critical point'), ('TMAX', 'T_MAX', 'T_max', 'Tmax'): ('K', 'Maximum temperature limit'), ('TMIN', 'T_MIN', 'T_min', 'Tmin'): ('K', 'Minimum temperature limit'), ('TTRIPLE', 'T_TRIPLE', 'T_triple', 'Ttriple'): ('K', 'Temperature at the triple point'), ('T_FREEZE', 'T_freeze'): ('K', 'Freezing temperature for incompressible solutions'), ('T_REDUCING', 'T_reducing'): ('K', 'Temperature at the reducing point'), ('U', 'UMASS', 'Umass'): ('J/kg', 'Mass specific internal energy'), ('UMOLAR', 'Umolar'): ('J/mol', 'Molar specific internal energy'), ('V', 'VISCOSITY', 'viscosity'): ('Pa*s', 'Viscosity'), ('Z',): ('dimensionless', 'Compressibility factor')}¶
- REPR_PROPERTIES: tuple[tuple[Annotated[str, 'CoolProp property name'], str], ...] = (('P', '.0f'), ('T', '.1f'), ('D', '.1f'), ('V', '.2g'))¶
- RETURN_UNITS: dict[Annotated[str, 'CoolProp property name'], Annotated[str, 'Unit string']] = {'C': 'kJ/kg/K', 'H': 'kJ/kg', 'P': 'kPa', 'T': '°C', 'TMAX': '°C', 'TMIN': '°C', 'TTRIPLE': '°C', 'T_FREEZE': '°C', 'V': 'cP'}¶
- check_exception(prop, e)[source]¶
- Return type:
None- Parameters:
prop (Annotated[str, 'CoolProp property name'])
e (ValueError)
- classmethod check_inputs(kwargs)[source]¶
- Return type:
None- Parameters:
kwargs (dict[Annotated[str, 'CoolProp property name'], Quantity[UnknownDimensionality]])
- construct_quantity(val, output, convert_magnitude=True)[source]¶
- Return type:
Quantity[UnknownDimensionality]- Parameters:
val (float | ndarray[tuple[int], dtype[float64]] | Expr)
output (Annotated[str, 'CoolProp property name'])
convert_magnitude (bool)
- classmethod describe(prop)[source]¶
- Return type:
str- Parameters:
prop (Annotated[str, 'CoolProp property name'])
- evaluate(output, *points)[source]¶
- Return type:
float|ndarray[tuple[int],dtype[float64]] |Expr- Parameters:
output (Annotated[str, 'CoolProp property name'])
points (tuple[Annotated[str, 'CoolProp property name'], float | ndarray[tuple[int], dtype[float64]] | Expr])
- evaluate_expression(output, *points)[source]¶
- Return type:
Expr- Parameters:
output (Annotated[str, 'CoolProp property name'])
points (tuple[Annotated[str, 'CoolProp property name'], Expr])
- evaluate_multiple(output, *points)[source]¶
- Return type:
ndarray[tuple[int],dtype[float64]]- Parameters:
output (Annotated[str, 'CoolProp property name'])
points (tuple[Annotated[str, 'CoolProp property name'], ndarray[tuple[int], dtype[float64]]])
- evaluate_multiple_separately(output, props, arrs_flat_masked, N)[source]¶
- Return type:
ndarray[tuple[int],dtype[float64]]- Parameters:
output (Annotated[str, 'CoolProp property name'])
props (list[Annotated[str, 'CoolProp property name']])
arrs_flat_masked (list[ndarray[tuple[int], dtype[float64]]])
N (int)
- evaluate_single(output, *points)[source]¶
- Return type:
float- Parameters:
output (Annotated[str, 'CoolProp property name'])
points (tuple[Annotated[str, 'CoolProp property name'], float])
- get(output, points=None, convert_magnitude=True)[source]¶
Wraps the function
CoolProp.CoolProp.PropsSI, handles input and output withencomp.units.Quantityobjects.- Parameters:
output (CProperty) – Name of the output property
points (list[tuple[CProperty, Quantity[Any, MT] | Quantity[Any, float]]] | None) – Fixed state variables: name and value of the property. The number of points must match the number expected by the CoolProp backend function. If None, the points from the
__init__method are usedconvert_magnitude (bool) – Whether to convert the output to the same magnitude type as the input, by default True
- Returns:
Quantity representing the output property
- Return type:
Quantity[Any, MT]
- classmethod get_coolprop_unit(prop)[source]¶
- Return type:
- Parameters:
prop (Annotated[str, 'CoolProp property name'])
- classmethod get_prop_key(prop)[source]¶
- Return type:
tuple[str,...]- Parameters:
prop (Annotated[str, 'CoolProp property name'])
- classmethod is_valid_prop(prop)[source]¶
- Return type:
bool- Parameters:
prop (Annotated[str, 'CoolProp property name'])
- name: Annotated[str, 'CoolProp fluid name']¶
- class Fluid(name, **kwargs)[source]¶
Bases:
CoolPropFluid[MT]Represents a fluid at a fixed state, for example at a specific temperature and pressure.
- Parameters:
name (CName) – Name of the fluid
kwargs (Quantity[Any, MT]) – Values for the two fixed points. The name of the keyword argument is the CoolProp property name.
- property phase: str¶
- class HumidAir(**kwargs)[source]¶
Bases:
CoolPropFluid[MT]Interface to the CoolProp function for humid air,
CoolProp.CoolProp.HAPropsSI. Needs three fixed points instead of two.- Parameters:
kwargs (Quantity[Any, MT]) – Values for the three fixed points. The name of the keyword argument is the CoolProp property name.
- ALL_PROPERTIES: set[Annotated[str, 'CoolProp property name']] = {'B', 'C', 'CV', 'CVha', 'Cha', 'Conductivity', 'D', 'DewPoint', 'Enthalpy', 'Entropy', 'H', 'Hda', 'Hha', 'HumRat', 'K', 'M', 'Omega', 'P', 'P_w', 'R', 'RH', 'RelHum', 'S', 'Sda', 'Sha', 'T', 'T_db', 'T_dp', 'T_wb', 'Tdb', 'Tdp', 'Twb', 'V', 'Vda', 'Vha', 'Visc', 'W', 'WetBulb', 'Y', 'Z', 'cp', 'cp_ha', 'cv_ha', 'k', 'mu', 'psi_w'}¶
- BACKEND: ClassVar[dict[Literal['backend'], Callable[[...], float | ndarray[tuple[int], dtype[float64]]]]] = {'backend': <cyfunction HAPropsSI>}¶
- PROPERTY_MAP: dict[tuple[Annotated[str, 'CoolProp property name'], ...], tuple[str, str]] = {('B', 'Twb', 'T_wb', 'WetBulb'): ('K', 'Wet-Bulb Temperature'), ('C', 'cp'): ('J/kg/K', 'Mixture specific heat per unit dry air'), ('CV',): ('J/kg/K', 'Mixture specific heat at constant volume per unit dry air'), ('CVha', 'cv_ha'): ('J/kg/K', 'Mixture specific heat at constant volume per unit humid air'), ('Cha', 'cp_ha'): ('J/kg/K', 'Mixture specific heat per unit humid air'), ('D', 'Tdp', 'DewPoint', 'T_dp'): ('K', 'Dew-Point Temperature'), ('H', 'Hda', 'Enthalpy'): ('J/kg', 'Mixture enthalpy per dry air'), ('Hha',): ('J/kg', 'Mixture enthalpy per humid air'), ('K', 'k', 'Conductivity'): ('W/m/K', 'Mixture thermal conductivity'), ('M', 'Visc', 'mu'): ('Pa*s', 'Mixture viscosity'), ('P',): ('Pa', 'Pressure'), ('P_w',): ('Pa', 'Partial pressure of water vapor'), ('R', 'RH', 'RelHum'): ('dimensionless', 'Relative humidity in [0, 1]'), ('S', 'Sda', 'Entropy'): ('J/kg/K', 'Mixture entropy per unit dry air'), ('Sha',): ('J/kg/K', 'Mixture entropy per unit humid air'), ('T', 'Tdb', 'T_db'): ('K', 'Dry-Bulb Temperature'), ('V', 'Vda'): ('m³/kg', 'Mixture volume per unit dry air'), ('Vha',): ('m³/kg', 'Mixture volume per unit humid air'), ('W', 'Omega', 'HumRat'): ('dimensionless', 'Humidity Rat mass water per mass dry air'), ('Z',): ('dimensionless', 'Compressibility factor'), ('psi_w', 'Y'): ('dimensionless', 'Water mole fraction')}¶
- REPR_PROPERTIES: tuple[tuple[Annotated[str, 'CoolProp property name'], str], ...] = (('P', '.0f'), ('T', '.1f'), ('R', '.2f'), ('Vda', '.1f'), ('Vha', '.1f'), ('M', '.2g'))¶
- RETURN_UNITS: dict[Annotated[str, 'CoolProp property name'], str] = {'B': '°C', 'D': '°C', 'M': 'cP', 'P': 'kPa', 'P_w': 'kPa', 'T': '°C'}¶
- point_1: tuple[Annotated[str, 'CoolProp property name'], Quantity[UnknownDimensionality] | Quantity[UnknownDimensionality, float]]¶
- point_2: tuple[Annotated[str, 'CoolProp property name'], Quantity[UnknownDimensionality] | Quantity[UnknownDimensionality, float]]¶
- class Water(**kwargs)[source]¶
Bases:
Fluid[MT]Convenience class to access water and steam properties via CoolProp.
- Parameters:
kwargs (Quantity[Any, MT]) – Values for the two fixed points. The name of the keyword argument is the CoolProp property name.
- REPR_PROPERTIES: tuple[tuple[str, str], ...] = (('P', '.0f'), ('T', '.1f'), ('D', '.1f'), ('V', '.1f'))¶
encomp.gases module¶
Functions related to gases: normal volume to mass conversion, compressibility, etc…
Todo
Implement for humid air
- actual_volume_to_normal_volume(volume, condition, fluid_name='Air')[source]¶
Convert actual volume to normal volume.
- Parameters:
volume (Quantity[Volume, Any] | Quantity[VolumeFlow, Any]) – Input actual volume or actual volume flow
condition (tuple[Quantity[Pressure, Any], Quantity[Temperature, Any]]) – Condition at which to calculate the normal volume
fluid_name (str, optional) – Name of the fluid, by default ‘Air’
- Returns:
Corresponding normal volume or normal volume flow
- Return type:
Quantity[Volume, Any] | Quantity[VolumeFlow, Any]
- convert_gas_volume(V1, condition_1='N', condition_2='N', fluid_name='Air')[source]¶
Converts the volume \(V_1\) (at \(T_1, P_1\)) to \(V_2\) (at \(T_1, P_1\)). Uses compressibility factors from CoolProp.
The values for \(T_i, P_i\) are passed as a tuple using the parameter
conditions_i. Optionally, the literal ‘N’ or ‘S’ can be passed to indicate normal and standard conditions.- Parameters:
V1 (Quantity[Volume, Any] | Quantity[VolumeFlow, Any]) – Volume or volume flow \(V_1\) at condition 1
condition_1 (tuple[Quantity[Pressure, Any], Quantity[Temperature, Any]] |) – Literal[‘N’, ‘S’], optional Pressure and temperature at condition 1, by default ‘N’
condition_2 (tuple[Quantity[Pressure, Any], Quantity[Temperature, Any]] |) – Literal[‘N’, ‘S’], optional Pressure and temperature at condition 2, by default ‘N’
fluid_name (str, optional) – CoolProp name of the fluid, by default ‘Air’
- Returns:
Volume or volume flow \(V_2\) at condition 2
- Return type:
Quantity[Volume, Any] | Quantity[VolumeFlow, Any]
- ideal_gas_density(T, P, M)[source]¶
Returns the density \(\rho\) of an ideal gas.
For an ideal gas, density is calculated from the ideal gas law:
\[\rho = \frac{p M}{R T}\]The gas constant \(R\) is \(8.3144598 \; \frac{\text{kg} \, \text{m}^2}{\text{s}^2 \, \text{K} \, \text{mol}}\).
- Parameters:
T (Quantity[Temperature, MT]) – Temperature of the gas
P (Quantity[Pressure, MT]) – Absolute pressure of the gas
M (Quantity[MolarMass, MT]) – Molar mass of the gas
- Returns:
Density of the ideal gas at the specified temperature and pressure
- Return type:
Quantity[Density, MT]
- mass_from_actual_volume(volume, condition, fluid_name='Air')[source]¶
Convert actual volume to mass.
- Parameters:
volume (Quantity[Volume, MT] | Quantity[VolumeFlow, MT]) – Input actual volume or actual volume flow
condition (tuple[Quantity[Pressure, MT], Quantity[Temperature, MT]]) – Condition at which to calculate the mass
fluid_name (str, optional) – Name of the fluid, by default ‘Air’
- Returns:
Corresponding mass or mass flow
- Return type:
Quantity[Mass, MT] | Quantity[MassFlow, MT]
- mass_from_normal_volume(volume, fluid_name='Air')[source]¶
Convert normal volume to mass.
- Parameters:
- volumeQuantity[Volume, MT] | Quantity[VolumeFlow, MT]
Input normal volume or normal volume flow
- fluid_namestr, optional
Name of the fluid, by default ‘Air’
- Returns:
- Quantity[Mass, MT] | Quantity[MassFlow, MT]
Corresponding mass or mass flow
- Parameters:
- Return type:
- mass_to_actual_volume(mass, condition, fluid_name='Air')[source]¶
Convert mass to actual volume.
- Parameters:
mass (Quantity[Mass, MT] | Quantity[MassFlow, MT]) – Input mass or mass flow
condition (tuple[Quantity[Pressure, MT], Quantity[Temperature, MT]]) – Condition at which to calculate the actual volume
fluid_name (str, optional) – Name of the fluid, by default ‘Air’
- Returns:
Corresponding actual volume or actual volume flow
- Return type:
Quantity[Volume, MT] | Quantity[VolumeFlow, MT]
- mass_to_normal_volume(mass, fluid_name='Air')[source]¶
Convert mass to normal volume.
- Parameters:
mass (Quantity[Mass, MT] | Quantity[MassFlow, MT]) – Input mass or mass flow
fluid_name (str, optional) – Name of the fluid, by default ‘Air’
- Returns:
Corresponding normal volume or normal volume flow
- Return type:
Quantity[Volume, MT] | Quantity[VolumeFlow, MT]
- normal_volume_to_actual_volume(volume, condition, fluid_name='Air')[source]¶
Convert normal volume to actual volume.
- Parameters:
volume (Quantity[Volume, Any] | Quantity[VolumeFlow, Any]) – Input normal volume or normal volume flow
condition (tuple[Quantity[Pressure, Any], Quantity[Temperature, Any]]) – Condition at which to calculate the actual volume
fluid_name (str, optional) – Name of the fluid, by default ‘Air’
- Returns:
Corresponding actual volume or actual volume flow
- Return type:
Quantity[Volume, Any] | Quantity[VolumeFlow, Any]
encomp.misc module¶
- grid_dimensions(N, nrows, ncols)[source]¶
Returns image grid dimensions (rows and columns) based on the total number of items
N.- Parameters:
N (int) – Total number of items
nrows (int) – Number or rows, -1 means determined by the number of items
ncols (int) – Number of columns, -1 means determined by the number of items
- Returns:
Number of rows and columns for a grid that fits all items
- Return type:
tuple[int, int]
encomp.settings module¶
Contains settings used elsewhere in the library.
- class Settings(_case_sensitive=None, _nested_model_default_partial_update=None, _env_prefix=None, _env_file=PosixPath('.'), _env_file_encoding=None, _env_ignore_empty=None, _env_nested_delimiter=None, _env_nested_max_split=None, _env_parse_none_str=None, _env_parse_enums=None, _cli_prog_name=None, _cli_parse_args=None, _cli_settings_source=None, _cli_parse_none_str=None, _cli_hide_none_type=None, _cli_avoid_json=None, _cli_enforce_required=None, _cli_use_class_docs_for_groups=None, _cli_exit_on_error=None, _cli_prefix=None, _cli_flag_prefix_char=None, _cli_implicit_flags=None, _cli_ignore_unknown_args=None, _cli_kebab_case=None, _cli_shortcuts=None, _secrets_dir=None, **values)[source]¶
Bases:
BaseSettingsSettings class.
Use an
.env-file to override the defaults, make sure to load it with thepython-dotenvpackage.The variables in the
.env-file have the same names (not case-sensitive) as the attributes of this class, with the additional prefixENCOMP_. In case of invalid values in the.env-file or environment variables, aValidationErroris raised.Note
Names that are defined as global environment variables (either on the system or user level) take precedence over names in the
.env-file. The global environment variables are loaded even if no.env-file was found.UNITS: path to a file with unit definitions forpintTYPESET_SYMBOL_SCRIPTS: whether to typeset Sympy symbol sub- and superscriptsIGNORE_NDARRAY_UNIT_STRIPPED_WARNING: whether to suppress thepintwarning when converting Quantity to Numpy array.IGNORE_COOLPROP_WARNINGS: whether to suppress warnings from the CoolProp backendAUTOCONVERT_OFFSET_TO_BASEUNIT: whether to automatically convert offset units in calculations. If this is False, °C must be converted to K before multiplication (for example)DEFAULT_UNIT_FORMAT: default unit format forQuantityobjects: one of~P(compact),~L(Latex),~H(HTML),~Lx(Latex with SIUNITX package)
Note
All names are case-insensitive.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
_case_sensitive (bool | None)
_nested_model_default_partial_update (bool | None)
_env_prefix (str | None)
_env_file (DotenvType | None)
_env_file_encoding (str | None)
_env_ignore_empty (bool | None)
_env_nested_delimiter (str | None)
_env_nested_max_split (int | None)
_env_parse_none_str (str | None)
_env_parse_enums (bool | None)
_cli_prog_name (str | None)
_cli_parse_args (bool | list[str] | tuple[str, ...] | None)
_cli_settings_source (CliSettingsSource[Any] | None)
_cli_parse_none_str (str | None)
_cli_hide_none_type (bool | None)
_cli_avoid_json (bool | None)
_cli_enforce_required (bool | None)
_cli_use_class_docs_for_groups (bool | None)
_cli_exit_on_error (bool | None)
_cli_prefix (str | None)
_cli_flag_prefix_char (str | None)
_cli_implicit_flags (bool | None)
_cli_ignore_unknown_args (bool | None)
_cli_kebab_case (bool | Literal['all', 'no_enums'] | None)
_cli_shortcuts (Mapping[str, str | list[str]] | None)
_secrets_dir (PathType | None)
units (Annotated[Path, PathType(path_type=file)])
typeset_symbol_scripts (bool)
ignore_ndarray_unit_stripped_warning (bool)
ignore_coolprop_warnings (bool)
autoconvert_offset_to_baseunit (bool)
default_unit_format (Literal['~P', '~L', '~H', '~Lx'])
- autoconvert_offset_to_baseunit: bool¶
- default_unit_format: Literal['~P', '~L', '~H', '~Lx']¶
- ignore_coolprop_warnings: bool¶
- ignore_ndarray_unit_stripped_warning: bool¶
- model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env', 'env_file_encoding': 'utf-8', 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': 'ENCOMP_', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- typeset_symbol_scripts: bool¶
- units: Annotated[Path, PathType(path_type=file)]¶
encomp.structures module¶
Data structures and related functions.
encomp.sympy module¶
Imports and extends the sympy library for symbolic mathematics.
Contains tools for converting Sympy expressions to Python modules and functions.
- class Symbol(name, **assumptions)[source]¶
Bases:
SymbolSymbols are identified by name and assumptions:
>>> from sympy import Symbol >>> Symbol("x") == Symbol("x")
True >>> Symbol(“x”, real=True) == Symbol(“x”, real=False) False
- append(s, where='sub')[source]¶
Adds the input
sto an existing sub- or superscript. Does not append to prefixes. Creates the sub- or superscript if it does not exist.- Parameters:
s (str | int) – Text or index to be added
where (Literal['sub', 'sup'], optional) – Whether to append to the subscript or superscript, by default ‘sub’
- Returns:
A new symbol with the same assumptions as the input, with updated sub- or superscript
- Return type:
- decorate(prefix=None, suffix=None, prefix_sub=None, prefix_sup=None, suffix_sub=None, suffix_sup=None)[source]¶
Method that decorates a symbol with subscripts and/or superscripts before or after the symbol. Returns a new symbol object with the same assumptions (i.e. real, positive, complex, etc…) as the input.
Using LaTeX syntax supported by
sympy:{prefix}^{prefix_sub}_{prefix_sup}{symbol}_{suffix_sub}^{suffix_sup}{suffix}symbolis the input symbol. Theprefixandsuffixparts are added without_or^. Each of the parts (exceptsymbol) can be empty.The decorations can be string or integer, floats are not allowed. In case the input symbol already contains sub- or superscripts, the decorations are not appended to those. Instead, a new level is introduced. To keep things simple, make sure that the input symbol is a simple symbol.
Use the
appendmethod to append to an existing sub- or superscript in the suffix.- Parameters:
prefix (str | int | None, optional) – Prefix added before the symbol, by default None
suffix (str | int | None, optional) – Suffix added after the symbol, by default None
prefix_sub (str | int | None, optional) – Subscript prefix before the symbol and after
prefix, by default Noneprefix_sup (str | int | None, optional) – Superscript prefix before the symbol and after
prefix, by default Nonesuffix_sub (str | int | None, optional) – Subscript suffix after the symbol and before
suffix, by default Nonesuffix_sup (str | int | None, optional) – Superscript suffix after the symbol and before
suffix, by default None
- Returns:
A new symbol with the same assumptions as the input, with added decorations
- Return type:
- default_assumptions = {}¶
- name¶
- evaluate(e, value_map, *, units=False)[source]¶
Evaluates the input expression, given the mapping of symbol to value in
value_map.- Parameters:
e (sp.Basic) – Input expression to evaluate
value_map (dict[sp.Symbol, Quantity | np.ndarray]) – Mapping from symbol to value for all required symbols in
e, additional symbols may be presentunits (bool, optional) – Whether to keep the units, if False Quantity is converted to float (after calling
to_base_units()), by default False
- Returns:
Value of the expression, Quantity if
units=Trueotherwise float- Return type:
Quantity | np.ndarray
- get_args(e)[source]¶
Returns a sorted list of identifiers for each free symbol in the input expression. The sort order is according to the string outputs from
encomp.sympy.to_identifier().- Parameters:
e (sp.Basic) – Input expression
- Returns:
Sorted list of identifiers for each free symbol
- Return type:
list[str]
- get_function(e, *, units=False)[source]¶
Wrapper around
encomp.sympy.get_lambda()that handles inputs and potential units.- Parameters:
e (sp.Basic) – Input expression
units (bool, optional) – Whether to keep the units, if False Quantity is converted to float (after calling
to_base_units()), by default False
- Returns:
Function that evaluates the input expression, can be called with extra kwargs. The kwargs can be a dict with mapping from symbol to value.
- Return type:
Callable
- get_lambda(e, *, to_str=False)[source]¶
Converts the input expression to a lambda function with valid identifiers as parameter names.
- Parameters:
e (sp.Basic) – Input expression
to_str (bool, optional) – Whether to return the string representation of the lambda function, by default False
- Returns:
The lambda function (or string representation) and the list of parameters to the function
- Return type:
tuple[Callable | str, list[str]]
- get_lambda_kwargs(value_map, include=None, *, units=False)[source]¶
Returns a mapping from identifier to value (Quantity or float) based on the input value map (Symbol to value). If
includeis a list, only these symbols will be included.- Parameters:
value_map (dict[sp.Symbol | str, Quantity | np.ndarray]) – Mapping from symbol or symbol identifier to value
include (Sequence[sp.Symbol | str] | None, optional) – Optional sequence of symbols or symbol identifiers to include, by default None
units (bool, optional) – Whether to keep the units, if False Quantity is converted to float (after calling
to_base_units()), by default False
- Returns:
Mapping from identifier to value
- Return type:
dict[str | Quantity | np.ndarray]
- get_lambda_matrix(M)[source]¶
Converts the input matrix into a lambda function that returns an array. Converts the matrix to Python source, it is not possible to use in-memory lambda functions for this. Use
eval(src)on the output from this function to create a function object.- Parameters:
M (sp.MutableDenseMatrix) – Input matrix
- Returns:
Python source code for the function and a list of parameters
- Return type:
tuple[str, list[str]]
- get_sol_expr(equations, symbol, avoid=None)[source]¶
Wrapper around
sp.solvethat returns the solution expression for a single symbol, or None in case Sympy could not solve for the specified symbol. Only considers equations in the input list that actually contains the symbol. Prefers to use equations that containsymbolon the LHS.- Parameters:
eqns (sp.Equality | list[sp.Equality]) – List of equations or a single equation
symbol (sp.Symbol) – Symbol to solve for (isolate)
avoid (set[sp.Symbol] | None, optional) – Set of symbols to avoid in the substitution expressions, by default None
equations (Equality | list[Equality])
- Returns:
Expression that equals
symbol, or None in case the equation(s) could not be solved- Return type:
sp.Basic | None
- recursive_subs(e, replacements)[source]¶
Substitute the expressions in
replacementsrecursively. This might not be necessary in all cases, Sympy’s builtinsubs()method should also do this recursively.Note
The order of the tuples in
replacementsmight matter, make sure to order these sensibly in case the expression contains a lot of nested substitutions.- Parameters:
e (sp.Basic) – Input expression
replacements (list[tuple[sp.Symbol, sp.Basic]]) – List of replacements:
symbol, replace
- Returns:
Substituted expression
- Return type:
sp.Basic
- simplify_exponents(e)[source]¶
Simplifies an expression by combining float and int exponents. This is not done automatically by Sympy.
Adapted from https://stackoverflow.com/questions/54243832/sympy-wont-simplify-or-expand-exponential-with-decimals
- Parameters:
e (sp.Basic) – A Sympy expression, potentially containing mixed float and int exponents
- Returns:
Simplified expression with float and int exponents combined
- Return type:
sp.Basic
- substitute_unknowns(e, knowns, eqns, avoid=None)[source]¶
Uses the equations
eqnsto substitute the unknown symbols in the input expression. Uses recursion to deal with nested substitutions.- Parameters:
e (sp.Basic) – Input expression that potentially contains unknown symbols
knowns (set[sp.Symbol]) – Set of known symbols
eqns (list[sp.Equality]) – List of equations that define the unknown symbols in terms of known ones
avoid (set[sp.Symbol] | None, optional) – Set of symbols to avoid in the substitution expressions, by default None
- Returns:
The substituted expression without any unknown symbols
- Return type:
sp.Basic
- to_identifier(s)[source]¶
Converts a Sympy symbol to a valid Python identifier. This function will only remove special characters.
The Latex command
\text{}is replaced withT. This is done to differentiate between symbols\text{kg}(returnsTkg) andkg(returnskg).- Parameters:
s (sp.Symbol | str) – Input symbol or string representation
- Returns:
Valid Python identifier created from the input symbol
- Return type:
str
- typeset(x)[source]¶
Does some additional typesetting for the input Latex string, for example
\text{}around strings and upper-case characters.Use comma
,to separate parts of the input, for exampleinput,i
will be typeset as
\text{input},i: theiis a separate part and is typeset with a math font. Spaces around commas will be removed to make sub- and superscripts more compact. Use~before a single upper-case letter to typeset it with a math font.Uses flags from
encomp.settingsto determine how to typeset the input.- Parameters:
x (str | int) – Input string or int (will be converted to str)
- Returns:
Output Latex string
- Return type:
str
encomp.thermo module¶
Functions relating to thermodynamics.
- heat_balance(*args, cp=<Quantity(4.18, 'kilojoule / kilogram / kelvin')>)[source]¶
Solves the heat balance equation
\[\dot{Q}_h = C_p \cdot \dot{m} \cdot \Delta T\]for the 3:rd unknown variable.
- Parameters:
args (Quantity) – The two known variables in the heat balance equation: mass, mass flow, energy, power or temperature difference. Temperature input is interpreted as temperature difference.
cp (Quantity[SpecificHeatCapacity], optional) – Heat capacity, by default 4.18 kg/kJ/K (water)
- Returns:
The third unknown variable
- Return type:
Quantity
- intermediate_temperatures(T_b, T_s, k, d, h_in, h_out, epsilon, tol=1e-06)[source]¶
Solves a nonlinear system of equations to find intermediate temperatures of a barrier with the following modes of heat transfer:
inner convection
conduction through the barrier
outer convection
outer radiation
- Parameters:
T_b (Quantity[Temperature]) – Bulk temperature inside the barrier
T_s (Quantity[Temperature]) – Bulk temperature outside the barrier (surroundings)
k (Quantity[ThermalConductivity]) – The thermal conductivity of the barrier material. Supply the combined value in case there are multiple layers
d (Quantity[Length]) –
Total thickness of the barrier
Note
In case
dis set to 0, it will be reset totolto avoid division by zero.h_in (Quantity[HeatTransferCoefficient]) – The convective heat transfer coefficient at the inner barrier wall
h_out (Quantity[HeatTransferCoefficient]) – The convective heat transfer coefficient at the outer barrier wall
epsilon (float) – The emissivity of the outside surface, used to account for radiative heat transfer
tol (float, optional) – Numerical accuracy for the conduction layer:
dis set to this if 0 is passed, by default 1e-6
- Returns:
The intermediate temperatures \(T_1\) and \(T_2\): the surface temperatures of the inside and outside of the barrier
- Return type:
tuple[Quantity[Temperature, float], Quantity[Temperature, float]]
encomp.units module¶
Imports and extends the pint library for physical units.
Always import this module when working with encomp (most other modules
will import this one).
Implements a type-aware system on top of pint that verifies
that the dimensionality of the unit is correct.
- exception DimensionalityComparisonError(msg='')[source]¶
Bases:
_DimensionalityError- Parameters:
msg (str)
- Return type:
None
- exception DimensionalityTypeError(msg='')[source]¶
Bases:
_DimensionalityError- Parameters:
msg (str)
- Return type:
None
- exception ExpectedDimensionalityError(msg='')[source]¶
Bases:
_DimensionalityError- Parameters:
msg (str)
- Return type:
None
- class Quantity(val, unit=None, _depth=0)[source]¶
Bases:
NumpyQuantity[Any],NonMultiplicativeQuantity[Any],MeasurementQuantity[Any],Generic[DT,MT]- Parameters:
- Return type:
Quantity[Any, Any]
- FORMATTING_SPECS = ('~P', '~L', '~H', '~Lx')¶
- NORMAL_M3_VARIANTS = ('nm³', 'Nm³', 'nm3', 'Nm3', 'nm**3', 'Nm**3', 'nm^3', 'Nm^3')¶
- TEMPERATURE_DIFFERENCE_UCS = (<UnitsContainer({'delta_degree_Celsius': 1})>, <UnitsContainer({'delta_degree_Fahrenheit': 1})>)¶
- asdim(other)[source]¶
- Return type:
Quantity[UnknownDimensionality]- Parameters:
other (type[DT_] | Quantity[UnknownDimensionality])
- astype(magnitude_type)[source]¶
- Return type:
Quantity[UnknownDimensionality]- Parameters:
magnitude_type (type[MT_])
- atol: float = 1e-12¶
- check(dimension)[source]¶
Return true if the quantity’s dimension matches passed dimension.
- Return type:
bool- Parameters:
dimension (Quantity[UnknownDimensionality] | UnitsContainer | Unit[DT_] | Unit | str | Dimensionality | type[Dimensionality])
- check_compatibility(other)[source]¶
- Return type:
None- Parameters:
other (Quantity[UnknownDimensionality] | float | int)
- property dt: type[DT]¶
- classmethod from_expr(expr)[source]¶
- Return type:
Quantity[UnknownDimensionality, float]- Parameters:
expr (Basic)
- get_subclass(dt, mt)[source]¶
- Return type:
type[Quantity[UnknownDimensionality]]- Parameters:
dt (type[DT_])
mt (type[MT_])
- classmethod get_unit(unit_name)[source]¶
- Return type:
- Parameters:
unit_name (Literal['', '%', 'percent', 'pct', '-', 'dimensionless'] | ~typing.Literal['SEK', 'EUR', 'USD', 'kSEK', 'kEUR', 'kUSD', 'MSEK', 'MEUR', 'MUSD'] | ~typing.Literal['SEK/MWh', 'EUR/MWh', 'SEK/kWh', 'EUR/kWh', 'SEK/GWh', 'EUR/GWh', 'SEK/TWh', 'EUR/TWh'] | ~typing.Literal['SEK/kg', 'EUR/kg', 'SEK/t', 'EUR/t', 'SEK/ton', 'EUR/ton', 'SEK/g', 'EUR/g', 'SEK/mg', 'EUR/mg', 'SEK/ug', 'EUR/ug'] | ~typing.Literal['SEK/L', 'EUR/L', 'SEK/l', 'EUR/l', 'SEK/liter', 'EUR/liter', 'SEK/m3', 'EUR/m3', 'SEK/m^3', 'EUR/m^3', 'SEK/m**3', 'EUR/m**3', 'SEK/m³', 'EUR/m³'] | ~typing.Literal['SEK/h', 'EUR/h', 'SEK/hr', 'EUR/hr', 'SEK/hour', 'EUR/hour', 'SEK/d', 'EUR/d', 'SEK/day', 'EUR/day', 'SEK/w', 'EUR/w', 'SEK/week', 'EUR/week', 'SEK/y', 'EUR/y', 'SEK/yr', 'EUR/yr', 'SEK/year', 'EUR/year', 'SEK/a', 'EUR/a'] | ~typing.Literal['m', 'meter', 'km', 'cm', 'mm', 'um'] | ~typing.Literal['kg', 'g', 'ton', 'tonne', 't', 'mg', 'ug'] | ~typing.Literal['s', 'second', 'min', 'minute', 'h', 'hr', 'hour', 'd', 'day', 'w', 'week', 'y', 'yr', 'a', 'year', 'ms', 'us'] | ~typing.Literal['degC', '°C', 'K', 'degF', '°F', '℃', '℉'] | ~typing.Literal['delta_°C', 'delta_degC', 'Δ°C', 'Δ℃', 'delta_°F', 'delta_degF', 'Δ°F', 'Δ℉'] | ~typing.Literal['mol', 'kmol'] | ~typing.Literal['g/mol', 'kg/kmol'] | ~typing.Literal['mol/g', 'kmol/kg'] | ~typing.Literal['A', 'mA'] | ~typing.Literal['lm'] | ~typing.Literal['m2', 'm^2', 'm**2', 'm²', 'cm2', 'cm^2', 'cm**2', 'cm²'] | ~typing.Literal['L', 'l', 'liter', 'm3', 'm^3', 'm³', 'm**3', 'dm3', 'dm^3', 'dm³', 'dm**3', 'cm3', 'cm^3', 'cm³', 'cm**3'] | ~typing.Literal['normal liter', 'Nm3', 'nm3', 'Nm^3', 'nm^3', 'Nm³', 'nm³', 'Nm**3', 'nm**3'] | ~typing.Literal['bar', 'kPa', 'Pa', 'MPa', 'mbar', 'mmHg', 'psi', 'atm', 'N/m2', 'N/m^2', 'N/m**2', 'N/m²'] | ~typing.Literal['kg/s', 'kg/h', 'kg/hr', 'g/s', 'g/h', 'g/hr', 'ton/h', 't/h', 'ton/hr', 't/hr', 't/d', 'ton/day', 't/w', 'ton/week', 't/y', 't/a', 't/year', 'ton/y', 'ton/a', 'ton/year'] | ~typing.Literal['m3/s', 'm3/h', 'm3/hr', 'm**3/s', 'm**3/h', 'm**3/hr', 'm^3/s', 'm^3/h', 'm^3/hr', 'm³/s', 'm³/h', 'm³/hr', 'liter/second', 'l/s', 'L/s', 'liter/s', 'liter/hour', 'l/h', 'L/h', 'L/hr', 'l/hr'] | ~typing.Literal['Nm3/s', 'Nm3/h', 'Nm3/hr', 'nm3/s', 'nm3/h', 'nm3/hr', 'Nm^3/s', 'Nm^3/h', 'Nm^3/hr', 'nm^3/s', 'nm^3/h', 'nm^3/hr', 'Nm³/s', 'Nm³/h', 'Nm³/hr', 'nm³/s', 'nm³/h', 'nm³/hr', 'Nm**3/s', 'Nm**3/h', 'Nm**3/hr', 'nm**3/s', 'nm**3/h', 'nm**3/hr'] | ~typing.Literal['kg/m3', 'kg/m**3', 'kg/m^3', 'kg/m³', 'kg/liter', 'g/l', 'g/L', 'gram/liter'] | ~typing.Literal['m3/kg', 'm^3/kg', 'm³/kg', 'l/g', 'L/g'] | ~typing.Literal['Nm3/kg', 'Nm^3/kg', 'Nm³/kg', 'nm3/kg', 'nm^3/kg', 'nm³/kg'] | ~typing.Literal['J', 'kJ', 'MJ', 'GJ', 'TJ', 'PJ', 'kWh', 'MWh', 'Wh', 'GWh', 'TWh'] | ~typing.Literal['W', 'kW', 'MW', 'GW', 'TW', 'mW', 'kWh/d', 'kWh/w', 'kWh/y', 'kWh/yr', 'kWh/year', 'MWh/d', 'MWh/w', 'MWh/y', 'MWh/yr', 'MWh/year', 'GWh/d', 'GWh/w', 'GWh/y', 'GWh/yr', 'GWh/year', 'TWh/d', 'TWh/w', 'TWh/y', 'TWh/yr', 'TWh/year'] | ~typing.Literal['m/s', 'km/s', 'm/min', 'cm/s', 'cm/min', 'km/h', 'kmh', 'kph'] | ~typing.Literal['N', 'kN', 'mN'] | ~typing.Literal['Pa*s', 'Pa s', 'cP'] | ~typing.Literal['m2/s', 'm**2/s', 'm^2/s', 'm²/s', 'cSt', 'cm2/s', 'cm**2/s', 'cm^2/s', 'cm²/s'] | ~typing.Literal['MJ/kg', 'MWh/kg', 'kJ/kg', 'kWh/kg', 'MJ/t', 'MWh/t', 'kJ/t', 'kWh/t', 'MJ/ton', 'MWh/ton', 'kJ/ton', 'kWh/ton'] | ~typing.Literal['kJ/kg/K', 'kJ/kg/delta_degC', 'kJ/kg/Δ°C', 'kJ/kg/Δ℃', 'kJ/kg/°C', 'kJ/kg/℃', 'kJ/kg/degC', 'J/kg/K', 'J/kg/delta_degC', 'J/kg/Δ°C', 'J/kg/Δ℃', 'J/kg/°C', 'J/kg/℃', 'J/kg/degC', 'J/g/K', 'J/g/delta_degC', 'J/g/Δ°C', 'J/g/Δ℃', 'J/g/°C', 'J/g/℃', 'J/g/degC'] | ~typing.Literal['W/m/K', 'W/m/delta_degC', 'W/m/Δ°C', 'W/m/Δ℃', 'kW/m/K', 'mW/m/K'] | ~typing.Literal['W/m2/K', 'W/m^2/K', 'W/m**2/K', 'W/m²/K', 'W/m2/delta_degC', 'W/m^2/delta_degC', 'W/m**2/delta_degC', 'W/m²/delta_degC', 'W/m2/Δ°C', 'W/m^2/Δ°C', 'W/m**2/Δ°C', 'W/m²/Δ°C', 'kW/m2/K', 'kW/m^2/K', 'kW/m**2/K', 'kW/m²/K'] | str)
- static get_unknown_dimensionality_subclass()[source]¶
- Return type:
type[Quantity[UnknownDimensionality]]
- is_compatible_with(other, *contexts, **ctx_kwargs)[source]¶
check if the other object is compatible
- Parameters:
other (
Quantity[UnknownDimensionality]|float|int) – The object to check. Treated as dimensionless if not a PlainQuantity, Unit or str.*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs (
Any) – Values for the Context/s
- Return type:
bool
- property is_scalar: bool¶
- ito(unit)[source]¶
Inplace rescale to different units.
- Parameters:
other (pint.PlainQuantity, str or dict) – Destination units. (Default value = None)
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
unit (Literal['', '%', 'percent', 'pct', '-', 'dimensionless'] | ~typing.Literal['SEK', 'EUR', 'USD', 'kSEK', 'kEUR', 'kUSD', 'MSEK', 'MEUR', 'MUSD'] | ~typing.Literal['SEK/MWh', 'EUR/MWh', 'SEK/kWh', 'EUR/kWh', 'SEK/GWh', 'EUR/GWh', 'SEK/TWh', 'EUR/TWh'] | ~typing.Literal['SEK/kg', 'EUR/kg', 'SEK/t', 'EUR/t', 'SEK/ton', 'EUR/ton', 'SEK/g', 'EUR/g', 'SEK/mg', 'EUR/mg', 'SEK/ug', 'EUR/ug'] | ~typing.Literal['SEK/L', 'EUR/L', 'SEK/l', 'EUR/l', 'SEK/liter', 'EUR/liter', 'SEK/m3', 'EUR/m3', 'SEK/m^3', 'EUR/m^3', 'SEK/m**3', 'EUR/m**3', 'SEK/m³', 'EUR/m³'] | ~typing.Literal['SEK/h', 'EUR/h', 'SEK/hr', 'EUR/hr', 'SEK/hour', 'EUR/hour', 'SEK/d', 'EUR/d', 'SEK/day', 'EUR/day', 'SEK/w', 'EUR/w', 'SEK/week', 'EUR/week', 'SEK/y', 'EUR/y', 'SEK/yr', 'EUR/yr', 'SEK/year', 'EUR/year', 'SEK/a', 'EUR/a'] | ~typing.Literal['m', 'meter', 'km', 'cm', 'mm', 'um'] | ~typing.Literal['kg', 'g', 'ton', 'tonne', 't', 'mg', 'ug'] | ~typing.Literal['s', 'second', 'min', 'minute', 'h', 'hr', 'hour', 'd', 'day', 'w', 'week', 'y', 'yr', 'a', 'year', 'ms', 'us'] | ~typing.Literal['degC', '°C', 'K', 'degF', '°F', '℃', '℉'] | ~typing.Literal['delta_°C', 'delta_degC', 'Δ°C', 'Δ℃', 'delta_°F', 'delta_degF', 'Δ°F', 'Δ℉'] | ~typing.Literal['mol', 'kmol'] | ~typing.Literal['g/mol', 'kg/kmol'] | ~typing.Literal['mol/g', 'kmol/kg'] | ~typing.Literal['A', 'mA'] | ~typing.Literal['lm'] | ~typing.Literal['m2', 'm^2', 'm**2', 'm²', 'cm2', 'cm^2', 'cm**2', 'cm²'] | ~typing.Literal['L', 'l', 'liter', 'm3', 'm^3', 'm³', 'm**3', 'dm3', 'dm^3', 'dm³', 'dm**3', 'cm3', 'cm^3', 'cm³', 'cm**3'] | ~typing.Literal['normal liter', 'Nm3', 'nm3', 'Nm^3', 'nm^3', 'Nm³', 'nm³', 'Nm**3', 'nm**3'] | ~typing.Literal['bar', 'kPa', 'Pa', 'MPa', 'mbar', 'mmHg', 'psi', 'atm', 'N/m2', 'N/m^2', 'N/m**2', 'N/m²'] | ~typing.Literal['kg/s', 'kg/h', 'kg/hr', 'g/s', 'g/h', 'g/hr', 'ton/h', 't/h', 'ton/hr', 't/hr', 't/d', 'ton/day', 't/w', 'ton/week', 't/y', 't/a', 't/year', 'ton/y', 'ton/a', 'ton/year'] | ~typing.Literal['m3/s', 'm3/h', 'm3/hr', 'm**3/s', 'm**3/h', 'm**3/hr', 'm^3/s', 'm^3/h', 'm^3/hr', 'm³/s', 'm³/h', 'm³/hr', 'liter/second', 'l/s', 'L/s', 'liter/s', 'liter/hour', 'l/h', 'L/h', 'L/hr', 'l/hr'] | ~typing.Literal['Nm3/s', 'Nm3/h', 'Nm3/hr', 'nm3/s', 'nm3/h', 'nm3/hr', 'Nm^3/s', 'Nm^3/h', 'Nm^3/hr', 'nm^3/s', 'nm^3/h', 'nm^3/hr', 'Nm³/s', 'Nm³/h', 'Nm³/hr', 'nm³/s', 'nm³/h', 'nm³/hr', 'Nm**3/s', 'Nm**3/h', 'Nm**3/hr', 'nm**3/s', 'nm**3/h', 'nm**3/hr'] | ~typing.Literal['kg/m3', 'kg/m**3', 'kg/m^3', 'kg/m³', 'kg/liter', 'g/l', 'g/L', 'gram/liter'] | ~typing.Literal['m3/kg', 'm^3/kg', 'm³/kg', 'l/g', 'L/g'] | ~typing.Literal['Nm3/kg', 'Nm^3/kg', 'Nm³/kg', 'nm3/kg', 'nm^3/kg', 'nm³/kg'] | ~typing.Literal['J', 'kJ', 'MJ', 'GJ', 'TJ', 'PJ', 'kWh', 'MWh', 'Wh', 'GWh', 'TWh'] | ~typing.Literal['W', 'kW', 'MW', 'GW', 'TW', 'mW', 'kWh/d', 'kWh/w', 'kWh/y', 'kWh/yr', 'kWh/year', 'MWh/d', 'MWh/w', 'MWh/y', 'MWh/yr', 'MWh/year', 'GWh/d', 'GWh/w', 'GWh/y', 'GWh/yr', 'GWh/year', 'TWh/d', 'TWh/w', 'TWh/y', 'TWh/yr', 'TWh/year'] | ~typing.Literal['m/s', 'km/s', 'm/min', 'cm/s', 'cm/min', 'km/h', 'kmh', 'kph'] | ~typing.Literal['N', 'kN', 'mN'] | ~typing.Literal['Pa*s', 'Pa s', 'cP'] | ~typing.Literal['m2/s', 'm**2/s', 'm^2/s', 'm²/s', 'cSt', 'cm2/s', 'cm**2/s', 'cm^2/s', 'cm²/s'] | ~typing.Literal['MJ/kg', 'MWh/kg', 'kJ/kg', 'kWh/kg', 'MJ/t', 'MWh/t', 'kJ/t', 'kWh/t', 'MJ/ton', 'MWh/ton', 'kJ/ton', 'kWh/ton'] | ~typing.Literal['kJ/kg/K', 'kJ/kg/delta_degC', 'kJ/kg/Δ°C', 'kJ/kg/Δ℃', 'kJ/kg/°C', 'kJ/kg/℃', 'kJ/kg/degC', 'J/kg/K', 'J/kg/delta_degC', 'J/kg/Δ°C', 'J/kg/Δ℃', 'J/kg/°C', 'J/kg/℃', 'J/kg/degC', 'J/g/K', 'J/g/delta_degC', 'J/g/Δ°C', 'J/g/Δ℃', 'J/g/°C', 'J/g/℃', 'J/g/degC'] | ~typing.Literal['W/m/K', 'W/m/delta_degC', 'W/m/Δ°C', 'W/m/Δ℃', 'kW/m/K', 'mW/m/K'] | ~typing.Literal['W/m2/K', 'W/m^2/K', 'W/m**2/K', 'W/m²/K', 'W/m2/delta_degC', 'W/m^2/delta_degC', 'W/m**2/delta_degC', 'W/m²/delta_degC', 'W/m2/Δ°C', 'W/m^2/Δ°C', 'W/m**2/Δ°C', 'W/m²/Δ°C', 'kW/m2/K', 'kW/m^2/K', 'kW/m**2/K', 'kW/m²/K'] | ~encomp.units.Unit[~encomp.utypes.DT] | ~pint.util.UnitsContainer | str | dict[str, ~numbers.Number])
- Return type:
None
- property m: MT¶
PlainQuantity’s magnitude. Short form for magnitude
- property mt: type[MT]¶
- property ndim: int¶
- rtol: float = 1e-09¶
- to(unit)[source]¶
Return PlainQuantity rescaled to different units.
- Parameters:
other (pint.PlainQuantity, str or dict) – destination units. (Default value = None)
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
unit (Literal['', '%', 'percent', 'pct', '-', 'dimensionless'] | ~typing.Literal['SEK', 'EUR', 'USD', 'kSEK', 'kEUR', 'kUSD', 'MSEK', 'MEUR', 'MUSD'] | ~typing.Literal['SEK/MWh', 'EUR/MWh', 'SEK/kWh', 'EUR/kWh', 'SEK/GWh', 'EUR/GWh', 'SEK/TWh', 'EUR/TWh'] | ~typing.Literal['SEK/kg', 'EUR/kg', 'SEK/t', 'EUR/t', 'SEK/ton', 'EUR/ton', 'SEK/g', 'EUR/g', 'SEK/mg', 'EUR/mg', 'SEK/ug', 'EUR/ug'] | ~typing.Literal['SEK/L', 'EUR/L', 'SEK/l', 'EUR/l', 'SEK/liter', 'EUR/liter', 'SEK/m3', 'EUR/m3', 'SEK/m^3', 'EUR/m^3', 'SEK/m**3', 'EUR/m**3', 'SEK/m³', 'EUR/m³'] | ~typing.Literal['SEK/h', 'EUR/h', 'SEK/hr', 'EUR/hr', 'SEK/hour', 'EUR/hour', 'SEK/d', 'EUR/d', 'SEK/day', 'EUR/day', 'SEK/w', 'EUR/w', 'SEK/week', 'EUR/week', 'SEK/y', 'EUR/y', 'SEK/yr', 'EUR/yr', 'SEK/year', 'EUR/year', 'SEK/a', 'EUR/a'] | ~typing.Literal['m', 'meter', 'km', 'cm', 'mm', 'um'] | ~typing.Literal['kg', 'g', 'ton', 'tonne', 't', 'mg', 'ug'] | ~typing.Literal['s', 'second', 'min', 'minute', 'h', 'hr', 'hour', 'd', 'day', 'w', 'week', 'y', 'yr', 'a', 'year', 'ms', 'us'] | ~typing.Literal['degC', '°C', 'K', 'degF', '°F', '℃', '℉'] | ~typing.Literal['delta_°C', 'delta_degC', 'Δ°C', 'Δ℃', 'delta_°F', 'delta_degF', 'Δ°F', 'Δ℉'] | ~typing.Literal['mol', 'kmol'] | ~typing.Literal['g/mol', 'kg/kmol'] | ~typing.Literal['mol/g', 'kmol/kg'] | ~typing.Literal['A', 'mA'] | ~typing.Literal['lm'] | ~typing.Literal['m2', 'm^2', 'm**2', 'm²', 'cm2', 'cm^2', 'cm**2', 'cm²'] | ~typing.Literal['L', 'l', 'liter', 'm3', 'm^3', 'm³', 'm**3', 'dm3', 'dm^3', 'dm³', 'dm**3', 'cm3', 'cm^3', 'cm³', 'cm**3'] | ~typing.Literal['normal liter', 'Nm3', 'nm3', 'Nm^3', 'nm^3', 'Nm³', 'nm³', 'Nm**3', 'nm**3'] | ~typing.Literal['bar', 'kPa', 'Pa', 'MPa', 'mbar', 'mmHg', 'psi', 'atm', 'N/m2', 'N/m^2', 'N/m**2', 'N/m²'] | ~typing.Literal['kg/s', 'kg/h', 'kg/hr', 'g/s', 'g/h', 'g/hr', 'ton/h', 't/h', 'ton/hr', 't/hr', 't/d', 'ton/day', 't/w', 'ton/week', 't/y', 't/a', 't/year', 'ton/y', 'ton/a', 'ton/year'] | ~typing.Literal['m3/s', 'm3/h', 'm3/hr', 'm**3/s', 'm**3/h', 'm**3/hr', 'm^3/s', 'm^3/h', 'm^3/hr', 'm³/s', 'm³/h', 'm³/hr', 'liter/second', 'l/s', 'L/s', 'liter/s', 'liter/hour', 'l/h', 'L/h', 'L/hr', 'l/hr'] | ~typing.Literal['Nm3/s', 'Nm3/h', 'Nm3/hr', 'nm3/s', 'nm3/h', 'nm3/hr', 'Nm^3/s', 'Nm^3/h', 'Nm^3/hr', 'nm^3/s', 'nm^3/h', 'nm^3/hr', 'Nm³/s', 'Nm³/h', 'Nm³/hr', 'nm³/s', 'nm³/h', 'nm³/hr', 'Nm**3/s', 'Nm**3/h', 'Nm**3/hr', 'nm**3/s', 'nm**3/h', 'nm**3/hr'] | ~typing.Literal['kg/m3', 'kg/m**3', 'kg/m^3', 'kg/m³', 'kg/liter', 'g/l', 'g/L', 'gram/liter'] | ~typing.Literal['m3/kg', 'm^3/kg', 'm³/kg', 'l/g', 'L/g'] | ~typing.Literal['Nm3/kg', 'Nm^3/kg', 'Nm³/kg', 'nm3/kg', 'nm^3/kg', 'nm³/kg'] | ~typing.Literal['J', 'kJ', 'MJ', 'GJ', 'TJ', 'PJ', 'kWh', 'MWh', 'Wh', 'GWh', 'TWh'] | ~typing.Literal['W', 'kW', 'MW', 'GW', 'TW', 'mW', 'kWh/d', 'kWh/w', 'kWh/y', 'kWh/yr', 'kWh/year', 'MWh/d', 'MWh/w', 'MWh/y', 'MWh/yr', 'MWh/year', 'GWh/d', 'GWh/w', 'GWh/y', 'GWh/yr', 'GWh/year', 'TWh/d', 'TWh/w', 'TWh/y', 'TWh/yr', 'TWh/year'] | ~typing.Literal['m/s', 'km/s', 'm/min', 'cm/s', 'cm/min', 'km/h', 'kmh', 'kph'] | ~typing.Literal['N', 'kN', 'mN'] | ~typing.Literal['Pa*s', 'Pa s', 'cP'] | ~typing.Literal['m2/s', 'm**2/s', 'm^2/s', 'm²/s', 'cSt', 'cm2/s', 'cm**2/s', 'cm^2/s', 'cm²/s'] | ~typing.Literal['MJ/kg', 'MWh/kg', 'kJ/kg', 'kWh/kg', 'MJ/t', 'MWh/t', 'kJ/t', 'kWh/t', 'MJ/ton', 'MWh/ton', 'kJ/ton', 'kWh/ton'] | ~typing.Literal['kJ/kg/K', 'kJ/kg/delta_degC', 'kJ/kg/Δ°C', 'kJ/kg/Δ℃', 'kJ/kg/°C', 'kJ/kg/℃', 'kJ/kg/degC', 'J/kg/K', 'J/kg/delta_degC', 'J/kg/Δ°C', 'J/kg/Δ℃', 'J/kg/°C', 'J/kg/℃', 'J/kg/degC', 'J/g/K', 'J/g/delta_degC', 'J/g/Δ°C', 'J/g/Δ℃', 'J/g/°C', 'J/g/℃', 'J/g/degC'] | ~typing.Literal['W/m/K', 'W/m/delta_degC', 'W/m/Δ°C', 'W/m/Δ℃', 'kW/m/K', 'mW/m/K'] | ~typing.Literal['W/m2/K', 'W/m^2/K', 'W/m**2/K', 'W/m²/K', 'W/m2/delta_degC', 'W/m^2/delta_degC', 'W/m**2/delta_degC', 'W/m²/delta_degC', 'W/m2/Δ°C', 'W/m^2/Δ°C', 'W/m**2/Δ°C', 'W/m²/Δ°C', 'kW/m2/K', 'kW/m^2/K', 'kW/m**2/K', 'kW/m²/K'] | ~encomp.units.Unit[~encomp.utypes.DT] | ~pint.util.UnitsContainer | str | dict[str, ~numbers.Number] | ~encomp.units.Quantity[UnknownDimensionality])
- Return type:
pint.PlainQuantity
- to_base_units()[source]¶
Return PlainQuantity rescaled to plain units.
- Return type:
Quantity[UnknownDimensionality]
- to_reduced_units()[source]¶
Return PlainQuantity scaled in place to reduced units, i.e. one unit per dimension. This will not reduce compound units (intentionally), nor can it make use of contexts at this time.
- Return type:
Quantity[UnknownDimensionality]
- to_root_units()[source]¶
Return PlainQuantity rescaled to root units.
- Return type:
Quantity[UnknownDimensionality]
- define_dimensionality(name, symbol=None, if_exists='raise')[source]¶
Defines a new dimensionality that can be combined with existing dimensionalities. In case the dimensionality is already defined,
DimensionalityRedefinitionErrorwill be raised.This can be used to define a new dimensionality for an amount of some specific substance. For instance, if the dimensionalities “air” and “fuel” are defined, the unit
(kg air) / (kg fuel)has the simplified dimensionality of[air] / [fuel].Note
Make sure to only define new custom dimensions using this function, since the unit needs to be appended to the
CUSTOM_DIMENSIONSlist as well.- Parameters:
name (str) – Name of the dimensionality
symbol (str | None, optional) – Optional (short) symbol, by default None
if_exists (Literal['raise', 'warn'])
- Return type:
None
encomp.utypes module¶
Contains type definitions for encomp.units.Quantity objects.
The dimensionalities defined in this module can be combined with * and /.
Some commonly used derived dimensionalities (like density) are defined for convenience.
- class Area[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2})>¶
- class Currency[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[currency]': 1})>¶
- class CurrencyPerEnergy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[currency]': 1, '[length]': -2, '[mass]': -1, '[time]': 2})>¶
- class CurrencyPerMass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[currency]': 1, '[mass]': -1})>¶
- class CurrencyPerTime[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[currency]': 1, '[time]': -1})>¶
- class CurrencyPerVolume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[currency]': 1, '[length]': -3})>¶
- class Current[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[current]': 1})>¶
- class Density[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -3, '[mass]': 1})>¶
- class Dimensionality[source]¶
Bases:
objectRepresents the dimensionality of a unit, i.e. a combination (product) of the base dimensions (with optional rational exponents).
A dimension ca be expressed as
\[\Pi \, d^n_d, d \in \{T, L, M ,I, \Theta, N, J, \ldots\}, n_d \in \mathbb{Q}\]where ${T, L, M, …}$ are the base dimensions (time, length, mass, …) and $n_d$ is a rational number.
Subclasses of this abstract base class are used as type parameters when creating instances of
encomp.units.Quantity.The
dimensionsclass attribute defines the dimensions of the dimensionality using an instance ofpint.unit.UnitsContainer.- dimensions: UnitsContainer = <UnitsContainer({})>¶
- classmethod get_dimensionality(dimensions)[source]¶
- Return type:
type[Dimensionality]- Parameters:
dimensions (UnitsContainer)
- class Dimensionless[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({})>¶
- class DynamicViscosity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -1, '[mass]': 1, '[time]': -1})>¶
- class Energy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[time]': -2})>¶
- class EnergyPerMass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class Force[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 1, '[mass]': 1, '[time]': -2})>¶
- class Frequency[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[time]': -1})>¶
- class HeatTransferCoefficient[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': 1, '[temperature]': -1, '[time]': -3})>¶
- class HeatingValue[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class HigherHeatingValue[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class IndistinctDimensionality[source]¶
Bases:
Dimensionality
- class KinematicViscosity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -1})>¶
- class Length[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 1})>¶
- class LowerHeatingValue[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class Luminosity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[luminosity]': 1})>¶
- class Mass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': 1})>¶
- class MassFlow[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': 1, '[time]': -1})>¶
- class MassPerEnergy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -2, '[time]': 2})>¶
- class MassPerNormalVolume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -3, '[mass]': 1, '[normal]': -1})>¶
- class MixtureEnthalpyPerDryAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class MixtureEnthalpyPerHumidAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class MixtureEntropyPerDryAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class MixtureEntropyPerHumidAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class MixtureVolumePerDryAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[mass]': -1})>¶
- class MixtureVolumePerHumidAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[mass]': -1})>¶
- class MolarDensity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -3, '[substance]': 1})>¶
- class MolarMass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': 1, '[substance]': -1})>¶
- class MolarSpecificEnthalpy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[substance]': -1, '[time]': -2})>¶
- class MolarSpecificEntropy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[substance]': -1, '[temperature]': -1, '[time]': -2})>¶
- class MolarSpecificInternalEnergy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[substance]': -1, '[time]': -2})>¶
- class Normal[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[normal]': 1})>¶
- class NormalTemperature[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[normal]': 1, '[temperature]': 1})>¶
- class NormalVolume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[normal]': 1})>¶
- class NormalVolumeFlow[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[normal]': 1, '[time]': -1})>¶
- class NormalVolumePerMass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[mass]': -1, '[normal]': 1})>¶
- class Power[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[time]': -3})>¶
- class PowerPerArea[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': 1, '[time]': -3})>¶
- class PowerPerLength[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 1, '[mass]': 1, '[time]': -3})>¶
- class PowerPerTemperature[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[mass]': 1, '[temperature]': -1, '[time]': -3})>¶
- class PowerPerVolume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -1, '[mass]': 1, '[time]': -3})>¶
- class Pressure[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': -1, '[mass]': 1, '[time]': -2})>¶
- class SpecificEnthalpy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class SpecificEntropy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class SpecificHeatCapacity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class SpecificHeatPerDryAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class SpecificHeatPerHumidAir[source]¶
Bases:
IndistinctDimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[temperature]': -1, '[time]': -2})>¶
- class SpecificInternalEnergy[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 2, '[time]': -2})>¶
- class SpecificVolume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[mass]': -1})>¶
- class Substance[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[substance]': 1})>¶
- class SubstancePerMass[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[mass]': -1, '[substance]': 1})>¶
- class Temperature[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[temperature]': 1})>¶
- class TemperatureDifference[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[temperature]': 1})>¶
- class ThermalConductivity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 1, '[mass]': 1, '[temperature]': -1, '[time]': -3})>¶
- class Time[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[time]': 1})>¶
- class UnknownDimensionality[source]¶
Bases:
Dimensionality
- class Velocity[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 1, '[time]': -1})>¶
- class Volume[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3})>¶
- class VolumeFlow[source]¶
Bases:
Dimensionality- dimensions: UnitsContainer = <UnitsContainer({'[length]': 3, '[time]': -1})>¶