INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Load playlists from local filepaths.
def get_local_playlists(filepaths, exclude_patterns=None, max_depth=float('inf')): """Load playlists from local filepaths. Parameters: filepaths (list or str): Filepath(s) to search for music files. exclude_patterns (list or str): Pattern(s) to exclude. Patterns are Python regex patterns. Filepaths ...
Load songs from local playlist.
def get_local_playlist_songs( playlist, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False, exclude_patterns=None): """Load songs from local playlist. Parameters: playlist (str): An M3U(8) playlist filepath. include_filters (list): A list of ``(field, pattern)`` tuples. ...
Prepare the lines read from the text file before starting to process it.
def _prepare_lines_(self, lines): """ Prepare the lines read from the text file before starting to process it. """ result = [] for line in lines: # Remove all whitespace from the start and end of the line. line = line.strip() # Replac...
Extract an alphabetically sorted list of elements from the compounds of the material.
def _create_element_list_(self): """ Extract an alphabetically sorted list of elements from the compounds of the material. :returns: An alphabetically sorted list of elements. """ element_set = stoich.elements(self.compounds) return sorted(list(element_set))
Add an assay to the material.
def add_assay(self, name, assay): """ Add an assay to the material. :param name: The name of the new assay. :param assay: A list containing the compound mass fractions for the assay. The sequence of the assay's elements must correspond to the sequence of the material...
Determines whether value is a tuple of the format ( compound ( str ) mass ( float )).
def _is_compound_mass_tuple(self, value): """ Determines whether value is a tuple of the format (compound(str), mass(float)). """ if not type(value) is tuple: return False elif not len(value) == 2: return False elif not type(value[0]) is s...
Create a complete copy of self.
def clone(self): """ Create a complete copy of self. :returns: A MaterialPackage that is identical to self. """ result = copy.copy(self) result.compound_masses = copy.deepcopy(self.compound_masses) return result
Determine the assay of self.
def get_assay(self): """ Determine the assay of self. :returns: [mass fractions] An array containing the assay of self. """ masses_sum = sum(self.compound_masses) return [m / masses_sum for m in self.compound_masses]
Get the masses of elements in the package.
def get_element_masses(self): """ Get the masses of elements in the package. :returns: [kg] An array of element masses. The sequence of the elements in the result corresponds with the sequence of elements in the element list of the material. """ result = [0]...
Determine the masses of elements in the package.
def get_element_mass(self, element): """ Determine the masses of elements in the package. :returns: [kg] An array of element masses. The sequence of the elements in the result corresponds with the sequence of elements in the element list of the material. """ ...
Extract other from self modifying self and returning the extracted material as a new package.
def extract(self, other): """ Extract 'other' from self, modifying self and returning the extracted material as a new package. :param other: Can be one of the following: * float: A mass equal to other is extracted from self. Self is reduced by other and the extrac...
Add another chem material package to this material package.
def add_to(self, other): """ Add another chem material package to this material package. :param other: The other material package. """ # Add another package. if type(other) is MaterialPackage: # Packages of the same material. if self.material ==...
Calculate the density at the specified temperature.
def calculate(self, **state): """ Calculate the density at the specified temperature. :param T: [K] temperature :returns: [kg/m3] density The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. ...
Calculate the density at the specified temperature pressure and composition.
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 ...
Set the parent path and the path from the new parent path.
def set_parent_path(self, value): """ Set the parent path and the path from the new parent path. :param value: The path to the object's parent """ self._parent_path = value self.path = value + r'/' + self.name self._update_childrens_parent_path()
Create a sub account in the account.
def create_account(self, name, number=None, description=None): """ Create a sub account in the account. :param name: The account name. :param description: The account description. :param number: The account number. :returns: The created account. """ new...
Remove an account from the account s sub accounts.
def remove_account(self, name): """ Remove an account from the account's sub accounts. :param name: The name of the account to remove. """ acc_to_remove = None for a in self.accounts: if a.name == name: acc_to_remove = a if acc_to_rem...
Retrieves a child account. This could be a descendant nested at any level.
def get_child_account(self, account_name): """ Retrieves a child account. This could be a descendant nested at any level. :param account_name: The name of the account to retrieve. :returns: The child account, if found, else None. """ if r'/' in account_name: ...
Create an account in the general ledger structure.
def _create_account_(self, name, number, account_type): """ Create an account in the general ledger structure. :param name: The account name. :param number: The account number. :param account_type: The account type. :returns: The created account. """ ne...
Retrieves an account s descendants from the general ledger structure given the account name.
def get_account_descendants(self, account): """ Retrieves an account's descendants from the general ledger structure given the account name. :param account_name: The account name. :returns: The decendants of the account. """ result = [] for child in acc...
Returns the account and all of it s sub accounts.
def _get_account_and_descendants_(self, account, result): """ Returns the account and all of it's sub accounts. :param account: The account. :param result: The list to add all the accounts to. """ result.append(account) for child in account.accounts: ...
Validates whether the accounts in a list of account names exists.
def validate_account_names(self, names): """ Validates whether the accounts in a list of account names exists. :param names: The names of the accounts. :returns: The descendants of the account. """ for name in names: if self.get_account(name) is None: ...
Returns a report of this class.
def report(self, format=ReportFormat.printout, output_path=None): """ Returns a report of this class. :param format: The format of the report. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :return...
Create a transaction in the general ledger.
def create_transaction(self, name, description=None, tx_date=datetime.min.date(), dt_account=None, cr_account=None, source=None, amount=0.00): """ Create a transaction in the general ledger. :param name: The transa...
Generate a transaction list report.
def transaction_list(self, start=datetime.min, end=datetime.max, format=ReportFormat.printout, component_path="", output_path=None): """ Generate a transaction list report. :param start: The star...
Generate a transaction list report.
def balance_sheet(self, end=datetime.max, format=ReportFormat.printout, output_path=None): """ Generate a transaction list report. :param end: The end date to generate the report for. :param format: The format of the report. :param output_path: The path to ...
Generate a transaction list report.
def income_statement(self, start=datetime.min, end=datetime.max, format=ReportFormat.printout, component_path="", output_path=None): """ Generate a transaction list report. :param start: The star...
Calculate a path relative to the specified module file.
def get_path_relative_to_module(module_file_path, relative_target_path): """ Calculate a path relative to the specified module file. :param module_file_path: The file path to the module. """ module_path = os.path.dirname(module_file_path) path = os.path.join(module_path, relative_target_path) ...
Get the date from a value that could be a date object or a string.
def get_date(date): """ Get the date from a value that could be a date object or a string. :param date: The date object or string. :returns: The date object. """ if type(date) is str: return datetime.strptime(date, '%Y-%m-%d').date() else: return date
Calculate the friction factor of turbulent flow ( t ) in a rough duct ( r ) for the provided conditions with Haaland s equation.
def f_tr_Haaland(Re_D, ɛ, D, warn=True): """ Calculate the friction factor of turbulent flow (t) in a rough duct (r) for the provided conditions with Haaland's equation. :param Re_D: Reynolds number for the specified hydraulic diameter. :param ɛ: [m] Surface roughness. :param D: [m] Duct hydrau...
Calculate the local Nusselt number.
def Nu_x(self, L, theta, Ts, **statef): """ Calculate the local Nusselt number. :param L: [m] characteristic length of the heat transfer surface :param theta: [°] angle of the surface with the vertical :param Ts: [K] heat transfer surface temperature :param Tf: [K] bulk ...
Calculate the average Nusselt number.
def Nu_L(self, L, theta, Ts, **statef): """ Calculate the average Nusselt number. :param L: [m] characteristic length of the heat transfer surface :param theta: [°] angle of the surface with the vertical :param Ts: [K] heat transfer surface temperature :param **statef: [...
Calculate the local heat transfer coefficient.
def h_x(self, L, theta, Ts, **statef): """ Calculate the local heat transfer coefficient. :param L: [m] characteristic length of the heat transfer surface :param theta: [°] angle of the surface with the vertical :param Ts: [K] heat transfer surface temperature :param Tf:...
Calculate the average heat transfer coefficient.
def h_L(self, L, theta, Ts, **statef): """ Calculate the average heat transfer coefficient. :param L: [m] characteristic length of the heat transfer surface :param theta: [°] angle of the surface with the vertical :param Ts: [K] heat transfer surface temperature :param T...
Prepare the lines read from the text file before starting to process it.
def _prepare_lines(self, lines): """ Prepare the lines read from the text file before starting to process it. """ result = list() for line in lines: # Remove all whitespace characters (e.g. spaces, line breaks, etc.) # from the start and end of th...
Add an assay to the material.
def add_assay(self, name, solid_density, H2O_fraction, assay): """Add an assay to the material. :param name: The name of the new assay. :param assay: A numpy array containing the size class mass fractions for the assay. The sequence of the assay's elements must correspond to...
Create a MaterialPackage based on the specified parameters.
def create_package(self, assay=None, mass=0.0, normalise=True): """ Create a MaterialPackage based on the specified parameters. :param assay: The name of the assay based on which the package must be created. :param mass: [kg] The mass of the package. :param normalise: ...
Determines whether value is a tuple of the format ( size class ( float ) mass ( float )).
def _is_size_class_mass_tuple(self, value): """ Determines whether value is a tuple of the format (size class(float), mass(float)). :param value: The value to check. :returns: Whether the value is a tuple in the required format. """ if not type(value) is tuple:...
Create a complete copy of self.
def clone(self): """ Create a complete copy of self. :returns: A MaterialPackage that is identical to self. """ result = copy.copy(self) result.size_class_masses = copy.deepcopy(self.size_class_masses) return result
Set all the size class masses and H20_mass in the package to zero and the solid_density to 1. 0
def clear(self): """ Set all the size class masses and H20_mass in the package to zero and the solid_density to 1.0 """ self.solid_density = 1.0 self.H2O_mass = 0.0 self.size_class_masses = self.size_class_masses * 0.0
Create a template csv file for a data set.
def create_template(material, path, show=False): """ Create a template csv file for a data set. :param material: the name of the material :param path: the path of the directory where the file must be written :param show: a boolean indicating whether the created file should be \ ...
Base calculate method for models. Validates the material state parameter ( s ).
def calculate(self, **state): """ Base calculate method for models. Validates the material state parameter(s). :param **state: The material state """ if not self.state_validator.validate(state): msg = f"{self.material} {self.property} model. The state " ...
Returns the response and body for a delete request endpoints = users # resource to access data = { username: blah password: blah } # DELETE body url_data = {} () # Used to modularize endpoints see __init__ parameters = {} (( ) () ) # URL paramters ex: google. com?q = a&f = b
def delete(self, endpoint, data, url_data=None, parameters=None): """Returns the response and body for a delete request endpoints = 'users' # resource to access data = {'username': 'blah, 'password': blah} # DELETE body url_data = {}, () # Used to modularize endpoints, see...
Returns the response and body for a head request endpoints = users # resource to access url_data = {} () # Used to modularize endpoints see __init__ parameters = {} (( ) () ) # URL paramters ex: google. com?q = a&f = b
def head(self, endpoint, url_data=None, parameters=None): """Returns the response and body for a head request endpoints = 'users' # resource to access url_data = {}, () # Used to modularize endpoints, see __init__ parameters = {}, ((),()) # URL paramters, ex: google.com?q=a...
Generate URL on the modularized endpoints and url parameters
def _url(self, endpoint, url_data=None, parameters=None): """Generate URL on the modularized endpoints and url parameters""" try: url = '%s/%s' % (self.base_url, self.endpoints[endpoint]) except KeyError: raise EndPointDoesNotExist(endpoint) if url_data: ...
Used to instantiate a regular HTTP request object
def _httplib2_init(username, password): """Used to instantiate a regular HTTP request object""" obj = httplib2.Http() if username and password: obj.add_credentials(username, password) return obj
Calculate dynamic viscosity at the specified temperature and composition:
def calculate(self, **state): """ Calculate dynamic viscosity at the specified temperature and composition: :param T: [K] temperature :param x: [mole fraction] composition dictionary , e.g. \ {'SiO2': 0.25, 'CaO': 0.25, 'MgO': 0.25, 'FeO': 0.25} :returns: [Pa.s]...
Calculate dynamic viscosity at the specified temperature and composition:
def calculate(self, **state): """ Calculate dynamic viscosity at the specified temperature and composition: :param T: [K] temperature :param y: [mass fraction] composition dictionary , e.g. \ {'SiO2': 0.25, 'CaO': 0.25, 'MgO': 0.25, 'FeO': 0.25} :returns: [Pa.s]...
Calculate dynamic viscosity at the specified temperature and composition:
def calculate(self, **state): """ Calculate dynamic viscosity at the specified temperature and composition: :param T: [K] temperature :param x: [mole fraction] composition dictionary , e.g. \ {'SiO2': 0.25, 'CaO': 0.25, 'MgO': 0.25, 'FeO': 0.25} :returns: [Pa.s]...
Calculate the alpha value given the material state.
def alpha(self, **state): """ Calculate the alpha value given the material state. :param **state: material state :returns: float """ return self.k(**state) / self.rho(**state) / self.Cp(**state)
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
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 fract...
Calculate the enthalpy at the specified temperature and composition using equation 9 in Merrick1983b.
def calculate(self, **state): """ Calculate the enthalpy at the specified temperature and composition using equation 9 in Merrick1983b. :param T: [K] temperature :param y_C: Carbon mass fraction :param y_H: Hydrogen mass fraction :param y_O: Oxygen mass fraction ...
Create an entity and add it to the model.
def create_entity(self, name, gl_structure, description=None): """ Create an entity and add it to the model. :param name: The entity name. :param gl_structure: The entity's general ledger structure. :param description: The entity description. :returns: The created entit...
Remove an entity from the model.
def remove_entity(self, name): """ Remove an entity from the model. :param name: The name of the entity to remove. """ entity_to_remove = None for e in self.entities: if e.name == name: entity_to_remove = e if entity_to_remove is not ...
Prepare the model for execution.
def prepare_to_run(self): """ Prepare the model for execution. """ self.clock.reset() for e in self.entities: e.prepare_to_run(self.clock, self.period_count)
Execute the model.
def run(self): """ Execute the model. """ self.prepare_to_run() for i in range(0, self.period_count): for e in self.entities: e.run(self.clock) self.clock.tick()
Extract an alphabetically sorted list of elements from the material s compounds.
def _create_element_list(self): """ Extract an alphabetically sorted list of elements from the material's compounds. :returns: Alphabetically sorted list of elements. """ element_set = stoich.elements(self.compounds) return sorted(list(element_set))
Add an assay to the material.
def add_assay(self, name, assay): """ Add an assay to the material. :param name: Assay name. :param assay: Numpy array containing the compound mass fractions for the assay. The sequence of the assay's elements must correspond to the sequence of the material's compou...
Create a MaterialPackage based on the specified parameters.
def create_package(self, assay=None, mass=0.0, P=1.0, T=25.0, normalise=True): """ Create a MaterialPackage based on the specified parameters. :param assay: Name of the assay to be used to create the package. :param mass: Package mass. [kg] :param...
Create a MaterialStream based on the specified parameters.
def create_stream(self, assay=None, mfr=0.0, P=1.0, T=25.0, normalise=True): """ Create a MaterialStream based on the specified parameters. :param assay: Name of the assay to be used to create the stream. :param mfr: Stream mass flow rate. [kg/h] :param P: ...
Calculate the enthalpy of the package at the specified temperature.
def _calculate_H(self, T): """ Calculate the enthalpy of the package at the specified temperature. :param T: Temperature. [°C] :returns: Enthalpy. [kWh] """ if self.isCoal: return self._calculate_Hfr_coal(T) H = 0.0 for compound in self.mat...
Calculate the enthalpy of the package at the specified temperature in case the material is coal.
def _calculate_H_coal(self, T): """ Calculate the enthalpy of the package at the specified temperature, in case the material is coal. :param T: [°C] temperature :returns: [kWh] enthalpy """ m_C = 0 # kg m_H = 0 # kg m_O = 0 # kg m_N =...
Calculate the temperature of the package given the specified enthalpy using a secant algorithm.
def _calculate_T(self, H): """ Calculate the temperature of the package given the specified enthalpy using a secant algorithm. :param H: Enthalpy. [kWh] :returns: Temperature. [°C] """ # Create the initial guesses for temperature. x = list() x.a...
Determines whether value is a tuple of the format ( compound ( str ) mass ( float )).
def _is_compound_mass_tuple(self, value): """ Determines whether value is a tuple of the format (compound(str), mass(float)). :param value: The value to be tested. :returns: True or False """ if not type(value) is tuple: return False elif no...
Set the enthalpy of the package to the specified value and recalculate it s temperature.
def H(self, H): """ Set the enthalpy of the package to the specified value, and recalculate it's temperature. :param H: The new enthalpy value. [kWh] """ self._H = H self._T = self._calculate_T(H)
Set the temperature of the package to the specified value and recalculate it s enthalpy.
def T(self, T): """ Set the temperature of the package to the specified value, and recalculate it's enthalpy. :param T: Temperature. [°C] """ self._T = T self._H = self._calculate_H(T)
Create a complete copy of the package.
def clone(self): """Create a complete copy of the package. :returns: A new MaterialPackage object.""" result = copy.copy(self) result._compound_masses = copy.deepcopy(self._compound_masses) return result
Set all the compound masses in the package to zero. Set the pressure to 1 the temperature to 25 and the enthalpy to zero.
def clear(self): """ Set all the compound masses in the package to zero. Set the pressure to 1, the temperature to 25 and the enthalpy to zero. """ self._compound_masses = self._compound_masses * 0.0 self._P = 1.0 self._T = 25.0 self._H = 0.0
Determine the mass of the specified compound in the package.
def get_compound_mass(self, compound): """ Determine the mass of the specified compound in the package. :param compound: Formula and phase of a compound, e.g. "Fe2O3[S1]". :returns: Mass. [kg] """ if compound in self.material.compounds: return self._compoun...
Determine the mole amounts of all the compounds.
def get_compound_amounts(self): """ Determine the mole amounts of all the compounds. :returns: List of amounts. [kmol] """ result = self._compound_masses * 1.0 for compound in self.material.compounds: index = self.material.get_compound_index(compound) ...
Determine the mole amount of the specified compound.
def get_compound_amount(self, compound): """ Determine the mole amount of the specified compound. :returns: Amount. [kmol] """ index = self.material.get_compound_index(compound) return stoich.amount(compound, self._compound_masses[index])
Determine the sum of mole amounts of all the compounds.
def amount(self): """ Determine the sum of mole amounts of all the compounds. :returns: Amount. [kmol] """ return sum(self.get_compound_amount(c) for c in self.material.compounds)
Determine the masses of elements in the package.
def get_element_masses(self, elements=None): """ Determine the masses of elements in the package. :returns: Array of element masses. [kg] """ if elements is None: elements = self.material.elements result = numpy.zeros(len(elements)) for compound in ...
Determine the masses of elements in the package and return as a dictionary.
def get_element_mass_dictionary(self): """ Determine the masses of elements in the package and return as a dictionary. :returns: Dictionary of element symbols and masses. [kg] """ element_symbols = self.material.elements element_masses = self.get_element_masses(...
Determine the mass of the specified elements in the package.
def get_element_mass(self, element): """ Determine the mass of the specified elements in the package. :returns: Masses. [kg] """ result = numpy.zeros(1) for compound in self.material.compounds: result += self.get_compound_mass(compound) *\ nu...
Extract other from this package modifying this package and returning the extracted material as a new package.
def extract(self, other): """ Extract 'other' from this package, modifying this package and returning the extracted material as a new package. :param other: Can be one of the following: * float: A mass equal to other is extracted from self. Self is reduced by othe...
Calculate the enthalpy flow rate of the stream at the specified temperature.
def _calculate_Hfr(self, T): """ Calculate the enthalpy flow rate of the stream at the specified temperature. :param T: Temperature. [°C] :returns: Enthalpy flow rate. [kWh/h] """ if self.isCoal: return self._calculate_Hfr_coal(T) Hfr = 0.0...
Calculate the enthalpy of formation of the dry - ash - free ( daf ) component of the coal.
def _calculate_DH298_coal(self): """ Calculate the enthalpy of formation of the dry-ash-free (daf) component of the coal. :returns: [kWh/kg daf] enthalpy of formation of daf coal """ m_C = 0 # kg m_H = 0 # kg m_O = 0 # kg m_N = 0 # kg m_S = 0...
Calculate the enthalpy flow rate of the stream at the specified temperature in the case of it being coal.
def _calculate_Hfr_coal(self, T): """ Calculate the enthalpy flow rate of the stream at the specified temperature, in the case of it being coal. :param T: Temperature. [°C] :returns: Enthalpy flow rate. [kWh/h] """ m_C = 0 # kg/h m_H = 0 # kg/h ...
Calculate the temperature of the stream given the specified enthalpy flow rate using a secant algorithm.
def _calculate_T(self, Hfr): """ Calculate the temperature of the stream given the specified enthalpy flow rate using a secant algorithm. :param H: Enthalpy flow rate. [kWh/h] :returns: Temperature. [°C] """ # Create the initial guesses for temperature. ...
Determines whether value is a tuple of the format ( compound ( str ) mfr ( float ) temperature ( float )).
def _is_compound_mfr_temperature_tuple(self, value): """Determines whether value is a tuple of the format (compound(str), mfr(float), temperature(float)). :param value: The value to be tested. :returns: True or False""" if not type(value) is tuple: return False ...
Set the enthalpy flow rate of the stream to the specified value and recalculate it s temperature.
def Hfr(self, Hfr): """ Set the enthalpy flow rate of the stream to the specified value, and recalculate it's temperature. :param H: The new enthalpy flow rate value. [kWh/h] """ self._Hfr = Hfr self._T = self._calculate_T(Hfr)
Set the temperature of the stream to the specified value and recalculate it s enthalpy.
def T(self, T): """ Set the temperature of the stream to the specified value, and recalculate it's enthalpy. :param T: Temperature. [°C] """ self._T = T self._Hfr = self._calculate_Hfr(T)
Set the higher heating value of the stream to the specified value and recalculate the formation enthalpy of the daf coal.
def HHV(self, HHV): """ Set the higher heating value of the stream to the specified value, and recalculate the formation enthalpy of the daf coal. :param HHV: MJ/kg coal, higher heating value """ self._HHV = HHV # MJ/kg coal if self.isCoal: self._DH...
Create a complete copy of the stream.
def clone(self): """Create a complete copy of the stream. :returns: A new MaterialStream object.""" result = copy.copy(self) result._compound_mfrs = copy.deepcopy(self._compound_mfrs) return result
Set all the compound mass flow rates in the stream to zero. Set the pressure to 1 the temperature to 25 and the enthalpy to zero.
def clear(self): """ Set all the compound mass flow rates in the stream to zero. Set the pressure to 1, the temperature to 25 and the enthalpy to zero. """ self._compound_mfrs = self._compound_mfrs * 0.0 self._P = 1.0 self._T = 25.0 self._H = 0.0
Determine the mass flow rate of the specified compound in the stream.
def get_compound_mfr(self, compound): """ Determine the mass flow rate of the specified compound in the stream. :param compound: Formula and phase of a compound, e.g. "Fe2O3[S1]". :returns: Mass flow rate. [kg/h] """ if compound in self.material.compounds: ...
Determine the amount flow rates of all the compounds.
def get_compound_afrs(self): """ Determine the amount flow rates of all the compounds. :returns: List of amount flow rates. [kmol/h] """ result = self._compound_mfrs * 1.0 for compound in self.material.compounds: index = self.material.get_compound_index(comp...
Determine the amount flow rate of the specified compound.
def get_compound_afr(self, compound): """ Determine the amount flow rate of the specified compound. :returns: Amount flow rate. [kmol/h] """ index = self.material.get_compound_index(compound) return stoich.amount(compound, self._compound_mfrs[index])
Determine the sum of amount flow rates of all the compounds.
def afr(self): """ Determine the sum of amount flow rates of all the compounds. :returns: Amount flow rate. [kmol/h] """ result = 0.0 for compound in self.material.compounds: result += self.get_compound_afr(compound) return result
Determine the mass flow rates of elements in the stream.
def get_element_mfrs(self, elements=None): """ Determine the mass flow rates of elements in the stream. :returns: Array of element mass flow rates. [kg/h] """ if elements is None: elements = self.material.elements result = numpy.zeros(len(elements)) ...
Determine the mass flow rates of elements in the stream and return as a dictionary.
def get_element_mfr_dictionary(self): """ Determine the mass flow rates of elements in the stream and return as a dictionary. :returns: Dictionary of element symbols and mass flow rates. [kg/h] """ element_symbols = self.material.elements element_mfrs = self.get...
Determine the mass flow rate of the specified elements in the stream.
def get_element_mfr(self, element): """ Determine the mass flow rate of the specified elements in the stream. :returns: Mass flow rates. [kg/h] """ result = 0.0 for compound in self.material.compounds: formula = compound.split('[')[0] result += s...
Extract other from this stream modifying this stream and returning the extracted material as a new stream.
def extract(self, other): """ Extract 'other' from this stream, modifying this stream and returning the extracted material as a new stream. :param other: Can be one of the following: * float: A mass flow rate equal to other is extracted from self. Self is reduced ...
Calculate the Grashof number.
def Gr(L: float, Ts: float, Tf: float, beta: float, nu: float, g: float): """ Calculate the Grashof number. :param L: [m] heat transfer surface characteristic length. :param Ts: [K] heat transfer surface temperature. :param Tf: [K] bulk fluid temperature. :param beta: [1/K] fluid coefficient of...
Calculate the Reynolds number.
def Re(L: float, v: float, nu: float) -> float: """ Calculate the Reynolds number. :param L: [m] surface characteristic length. :param v: [m/s] fluid velocity relative to the object. :param nu: [m2/s] fluid kinematic viscosity. :returns: float """ return v * L / nu
Calculate the Ralleigh number.
def Ra(L: float, Ts: float, Tf: float, alpha: float, beta: float, nu: float ) -> float: """ Calculate the Ralleigh number. :param L: [m] heat transfer surface characteristic length. :param Ts: [K] heat transfer surface temperature. :param Tf: [K] bulk fluid temperature. :param alpha: [m2...
Calculate the Nusselt number.
def Nu(L: float, h: float, k: float) -> float: """ Calculate the Nusselt number. :param L: [m] heat transfer surface characteristic length. :param h: [W/K/m2] convective heat transfer coefficient. :param k: [W/K/m] fluid thermal conductivity. :returns: float """ return h * L / k
Calculate the Sherwood number.
def Sh(L: float, h: float, D: float) -> float: """ Calculate the Sherwood number. :param L: [m] mass transfer surface characteristic length. :param h: [m/s] mass transfer coefficient. :param D: [m2/s] fluid mass diffusivity. :returns: float """ return h * L / D
Create a model object from the data set for the property specified by the supplied symbol using the specified polynomial degree.
def create(dataset, symbol, degree): """ Create a model object from the data set for the property specified by the supplied symbol, using the specified polynomial degree. :param dataset: a DataSet object :param symbol: the symbol of the property to be described, e.g. 'rho' ...