def _calc_a(self, y_C, y_H, y_O, y_N, y_S): """ Calculate the mean atomic weight for the specified element mass fractions. :param y_C: Carbon mass fraction :param y_H: Hydrogen mass fraction :param y_O: Oxygen mass fraction :param y_N: Nitrogen mass fraction :param y_S: Sulphur mass fraction :returns: [kg/kmol] mean atomic weight See equation at bottom of page 538 of Merrick1983a. """ return 1 / (y_C / mm("C") + y_H / mm("H") + y_O / mm("O") + y_N / mm("N") + y_S / mm("S"))
def molar_mass(compound): """ Determine the molar mass of a chemical compound. :param compound: Formula of a chemical compound, e.g. 'Fe2O3'. :returns: [kg/mol] Molar mass. """ return mm(compound) / 1000.0
def _create_x_and_mm(self): x = {} x['N2'] = random.uniform(0.0, 10.0) x['O2'] = random.uniform(0.0, 10.0) x['Ar'] = random.uniform(0.0, 10.0) x['H2O'] = random.uniform(0.0, 10.0) total = sum(x.values()) x = {key: x[key]/total for key in x.keys()} molar_mass = sum([x[key]*mm(key) for key in x.keys()]) return x, molar_mass
def _create_x_and_mm(self): x = { 'N2': random.uniform(0.0, 10.0), 'O2': random.uniform(0.0, 10.0), 'Ar': random.uniform(0.0, 10.0), 'H2O': random.uniform(0.0, 10.0) } total = sum(x.values()) x = {key: x[key] / total for key in x.keys()} molar_mass = sum([x[key] * mm(key) for key in x.keys()]) return x, molar_mass
def __init__(self, dictionary): self.formula = dictionary['Formula'] """Chemical formula, e.g. 'Fe', 'CO2'.""" self.molar_mass = mm(self.formula) / 1000.0 """Molar mass. [kg/mol]""" self._phases = {} """Dictionary containing the compound's phase objects.""" if 'Reference' in dictionary: self.reference = dictionary['Reference'] else: self.reference = "" """Reference to the publisher of the thermo data.""" for k, v in dictionary['Phases'].items(): self._phases[k] = Phase(v)
def __init__(self, dictionary): self.formula = dictionary['Formula'] """Chemical formula, e.g. 'Fe', 'CO2'.""" self.molar_mass = mm(self.formula) / 1000.0 """Molar mass. [kg/mol]""" self._phases = {} """Dictionary containing the compound's phase objects.""" if 'Reference' in dictionary: self.reference = dictionary['Reference'] else: self.reference = "" """Reference to the publisher of the thermo data.""" for k, v in dictionary['Phases'].items(): if not 'Symbol' in v: v['Symbol'] = k self._phases[k] = Phase(v)
def calculate(self, **state): """ Calculate the density at the specified temperature, pressure, and composition. :param T: [K] temperature :param P: [Pa] pressure :param x: [mole fraction] dictionary of compounds and mole fractions :returns: [kg/m3] density The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ super().calculate(**state) mm_average = 0.0 for compound, molefraction in state['x'].items(): mm_average += molefraction * mm(compound) mm_average /= 1000.0 return mm_average * state['P'] / R / state['T']