""" Defines common/useful physical constants. """ import math import warnings from pint import UnitRegistry, Quantity with warnings.catch_warnings(): warnings.simplefilter("ignore") Quantity([]) unit_registry = UnitRegistry() unit_registry.setup_matplotlib() # Register gamma*beta units for electrons unit_registry.define('GB = 510998.946 * eV/c') # physical_constants c = 299792458 * unit_registry.parse_expression("m/s") e = 1.602176634e-19 * unit_registry.parse_expression( "coulomb") # Fundamental Charge Unit qe = -e # Charge on electron me = 9.1093837015e-31 * unit_registry.kg # Mass of electron MC2 = (me * c * c).to(unit_registry.electron_volt) # Electron rest mass # Mathematical constants pi = math.pi * unit_registry("rad")
import sys import CoolProp from pint import UnitRegistry, DimensionalityError from pint.unit import UnitsContainer, UnitDefinition from pint.converters import ScaleConverter try: # pragma: no cover from IPython.core.ultratb import AutoFormattedTB except ImportError: # pragma: no cover AutoFormattedTB = None units = UnitRegistry(autoconvert_offset_to_baseunit=True) Q_ = units.Quantity units.define(UnitDefinition("percent", "pct", (), ScaleConverter(1.0 / 100.0))) units.setup_matplotlib() # Don't add the _render_traceback_ function to DimensionalityError if # IPython isn't present. This function is only used by the IPython/ipykernel # anyways, so it doesn't matter if it's missing if IPython isn't available. if AutoFormattedTB is not None: # pragma: no cover def render_traceback(self): """Render a minimized version of the DimensionalityError traceback. The default Jupyter/IPython traceback includes a lot of context from within pint that actually raises the DimensionalityError. This context isn't really needed for this particular error, since the problem is almost certainly in the user code. This function removes the additional context. """
# # eq['p_p'] = export_latex(_p_p(rho_m, v_s, v_p), p_p) # # eq['p_man'] = export_latex(_p_man(p_p, p_s), p_man) #save_to_tex(eq) #%% Q_h graph from pint import UnitRegistry import matplotlib.pyplot as plt import seaborn as sns import pandas as pd u = UnitRegistry() u.setup_matplotlib() p_atm = (1. * u.atmosphere).to('Pa') L_p = 200. * u.m L_s = 10. * u.m L_a = 7. * u.m theta = 10. * u.deg S = 30. * u.m H = 32. * u.m a = S - L_a * np.sin(theta.to('rad').m) D_s = 100. * u.mm D_p = 150. * u.mm epsilon_b = 0.4
import numpy as np import six from IPython.display import Latex import matplotlib.pyplot as plt import pytablewriter from enum import Enum from collections import UserList from pint import UnitRegistry, set_application_registry from pint import __version__ as pint_version u = UnitRegistry(autoconvert_offset_to_baseunit=True) if int(pint_version.split('.')[0]) * 10 + int(pint_version.split('.')[1]) > 8: u.setup_matplotlib(True) u.default_format = '.4f~L' set_application_registry(u) np.set_printoptions(precision=3) __all__ = [ 'density', 'specific_volume', 'u', 'np', 'latex', 'V_flux', 'delta_u', 'speed', 'Delta_speed', 'isentropisch_work', 'isentropische_dT', 'isentropische_dV', 'isentropische_dv', 'isentropische_dP', 'isobaar_heat', 'isobaar_work', 'isobaar_dv', 'isobaar_dT', 'technical_work', 'delta_e_kin', 'delta_h', 'ProcessType', 'TransitionState', 'Transition', 'Cycle', 'States', 'mass_flux' ] class ProcessType(Enum): POLYTROPIC = -1
from pint import UnitRegistry ureg = UnitRegistry() Q_ = ureg.Quantity ureg.setup_matplotlib(True)
from pint import UnitRegistry ureg = UnitRegistry() Q_ = ureg.Quantity ureg.setup_matplotlib() mks_units = { "Supply Temperature": ureg.degC, "Target Temperature": ureg.degC, "Heat Capacity Flowrate": ureg.kilowatt / ureg.degK, "Enthalpy": ureg.megajoule / ureg.hour, } imperial_units = { "Supply Temperature": ureg.degF, "Target Temperature": ureg.degF, "Heat Capacity Flowrate": ureg.btu / ureg.delta_degF / ureg.hour, "Enthalpy": ureg.btu / ureg.hour, }