partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
_BaseWrapper.get_local_playlists
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 are excluded if they match any of the exclude patterns. max_depth (int): The depth in the directory tree to walk. A depth of '0' limits the walk to the top directory. Default: No limit. Returns: A list of local playlist filepaths matching criteria and a list of local playlist filepaths excluded using exclusion criteria.
gmusicapi_wrapper/base.py
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 are excluded if they match any of the exclude patterns. max_depth (int): The depth in the directory tree to walk. A depth of '0' limits the walk to the top directory. Default: No limit. Returns: A list of local playlist filepaths matching criteria and a list of local playlist filepaths excluded using exclusion criteria. """ logger.info("Loading local playlists...") included_playlists = [] excluded_playlists = [] supported_filepaths = get_supported_filepaths(filepaths, SUPPORTED_PLAYLIST_FORMATS, max_depth=max_depth) included_playlists, excluded_playlists = exclude_filepaths(supported_filepaths, exclude_patterns=exclude_patterns) logger.info("Excluded {0} local playlists".format(len(excluded_playlists))) logger.info("Loaded {0} local playlists".format(len(included_playlists))) return included_playlists, excluded_playlists
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 are excluded if they match any of the exclude patterns. max_depth (int): The depth in the directory tree to walk. A depth of '0' limits the walk to the top directory. Default: No limit. Returns: A list of local playlist filepaths matching criteria and a list of local playlist filepaths excluded using exclusion criteria. """ logger.info("Loading local playlists...") included_playlists = [] excluded_playlists = [] supported_filepaths = get_supported_filepaths(filepaths, SUPPORTED_PLAYLIST_FORMATS, max_depth=max_depth) included_playlists, excluded_playlists = exclude_filepaths(supported_filepaths, exclude_patterns=exclude_patterns) logger.info("Excluded {0} local playlists".format(len(excluded_playlists))) logger.info("Loaded {0} local playlists".format(len(included_playlists))) return included_playlists, excluded_playlists
[ "Load", "playlists", "from", "local", "filepaths", "." ]
thebigmunch/gmusicapi-wrapper
python
https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/base.py#L95-L126
[ "def", "get_local_playlists", "(", "filepaths", ",", "exclude_patterns", "=", "None", ",", "max_depth", "=", "float", "(", "'inf'", ")", ")", ":", "logger", ".", "info", "(", "\"Loading local playlists...\"", ")", "included_playlists", "=", "[", "]", "excluded_playlists", "=", "[", "]", "supported_filepaths", "=", "get_supported_filepaths", "(", "filepaths", ",", "SUPPORTED_PLAYLIST_FORMATS", ",", "max_depth", "=", "max_depth", ")", "included_playlists", ",", "excluded_playlists", "=", "exclude_filepaths", "(", "supported_filepaths", ",", "exclude_patterns", "=", "exclude_patterns", ")", "logger", ".", "info", "(", "\"Excluded {0} local playlists\"", ".", "format", "(", "len", "(", "excluded_playlists", ")", ")", ")", "logger", ".", "info", "(", "\"Loaded {0} local playlists\"", ".", "format", "(", "len", "(", "included_playlists", ")", ")", ")", "return", "included_playlists", ",", "excluded_playlists" ]
8708683cd33955def1378fc28319ef37805b851d
valid
_BaseWrapper.get_local_playlist_songs
Load songs from local playlist. Parameters: playlist (str): An M3U(8) playlist filepath. include_filters (list): A list of ``(field, pattern)`` tuples. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values don't match any of the given patterns. exclude_filters (list): A list of ``(field, pattern)`` tuples. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values match any of the given patterns. all_includes (bool): If ``True``, all include_filters criteria must match to include a song. all_excludes (bool): If ``True``, all exclude_filters criteria must match to exclude a song. exclude_patterns (list or str): Pattern(s) to exclude. Patterns are Python regex patterns. Filepaths are excluded if they match any of the exclude patterns. Returns: A list of local playlist song filepaths matching criteria, a list of local playlist song filepaths filtered out using filter criteria, and a list of local playlist song filepaths excluded using exclusion criteria.
gmusicapi_wrapper/base.py
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. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values don't match any of the given patterns. exclude_filters (list): A list of ``(field, pattern)`` tuples. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values match any of the given patterns. all_includes (bool): If ``True``, all include_filters criteria must match to include a song. all_excludes (bool): If ``True``, all exclude_filters criteria must match to exclude a song. exclude_patterns (list or str): Pattern(s) to exclude. Patterns are Python regex patterns. Filepaths are excluded if they match any of the exclude patterns. Returns: A list of local playlist song filepaths matching criteria, a list of local playlist song filepaths filtered out using filter criteria, and a list of local playlist song filepaths excluded using exclusion criteria. """ logger.info("Loading local playlist songs...") if os.name == 'nt' and CYGPATH_RE.match(playlist): playlist = convert_cygwin_path(playlist) filepaths = [] base_filepath = os.path.dirname(os.path.abspath(playlist)) with open(playlist) as local_playlist: for line in local_playlist.readlines(): line = line.strip() if line.lower().endswith(SUPPORTED_SONG_FORMATS): path = line if not os.path.isabs(path): path = os.path.join(base_filepath, path) if os.path.isfile(path): filepaths.append(path) supported_filepaths = get_supported_filepaths(filepaths, SUPPORTED_SONG_FORMATS) included_songs, excluded_songs = exclude_filepaths(supported_filepaths, exclude_patterns=exclude_patterns) matched_songs, filtered_songs = filter_local_songs( included_songs, include_filters=include_filters, exclude_filters=exclude_filters, all_includes=all_includes, all_excludes=all_excludes ) logger.info("Excluded {0} local playlist songs".format(len(excluded_songs))) logger.info("Filtered {0} local playlist songs".format(len(filtered_songs))) logger.info("Loaded {0} local playlist songs".format(len(matched_songs))) return matched_songs, filtered_songs, excluded_songs
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. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values don't match any of the given patterns. exclude_filters (list): A list of ``(field, pattern)`` tuples. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata field values match any of the given patterns. all_includes (bool): If ``True``, all include_filters criteria must match to include a song. all_excludes (bool): If ``True``, all exclude_filters criteria must match to exclude a song. exclude_patterns (list or str): Pattern(s) to exclude. Patterns are Python regex patterns. Filepaths are excluded if they match any of the exclude patterns. Returns: A list of local playlist song filepaths matching criteria, a list of local playlist song filepaths filtered out using filter criteria, and a list of local playlist song filepaths excluded using exclusion criteria. """ logger.info("Loading local playlist songs...") if os.name == 'nt' and CYGPATH_RE.match(playlist): playlist = convert_cygwin_path(playlist) filepaths = [] base_filepath = os.path.dirname(os.path.abspath(playlist)) with open(playlist) as local_playlist: for line in local_playlist.readlines(): line = line.strip() if line.lower().endswith(SUPPORTED_SONG_FORMATS): path = line if not os.path.isabs(path): path = os.path.join(base_filepath, path) if os.path.isfile(path): filepaths.append(path) supported_filepaths = get_supported_filepaths(filepaths, SUPPORTED_SONG_FORMATS) included_songs, excluded_songs = exclude_filepaths(supported_filepaths, exclude_patterns=exclude_patterns) matched_songs, filtered_songs = filter_local_songs( included_songs, include_filters=include_filters, exclude_filters=exclude_filters, all_includes=all_includes, all_excludes=all_excludes ) logger.info("Excluded {0} local playlist songs".format(len(excluded_songs))) logger.info("Filtered {0} local playlist songs".format(len(filtered_songs))) logger.info("Loaded {0} local playlist songs".format(len(matched_songs))) return matched_songs, filtered_songs, excluded_songs
[ "Load", "songs", "from", "local", "playlist", "." ]
thebigmunch/gmusicapi-wrapper
python
https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/base.py#L129-L193
[ "def", "get_local_playlist_songs", "(", "playlist", ",", "include_filters", "=", "None", ",", "exclude_filters", "=", "None", ",", "all_includes", "=", "False", ",", "all_excludes", "=", "False", ",", "exclude_patterns", "=", "None", ")", ":", "logger", ".", "info", "(", "\"Loading local playlist songs...\"", ")", "if", "os", ".", "name", "==", "'nt'", "and", "CYGPATH_RE", ".", "match", "(", "playlist", ")", ":", "playlist", "=", "convert_cygwin_path", "(", "playlist", ")", "filepaths", "=", "[", "]", "base_filepath", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "playlist", ")", ")", "with", "open", "(", "playlist", ")", "as", "local_playlist", ":", "for", "line", "in", "local_playlist", ".", "readlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", ".", "lower", "(", ")", ".", "endswith", "(", "SUPPORTED_SONG_FORMATS", ")", ":", "path", "=", "line", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "base_filepath", ",", "path", ")", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "filepaths", ".", "append", "(", "path", ")", "supported_filepaths", "=", "get_supported_filepaths", "(", "filepaths", ",", "SUPPORTED_SONG_FORMATS", ")", "included_songs", ",", "excluded_songs", "=", "exclude_filepaths", "(", "supported_filepaths", ",", "exclude_patterns", "=", "exclude_patterns", ")", "matched_songs", ",", "filtered_songs", "=", "filter_local_songs", "(", "included_songs", ",", "include_filters", "=", "include_filters", ",", "exclude_filters", "=", "exclude_filters", ",", "all_includes", "=", "all_includes", ",", "all_excludes", "=", "all_excludes", ")", "logger", ".", "info", "(", "\"Excluded {0} local playlist songs\"", ".", "format", "(", "len", "(", "excluded_songs", ")", ")", ")", "logger", ".", "info", "(", "\"Filtered {0} local playlist songs\"", ".", "format", "(", "len", "(", "filtered_songs", ")", ")", ")", "logger", ".", "info", "(", "\"Loaded {0} local playlist songs\"", ".", "format", "(", "len", "(", "matched_songs", ")", ")", ")", "return", "matched_songs", ",", "filtered_songs", ",", "excluded_songs" ]
8708683cd33955def1378fc28319ef37805b851d
valid
Material._prepare_lines_
Prepare the lines read from the text file before starting to process it.
auxi/modelling/process/materials/chem.py
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() # Replace all tabs with spaces. line = line.replace('\t', ' ') # Replace all repeating spaces with a single space. while line.find(' ') > -1: line = line.replace(' ', ' ') result.append(line) return result
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() # Replace all tabs with spaces. line = line.replace('\t', ' ') # Replace all repeating spaces with a single space. while line.find(' ') > -1: line = line.replace(' ', ' ') result.append(line) return result
[ "Prepare", "the", "lines", "read", "from", "the", "text", "file", "before", "starting", "to", "process", "it", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L123-L143
[ "def", "_prepare_lines_", "(", "self", ",", "lines", ")", ":", "result", "=", "[", "]", "for", "line", "in", "lines", ":", "# Remove all whitespace from the start and end of the line.", "line", "=", "line", ".", "strip", "(", ")", "# Replace all tabs with spaces.", "line", "=", "line", ".", "replace", "(", "'\\t'", ",", "' '", ")", "# Replace all repeating spaces with a single space.", "while", "line", ".", "find", "(", "' '", ")", ">", "-", "1", ":", "line", "=", "line", ".", "replace", "(", "' '", ",", "' '", ")", "result", ".", "append", "(", "line", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material._create_element_list_
Extract an alphabetically sorted list of elements from the compounds of the material. :returns: An alphabetically sorted list of elements.
auxi/modelling/process/materials/chem.py
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))
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))
[ "Extract", "an", "alphabetically", "sorted", "list", "of", "elements", "from", "the", "compounds", "of", "the", "material", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L145-L154
[ "def", "_create_element_list_", "(", "self", ")", ":", "element_set", "=", "stoich", ".", "elements", "(", "self", ".", "compounds", ")", "return", "sorted", "(", "list", "(", "element_set", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.add_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's compounds.
auxi/modelling/process/materials/chem.py
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's compounds. """ if not type(assay) is list: raise Exception('Invalid assay. It must be a list.') elif not len(assay) == self.compound_count: raise Exception('Invalid assay: It must have the same number of ' 'elements as the material has compounds.') elif name in self.assays: raise Exception('Invalid assay: An assay with that name already ' 'exists.') self.assays[name] = assay
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's compounds. """ if not type(assay) is list: raise Exception('Invalid assay. It must be a list.') elif not len(assay) == self.compound_count: raise Exception('Invalid assay: It must have the same number of ' 'elements as the material has compounds.') elif name in self.assays: raise Exception('Invalid assay: An assay with that name already ' 'exists.') self.assays[name] = assay
[ "Add", "an", "assay", "to", "the", "material", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L178-L199
[ "def", "add_assay", "(", "self", ",", "name", ",", "assay", ")", ":", "if", "not", "type", "(", "assay", ")", "is", "list", ":", "raise", "Exception", "(", "'Invalid assay. It must be a list.'", ")", "elif", "not", "len", "(", "assay", ")", "==", "self", ".", "compound_count", ":", "raise", "Exception", "(", "'Invalid assay: It must have the same number of '", "'elements as the material has compounds.'", ")", "elif", "name", "in", "self", ".", "assays", ":", "raise", "Exception", "(", "'Invalid assay: An assay with that name already '", "'exists.'", ")", "self", ".", "assays", "[", "name", "]", "=", "assay" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._is_compound_mass_tuple
Determines whether value is a tuple of the format (compound(str), mass(float)).
auxi/modelling/process/materials/chem.py
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 str: return False elif not type(value[1]) is float: return False else: return True
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 str: return False elif not type(value[1]) is float: return False else: return True
[ "Determines", "whether", "value", "is", "a", "tuple", "of", "the", "format", "(", "compound", "(", "str", ")", "mass", "(", "float", "))", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L346-L361
[ "def", "_is_compound_mass_tuple", "(", "self", ",", "value", ")", ":", "if", "not", "type", "(", "value", ")", "is", "tuple", ":", "return", "False", "elif", "not", "len", "(", "value", ")", "==", "2", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "0", "]", ")", "is", "str", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "1", "]", ")", "is", "float", ":", "return", "False", "else", ":", "return", "True" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.clone
Create a complete copy of self. :returns: A MaterialPackage that is identical to self.
auxi/modelling/process/materials/chem.py
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
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
[ "Create", "a", "complete", "copy", "of", "self", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L363-L373
[ "def", "clone", "(", "self", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ")", "result", ".", "compound_masses", "=", "copy", ".", "deepcopy", "(", "self", ".", "compound_masses", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_assay
Determine the assay of self. :returns: [mass fractions] An array containing the assay of self.
auxi/modelling/process/materials/chem.py
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]
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]
[ "Determine", "the", "assay", "of", "self", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L383-L391
[ "def", "get_assay", "(", "self", ")", ":", "masses_sum", "=", "sum", "(", "self", ".", "compound_masses", ")", "return", "[", "m", "/", "masses_sum", "for", "m", "in", "self", ".", "compound_masses", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_element_masses
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.
auxi/modelling/process/materials/chem.py
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] * len(self.material.elements) for compound in self.material.compounds: c = self.get_compound_mass(compound) f = [c * x for x in emf(compound, self.material.elements)] result = [v+f[ix] for ix, v in enumerate(result)] return result
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] * len(self.material.elements) for compound in self.material.compounds: c = self.get_compound_mass(compound) f = [c * x for x in emf(compound, self.material.elements)] result = [v+f[ix] for ix, v in enumerate(result)] return result
[ "Get", "the", "masses", "of", "elements", "in", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L425-L440
[ "def", "get_element_masses", "(", "self", ")", ":", "result", "=", "[", "0", "]", "*", "len", "(", "self", ".", "material", ".", "elements", ")", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "c", "=", "self", ".", "get_compound_mass", "(", "compound", ")", "f", "=", "[", "c", "*", "x", "for", "x", "in", "emf", "(", "compound", ",", "self", ".", "material", ".", "elements", ")", "]", "result", "=", "[", "v", "+", "f", "[", "ix", "]", "for", "ix", ",", "v", "in", "enumerate", "(", "result", ")", "]", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_element_mass
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.
auxi/modelling/process/materials/chem.py
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. """ result = [0] for compound in self.material.compounds: c = self.get_compound_mass(compound) f = [c * x for x in emf(compound, [element])] result = [v+f[ix] for ix, v in enumerate(result)] return result[0]
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. """ result = [0] for compound in self.material.compounds: c = self.get_compound_mass(compound) f = [c * x for x in emf(compound, [element])] result = [v+f[ix] for ix, v in enumerate(result)] return result[0]
[ "Determine", "the", "masses", "of", "elements", "in", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L459-L474
[ "def", "get_element_mass", "(", "self", ",", "element", ")", ":", "result", "=", "[", "0", "]", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "c", "=", "self", ".", "get_compound_mass", "(", "compound", ")", "f", "=", "[", "c", "*", "x", "for", "x", "in", "emf", "(", "compound", ",", "[", "element", "]", ")", "]", "result", "=", "[", "v", "+", "f", "[", "ix", "]", "for", "ix", ",", "v", "in", "enumerate", "(", "result", ")", "]", "return", "result", "[", "0", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.extract
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 extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. :returns: A new material package containing the material that was extracted from self.
auxi/modelling/process/materials/chem.py
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 extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. :returns: A new material package containing the material that was extracted from self. """ # Extract the specified mass. if type(other) is float: if other > self.get_mass(): raise Exception('Invalid extraction operation. Cannot extract' 'a mass larger than the package\'s mass.') fraction_to_subtract = other / self.get_mass() result = MaterialPackage( self.material, [m * fraction_to_subtract for m in self.compound_masses]) self.compound_masses = [m * (1.0 - fraction_to_subtract) for m in self.compound_masses] return result # Extract the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): index = self.material.get_compound_index(other[0]) if other[1] > self.compound_masses[index]: raise Exception('Invalid extraction operation. Cannot extract' 'a compound mass larger than what the package' 'contains.') self.compound_masses[index] -= other[1] resultarray = [0.0] * len(self.compound_masses) resultarray[index] = other[1] result = MaterialPackage(self.material, resultarray) return result # Extract all of the specified compound. elif type(other) is str: index = self.material.get_compound_index(other) result = self * 0.0 result.compound_masses[index] = self.compound_masses[index] self.compound_masses[index] = 0.0 return result # If not one of the above, it must be an invalid argument. else: raise TypeError('Invalid extraction argument.')
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 extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. :returns: A new material package containing the material that was extracted from self. """ # Extract the specified mass. if type(other) is float: if other > self.get_mass(): raise Exception('Invalid extraction operation. Cannot extract' 'a mass larger than the package\'s mass.') fraction_to_subtract = other / self.get_mass() result = MaterialPackage( self.material, [m * fraction_to_subtract for m in self.compound_masses]) self.compound_masses = [m * (1.0 - fraction_to_subtract) for m in self.compound_masses] return result # Extract the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): index = self.material.get_compound_index(other[0]) if other[1] > self.compound_masses[index]: raise Exception('Invalid extraction operation. Cannot extract' 'a compound mass larger than what the package' 'contains.') self.compound_masses[index] -= other[1] resultarray = [0.0] * len(self.compound_masses) resultarray[index] = other[1] result = MaterialPackage(self.material, resultarray) return result # Extract all of the specified compound. elif type(other) is str: index = self.material.get_compound_index(other) result = self * 0.0 result.compound_masses[index] = self.compound_masses[index] self.compound_masses[index] = 0.0 return result # If not one of the above, it must be an invalid argument. else: raise TypeError('Invalid extraction argument.')
[ "Extract", "other", "from", "self", "modifying", "self", "and", "returning", "the", "extracted", "material", "as", "a", "new", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L476-L541
[ "def", "extract", "(", "self", ",", "other", ")", ":", "# Extract the specified mass.", "if", "type", "(", "other", ")", "is", "float", ":", "if", "other", ">", "self", ".", "get_mass", "(", ")", ":", "raise", "Exception", "(", "'Invalid extraction operation. Cannot extract'", "'a mass larger than the package\\'s mass.'", ")", "fraction_to_subtract", "=", "other", "/", "self", ".", "get_mass", "(", ")", "result", "=", "MaterialPackage", "(", "self", ".", "material", ",", "[", "m", "*", "fraction_to_subtract", "for", "m", "in", "self", ".", "compound_masses", "]", ")", "self", ".", "compound_masses", "=", "[", "m", "*", "(", "1.0", "-", "fraction_to_subtract", ")", "for", "m", "in", "self", ".", "compound_masses", "]", "return", "result", "# Extract the specified mass of the specified compound.", "elif", "self", ".", "_is_compound_mass_tuple", "(", "other", ")", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "other", "[", "0", "]", ")", "if", "other", "[", "1", "]", ">", "self", ".", "compound_masses", "[", "index", "]", ":", "raise", "Exception", "(", "'Invalid extraction operation. Cannot extract'", "'a compound mass larger than what the package'", "'contains.'", ")", "self", ".", "compound_masses", "[", "index", "]", "-=", "other", "[", "1", "]", "resultarray", "=", "[", "0.0", "]", "*", "len", "(", "self", ".", "compound_masses", ")", "resultarray", "[", "index", "]", "=", "other", "[", "1", "]", "result", "=", "MaterialPackage", "(", "self", ".", "material", ",", "resultarray", ")", "return", "result", "# Extract all of the specified compound.", "elif", "type", "(", "other", ")", "is", "str", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "other", ")", "result", "=", "self", "*", "0.0", "result", ".", "compound_masses", "[", "index", "]", "=", "self", ".", "compound_masses", "[", "index", "]", "self", ".", "compound_masses", "[", "index", "]", "=", "0.0", "return", "result", "# If not one of the above, it must be an invalid argument.", "else", ":", "raise", "TypeError", "(", "'Invalid extraction argument.'", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.add_to
Add another chem material package to this material package. :param other: The other material package.
auxi/modelling/process/materials/chem.py
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 == other.material: self.compound_masses += other.compound_masses # Packages of different materials. else: for compound in other.material.compounds: if compound not in self.material.compounds: raise Exception("Packages of '" + other.material.name + "' cannot be added to packages of '" + self.material.name + "'. The compound '" + compound + "' was not found in '" + self.material.name + "'.") self.add_to((compound, other.get_compound_mass(compound))) # Add the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): # Added material variables. compound = other[0] compound_index = self.material.get_compound_index(compound) mass = other[1] # Create the result package. self.compound_masses[compound_index] += mass # If not one of the above, it must be an invalid argument. else: raise TypeError('Invalid addition argument.')
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 == other.material: self.compound_masses += other.compound_masses # Packages of different materials. else: for compound in other.material.compounds: if compound not in self.material.compounds: raise Exception("Packages of '" + other.material.name + "' cannot be added to packages of '" + self.material.name + "'. The compound '" + compound + "' was not found in '" + self.material.name + "'.") self.add_to((compound, other.get_compound_mass(compound))) # Add the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): # Added material variables. compound = other[0] compound_index = self.material.get_compound_index(compound) mass = other[1] # Create the result package. self.compound_masses[compound_index] += mass # If not one of the above, it must be an invalid argument. else: raise TypeError('Invalid addition argument.')
[ "Add", "another", "chem", "material", "package", "to", "this", "material", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/chem.py#L544-L582
[ "def", "add_to", "(", "self", ",", "other", ")", ":", "# Add another package.", "if", "type", "(", "other", ")", "is", "MaterialPackage", ":", "# Packages of the same material.", "if", "self", ".", "material", "==", "other", ".", "material", ":", "self", ".", "compound_masses", "+=", "other", ".", "compound_masses", "# Packages of different materials.", "else", ":", "for", "compound", "in", "other", ".", "material", ".", "compounds", ":", "if", "compound", "not", "in", "self", ".", "material", ".", "compounds", ":", "raise", "Exception", "(", "\"Packages of '\"", "+", "other", ".", "material", ".", "name", "+", "\"' cannot be added to packages of '\"", "+", "self", ".", "material", ".", "name", "+", "\"'. The compound '\"", "+", "compound", "+", "\"' was not found in '\"", "+", "self", ".", "material", ".", "name", "+", "\"'.\"", ")", "self", ".", "add_to", "(", "(", "compound", ",", "other", ".", "get_compound_mass", "(", "compound", ")", ")", ")", "# Add the specified mass of the specified compound.", "elif", "self", ".", "_is_compound_mass_tuple", "(", "other", ")", ":", "# Added material variables.", "compound", "=", "other", "[", "0", "]", "compound_index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "mass", "=", "other", "[", "1", "]", "# Create the result package.", "self", ".", "compound_masses", "[", "compound_index", "]", "+=", "mass", "# If not one of the above, it must be an invalid argument.", "else", ":", "raise", "TypeError", "(", "'Invalid addition argument.'", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
RhoT.calculate
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.
auxi/tools/materialphysicalproperties/idealgas.py
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. """ super().calculate(**state) return self.mm * self.P / R / state["T"]
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. """ super().calculate(**state) return self.mm * self.P / R / state["T"]
[ "Calculate", "the", "density", "at", "the", "specified", "temperature", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/idealgas.py#L72-L84
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "super", "(", ")", ".", "calculate", "(", "*", "*", "state", ")", "return", "self", ".", "mm", "*", "self", ".", "P", "/", "R", "/", "state", "[", "\"T\"", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
RhoTPx.calculate
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.
auxi/tools/materialphysicalproperties/idealgas.py
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"]
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"]
[ "Calculate", "the", "density", "at", "the", "specified", "temperature", "pressure", "and", "composition", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/idealgas.py#L167-L187
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "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\"", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerAccount.set_parent_path
Set the parent path and the path from the new parent path. :param value: The path to the object's parent
auxi/modelling/financial/des.py
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()
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()
[ "Set", "the", "parent", "path", "and", "the", "path", "from", "the", "new", "parent", "path", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L64-L73
[ "def", "set_parent_path", "(", "self", ",", "value", ")", ":", "self", ".", "_parent_path", "=", "value", "self", ".", "path", "=", "value", "+", "r'/'", "+", "self", ".", "name", "self", ".", "_update_childrens_parent_path", "(", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerAccount.create_account
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.
auxi/modelling/financial/des.py
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_account = GeneralLedgerAccount(name, description, number, self.account_type) new_account.set_parent_path(self.path) self.accounts.append(new_account) return new_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_account = GeneralLedgerAccount(name, description, number, self.account_type) new_account.set_parent_path(self.path) self.accounts.append(new_account) return new_account
[ "Create", "a", "sub", "account", "in", "the", "account", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L92-L107
[ "def", "create_account", "(", "self", ",", "name", ",", "number", "=", "None", ",", "description", "=", "None", ")", ":", "new_account", "=", "GeneralLedgerAccount", "(", "name", ",", "description", ",", "number", ",", "self", ".", "account_type", ")", "new_account", ".", "set_parent_path", "(", "self", ".", "path", ")", "self", ".", "accounts", ".", "append", "(", "new_account", ")", "return", "new_account" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerAccount.remove_account
Remove an account from the account's sub accounts. :param name: The name of the account to remove.
auxi/modelling/financial/des.py
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_remove is not None: self.accounts.remove(acc_to_remove)
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_remove is not None: self.accounts.remove(acc_to_remove)
[ "Remove", "an", "account", "from", "the", "account", "s", "sub", "accounts", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L109-L121
[ "def", "remove_account", "(", "self", ",", "name", ")", ":", "acc_to_remove", "=", "None", "for", "a", "in", "self", ".", "accounts", ":", "if", "a", ".", "name", "==", "name", ":", "acc_to_remove", "=", "a", "if", "acc_to_remove", "is", "not", "None", ":", "self", ".", "accounts", ".", "remove", "(", "acc_to_remove", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerAccount.get_child_account
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.
auxi/modelling/financial/des.py
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: accs_in_path = account_name.split(r'/', 1) curr_acc = self[accs_in_path[0]] if curr_acc is None: return None return curr_acc.get_child_account(accs_in_path[1]) pass else: return self[account_name]
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: accs_in_path = account_name.split(r'/', 1) curr_acc = self[accs_in_path[0]] if curr_acc is None: return None return curr_acc.get_child_account(accs_in_path[1]) pass else: return self[account_name]
[ "Retrieves", "a", "child", "account", ".", "This", "could", "be", "a", "descendant", "nested", "at", "any", "level", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L123-L142
[ "def", "get_child_account", "(", "self", ",", "account_name", ")", ":", "if", "r'/'", "in", "account_name", ":", "accs_in_path", "=", "account_name", ".", "split", "(", "r'/'", ",", "1", ")", "curr_acc", "=", "self", "[", "accs_in_path", "[", "0", "]", "]", "if", "curr_acc", "is", "None", ":", "return", "None", "return", "curr_acc", ".", "get_child_account", "(", "accs_in_path", "[", "1", "]", ")", "pass", "else", ":", "return", "self", "[", "account_name", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerStructure._create_account_
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.
auxi/modelling/financial/des.py
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. """ new_acc = GeneralLedgerAccount(name, None, number, account_type) self.accounts.append(new_acc) return new_acc
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. """ new_acc = GeneralLedgerAccount(name, None, number, account_type) self.accounts.append(new_acc) return new_acc
[ "Create", "an", "account", "in", "the", "general", "ledger", "structure", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L264-L277
[ "def", "_create_account_", "(", "self", ",", "name", ",", "number", ",", "account_type", ")", ":", "new_acc", "=", "GeneralLedgerAccount", "(", "name", ",", "None", ",", "number", ",", "account_type", ")", "self", ".", "accounts", ".", "append", "(", "new_acc", ")", "return", "new_acc" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerStructure.get_account_descendants
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.
auxi/modelling/financial/des.py
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 account.accounts: self._get_account_and_descendants_(child, result) return result
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 account.accounts: self._get_account_and_descendants_(child, result) return result
[ "Retrieves", "an", "account", "s", "descendants", "from", "the", "general", "ledger", "structure", "given", "the", "account", "name", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L300-L313
[ "def", "get_account_descendants", "(", "self", ",", "account", ")", ":", "result", "=", "[", "]", "for", "child", "in", "account", ".", "accounts", ":", "self", ".", "_get_account_and_descendants_", "(", "child", ",", "result", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerStructure._get_account_and_descendants_
Returns the account and all of it's sub accounts. :param account: The account. :param result: The list to add all the accounts to.
auxi/modelling/financial/des.py
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: self._get_account_and_descendants_(child, result)
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: self._get_account_and_descendants_(child, result)
[ "Returns", "the", "account", "and", "all", "of", "it", "s", "sub", "accounts", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L315-L325
[ "def", "_get_account_and_descendants_", "(", "self", ",", "account", ",", "result", ")", ":", "result", ".", "append", "(", "account", ")", "for", "child", "in", "account", ".", "accounts", ":", "self", ".", "_get_account_and_descendants_", "(", "child", ",", "result", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerStructure.validate_account_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.
auxi/modelling/financial/des.py
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: raise ValueError("The account '{}' does not exist in the" " general ledger structure.".format(name))
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: raise ValueError("The account '{}' does not exist in the" " general ledger structure.".format(name))
[ "Validates", "whether", "the", "accounts", "in", "a", "list", "of", "account", "names", "exists", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L327-L339
[ "def", "validate_account_names", "(", "self", ",", "names", ")", ":", "for", "name", "in", "names", ":", "if", "self", ".", "get_account", "(", "name", ")", "is", "None", ":", "raise", "ValueError", "(", "\"The account '{}' does not exist in the\"", "\" general ledger structure.\"", ".", "format", "(", "name", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedgerStructure.report
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. :returns: The descendants of the account.
auxi/modelling/financial/des.py
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. :returns: The descendants of the account. """ rpt = GlsRpt(self, output_path) return rpt.render(format)
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. :returns: The descendants of the account. """ rpt = GlsRpt(self, output_path) return rpt.render(format)
[ "Returns", "a", "report", "of", "this", "class", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L341-L353
[ "def", "report", "(", "self", ",", "format", "=", "ReportFormat", ".", "printout", ",", "output_path", "=", "None", ")", ":", "rpt", "=", "GlsRpt", "(", "self", ",", "output_path", ")", "return", "rpt", ".", "render", "(", "format", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedger.create_transaction
Create a transaction in the general ledger. :param name: The transaction's name. :param description: The transaction's description. :param tx_date: The date of the transaction. :param cr_account: The transaction's credit account's name. :param dt_account: The transaction's debit account's name. :param source: The name of source the transaction originated from. :param amount: The transaction amount. :returns: The created transaction.
auxi/modelling/financial/des.py
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 transaction's name. :param description: The transaction's description. :param tx_date: The date of the transaction. :param cr_account: The transaction's credit account's name. :param dt_account: The transaction's debit account's name. :param source: The name of source the transaction originated from. :param amount: The transaction amount. :returns: The created transaction. """ new_tx = Transaction(name, description, tx_date, dt_account, cr_account, source, amount) self.transactions.append(new_tx) return new_tx
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 transaction's name. :param description: The transaction's description. :param tx_date: The date of the transaction. :param cr_account: The transaction's credit account's name. :param dt_account: The transaction's debit account's name. :param source: The name of source the transaction originated from. :param amount: The transaction amount. :returns: The created transaction. """ new_tx = Transaction(name, description, tx_date, dt_account, cr_account, source, amount) self.transactions.append(new_tx) return new_tx
[ "Create", "a", "transaction", "in", "the", "general", "ledger", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L370-L391
[ "def", "create_transaction", "(", "self", ",", "name", ",", "description", "=", "None", ",", "tx_date", "=", "datetime", ".", "min", ".", "date", "(", ")", ",", "dt_account", "=", "None", ",", "cr_account", "=", "None", ",", "source", "=", "None", ",", "amount", "=", "0.00", ")", ":", "new_tx", "=", "Transaction", "(", "name", ",", "description", ",", "tx_date", ",", "dt_account", ",", "cr_account", ",", "source", ",", "amount", ")", "self", ".", "transactions", ".", "append", "(", "new_tx", ")", "return", "new_tx" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedger.transaction_list
Generate a transaction list report. :param start: The start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report.
auxi/modelling/financial/des.py
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 start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = TransactionList(self, start, end, component_path, output_path) return rpt.render(format)
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 start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = TransactionList(self, start, end, component_path, output_path) return rpt.render(format)
[ "Generate", "a", "transaction", "list", "report", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L393-L413
[ "def", "transaction_list", "(", "self", ",", "start", "=", "datetime", ".", "min", ",", "end", "=", "datetime", ".", "max", ",", "format", "=", "ReportFormat", ".", "printout", ",", "component_path", "=", "\"\"", ",", "output_path", "=", "None", ")", ":", "rpt", "=", "TransactionList", "(", "self", ",", "start", ",", "end", ",", "component_path", ",", "output_path", ")", "return", "rpt", ".", "render", "(", "format", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedger.balance_sheet
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 the file the report is written to. If None, then the report is not written to a file. :returns: The generated report.
auxi/modelling/financial/des.py
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 the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = BalanceSheet(self, end, output_path) return rpt.render(format)
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 the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = BalanceSheet(self, end, output_path) return rpt.render(format)
[ "Generate", "a", "transaction", "list", "report", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L415-L429
[ "def", "balance_sheet", "(", "self", ",", "end", "=", "datetime", ".", "max", ",", "format", "=", "ReportFormat", ".", "printout", ",", "output_path", "=", "None", ")", ":", "rpt", "=", "BalanceSheet", "(", "self", ",", "end", ",", "output_path", ")", "return", "rpt", ".", "render", "(", "format", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
GeneralLedger.income_statement
Generate a transaction list report. :param start: The start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report.
auxi/modelling/financial/des.py
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 start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = IncomeStatement(self, start, end, component_path, output_path) return rpt.render(format)
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 start date to generate the report for. :param end: The end date to generate the report for. :param format: The format of the report. :param component_path: The path of the component to filter the report's transactions by. :param output_path: The path to the file the report is written to. If None, then the report is not written to a file. :returns: The generated report. """ rpt = IncomeStatement(self, start, end, component_path, output_path) return rpt.render(format)
[ "Generate", "a", "transaction", "list", "report", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/financial/des.py#L431-L451
[ "def", "income_statement", "(", "self", ",", "start", "=", "datetime", ".", "min", ",", "end", "=", "datetime", ".", "max", ",", "format", "=", "ReportFormat", ".", "printout", ",", "component_path", "=", "\"\"", ",", "output_path", "=", "None", ")", ":", "rpt", "=", "IncomeStatement", "(", "self", ",", "start", ",", "end", ",", "component_path", ",", "output_path", ")", "return", "rpt", ".", "render", "(", "format", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
get_path_relative_to_module
Calculate a path relative to the specified module file. :param module_file_path: The file path to the module.
auxi/core/helpers.py
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) path = os.path.abspath(path) return path
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) path = os.path.abspath(path) return path
[ "Calculate", "a", "path", "relative", "to", "the", "specified", "module", "file", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/core/helpers.py#L11-L20
[ "def", "get_path_relative_to_module", "(", "module_file_path", ",", "relative_target_path", ")", ":", "module_path", "=", "os", ".", "path", ".", "dirname", "(", "module_file_path", ")", "path", "=", "os", ".", "path", ".", "join", "(", "module_path", ",", "relative_target_path", ")", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "return", "path" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
get_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.
auxi/core/helpers.py
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
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
[ "Get", "the", "date", "from", "a", "value", "that", "could", "be", "a", "date", "object", "or", "a", "string", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/core/helpers.py#L23-L34
[ "def", "get_date", "(", "date", ")", ":", "if", "type", "(", "date", ")", "is", "str", ":", "return", "datetime", ".", "strptime", "(", "date", ",", "'%Y-%m-%d'", ")", ".", "date", "(", ")", "else", ":", "return", "date" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
f_tr_Haaland
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 hydraulic diameter. :return: Friction factor. Source: lienhard2018, Eq. 7.50.
auxi/tools/transportphenomena/fluidflow/pressuredrop.py
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 hydraulic diameter. :return: Friction factor. Source: lienhard2018, Eq. 7.50. """ if warn: try: if (ɛ / D) < 0.0 or (ɛ / D) > 0.05: raise Warning( f"ɛ/D '{ɛ / D:.3e}' out of range 0.0 <= ɛ/D <= 0.05.") except Warning as w: ex_type, ex_value, ex_traceback = sys.exc_info() print(color_warn("WARNING: "), ex_value) try: if Re_D < 4000.0 or Re_D > 1.0E8: raise Warning( f"Reynolds number '{Re_D:.3e}' out of range " "4000 <= Re_D <= 1E8.") except Warning as w: ex_type, ex_value, ex_traceback = sys.exc_info() print(color_warn("WARNING: "), ex_value) return 1 / (1.8 * log10((6.9 / Re_D) + (ɛ / D / 3.7)**1.11))**2
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 hydraulic diameter. :return: Friction factor. Source: lienhard2018, Eq. 7.50. """ if warn: try: if (ɛ / D) < 0.0 or (ɛ / D) > 0.05: raise Warning( f"ɛ/D '{ɛ / D:.3e}' out of range 0.0 <= ɛ/D <= 0.05.") except Warning as w: ex_type, ex_value, ex_traceback = sys.exc_info() print(color_warn("WARNING: "), ex_value) try: if Re_D < 4000.0 or Re_D > 1.0E8: raise Warning( f"Reynolds number '{Re_D:.3e}' out of range " "4000 <= Re_D <= 1E8.") except Warning as w: ex_type, ex_value, ex_traceback = sys.exc_info() print(color_warn("WARNING: "), ex_value) return 1 / (1.8 * log10((6.9 / Re_D) + (ɛ / D / 3.7)**1.11))**2
[ "Calculate", "the", "friction", "factor", "of", "turbulent", "flow", "(", "t", ")", "in", "a", "rough", "duct", "(", "r", ")", "for", "the", "provided", "conditions", "with", "Haaland", "s", "equation", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/fluidflow/pressuredrop.py#L50-L80
[ "def", "f_tr_Haaland", "(", "Re_D", ",", "ɛ,", " ", ",", " ", "arn=", "T", "rue)", ":", "", "if", "warn", ":", "try", ":", "if", "(", "ɛ ", " ", ")", " ", " ", ".0 ", "r ", "ɛ", " /", "D", " ", ">", "0", "05:", "", "raise", "Warning", "(", "f\"ɛ/D '{ɛ / D:.3e}' out of range 0.0 <= ɛ/D <= 0.05.\")", "", "except", "Warning", "as", "w", ":", "ex_type", ",", "ex_value", ",", "ex_traceback", "=", "sys", ".", "exc_info", "(", ")", "print", "(", "color_warn", "(", "\"WARNING: \"", ")", ",", "ex_value", ")", "try", ":", "if", "Re_D", "<", "4000.0", "or", "Re_D", ">", "1.0E8", ":", "raise", "Warning", "(", "f\"Reynolds number '{Re_D:.3e}' out of range \"", "\"4000 <= Re_D <= 1E8.\"", ")", "except", "Warning", "as", "w", ":", "ex_type", ",", "ex_value", ",", "ex_traceback", "=", "sys", ".", "exc_info", "(", ")", "print", "(", "color_warn", "(", "\"WARNING: \"", ")", ",", "ex_value", ")", "return", "1", "/", "(", "1.8", "*", "log10", "(", "(", "6.9", "/", "Re_D", ")", "+", "(", "ɛ ", " ", " ", " ", ".7)", "*", "*1", ".11)", ")", "*", "*2", "" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
IsothermalFlatSurface.Nu_x
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 fluid temperature :returns: float
auxi/tools/transportphenomena/heattransfer/naturalconvection.py
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 fluid temperature :returns: float """ Tf = statef['T'] thetar = radians(theta) if self._isgas: self.Tr = Ts - 0.38 * (Ts - Tf) beta = self._fluid.beta(T=Tf) else: # for liquids self.Tr = Ts - 0.5 * (Ts - Tf) beta = self._fluid.beta(T=self.Tr) if Ts > Tf: # hot surface if 0.0 < theta < 45.0: g = const.g*cos(thetar) else: g = const.g else: # cold surface if -45.0 < theta < 0.0: g = const.g*cos(thetar) else: g = const.g nu = self._fluid.nu(T=self.Tr) alpha = self._fluid.alpha(T=self.Tr) Gr = dq.Gr(L, Ts, Tf, beta, nu, g) Pr = dq.Pr(nu, alpha) Ra = Gr * Pr eq = [self.equation_dict[r] for r in self.regions if r.contains_point(theta, Ra)][0] return eq(self, Ra, Pr)
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 fluid temperature :returns: float """ Tf = statef['T'] thetar = radians(theta) if self._isgas: self.Tr = Ts - 0.38 * (Ts - Tf) beta = self._fluid.beta(T=Tf) else: # for liquids self.Tr = Ts - 0.5 * (Ts - Tf) beta = self._fluid.beta(T=self.Tr) if Ts > Tf: # hot surface if 0.0 < theta < 45.0: g = const.g*cos(thetar) else: g = const.g else: # cold surface if -45.0 < theta < 0.0: g = const.g*cos(thetar) else: g = const.g nu = self._fluid.nu(T=self.Tr) alpha = self._fluid.alpha(T=self.Tr) Gr = dq.Gr(L, Ts, Tf, beta, nu, g) Pr = dq.Pr(nu, alpha) Ra = Gr * Pr eq = [self.equation_dict[r] for r in self.regions if r.contains_point(theta, Ra)][0] return eq(self, Ra, Pr)
[ "Calculate", "the", "local", "Nusselt", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/heattransfer/naturalconvection.py#L283-L326
[ "def", "Nu_x", "(", "self", ",", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", ":", "Tf", "=", "statef", "[", "'T'", "]", "thetar", "=", "radians", "(", "theta", ")", "if", "self", ".", "_isgas", ":", "self", ".", "Tr", "=", "Ts", "-", "0.38", "*", "(", "Ts", "-", "Tf", ")", "beta", "=", "self", ".", "_fluid", ".", "beta", "(", "T", "=", "Tf", ")", "else", ":", "# for liquids", "self", ".", "Tr", "=", "Ts", "-", "0.5", "*", "(", "Ts", "-", "Tf", ")", "beta", "=", "self", ".", "_fluid", ".", "beta", "(", "T", "=", "self", ".", "Tr", ")", "if", "Ts", ">", "Tf", ":", "# hot surface", "if", "0.0", "<", "theta", "<", "45.0", ":", "g", "=", "const", ".", "g", "*", "cos", "(", "thetar", ")", "else", ":", "g", "=", "const", ".", "g", "else", ":", "# cold surface", "if", "-", "45.0", "<", "theta", "<", "0.0", ":", "g", "=", "const", ".", "g", "*", "cos", "(", "thetar", ")", "else", ":", "g", "=", "const", ".", "g", "nu", "=", "self", ".", "_fluid", ".", "nu", "(", "T", "=", "self", ".", "Tr", ")", "alpha", "=", "self", ".", "_fluid", ".", "alpha", "(", "T", "=", "self", ".", "Tr", ")", "Gr", "=", "dq", ".", "Gr", "(", "L", ",", "Ts", ",", "Tf", ",", "beta", ",", "nu", ",", "g", ")", "Pr", "=", "dq", ".", "Pr", "(", "nu", ",", "alpha", ")", "Ra", "=", "Gr", "*", "Pr", "eq", "=", "[", "self", ".", "equation_dict", "[", "r", "]", "for", "r", "in", "self", ".", "regions", "if", "r", ".", "contains_point", "(", "theta", ",", "Ra", ")", "]", "[", "0", "]", "return", "eq", "(", "self", ",", "Ra", ",", "Pr", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
IsothermalFlatSurface.Nu_L
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: [K] bulk fluid temperature :returns: float
auxi/tools/transportphenomena/heattransfer/naturalconvection.py
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: [K] bulk fluid temperature :returns: float """ return self.Nu_x(L, theta, Ts, **statef) / 0.75
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: [K] bulk fluid temperature :returns: float """ return self.Nu_x(L, theta, Ts, **statef) / 0.75
[ "Calculate", "the", "average", "Nusselt", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/heattransfer/naturalconvection.py#L328-L340
[ "def", "Nu_L", "(", "self", ",", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", ":", "return", "self", ".", "Nu_x", "(", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", "/", "0.75" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
IsothermalFlatSurface.h_x
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: [K] bulk fluid temperature :returns: [W/m2/K] float
auxi/tools/transportphenomena/heattransfer/naturalconvection.py
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: [K] bulk fluid temperature :returns: [W/m2/K] float """ Nu_x = self.Nu_x(L, theta, Ts, **statef) k = self._fluid.k(T=self.Tr) return Nu_x * k / L
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: [K] bulk fluid temperature :returns: [W/m2/K] float """ Nu_x = self.Nu_x(L, theta, Ts, **statef) k = self._fluid.k(T=self.Tr) return Nu_x * k / L
[ "Calculate", "the", "local", "heat", "transfer", "coefficient", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/heattransfer/naturalconvection.py#L342-L356
[ "def", "h_x", "(", "self", ",", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", ":", "Nu_x", "=", "self", ".", "Nu_x", "(", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", "k", "=", "self", ".", "_fluid", ".", "k", "(", "T", "=", "self", ".", "Tr", ")", "return", "Nu_x", "*", "k", "/", "L" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
IsothermalFlatSurface.h_L
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 Tf: [K] bulk fluid temperature :returns: [W/m2/K] float
auxi/tools/transportphenomena/heattransfer/naturalconvection.py
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 Tf: [K] bulk fluid temperature :returns: [W/m2/K] float """ Nu_L = self.Nu_L(L, theta, Ts, **statef) k = self._fluid.k(T=self.Tr) return Nu_L * k / L
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 Tf: [K] bulk fluid temperature :returns: [W/m2/K] float """ Nu_L = self.Nu_L(L, theta, Ts, **statef) k = self._fluid.k(T=self.Tr) return Nu_L * k / L
[ "Calculate", "the", "average", "heat", "transfer", "coefficient", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/heattransfer/naturalconvection.py#L358-L372
[ "def", "h_L", "(", "self", ",", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", ":", "Nu_L", "=", "self", ".", "Nu_L", "(", "L", ",", "theta", ",", "Ts", ",", "*", "*", "statef", ")", "k", "=", "self", ".", "_fluid", ".", "k", "(", "T", "=", "self", ".", "Tr", ")", "return", "Nu_L", "*", "k", "/", "L" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material._prepare_lines
Prepare the lines read from the text file before starting to process it.
auxi/modelling/process/materials/slurry.py
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 the line. line = line.strip() # Replace all tabs with spaces. line = line.replace("\t", " ") # Replace all repeating spaces with a single space. while line.find(" ") > -1: line = line.replace(" ", " ") result.append(line) return result
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 the line. line = line.strip() # Replace all tabs with spaces. line = line.replace("\t", " ") # Replace all repeating spaces with a single space. while line.find(" ") > -1: line = line.replace(" ", " ") result.append(line) return result
[ "Prepare", "the", "lines", "read", "from", "the", "text", "file", "before", "starting", "to", "process", "it", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L176-L193
[ "def", "_prepare_lines", "(", "self", ",", "lines", ")", ":", "result", "=", "list", "(", ")", "for", "line", "in", "lines", ":", "# Remove all whitespace characters (e.g. spaces, line breaks, etc.)", "# from the start and end of the line.", "line", "=", "line", ".", "strip", "(", ")", "# Replace all tabs with spaces.", "line", "=", "line", ".", "replace", "(", "\"\\t\"", ",", "\" \"", ")", "# Replace all repeating spaces with a single space.", "while", "line", ".", "find", "(", "\" \"", ")", ">", "-", "1", ":", "line", "=", "line", ".", "replace", "(", "\" \"", ",", "\" \"", ")", "result", ".", "append", "(", "line", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.add_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 the sequence of the material's size classes.
auxi/modelling/process/materials/slurry.py
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 the sequence of the material's size classes. """ if not type(solid_density) is float: raise Exception("Invalid solid density. It must be a float.") self.solid_densities[name] = solid_density if not type(H2O_fraction) is float: raise Exception("Invalid H2O fraction. It must be a float.") self.H2O_fractions[name] = H2O_fraction if not type(assay) is numpy.ndarray: raise Exception("Invalid assay. It must be a numpy array.") elif not assay.shape == (self.size_class_count,): raise Exception( "Invalid assay: It must have the same number of elements as " "the material has size classes.") elif name in self.assays.keys(): raise Exception( "Invalid assay: An assay with that name already exists.") self.assays[name] = assay
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 the sequence of the material's size classes. """ if not type(solid_density) is float: raise Exception("Invalid solid density. It must be a float.") self.solid_densities[name] = solid_density if not type(H2O_fraction) is float: raise Exception("Invalid H2O fraction. It must be a float.") self.H2O_fractions[name] = H2O_fraction if not type(assay) is numpy.ndarray: raise Exception("Invalid assay. It must be a numpy array.") elif not assay.shape == (self.size_class_count,): raise Exception( "Invalid assay: It must have the same number of elements as " "the material has size classes.") elif name in self.assays.keys(): raise Exception( "Invalid assay: An assay with that name already exists.") self.assays[name] = assay
[ "Add", "an", "assay", "to", "the", "material", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L230-L256
[ "def", "add_assay", "(", "self", ",", "name", ",", "solid_density", ",", "H2O_fraction", ",", "assay", ")", ":", "if", "not", "type", "(", "solid_density", ")", "is", "float", ":", "raise", "Exception", "(", "\"Invalid solid density. It must be a float.\"", ")", "self", ".", "solid_densities", "[", "name", "]", "=", "solid_density", "if", "not", "type", "(", "H2O_fraction", ")", "is", "float", ":", "raise", "Exception", "(", "\"Invalid H2O fraction. It must be a float.\"", ")", "self", ".", "H2O_fractions", "[", "name", "]", "=", "H2O_fraction", "if", "not", "type", "(", "assay", ")", "is", "numpy", ".", "ndarray", ":", "raise", "Exception", "(", "\"Invalid assay. It must be a numpy array.\"", ")", "elif", "not", "assay", ".", "shape", "==", "(", "self", ".", "size_class_count", ",", ")", ":", "raise", "Exception", "(", "\"Invalid assay: It must have the same number of elements as \"", "\"the material has size classes.\"", ")", "elif", "name", "in", "self", ".", "assays", ".", "keys", "(", ")", ":", "raise", "Exception", "(", "\"Invalid assay: An assay with that name already exists.\"", ")", "self", ".", "assays", "[", "name", "]", "=", "assay" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.create_package
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: Indicates whether the assay must be normalised before creating the package. :returns: The created MaterialPackage.
auxi/modelling/process/materials/slurry.py
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: Indicates whether the assay must be normalised before creating the package. :returns: The created MaterialPackage. """ if assay is None: return MaterialPackage(self, 1.0, 0.0, self.create_empty_assay()) if normalise: assay_total = self.get_assay_total(assay) if assay_total == 0.0: assay_total = 1.0 else: assay_total = 1.0 H2O_mass = mass * self.H2O_fractions[assay] solid_mass = mass - H2O_mass return MaterialPackage(self, self.solid_densities[assay], H2O_mass, solid_mass * self.assays[assay] / assay_total)
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: Indicates whether the assay must be normalised before creating the package. :returns: The created MaterialPackage. """ if assay is None: return MaterialPackage(self, 1.0, 0.0, self.create_empty_assay()) if normalise: assay_total = self.get_assay_total(assay) if assay_total == 0.0: assay_total = 1.0 else: assay_total = 1.0 H2O_mass = mass * self.H2O_fractions[assay] solid_mass = mass - H2O_mass return MaterialPackage(self, self.solid_densities[assay], H2O_mass, solid_mass * self.assays[assay] / assay_total)
[ "Create", "a", "MaterialPackage", "based", "on", "the", "specified", "parameters", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L281-L308
[ "def", "create_package", "(", "self", ",", "assay", "=", "None", ",", "mass", "=", "0.0", ",", "normalise", "=", "True", ")", ":", "if", "assay", "is", "None", ":", "return", "MaterialPackage", "(", "self", ",", "1.0", ",", "0.0", ",", "self", ".", "create_empty_assay", "(", ")", ")", "if", "normalise", ":", "assay_total", "=", "self", ".", "get_assay_total", "(", "assay", ")", "if", "assay_total", "==", "0.0", ":", "assay_total", "=", "1.0", "else", ":", "assay_total", "=", "1.0", "H2O_mass", "=", "mass", "*", "self", ".", "H2O_fractions", "[", "assay", "]", "solid_mass", "=", "mass", "-", "H2O_mass", "return", "MaterialPackage", "(", "self", ",", "self", ".", "solid_densities", "[", "assay", "]", ",", "H2O_mass", ",", "solid_mass", "*", "self", ".", "assays", "[", "assay", "]", "/", "assay_total", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._is_size_class_mass_tuple
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.
auxi/modelling/process/materials/slurry.py
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: return False elif not len(value) == 2: return False elif not type(value[0]) is float: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
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: return False elif not len(value) == 2: return False elif not type(value[0]) is float: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
[ "Determines", "whether", "value", "is", "a", "tuple", "of", "the", "format", "(", "size", "class", "(", "float", ")", "mass", "(", "float", "))", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L464-L485
[ "def", "_is_size_class_mass_tuple", "(", "self", ",", "value", ")", ":", "if", "not", "type", "(", "value", ")", "is", "tuple", ":", "return", "False", "elif", "not", "len", "(", "value", ")", "==", "2", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "0", "]", ")", "is", "float", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "1", "]", ")", "is", "float", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float64", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float32", ":", "return", "False", "else", ":", "return", "True" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.clone
Create a complete copy of self. :returns: A MaterialPackage that is identical to self.
auxi/modelling/process/materials/slurry.py
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
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
[ "Create", "a", "complete", "copy", "of", "self", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L510-L519
[ "def", "clone", "(", "self", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ")", "result", ".", "size_class_masses", "=", "copy", ".", "deepcopy", "(", "self", ".", "size_class_masses", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.clear
Set all the size class masses and H20_mass in the package to zero and the solid_density to 1.0
auxi/modelling/process/materials/slurry.py
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
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
[ "Set", "all", "the", "size", "class", "masses", "and", "H20_mass", "in", "the", "package", "to", "zero", "and", "the", "solid_density", "to", "1", ".", "0" ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/slurry.py#L521-L529
[ "def", "clear", "(", "self", ")", ":", "self", ".", "solid_density", "=", "1.0", "self", ".", "H2O_mass", "=", "0.0", "self", ".", "size_class_masses", "=", "self", ".", "size_class_masses", "*", "0.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
DataSet.create_template
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 \ displayed after creation
auxi/tools/materialphysicalproperties/core.py
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 \ displayed after creation """ file_name = 'dataset-%s.csv' % material.lower() file_path = os.path.join(path, file_name) with open(file_path, 'w', newline='') as csvfile: writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) writer.writerow(['Name', material]) writer.writerow(['Description', '<Add a data set description ' 'here.>']) writer.writerow(['Reference', '<Add a reference to the source of ' 'the data set here.>']) writer.writerow(['Temperature', '<parameter 1 name>', '<parameter 2 name>', '<parameter 3 name>']) writer.writerow(['T', '<parameter 1 display symbol>', '<parameter 2 display symbol>', '<parameter 3 display symbol>']) writer.writerow(['K', '<parameter 1 units>', '<parameter 2 units>', '<parameter 3 units>']) writer.writerow(['T', '<parameter 1 symbol>', '<parameter 2 symbol>', '<parameter 3 symbol>']) for i in range(10): writer.writerow([100.0 + i*50, float(i), 10.0 + i, 100.0 + i]) if show is True: webbrowser.open_new(file_path)
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 \ displayed after creation """ file_name = 'dataset-%s.csv' % material.lower() file_path = os.path.join(path, file_name) with open(file_path, 'w', newline='') as csvfile: writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) writer.writerow(['Name', material]) writer.writerow(['Description', '<Add a data set description ' 'here.>']) writer.writerow(['Reference', '<Add a reference to the source of ' 'the data set here.>']) writer.writerow(['Temperature', '<parameter 1 name>', '<parameter 2 name>', '<parameter 3 name>']) writer.writerow(['T', '<parameter 1 display symbol>', '<parameter 2 display symbol>', '<parameter 3 display symbol>']) writer.writerow(['K', '<parameter 1 units>', '<parameter 2 units>', '<parameter 3 units>']) writer.writerow(['T', '<parameter 1 symbol>', '<parameter 2 symbol>', '<parameter 3 symbol>']) for i in range(10): writer.writerow([100.0 + i*50, float(i), 10.0 + i, 100.0 + i]) if show is True: webbrowser.open_new(file_path)
[ "Create", "a", "template", "csv", "file", "for", "a", "data", "set", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/core.py#L53-L86
[ "def", "create_template", "(", "material", ",", "path", ",", "show", "=", "False", ")", ":", "file_name", "=", "'dataset-%s.csv'", "%", "material", ".", "lower", "(", ")", "file_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "file_name", ")", "with", "open", "(", "file_path", ",", "'w'", ",", "newline", "=", "''", ")", "as", "csvfile", ":", "writer", "=", "csv", ".", "writer", "(", "csvfile", ",", "delimiter", "=", "','", ",", "quotechar", "=", "'\"'", ",", "quoting", "=", "csv", ".", "QUOTE_MINIMAL", ")", "writer", ".", "writerow", "(", "[", "'Name'", ",", "material", "]", ")", "writer", ".", "writerow", "(", "[", "'Description'", ",", "'<Add a data set description '", "'here.>'", "]", ")", "writer", ".", "writerow", "(", "[", "'Reference'", ",", "'<Add a reference to the source of '", "'the data set here.>'", "]", ")", "writer", ".", "writerow", "(", "[", "'Temperature'", ",", "'<parameter 1 name>'", ",", "'<parameter 2 name>'", ",", "'<parameter 3 name>'", "]", ")", "writer", ".", "writerow", "(", "[", "'T'", ",", "'<parameter 1 display symbol>'", ",", "'<parameter 2 display symbol>'", ",", "'<parameter 3 display symbol>'", "]", ")", "writer", ".", "writerow", "(", "[", "'K'", ",", "'<parameter 1 units>'", ",", "'<parameter 2 units>'", ",", "'<parameter 3 units>'", "]", ")", "writer", ".", "writerow", "(", "[", "'T'", ",", "'<parameter 1 symbol>'", ",", "'<parameter 2 symbol>'", ",", "'<parameter 3 symbol>'", "]", ")", "for", "i", "in", "range", "(", "10", ")", ":", "writer", ".", "writerow", "(", "[", "100.0", "+", "i", "*", "50", ",", "float", "(", "i", ")", ",", "10.0", "+", "i", ",", "100.0", "+", "i", "]", ")", "if", "show", "is", "True", ":", "webbrowser", ".", "open_new", "(", "file_path", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Model.calculate
Base calculate method for models. Validates the material state parameter(s). :param **state: The material state
auxi/tools/materialphysicalproperties/core.py
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 " msg += f"description ({state}) contains errors:" for key, value in self.state_validator.errors.items(): msg += ' %s: %s;' % (key, value) msg = msg[0:-1]+'.' raise ValidationError(msg)
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 " msg += f"description ({state}) contains errors:" for key, value in self.state_validator.errors.items(): msg += ' %s: %s;' % (key, value) msg = msg[0:-1]+'.' raise ValidationError(msg)
[ "Base", "calculate", "method", "for", "models", ".", "Validates", "the", "material", "state", "parameter", "(", "s", ")", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/core.py#L190-L203
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "if", "not", "self", ".", "state_validator", ".", "validate", "(", "state", ")", ":", "msg", "=", "f\"{self.material} {self.property} model. The state \"", "msg", "+=", "f\"description ({state}) contains errors:\"", "for", "key", ",", "value", "in", "self", ".", "state_validator", ".", "errors", ".", "items", "(", ")", ":", "msg", "+=", "' %s: %s;'", "%", "(", "key", ",", "value", ")", "msg", "=", "msg", "[", "0", ":", "-", "1", "]", "+", "'.'", "raise", "ValidationError", "(", "msg", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Api.delete
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
api.py
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 __init__ parameters = {}, ((),()) # URL paramters, ex: google.com?q=a&f=b """ return self.request_handler.request( self._url(endpoint, url_data, parameters), method=Api._method['delete'], body=urllib.urlencode(data) )
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 __init__ parameters = {}, ((),()) # URL paramters, ex: google.com?q=a&f=b """ return self.request_handler.request( self._url(endpoint, url_data, parameters), method=Api._method['delete'], body=urllib.urlencode(data) )
[ "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" ]
travisby/pyrest
python
https://github.com/travisby/pyrest/blob/1bd625028aa0c2b901f27e1a8ef0a45d12404830/api.py#L106-L117
[ "def", "delete", "(", "self", ",", "endpoint", ",", "data", ",", "url_data", "=", "None", ",", "parameters", "=", "None", ")", ":", "return", "self", ".", "request_handler", ".", "request", "(", "self", ".", "_url", "(", "endpoint", ",", "url_data", ",", "parameters", ")", ",", "method", "=", "Api", ".", "_method", "[", "'delete'", "]", ",", "body", "=", "urllib", ".", "urlencode", "(", "data", ")", ")" ]
1bd625028aa0c2b901f27e1a8ef0a45d12404830
valid
Api.head
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
api.py
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&f=b """ return self.request_handler.request( self._url(endpoint, url_data, parameters), method=Api._method['head'] )
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&f=b """ return self.request_handler.request( self._url(endpoint, url_data, parameters), method=Api._method['head'] )
[ "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" ]
travisby/pyrest
python
https://github.com/travisby/pyrest/blob/1bd625028aa0c2b901f27e1a8ef0a45d12404830/api.py#L119-L128
[ "def", "head", "(", "self", ",", "endpoint", ",", "url_data", "=", "None", ",", "parameters", "=", "None", ")", ":", "return", "self", ".", "request_handler", ".", "request", "(", "self", ".", "_url", "(", "endpoint", ",", "url_data", ",", "parameters", ")", ",", "method", "=", "Api", ".", "_method", "[", "'head'", "]", ")" ]
1bd625028aa0c2b901f27e1a8ef0a45d12404830
valid
Api._url
Generate URL on the modularized endpoints and url parameters
api.py
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: url = url % url_data if parameters: # url = url?key=value&key=value&key=value... url = '%s?%s' % (url, urllib.urlencode(parameters, True)) return url
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: url = url % url_data if parameters: # url = url?key=value&key=value&key=value... url = '%s?%s' % (url, urllib.urlencode(parameters, True)) return url
[ "Generate", "URL", "on", "the", "modularized", "endpoints", "and", "url", "parameters" ]
travisby/pyrest
python
https://github.com/travisby/pyrest/blob/1bd625028aa0c2b901f27e1a8ef0a45d12404830/api.py#L130-L141
[ "def", "_url", "(", "self", ",", "endpoint", ",", "url_data", "=", "None", ",", "parameters", "=", "None", ")", ":", "try", ":", "url", "=", "'%s/%s'", "%", "(", "self", ".", "base_url", ",", "self", ".", "endpoints", "[", "endpoint", "]", ")", "except", "KeyError", ":", "raise", "EndPointDoesNotExist", "(", "endpoint", ")", "if", "url_data", ":", "url", "=", "url", "%", "url_data", "if", "parameters", ":", "# url = url?key=value&key=value&key=value...", "url", "=", "'%s?%s'", "%", "(", "url", ",", "urllib", ".", "urlencode", "(", "parameters", ",", "True", ")", ")", "return", "url" ]
1bd625028aa0c2b901f27e1a8ef0a45d12404830
valid
Api._httplib2_init
Used to instantiate a regular HTTP request object
api.py
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
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
[ "Used", "to", "instantiate", "a", "regular", "HTTP", "request", "object" ]
travisby/pyrest
python
https://github.com/travisby/pyrest/blob/1bd625028aa0c2b901f27e1a8ef0a45d12404830/api.py#L144-L149
[ "def", "_httplib2_init", "(", "username", ",", "password", ")", ":", "obj", "=", "httplib2", ".", "Http", "(", ")", "if", "username", "and", "password", ":", "obj", ".", "add_credentials", "(", "username", ",", "password", ")", "return", "obj" ]
1bd625028aa0c2b901f27e1a8ef0a45d12404830
valid
UrbainViscosityTx.calculate
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material.
auxi/tools/materialphysicalproperties/slags.py
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] x = state['x'] # normalise mole fractions x_total = sum(x.values()) x = {compound: x[compound]/x_total for compound in x.keys()} xg = x.get('SiO2', .00) + x.get('P2O5', 0.0) xm = x.get('CaO', 0.0) + x.get('MgO', 0.0) + x.get('Na2O', 0.0) + \ x.get('K2O', 0.0) + 3.0*x.get('CaF2', 0.0) + x.get('FeO', 0.0) + \ x.get('MnO', 0.0) + 2.0*x.get('TiO2', 0.0) + 2.0*x.get('ZrO2', 0.0) xa = x.get('Al2O3', 0.0) + x.get('Fe2O3', 0.0) + x.get('B2O3', 0.0) # Note 2*XFeO1.5 = XFe2O3 norm = 1.0 + x.get('CaF2', 0.0) + x.get('Fe2O3', 0.0) + \ x.get('TiO2', 0.0) + x.get('ZrO2', 0.0) xg_norm = xg / norm xm_norm = xm / norm xa_norm = xa / norm alpha = xm_norm / (xm_norm + xa_norm) B0 = 13.8 + 39.9355*alpha - 44.049*alpha**2.0 B1 = 30.481 - 117.1505*alpha + 129.9978*alpha**2.0 B2 = -40.9429 + 234.0846*alpha - 300.04*alpha**2.0 B3 = 60.7619 - 153.9276*alpha + 211.1616*alpha**2.0 B = B0 + B1*xg_norm + B2*xg_norm**2.0 + B3*xg_norm**3.0 A = exp(-0.2693*B - 11.6725) result = A*T*exp(1000.0*B/T) # [P] return result / 10.0
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] x = state['x'] # normalise mole fractions x_total = sum(x.values()) x = {compound: x[compound]/x_total for compound in x.keys()} xg = x.get('SiO2', .00) + x.get('P2O5', 0.0) xm = x.get('CaO', 0.0) + x.get('MgO', 0.0) + x.get('Na2O', 0.0) + \ x.get('K2O', 0.0) + 3.0*x.get('CaF2', 0.0) + x.get('FeO', 0.0) + \ x.get('MnO', 0.0) + 2.0*x.get('TiO2', 0.0) + 2.0*x.get('ZrO2', 0.0) xa = x.get('Al2O3', 0.0) + x.get('Fe2O3', 0.0) + x.get('B2O3', 0.0) # Note 2*XFeO1.5 = XFe2O3 norm = 1.0 + x.get('CaF2', 0.0) + x.get('Fe2O3', 0.0) + \ x.get('TiO2', 0.0) + x.get('ZrO2', 0.0) xg_norm = xg / norm xm_norm = xm / norm xa_norm = xa / norm alpha = xm_norm / (xm_norm + xa_norm) B0 = 13.8 + 39.9355*alpha - 44.049*alpha**2.0 B1 = 30.481 - 117.1505*alpha + 129.9978*alpha**2.0 B2 = -40.9429 + 234.0846*alpha - 300.04*alpha**2.0 B3 = 60.7619 - 153.9276*alpha + 211.1616*alpha**2.0 B = B0 + B1*xg_norm + B2*xg_norm**2.0 + B3*xg_norm**3.0 A = exp(-0.2693*B - 11.6725) result = A*T*exp(1000.0*B/T) # [P] return result / 10.0
[ "Calculate", "dynamic", "viscosity", "at", "the", "specified", "temperature", "and", "composition", ":" ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/slags.py#L43-L94
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "T", "=", "state", "[", "'T'", "]", "x", "=", "state", "[", "'x'", "]", "# normalise mole fractions", "x_total", "=", "sum", "(", "x", ".", "values", "(", ")", ")", "x", "=", "{", "compound", ":", "x", "[", "compound", "]", "/", "x_total", "for", "compound", "in", "x", ".", "keys", "(", ")", "}", "xg", "=", "x", ".", "get", "(", "'SiO2'", ",", ".00", ")", "+", "x", ".", "get", "(", "'P2O5'", ",", "0.0", ")", "xm", "=", "x", ".", "get", "(", "'CaO'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'MgO'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'Na2O'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'K2O'", ",", "0.0", ")", "+", "3.0", "*", "x", ".", "get", "(", "'CaF2'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'FeO'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'MnO'", ",", "0.0", ")", "+", "2.0", "*", "x", ".", "get", "(", "'TiO2'", ",", "0.0", ")", "+", "2.0", "*", "x", ".", "get", "(", "'ZrO2'", ",", "0.0", ")", "xa", "=", "x", ".", "get", "(", "'Al2O3'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'Fe2O3'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'B2O3'", ",", "0.0", ")", "# Note 2*XFeO1.5 = XFe2O3", "norm", "=", "1.0", "+", "x", ".", "get", "(", "'CaF2'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'Fe2O3'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'TiO2'", ",", "0.0", ")", "+", "x", ".", "get", "(", "'ZrO2'", ",", "0.0", ")", "xg_norm", "=", "xg", "/", "norm", "xm_norm", "=", "xm", "/", "norm", "xa_norm", "=", "xa", "/", "norm", "alpha", "=", "xm_norm", "/", "(", "xm_norm", "+", "xa_norm", ")", "B0", "=", "13.8", "+", "39.9355", "*", "alpha", "-", "44.049", "*", "alpha", "**", "2.0", "B1", "=", "30.481", "-", "117.1505", "*", "alpha", "+", "129.9978", "*", "alpha", "**", "2.0", "B2", "=", "-", "40.9429", "+", "234.0846", "*", "alpha", "-", "300.04", "*", "alpha", "**", "2.0", "B3", "=", "60.7619", "-", "153.9276", "*", "alpha", "+", "211.1616", "*", "alpha", "**", "2.0", "B", "=", "B0", "+", "B1", "*", "xg_norm", "+", "B2", "*", "xg_norm", "**", "2.0", "+", "B3", "*", "xg_norm", "**", "3.0", "A", "=", "exp", "(", "-", "0.2693", "*", "B", "-", "11.6725", ")", "result", "=", "A", "*", "T", "*", "exp", "(", "1000.0", "*", "B", "/", "T", ")", "# [P]", "return", "result", "/", "10.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
UrbainViscosityTy.calculate
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material.
auxi/tools/materialphysicalproperties/slags.py
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] y = state['y'] x = amount_fractions(y) return super().calculate(T=T, x=x)
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] y = state['y'] x = amount_fractions(y) return super().calculate(T=T, x=x)
[ "Calculate", "dynamic", "viscosity", "at", "the", "specified", "temperature", "and", "composition", ":" ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/slags.py#L110-L128
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "T", "=", "state", "[", "'T'", "]", "y", "=", "state", "[", "'y'", "]", "x", "=", "amount_fractions", "(", "y", ")", "return", "super", "(", ")", ".", "calculate", "(", "T", "=", "T", ",", "x", "=", "x", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
RiboudViscosityTx.calculate
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material.
auxi/tools/materialphysicalproperties/slags.py
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] x = state['x'] # create the slag constituent categories compounds_sio2 = ['SiO2', 'PO2.5', 'TiO2', 'ZrO2'] compounds_cao = ['CaO', 'MgO', 'FeO1.5', 'FeO', 'MnO', 'BO1.5'] compounds_al2o3 = ['Al2O3'] compounds_caf2 = ['CaF2'] compounds_na2o = ['Na2O', 'K2O'] compounds_all = (compounds_sio2 + compounds_cao + compounds_al2o3 + compounds_caf2 + compounds_na2o) # convert compounds with two cations to single cation equivalents if 'P2O5' in x: x['PO2.5'] = 2.0 * x['P2O5'] if 'Fe2O3' in x: x['FeO1.5'] = 2.0 * x['Fe2O3'] if 'B2O3' in x: x['BO1.5'] = 2.0 * x['B2O3'] # normalise mole fractions, use only compounds in compounds_all x_total = sum([x.get(c, 0.0) for c in compounds_all]) x = {c: x.get(c, 0.0)/x_total for c in compounds_all} # calculate the cateogry mole fractions x1 = sum([x.get(c, 0.0) for c in compounds_sio2]) x2 = sum([x.get(c, 0.0) for c in compounds_cao]) x3 = sum([x.get(c, 0.0) for c in compounds_al2o3]) x4 = sum([x.get(c, 0.0) for c in compounds_caf2]) x5 = sum([x.get(c, 0.0) for c in compounds_na2o]) # TODO: Why is x1 not used? This looks suspicious. A = exp(-17.51 + 1.73*x2 + 5.82*x4 + 7.02*x5 - 33.76*x3) B = 31140.0 - 23896.0*x2 - 46356.0*x4 - 39159.0*x5 + 68833.0*x3 result = A*T*exp(B/T) # [P] return result / 10.0
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] dynamic viscosity The **state parameter contains the keyword argument(s) specified above\ that are used to describe the state of the material. """ T = state['T'] x = state['x'] # create the slag constituent categories compounds_sio2 = ['SiO2', 'PO2.5', 'TiO2', 'ZrO2'] compounds_cao = ['CaO', 'MgO', 'FeO1.5', 'FeO', 'MnO', 'BO1.5'] compounds_al2o3 = ['Al2O3'] compounds_caf2 = ['CaF2'] compounds_na2o = ['Na2O', 'K2O'] compounds_all = (compounds_sio2 + compounds_cao + compounds_al2o3 + compounds_caf2 + compounds_na2o) # convert compounds with two cations to single cation equivalents if 'P2O5' in x: x['PO2.5'] = 2.0 * x['P2O5'] if 'Fe2O3' in x: x['FeO1.5'] = 2.0 * x['Fe2O3'] if 'B2O3' in x: x['BO1.5'] = 2.0 * x['B2O3'] # normalise mole fractions, use only compounds in compounds_all x_total = sum([x.get(c, 0.0) for c in compounds_all]) x = {c: x.get(c, 0.0)/x_total for c in compounds_all} # calculate the cateogry mole fractions x1 = sum([x.get(c, 0.0) for c in compounds_sio2]) x2 = sum([x.get(c, 0.0) for c in compounds_cao]) x3 = sum([x.get(c, 0.0) for c in compounds_al2o3]) x4 = sum([x.get(c, 0.0) for c in compounds_caf2]) x5 = sum([x.get(c, 0.0) for c in compounds_na2o]) # TODO: Why is x1 not used? This looks suspicious. A = exp(-17.51 + 1.73*x2 + 5.82*x4 + 7.02*x5 - 33.76*x3) B = 31140.0 - 23896.0*x2 - 46356.0*x4 - 39159.0*x5 + 68833.0*x3 result = A*T*exp(B/T) # [P] return result / 10.0
[ "Calculate", "dynamic", "viscosity", "at", "the", "specified", "temperature", "and", "composition", ":" ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/slags.py#L144-L196
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "T", "=", "state", "[", "'T'", "]", "x", "=", "state", "[", "'x'", "]", "# create the slag constituent categories", "compounds_sio2", "=", "[", "'SiO2'", ",", "'PO2.5'", ",", "'TiO2'", ",", "'ZrO2'", "]", "compounds_cao", "=", "[", "'CaO'", ",", "'MgO'", ",", "'FeO1.5'", ",", "'FeO'", ",", "'MnO'", ",", "'BO1.5'", "]", "compounds_al2o3", "=", "[", "'Al2O3'", "]", "compounds_caf2", "=", "[", "'CaF2'", "]", "compounds_na2o", "=", "[", "'Na2O'", ",", "'K2O'", "]", "compounds_all", "=", "(", "compounds_sio2", "+", "compounds_cao", "+", "compounds_al2o3", "+", "compounds_caf2", "+", "compounds_na2o", ")", "# convert compounds with two cations to single cation equivalents", "if", "'P2O5'", "in", "x", ":", "x", "[", "'PO2.5'", "]", "=", "2.0", "*", "x", "[", "'P2O5'", "]", "if", "'Fe2O3'", "in", "x", ":", "x", "[", "'FeO1.5'", "]", "=", "2.0", "*", "x", "[", "'Fe2O3'", "]", "if", "'B2O3'", "in", "x", ":", "x", "[", "'BO1.5'", "]", "=", "2.0", "*", "x", "[", "'B2O3'", "]", "# normalise mole fractions, use only compounds in compounds_all", "x_total", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_all", "]", ")", "x", "=", "{", "c", ":", "x", ".", "get", "(", "c", ",", "0.0", ")", "/", "x_total", "for", "c", "in", "compounds_all", "}", "# calculate the cateogry mole fractions", "x1", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_sio2", "]", ")", "x2", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_cao", "]", ")", "x3", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_al2o3", "]", ")", "x4", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_caf2", "]", ")", "x5", "=", "sum", "(", "[", "x", ".", "get", "(", "c", ",", "0.0", ")", "for", "c", "in", "compounds_na2o", "]", ")", "# TODO: Why is x1 not used? This looks suspicious.", "A", "=", "exp", "(", "-", "17.51", "+", "1.73", "*", "x2", "+", "5.82", "*", "x4", "+", "7.02", "*", "x5", "-", "33.76", "*", "x3", ")", "B", "=", "31140.0", "-", "23896.0", "*", "x2", "-", "46356.0", "*", "x4", "-", "39159.0", "*", "x5", "+", "68833.0", "*", "x3", "result", "=", "A", "*", "T", "*", "exp", "(", "B", "/", "T", ")", "# [P]", "return", "result", "/", "10.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.alpha
Calculate the alpha value given the material state. :param **state: material state :returns: float
auxi/modelling/process/materials/core.py
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)
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", "alpha", "value", "given", "the", "material", "state", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/core.py#L59-L68
[ "def", "alpha", "(", "self", ",", "*", "*", "state", ")", ":", "return", "self", ".", "k", "(", "*", "*", "state", ")", "/", "self", ".", "rho", "(", "*", "*", "state", ")", "/", "self", ".", "Cp", "(", "*", "*", "state", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
DafThermoTy._calc_a
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.
auxi/tools/materialphysicalproperties/coals.py
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 _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"))
[ "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" ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/coals.py#L54-L71
[ "def", "_calc_a", "(", "self", ",", "y_C", ",", "y_H", ",", "y_O", ",", "y_N", ",", "y_S", ")", ":", "return", "1", "/", "(", "y_C", "/", "mm", "(", "\"C\"", ")", "+", "y_H", "/", "mm", "(", "\"H\"", ")", "+", "y_O", "/", "mm", "(", "\"O\"", ")", "+", "y_N", "/", "mm", "(", "\"N\"", ")", "+", "y_S", "/", "mm", "(", "\"S\"", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
DafHTy.calculate
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 :param y_N: Nitrogen mass fraction :param y_S: Sulphur mass fraction :returns: [J/kg] enthalpy The **state parameter contains the keyword argument(s) specified above that are used to describe the state of the material.
auxi/tools/materialphysicalproperties/coals.py
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 :param y_N: Nitrogen mass fraction :param y_S: Sulphur mass fraction :returns: [J/kg] enthalpy The **state parameter contains the keyword argument(s) specified above that are used to describe the state of the material. """ T = state['T'] y_C = state['y_C'] y_H = state['y_H'] y_O = state['y_O'] y_N = state['y_N'] y_S = state['y_S'] a = self._calc_a(y_C, y_H, y_O, y_N, y_S) / 1000 # kg/mol result = (R/a) * (380*self._calc_g0(380/T) + 3600*self._calc_g0(1800/T)) return result
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 :param y_N: Nitrogen mass fraction :param y_S: Sulphur mass fraction :returns: [J/kg] enthalpy The **state parameter contains the keyword argument(s) specified above that are used to describe the state of the material. """ T = state['T'] y_C = state['y_C'] y_H = state['y_H'] y_O = state['y_O'] y_N = state['y_N'] y_S = state['y_S'] a = self._calc_a(y_C, y_H, y_O, y_N, y_S) / 1000 # kg/mol result = (R/a) * (380*self._calc_g0(380/T) + 3600*self._calc_g0(1800/T)) return result
[ "Calculate", "the", "enthalpy", "at", "the", "specified", "temperature", "and", "composition", "using", "equation", "9", "in", "Merrick1983b", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/coals.py#L143-L170
[ "def", "calculate", "(", "self", ",", "*", "*", "state", ")", ":", "T", "=", "state", "[", "'T'", "]", "y_C", "=", "state", "[", "'y_C'", "]", "y_H", "=", "state", "[", "'y_H'", "]", "y_O", "=", "state", "[", "'y_O'", "]", "y_N", "=", "state", "[", "'y_N'", "]", "y_S", "=", "state", "[", "'y_S'", "]", "a", "=", "self", ".", "_calc_a", "(", "y_C", ",", "y_H", ",", "y_O", ",", "y_N", ",", "y_S", ")", "/", "1000", "# kg/mol", "result", "=", "(", "R", "/", "a", ")", "*", "(", "380", "*", "self", ".", "_calc_g0", "(", "380", "/", "T", ")", "+", "3600", "*", "self", ".", "_calc_g0", "(", "1800", "/", "T", ")", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
TimeBasedModel.create_entity
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 entity.
auxi/modelling/business/models.py
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 entity. """ new_entity = Entity(name, gl_structure, description=description) self.entities.append(new_entity) return new_entity
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 entity. """ new_entity = Entity(name, gl_structure, description=description) self.entities.append(new_entity) return new_entity
[ "Create", "an", "entity", "and", "add", "it", "to", "the", "model", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/business/models.py#L65-L78
[ "def", "create_entity", "(", "self", ",", "name", ",", "gl_structure", ",", "description", "=", "None", ")", ":", "new_entity", "=", "Entity", "(", "name", ",", "gl_structure", ",", "description", "=", "description", ")", "self", ".", "entities", ".", "append", "(", "new_entity", ")", "return", "new_entity" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
TimeBasedModel.remove_entity
Remove an entity from the model. :param name: The name of the entity to remove.
auxi/modelling/business/models.py
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 None: self.entities.remove(entity_to_remove)
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 None: self.entities.remove(entity_to_remove)
[ "Remove", "an", "entity", "from", "the", "model", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/business/models.py#L80-L92
[ "def", "remove_entity", "(", "self", ",", "name", ")", ":", "entity_to_remove", "=", "None", "for", "e", "in", "self", ".", "entities", ":", "if", "e", ".", "name", "==", "name", ":", "entity_to_remove", "=", "e", "if", "entity_to_remove", "is", "not", "None", ":", "self", ".", "entities", ".", "remove", "(", "entity_to_remove", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
TimeBasedModel.prepare_to_run
Prepare the model for execution.
auxi/modelling/business/models.py
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)
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)
[ "Prepare", "the", "model", "for", "execution", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/business/models.py#L94-L101
[ "def", "prepare_to_run", "(", "self", ")", ":", "self", ".", "clock", ".", "reset", "(", ")", "for", "e", "in", "self", ".", "entities", ":", "e", ".", "prepare_to_run", "(", "self", ".", "clock", ",", "self", ".", "period_count", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
TimeBasedModel.run
Execute the model.
auxi/modelling/business/models.py
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()
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()
[ "Execute", "the", "model", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/business/models.py#L103-L112
[ "def", "run", "(", "self", ")", ":", "self", ".", "prepare_to_run", "(", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "period_count", ")", ":", "for", "e", "in", "self", ".", "entities", ":", "e", ".", "run", "(", "self", ".", "clock", ")", "self", ".", "clock", ".", "tick", "(", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material._create_element_list
Extract an alphabetically sorted list of elements from the material's compounds. :returns: Alphabetically sorted list of elements.
auxi/modelling/process/materials/thermo.py
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))
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))
[ "Extract", "an", "alphabetically", "sorted", "list", "of", "elements", "from", "the", "material", "s", "compounds", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L246-L255
[ "def", "_create_element_list", "(", "self", ")", ":", "element_set", "=", "stoich", ".", "elements", "(", "self", ".", "compounds", ")", "return", "sorted", "(", "list", "(", "element_set", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.add_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 compounds.
auxi/modelling/process/materials/thermo.py
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 compounds. """ if not type(assay) is numpy.ndarray: raise Exception("Invalid assay. It must be a numpy array.") elif not assay.shape == (self.compound_count,): raise Exception("Invalid assay: It must have the same number of " "elements as the material has compounds.") elif name in self.raw_assays.keys(): raise Exception("Invalid assay: An assay with that name already " "exists.") self.raw_assays[name] = assay self.converted_assays[name] = assay
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 compounds. """ if not type(assay) is numpy.ndarray: raise Exception("Invalid assay. It must be a numpy array.") elif not assay.shape == (self.compound_count,): raise Exception("Invalid assay: It must have the same number of " "elements as the material has compounds.") elif name in self.raw_assays.keys(): raise Exception("Invalid assay: An assay with that name already " "exists.") self.raw_assays[name] = assay self.converted_assays[name] = assay
[ "Add", "an", "assay", "to", "the", "material", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L289-L308
[ "def", "add_assay", "(", "self", ",", "name", ",", "assay", ")", ":", "if", "not", "type", "(", "assay", ")", "is", "numpy", ".", "ndarray", ":", "raise", "Exception", "(", "\"Invalid assay. It must be a numpy array.\"", ")", "elif", "not", "assay", ".", "shape", "==", "(", "self", ".", "compound_count", ",", ")", ":", "raise", "Exception", "(", "\"Invalid assay: It must have the same number of \"", "\"elements as the material has compounds.\"", ")", "elif", "name", "in", "self", ".", "raw_assays", ".", "keys", "(", ")", ":", "raise", "Exception", "(", "\"Invalid assay: An assay with that name already \"", "\"exists.\"", ")", "self", ".", "raw_assays", "[", "name", "]", "=", "assay", "self", ".", "converted_assays", "[", "name", "]", "=", "assay" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.create_package
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 P: Package pressure. [atm] :param T: Package temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the package. :returns: MaterialPackage object.
auxi/modelling/process/materials/thermo.py
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 P: Package pressure. [atm] :param T: Package temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the package. :returns: MaterialPackage object. """ if assay is None: return MaterialPackage(self, self.create_empty_assay(), P, T) if normalise: assay_total = self.get_assay_total(assay) else: assay_total = 1.0 return MaterialPackage(self, mass * self.converted_assays[assay] / assay_total, P, T, self._isCoal(assay), self._get_HHV(assay))
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 P: Package pressure. [atm] :param T: Package temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the package. :returns: MaterialPackage object. """ if assay is None: return MaterialPackage(self, self.create_empty_assay(), P, T) if normalise: assay_total = self.get_assay_total(assay) else: assay_total = 1.0 return MaterialPackage(self, mass * self.converted_assays[assay] / assay_total, P, T, self._isCoal(assay), self._get_HHV(assay))
[ "Create", "a", "MaterialPackage", "based", "on", "the", "specified", "parameters", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L321-L346
[ "def", "create_package", "(", "self", ",", "assay", "=", "None", ",", "mass", "=", "0.0", ",", "P", "=", "1.0", ",", "T", "=", "25.0", ",", "normalise", "=", "True", ")", ":", "if", "assay", "is", "None", ":", "return", "MaterialPackage", "(", "self", ",", "self", ".", "create_empty_assay", "(", ")", ",", "P", ",", "T", ")", "if", "normalise", ":", "assay_total", "=", "self", ".", "get_assay_total", "(", "assay", ")", "else", ":", "assay_total", "=", "1.0", "return", "MaterialPackage", "(", "self", ",", "mass", "*", "self", ".", "converted_assays", "[", "assay", "]", "/", "assay_total", ",", "P", ",", "T", ",", "self", ".", "_isCoal", "(", "assay", ")", ",", "self", ".", "_get_HHV", "(", "assay", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Material.create_stream
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: Stream pressure. [atm] :param T: Stream temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the Stream. :returns: MaterialStream object.
auxi/modelling/process/materials/thermo.py
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: Stream pressure. [atm] :param T: Stream temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the Stream. :returns: MaterialStream object. """ if assay is None: return MaterialStream(self, self.create_empty_assay(), P, T) if normalise: assay_total = self.get_assay_total(assay) else: assay_total = 1.0 return MaterialStream(self, mfr * self.converted_assays[assay] / assay_total, P, T, self._isCoal(assay), self._get_HHV(assay))
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: Stream pressure. [atm] :param T: Stream temperature. [°C] :param normalise: Indicates whether the assay must be normalised before creating the Stream. :returns: MaterialStream object. """ if assay is None: return MaterialStream(self, self.create_empty_assay(), P, T) if normalise: assay_total = self.get_assay_total(assay) else: assay_total = 1.0 return MaterialStream(self, mfr * self.converted_assays[assay] / assay_total, P, T, self._isCoal(assay), self._get_HHV(assay))
[ "Create", "a", "MaterialStream", "based", "on", "the", "specified", "parameters", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L348-L373
[ "def", "create_stream", "(", "self", ",", "assay", "=", "None", ",", "mfr", "=", "0.0", ",", "P", "=", "1.0", ",", "T", "=", "25.0", ",", "normalise", "=", "True", ")", ":", "if", "assay", "is", "None", ":", "return", "MaterialStream", "(", "self", ",", "self", ".", "create_empty_assay", "(", ")", ",", "P", ",", "T", ")", "if", "normalise", ":", "assay_total", "=", "self", ".", "get_assay_total", "(", "assay", ")", "else", ":", "assay_total", "=", "1.0", "return", "MaterialStream", "(", "self", ",", "mfr", "*", "self", ".", "converted_assays", "[", "assay", "]", "/", "assay_total", ",", "P", ",", "T", ",", "self", ".", "_isCoal", "(", "assay", ")", ",", "self", ".", "_get_HHV", "(", "assay", ")", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._calculate_H
Calculate the enthalpy of the package at the specified temperature. :param T: Temperature. [°C] :returns: Enthalpy. [kWh]
auxi/modelling/process/materials/thermo.py
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.material.compounds: index = self.material.get_compound_index(compound) dH = thermo.H(compound, T, self._compound_masses[index]) H = H + dH return H
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.material.compounds: index = self.material.get_compound_index(compound) dH = thermo.H(compound, T, self._compound_masses[index]) H = H + dH return H
[ "Calculate", "the", "enthalpy", "of", "the", "package", "at", "the", "specified", "temperature", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L582-L599
[ "def", "_calculate_H", "(", "self", ",", "T", ")", ":", "if", "self", ".", "isCoal", ":", "return", "self", ".", "_calculate_Hfr_coal", "(", "T", ")", "H", "=", "0.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "dH", "=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_masses", "[", "index", "]", ")", "H", "=", "H", "+", "dH", "return", "H" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._calculate_H_coal
Calculate the enthalpy of the package at the specified temperature, in case the material is coal. :param T: [°C] temperature :returns: [kWh] enthalpy
auxi/modelling/process/materials/thermo.py
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 = 0 # kg m_S = 0 # kg H = 0.0 # kWh/h for compound in self.material.compounds: index = self.material.get_compound_index(compound) if stoich.element_mass_fraction(compound, 'C') == 1.0: m_C += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'H') == 1.0: m_H += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'O') == 1.0: m_O += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'N') == 1.0: m_N += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'S') == 1.0: m_S += self._compound_masses[index] else: dH = thermo.H(compound, T, self._compound_masses[index]) H += dH m_total = y_C + y_H + y_O + y_N + y_S # kg/h y_C = m_C / m_total y_H = m_H / m_total y_O = m_O / m_total y_N = m_N / m_total y_S = m_S / m_total hmodel = coals.DafHTy() H = hmodel.calculate(T=T+273.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg H298 = hmodel.calculate(T=298.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg Hdaf = H - H298 + self._DH298 # kWh/kg Hdaf *= m_total # kWh H += Hdaf return H
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 = 0 # kg m_S = 0 # kg H = 0.0 # kWh/h for compound in self.material.compounds: index = self.material.get_compound_index(compound) if stoich.element_mass_fraction(compound, 'C') == 1.0: m_C += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'H') == 1.0: m_H += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'O') == 1.0: m_O += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'N') == 1.0: m_N += self._compound_masses[index] elif stoich.element_mass_fraction(compound, 'S') == 1.0: m_S += self._compound_masses[index] else: dH = thermo.H(compound, T, self._compound_masses[index]) H += dH m_total = y_C + y_H + y_O + y_N + y_S # kg/h y_C = m_C / m_total y_H = m_H / m_total y_O = m_O / m_total y_N = m_N / m_total y_S = m_S / m_total hmodel = coals.DafHTy() H = hmodel.calculate(T=T+273.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg H298 = hmodel.calculate(T=298.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg Hdaf = H - H298 + self._DH298 # kWh/kg Hdaf *= m_total # kWh H += Hdaf return H
[ "Calculate", "the", "enthalpy", "of", "the", "package", "at", "the", "specified", "temperature", "in", "case", "the", "material", "is", "coal", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L654-L704
[ "def", "_calculate_H_coal", "(", "self", ",", "T", ")", ":", "m_C", "=", "0", "# kg", "m_H", "=", "0", "# kg", "m_O", "=", "0", "# kg", "m_N", "=", "0", "# kg", "m_S", "=", "0", "# kg", "H", "=", "0.0", "# kWh/h", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "if", "stoich", ".", "element_mass_fraction", "(", "compound", ",", "'C'", ")", "==", "1.0", ":", "m_C", "+=", "self", ".", "_compound_masses", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "compound", ",", "'H'", ")", "==", "1.0", ":", "m_H", "+=", "self", ".", "_compound_masses", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "compound", ",", "'O'", ")", "==", "1.0", ":", "m_O", "+=", "self", ".", "_compound_masses", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "compound", ",", "'N'", ")", "==", "1.0", ":", "m_N", "+=", "self", ".", "_compound_masses", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "compound", ",", "'S'", ")", "==", "1.0", ":", "m_S", "+=", "self", ".", "_compound_masses", "[", "index", "]", "else", ":", "dH", "=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_masses", "[", "index", "]", ")", "H", "+=", "dH", "m_total", "=", "y_C", "+", "y_H", "+", "y_O", "+", "y_N", "+", "y_S", "# kg/h", "y_C", "=", "m_C", "/", "m_total", "y_H", "=", "m_H", "/", "m_total", "y_O", "=", "m_O", "/", "m_total", "y_N", "=", "m_N", "/", "m_total", "y_S", "=", "m_S", "/", "m_total", "hmodel", "=", "coals", ".", "DafHTy", "(", ")", "H", "=", "hmodel", ".", "calculate", "(", "T", "=", "T", "+", "273.15", ",", "y_C", "=", "y_C", ",", "y_H", "=", "y_H", ",", "y_O", "=", "y_O", ",", "y_N", "=", "y_N", ",", "y_S", "=", "y_S", ")", "/", "3.6e6", "# kWh/kg", "H298", "=", "hmodel", ".", "calculate", "(", "T", "=", "298.15", ",", "y_C", "=", "y_C", ",", "y_H", "=", "y_H", ",", "y_O", "=", "y_O", ",", "y_N", "=", "y_N", ",", "y_S", "=", "y_S", ")", "/", "3.6e6", "# kWh/kg", "Hdaf", "=", "H", "-", "H298", "+", "self", ".", "_DH298", "# kWh/kg", "Hdaf", "*=", "m_total", "# kWh", "H", "+=", "Hdaf", "return", "H" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._calculate_T
Calculate the temperature of the package given the specified enthalpy using a secant algorithm. :param H: Enthalpy. [kWh] :returns: Temperature. [°C]
auxi/modelling/process/materials/thermo.py
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.append(self._T) x.append(self._T + 10.0) # Evaluate the enthalpy for the initial guesses. y = list() y.append(self._calculate_H(x[0]) - H) y.append(self._calculate_H(x[1]) - H) # Solve for temperature. for i in range(2, 50): x.append(x[i-1] - y[i-1]*((x[i-1] - x[i-2])/(y[i-1] - y[i-2]))) y.append(self._calculate_H(x[i]) - H) if abs(y[i-1]) < 1.0e-5: break return x[len(x) - 1]
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.append(self._T) x.append(self._T + 10.0) # Evaluate the enthalpy for the initial guesses. y = list() y.append(self._calculate_H(x[0]) - H) y.append(self._calculate_H(x[1]) - H) # Solve for temperature. for i in range(2, 50): x.append(x[i-1] - y[i-1]*((x[i-1] - x[i-2])/(y[i-1] - y[i-2]))) y.append(self._calculate_H(x[i]) - H) if abs(y[i-1]) < 1.0e-5: break return x[len(x) - 1]
[ "Calculate", "the", "temperature", "of", "the", "package", "given", "the", "specified", "enthalpy", "using", "a", "secant", "algorithm", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L706-L733
[ "def", "_calculate_T", "(", "self", ",", "H", ")", ":", "# Create the initial guesses for temperature.", "x", "=", "list", "(", ")", "x", ".", "append", "(", "self", ".", "_T", ")", "x", ".", "append", "(", "self", ".", "_T", "+", "10.0", ")", "# Evaluate the enthalpy for the initial guesses.", "y", "=", "list", "(", ")", "y", ".", "append", "(", "self", ".", "_calculate_H", "(", "x", "[", "0", "]", ")", "-", "H", ")", "y", ".", "append", "(", "self", ".", "_calculate_H", "(", "x", "[", "1", "]", ")", "-", "H", ")", "# Solve for temperature.", "for", "i", "in", "range", "(", "2", ",", "50", ")", ":", "x", ".", "append", "(", "x", "[", "i", "-", "1", "]", "-", "y", "[", "i", "-", "1", "]", "*", "(", "(", "x", "[", "i", "-", "1", "]", "-", "x", "[", "i", "-", "2", "]", ")", "/", "(", "y", "[", "i", "-", "1", "]", "-", "y", "[", "i", "-", "2", "]", ")", ")", ")", "y", ".", "append", "(", "self", ".", "_calculate_H", "(", "x", "[", "i", "]", ")", "-", "H", ")", "if", "abs", "(", "y", "[", "i", "-", "1", "]", ")", "<", "1.0e-5", ":", "break", "return", "x", "[", "len", "(", "x", ")", "-", "1", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage._is_compound_mass_tuple
Determines whether value is a tuple of the format (compound(str), mass(float)). :param value: The value to be tested. :returns: True or False
auxi/modelling/process/materials/thermo.py
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 not len(value) == 2: return False elif not type(value[0]) is str: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
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 not len(value) == 2: return False elif not type(value[0]) is str: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
[ "Determines", "whether", "value", "is", "a", "tuple", "of", "the", "format", "(", "compound", "(", "str", ")", "mass", "(", "float", "))", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L735-L756
[ "def", "_is_compound_mass_tuple", "(", "self", ",", "value", ")", ":", "if", "not", "type", "(", "value", ")", "is", "tuple", ":", "return", "False", "elif", "not", "len", "(", "value", ")", "==", "2", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "0", "]", ")", "is", "str", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "1", "]", ")", "is", "float", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float64", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float32", ":", "return", "False", "else", ":", "return", "True" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.H
Set the enthalpy of the package to the specified value, and recalculate it's temperature. :param H: The new enthalpy value. [kWh]
auxi/modelling/process/materials/thermo.py
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)
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", "enthalpy", "of", "the", "package", "to", "the", "specified", "value", "and", "recalculate", "it", "s", "temperature", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L794-L803
[ "def", "H", "(", "self", ",", "H", ")", ":", "self", ".", "_H", "=", "H", "self", ".", "_T", "=", "self", ".", "_calculate_T", "(", "H", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.T
Set the temperature of the package to the specified value, and recalculate it's enthalpy. :param T: Temperature. [°C]
auxi/modelling/process/materials/thermo.py
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)
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)
[ "Set", "the", "temperature", "of", "the", "package", "to", "the", "specified", "value", "and", "recalculate", "it", "s", "enthalpy", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L816-L825
[ "def", "T", "(", "self", ",", "T", ")", ":", "self", ".", "_T", "=", "T", "self", ".", "_H", "=", "self", ".", "_calculate_H", "(", "T", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.clone
Create a complete copy of the package. :returns: A new MaterialPackage object.
auxi/modelling/process/materials/thermo.py
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
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
[ "Create", "a", "complete", "copy", "of", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L846-L853
[ "def", "clone", "(", "self", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ")", "result", ".", "_compound_masses", "=", "copy", ".", "deepcopy", "(", "self", ".", "_compound_masses", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.clear
Set all the compound masses in the package to zero. Set the pressure to 1, the temperature to 25 and the enthalpy to zero.
auxi/modelling/process/materials/thermo.py
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
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
[ "Set", "all", "the", "compound", "masses", "in", "the", "package", "to", "zero", ".", "Set", "the", "pressure", "to", "1", "the", "temperature", "to", "25", "and", "the", "enthalpy", "to", "zero", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L855-L864
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_compound_masses", "=", "self", ".", "_compound_masses", "*", "0.0", "self", ".", "_P", "=", "1.0", "self", ".", "_T", "=", "25.0", "self", ".", "_H", "=", "0.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_compound_mass
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]
auxi/modelling/process/materials/thermo.py
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._compound_masses[ self.material.get_compound_index(compound)] else: return 0.0
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._compound_masses[ self.material.get_compound_index(compound)] else: return 0.0
[ "Determine", "the", "mass", "of", "the", "specified", "compound", "in", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L885-L898
[ "def", "get_compound_mass", "(", "self", ",", "compound", ")", ":", "if", "compound", "in", "self", ".", "material", ".", "compounds", ":", "return", "self", ".", "_compound_masses", "[", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "]", "else", ":", "return", "0.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_compound_amounts
Determine the mole amounts of all the compounds. :returns: List of amounts. [kmol]
auxi/modelling/process/materials/thermo.py
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) result[index] = stoich.amount(compound, result[index]) return result
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) result[index] = stoich.amount(compound, result[index]) return result
[ "Determine", "the", "mole", "amounts", "of", "all", "the", "compounds", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L900-L911
[ "def", "get_compound_amounts", "(", "self", ")", ":", "result", "=", "self", ".", "_compound_masses", "*", "1.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "result", "[", "index", "]", "=", "stoich", ".", "amount", "(", "compound", ",", "result", "[", "index", "]", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_compound_amount
Determine the mole amount of the specified compound. :returns: Amount. [kmol]
auxi/modelling/process/materials/thermo.py
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])
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", "mole", "amount", "of", "the", "specified", "compound", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L913-L921
[ "def", "get_compound_amount", "(", "self", ",", "compound", ")", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "return", "stoich", ".", "amount", "(", "compound", ",", "self", ".", "_compound_masses", "[", "index", "]", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.amount
Determine the sum of mole amounts of all the compounds. :returns: Amount. [kmol]
auxi/modelling/process/materials/thermo.py
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)
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", "sum", "of", "mole", "amounts", "of", "all", "the", "compounds", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L924-L931
[ "def", "amount", "(", "self", ")", ":", "return", "sum", "(", "self", ".", "get_compound_amount", "(", "c", ")", "for", "c", "in", "self", ".", "material", ".", "compounds", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_element_masses
Determine the masses of elements in the package. :returns: Array of element masses. [kg]
auxi/modelling/process/materials/thermo.py
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 self.material.compounds: result += self.get_compound_mass(compound) *\ numpy.array(stoich.element_mass_fractions(compound, elements)) return result
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 self.material.compounds: result += self.get_compound_mass(compound) *\ numpy.array(stoich.element_mass_fractions(compound, elements)) return result
[ "Determine", "the", "masses", "of", "elements", "in", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L933-L947
[ "def", "get_element_masses", "(", "self", ",", "elements", "=", "None", ")", ":", "if", "elements", "is", "None", ":", "elements", "=", "self", ".", "material", ".", "elements", "result", "=", "numpy", ".", "zeros", "(", "len", "(", "elements", ")", ")", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "result", "+=", "self", ".", "get_compound_mass", "(", "compound", ")", "*", "numpy", ".", "array", "(", "stoich", ".", "element_mass_fractions", "(", "compound", ",", "elements", ")", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_element_mass_dictionary
Determine the masses of elements in the package and return as a dictionary. :returns: Dictionary of element symbols and masses. [kg]
auxi/modelling/process/materials/thermo.py
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() return {s: m for s, m in zip(element_symbols, element_masses)}
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() return {s: m for s, m in zip(element_symbols, element_masses)}
[ "Determine", "the", "masses", "of", "elements", "in", "the", "package", "and", "return", "as", "a", "dictionary", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L949-L960
[ "def", "get_element_mass_dictionary", "(", "self", ")", ":", "element_symbols", "=", "self", ".", "material", ".", "elements", "element_masses", "=", "self", ".", "get_element_masses", "(", ")", "return", "{", "s", ":", "m", "for", "s", ",", "m", "in", "zip", "(", "element_symbols", ",", "element_masses", ")", "}" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.get_element_mass
Determine the mass of the specified elements in the package. :returns: Masses. [kg]
auxi/modelling/process/materials/thermo.py
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) *\ numpy.array(stoich.element_mass_fractions(compound, [element])) return result[0]
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) *\ numpy.array(stoich.element_mass_fractions(compound, [element])) return result[0]
[ "Determine", "the", "mass", "of", "the", "specified", "elements", "in", "the", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L962-L973
[ "def", "get_element_mass", "(", "self", ",", "element", ")", ":", "result", "=", "numpy", ".", "zeros", "(", "1", ")", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "result", "+=", "self", ".", "get_compound_mass", "(", "compound", ")", "*", "numpy", ".", "array", "(", "stoich", ".", "element_mass_fractions", "(", "compound", ",", "[", "element", "]", ")", ")", "return", "result", "[", "0", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialPackage.extract
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 other and the extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialPackage object.
auxi/modelling/process/materials/thermo.py
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 other and the extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialPackage object. """ # Extract the specified mass. if type(other) is float or \ type(other) is numpy.float64 or \ type(other) is numpy.float32: return self._extract_mass(other) # Extract the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): return self._extract_compound_mass(other[0], other[1]) # Extract all of the specified compound. elif type(other) is str: return self._extract_compound(other) # TODO: Test # Extract all of the compounds of the specified material. elif type(other) is Material: return self._extract_material(other) # If not one of the above, it must be an invalid argument. else: raise TypeError("Invalid extraction argument.")
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 other and the extracted package is returned as a new package. * tuple (compound, mass): The other tuple specifies the mass of a compound to be extracted. It is extracted from self and the extracted mass is returned as a new package. * string: The 'other' string specifies the compound to be extracted. All of the mass of that compound will be removed from self and a new package created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialPackage object. """ # Extract the specified mass. if type(other) is float or \ type(other) is numpy.float64 or \ type(other) is numpy.float32: return self._extract_mass(other) # Extract the specified mass of the specified compound. elif self._is_compound_mass_tuple(other): return self._extract_compound_mass(other[0], other[1]) # Extract all of the specified compound. elif type(other) is str: return self._extract_compound(other) # TODO: Test # Extract all of the compounds of the specified material. elif type(other) is Material: return self._extract_material(other) # If not one of the above, it must be an invalid argument. else: raise TypeError("Invalid extraction argument.")
[ "Extract", "other", "from", "this", "package", "modifying", "this", "package", "and", "returning", "the", "extracted", "material", "as", "a", "new", "package", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L975-L1019
[ "def", "extract", "(", "self", ",", "other", ")", ":", "# Extract the specified mass.", "if", "type", "(", "other", ")", "is", "float", "or", "type", "(", "other", ")", "is", "numpy", ".", "float64", "or", "type", "(", "other", ")", "is", "numpy", ".", "float32", ":", "return", "self", ".", "_extract_mass", "(", "other", ")", "# Extract the specified mass of the specified compound.", "elif", "self", ".", "_is_compound_mass_tuple", "(", "other", ")", ":", "return", "self", ".", "_extract_compound_mass", "(", "other", "[", "0", "]", ",", "other", "[", "1", "]", ")", "# Extract all of the specified compound.", "elif", "type", "(", "other", ")", "is", "str", ":", "return", "self", ".", "_extract_compound", "(", "other", ")", "# TODO: Test", "# Extract all of the compounds of the specified material.", "elif", "type", "(", "other", ")", "is", "Material", ":", "return", "self", ".", "_extract_material", "(", "other", ")", "# If not one of the above, it must be an invalid argument.", "else", ":", "raise", "TypeError", "(", "\"Invalid extraction argument.\"", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream._calculate_Hfr
Calculate the enthalpy flow rate of the stream at the specified temperature. :param T: Temperature. [°C] :returns: Enthalpy flow rate. [kWh/h]
auxi/modelling/process/materials/thermo.py
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 for compound in self.material.compounds: index = self.material.get_compound_index(compound) dHfr = thermo.H(compound, T, self._compound_mfrs[index]) Hfr = Hfr + dHfr return Hfr
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 for compound in self.material.compounds: index = self.material.get_compound_index(compound) dHfr = thermo.H(compound, T, self._compound_mfrs[index]) Hfr = Hfr + dHfr return Hfr
[ "Calculate", "the", "enthalpy", "flow", "rate", "of", "the", "stream", "at", "the", "specified", "temperature", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1297-L1315
[ "def", "_calculate_Hfr", "(", "self", ",", "T", ")", ":", "if", "self", ".", "isCoal", ":", "return", "self", ".", "_calculate_Hfr_coal", "(", "T", ")", "Hfr", "=", "0.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "dHfr", "=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "Hfr", "=", "Hfr", "+", "dHfr", "return", "Hfr" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream._calculate_DH298_coal
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
auxi/modelling/process/materials/thermo.py
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 # kg T = 25 # °C Hin = 0.0 # kWh for compound in self.material.compounds: index = self.material.get_compound_index(compound) formula = compound.split('[')[0] if stoich.element_mass_fraction(formula, 'C') == 1.0: m_C += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'H') == 1.0: m_H += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'O') == 1.0: m_O += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'N') == 1.0: m_N += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'S') == 1.0: m_S += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) m_total = m_C + m_H + m_O + m_N + m_S # kg Hout = 0.0 # kWh Hout += thermo.H('CO2[G]', T, cc(m_C, 'C', 'CO2', 'C')) Hout += thermo.H('H2O[L]', T, cc(m_H, 'H', 'H2O', 'H')) Hout += thermo.H('O2[G]', T, m_O) Hout += thermo.H('N2[G]', T, m_N) Hout += thermo.H('SO2[G]', T, cc(m_S, 'S', 'SO2', 'S')) Hout /= m_total if self.HHV is None: # If no HHV is specified, calculate it from the proximate assay # using C-H-O-N-S. HHV = (Hout - Hin) / m_total # kWh/kg daf else: # If an HHV is specified, convert it from MJ/kg coal to kWh/kg daf. HHV = self.HHV / 3.6 # kWh/kg coal HHV *= self.mfr / m_total # kWh/kg daf return HHV + Hout
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 # kg T = 25 # °C Hin = 0.0 # kWh for compound in self.material.compounds: index = self.material.get_compound_index(compound) formula = compound.split('[')[0] if stoich.element_mass_fraction(formula, 'C') == 1.0: m_C += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'H') == 1.0: m_H += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'O') == 1.0: m_O += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'N') == 1.0: m_N += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) elif stoich.element_mass_fraction(formula, 'S') == 1.0: m_S += self._compound_mfrs[index] Hin += thermo.H(compound, T, self._compound_mfrs[index]) m_total = m_C + m_H + m_O + m_N + m_S # kg Hout = 0.0 # kWh Hout += thermo.H('CO2[G]', T, cc(m_C, 'C', 'CO2', 'C')) Hout += thermo.H('H2O[L]', T, cc(m_H, 'H', 'H2O', 'H')) Hout += thermo.H('O2[G]', T, m_O) Hout += thermo.H('N2[G]', T, m_N) Hout += thermo.H('SO2[G]', T, cc(m_S, 'S', 'SO2', 'S')) Hout /= m_total if self.HHV is None: # If no HHV is specified, calculate it from the proximate assay # using C-H-O-N-S. HHV = (Hout - Hin) / m_total # kWh/kg daf else: # If an HHV is specified, convert it from MJ/kg coal to kWh/kg daf. HHV = self.HHV / 3.6 # kWh/kg coal HHV *= self.mfr / m_total # kWh/kg daf return HHV + Hout
[ "Calculate", "the", "enthalpy", "of", "formation", "of", "the", "dry", "-", "ash", "-", "free", "(", "daf", ")", "component", "of", "the", "coal", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1317-L1370
[ "def", "_calculate_DH298_coal", "(", "self", ")", ":", "m_C", "=", "0", "# kg", "m_H", "=", "0", "# kg", "m_O", "=", "0", "# kg", "m_N", "=", "0", "# kg", "m_S", "=", "0", "# kg", "T", "=", "25", "# °C", "Hin", "=", "0.0", "# kWh", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "formula", "=", "compound", ".", "split", "(", "'['", ")", "[", "0", "]", "if", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'C'", ")", "==", "1.0", ":", "m_C", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "Hin", "+=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'H'", ")", "==", "1.0", ":", "m_H", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "Hin", "+=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'O'", ")", "==", "1.0", ":", "m_O", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "Hin", "+=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'N'", ")", "==", "1.0", ":", "m_N", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "Hin", "+=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'S'", ")", "==", "1.0", ":", "m_S", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "Hin", "+=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "m_total", "=", "m_C", "+", "m_H", "+", "m_O", "+", "m_N", "+", "m_S", "# kg", "Hout", "=", "0.0", "# kWh", "Hout", "+=", "thermo", ".", "H", "(", "'CO2[G]'", ",", "T", ",", "cc", "(", "m_C", ",", "'C'", ",", "'CO2'", ",", "'C'", ")", ")", "Hout", "+=", "thermo", ".", "H", "(", "'H2O[L]'", ",", "T", ",", "cc", "(", "m_H", ",", "'H'", ",", "'H2O'", ",", "'H'", ")", ")", "Hout", "+=", "thermo", ".", "H", "(", "'O2[G]'", ",", "T", ",", "m_O", ")", "Hout", "+=", "thermo", ".", "H", "(", "'N2[G]'", ",", "T", ",", "m_N", ")", "Hout", "+=", "thermo", ".", "H", "(", "'SO2[G]'", ",", "T", ",", "cc", "(", "m_S", ",", "'S'", ",", "'SO2'", ",", "'S'", ")", ")", "Hout", "/=", "m_total", "if", "self", ".", "HHV", "is", "None", ":", "# If no HHV is specified, calculate it from the proximate assay", "# using C-H-O-N-S.", "HHV", "=", "(", "Hout", "-", "Hin", ")", "/", "m_total", "# kWh/kg daf", "else", ":", "# If an HHV is specified, convert it from MJ/kg coal to kWh/kg daf.", "HHV", "=", "self", ".", "HHV", "/", "3.6", "# kWh/kg coal", "HHV", "*=", "self", ".", "mfr", "/", "m_total", "# kWh/kg daf", "return", "HHV", "+", "Hout" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream._calculate_Hfr_coal
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]
auxi/modelling/process/materials/thermo.py
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 m_O = 0 # kg/h m_N = 0 # kg/h m_S = 0 # kg/h Hfr = 0.0 # kWh/h for compound in self.material.compounds: index = self.material.get_compound_index(compound) formula = compound.split('[')[0] if stoich.element_mass_fraction(formula, 'C') == 1.0: m_C += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'H') == 1.0: m_H += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'O') == 1.0: m_O += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'N') == 1.0: m_N += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'S') == 1.0: m_S += self._compound_mfrs[index] else: dHfr = thermo.H(compound, T, self._compound_mfrs[index]) Hfr += dHfr m_total = m_C + m_H + m_O + m_N + m_S # kg/h y_C = m_C / m_total y_H = m_H / m_total y_O = m_O / m_total y_N = m_N / m_total y_S = m_S / m_total hmodel = coals.DafHTy() H = hmodel.calculate(T=T+273.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg H298 = hmodel.calculate(T=298.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg Hdaf = H - H298 + self._DH298 # kWh/kg Hdaf *= m_total # kWh/h Hfr += Hdaf return Hfr
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 m_O = 0 # kg/h m_N = 0 # kg/h m_S = 0 # kg/h Hfr = 0.0 # kWh/h for compound in self.material.compounds: index = self.material.get_compound_index(compound) formula = compound.split('[')[0] if stoich.element_mass_fraction(formula, 'C') == 1.0: m_C += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'H') == 1.0: m_H += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'O') == 1.0: m_O += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'N') == 1.0: m_N += self._compound_mfrs[index] elif stoich.element_mass_fraction(formula, 'S') == 1.0: m_S += self._compound_mfrs[index] else: dHfr = thermo.H(compound, T, self._compound_mfrs[index]) Hfr += dHfr m_total = m_C + m_H + m_O + m_N + m_S # kg/h y_C = m_C / m_total y_H = m_H / m_total y_O = m_O / m_total y_N = m_N / m_total y_S = m_S / m_total hmodel = coals.DafHTy() H = hmodel.calculate(T=T+273.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg H298 = hmodel.calculate(T=298.15, y_C=y_C, y_H=y_H, y_O=y_O, y_N=y_N, y_S=y_S) / 3.6e6 # kWh/kg Hdaf = H - H298 + self._DH298 # kWh/kg Hdaf *= m_total # kWh/h Hfr += Hdaf return Hfr
[ "Calculate", "the", "enthalpy", "flow", "rate", "of", "the", "stream", "at", "the", "specified", "temperature", "in", "the", "case", "of", "it", "being", "coal", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1372-L1423
[ "def", "_calculate_Hfr_coal", "(", "self", ",", "T", ")", ":", "m_C", "=", "0", "# kg/h", "m_H", "=", "0", "# kg/h", "m_O", "=", "0", "# kg/h", "m_N", "=", "0", "# kg/h", "m_S", "=", "0", "# kg/h", "Hfr", "=", "0.0", "# kWh/h", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "formula", "=", "compound", ".", "split", "(", "'['", ")", "[", "0", "]", "if", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'C'", ")", "==", "1.0", ":", "m_C", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'H'", ")", "==", "1.0", ":", "m_H", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'O'", ")", "==", "1.0", ":", "m_O", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'N'", ")", "==", "1.0", ":", "m_N", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "elif", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "'S'", ")", "==", "1.0", ":", "m_S", "+=", "self", ".", "_compound_mfrs", "[", "index", "]", "else", ":", "dHfr", "=", "thermo", ".", "H", "(", "compound", ",", "T", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")", "Hfr", "+=", "dHfr", "m_total", "=", "m_C", "+", "m_H", "+", "m_O", "+", "m_N", "+", "m_S", "# kg/h", "y_C", "=", "m_C", "/", "m_total", "y_H", "=", "m_H", "/", "m_total", "y_O", "=", "m_O", "/", "m_total", "y_N", "=", "m_N", "/", "m_total", "y_S", "=", "m_S", "/", "m_total", "hmodel", "=", "coals", ".", "DafHTy", "(", ")", "H", "=", "hmodel", ".", "calculate", "(", "T", "=", "T", "+", "273.15", ",", "y_C", "=", "y_C", ",", "y_H", "=", "y_H", ",", "y_O", "=", "y_O", ",", "y_N", "=", "y_N", ",", "y_S", "=", "y_S", ")", "/", "3.6e6", "# kWh/kg", "H298", "=", "hmodel", ".", "calculate", "(", "T", "=", "298.15", ",", "y_C", "=", "y_C", ",", "y_H", "=", "y_H", ",", "y_O", "=", "y_O", ",", "y_N", "=", "y_N", ",", "y_S", "=", "y_S", ")", "/", "3.6e6", "# kWh/kg", "Hdaf", "=", "H", "-", "H298", "+", "self", ".", "_DH298", "# kWh/kg", "Hdaf", "*=", "m_total", "# kWh/h", "Hfr", "+=", "Hdaf", "return", "Hfr" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream._calculate_T
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]
auxi/modelling/process/materials/thermo.py
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. x = list() x.append(self._T) x.append(self._T + 10.0) # Evaluate the enthalpy for the initial guesses. y = list() y.append(self._calculate_Hfr(x[0]) - Hfr) y.append(self._calculate_Hfr(x[1]) - Hfr) # Solve for temperature. for i in range(2, 50): x.append(x[i-1] - y[i-1]*((x[i-1] - x[i-2])/(y[i-1] - y[i-2]))) y.append(self._calculate_Hfr(x[i]) - Hfr) if abs(y[i-1]) < 1.0e-5: break return x[len(x) - 1]
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. x = list() x.append(self._T) x.append(self._T + 10.0) # Evaluate the enthalpy for the initial guesses. y = list() y.append(self._calculate_Hfr(x[0]) - Hfr) y.append(self._calculate_Hfr(x[1]) - Hfr) # Solve for temperature. for i in range(2, 50): x.append(x[i-1] - y[i-1]*((x[i-1] - x[i-2])/(y[i-1] - y[i-2]))) y.append(self._calculate_Hfr(x[i]) - Hfr) if abs(y[i-1]) < 1.0e-5: break return x[len(x) - 1]
[ "Calculate", "the", "temperature", "of", "the", "stream", "given", "the", "specified", "enthalpy", "flow", "rate", "using", "a", "secant", "algorithm", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1425-L1452
[ "def", "_calculate_T", "(", "self", ",", "Hfr", ")", ":", "# Create the initial guesses for temperature.", "x", "=", "list", "(", ")", "x", ".", "append", "(", "self", ".", "_T", ")", "x", ".", "append", "(", "self", ".", "_T", "+", "10.0", ")", "# Evaluate the enthalpy for the initial guesses.", "y", "=", "list", "(", ")", "y", ".", "append", "(", "self", ".", "_calculate_Hfr", "(", "x", "[", "0", "]", ")", "-", "Hfr", ")", "y", ".", "append", "(", "self", ".", "_calculate_Hfr", "(", "x", "[", "1", "]", ")", "-", "Hfr", ")", "# Solve for temperature.", "for", "i", "in", "range", "(", "2", ",", "50", ")", ":", "x", ".", "append", "(", "x", "[", "i", "-", "1", "]", "-", "y", "[", "i", "-", "1", "]", "*", "(", "(", "x", "[", "i", "-", "1", "]", "-", "x", "[", "i", "-", "2", "]", ")", "/", "(", "y", "[", "i", "-", "1", "]", "-", "y", "[", "i", "-", "2", "]", ")", ")", ")", "y", ".", "append", "(", "self", ".", "_calculate_Hfr", "(", "x", "[", "i", "]", ")", "-", "Hfr", ")", "if", "abs", "(", "y", "[", "i", "-", "1", "]", ")", "<", "1.0e-5", ":", "break", "return", "x", "[", "len", "(", "x", ")", "-", "1", "]" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream._is_compound_mfr_temperature_tuple
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
auxi/modelling/process/materials/thermo.py
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 elif not len(value) == 3: return False elif not type(value[0]) is str: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
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 elif not len(value) == 3: return False elif not type(value[0]) is str: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False elif not type(value[1]) is float and \ not type(value[1]) is numpy.float64 and \ not type(value[1]) is numpy.float32: return False else: return True
[ "Determines", "whether", "value", "is", "a", "tuple", "of", "the", "format", "(", "compound", "(", "str", ")", "mfr", "(", "float", ")", "temperature", "(", "float", "))", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1477-L1500
[ "def", "_is_compound_mfr_temperature_tuple", "(", "self", ",", "value", ")", ":", "if", "not", "type", "(", "value", ")", "is", "tuple", ":", "return", "False", "elif", "not", "len", "(", "value", ")", "==", "3", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "0", "]", ")", "is", "str", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "1", "]", ")", "is", "float", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float64", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float32", ":", "return", "False", "elif", "not", "type", "(", "value", "[", "1", "]", ")", "is", "float", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float64", "and", "not", "type", "(", "value", "[", "1", "]", ")", "is", "numpy", ".", "float32", ":", "return", "False", "else", ":", "return", "True" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.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]
auxi/modelling/process/materials/thermo.py
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)
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", "enthalpy", "flow", "rate", "of", "the", "stream", "to", "the", "specified", "value", "and", "recalculate", "it", "s", "temperature", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1513-L1522
[ "def", "Hfr", "(", "self", ",", "Hfr", ")", ":", "self", ".", "_Hfr", "=", "Hfr", "self", ".", "_T", "=", "self", ".", "_calculate_T", "(", "Hfr", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.T
Set the temperature of the stream to the specified value, and recalculate it's enthalpy. :param T: Temperature. [°C]
auxi/modelling/process/materials/thermo.py
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)
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", "temperature", "of", "the", "stream", "to", "the", "specified", "value", "and", "recalculate", "it", "s", "enthalpy", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1535-L1544
[ "def", "T", "(", "self", ",", "T", ")", ":", "self", ".", "_T", "=", "T", "self", ".", "_Hfr", "=", "self", ".", "_calculate_Hfr", "(", "T", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.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
auxi/modelling/process/materials/thermo.py
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._DH298 = self._calculate_DH298_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._DH298 = self._calculate_DH298_coal()
[ "Set", "the", "higher", "heating", "value", "of", "the", "stream", "to", "the", "specified", "value", "and", "recalculate", "the", "formation", "enthalpy", "of", "the", "daf", "coal", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1557-L1567
[ "def", "HHV", "(", "self", ",", "HHV", ")", ":", "self", ".", "_HHV", "=", "HHV", "# MJ/kg coal", "if", "self", ".", "isCoal", ":", "self", ".", "_DH298", "=", "self", ".", "_calculate_DH298_coal", "(", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.clone
Create a complete copy of the stream. :returns: A new MaterialStream object.
auxi/modelling/process/materials/thermo.py
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
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
[ "Create", "a", "complete", "copy", "of", "the", "stream", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1588-L1595
[ "def", "clone", "(", "self", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ")", "result", ".", "_compound_mfrs", "=", "copy", ".", "deepcopy", "(", "self", ".", "_compound_mfrs", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.clear
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.
auxi/modelling/process/materials/thermo.py
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
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
[ "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", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1597-L1606
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_compound_mfrs", "=", "self", ".", "_compound_mfrs", "*", "0.0", "self", ".", "_P", "=", "1.0", "self", ".", "_T", "=", "25.0", "self", ".", "_H", "=", "0.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_compound_mfr
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]
auxi/modelling/process/materials/thermo.py
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: return self._compound_mfrs[ self.material.get_compound_index(compound)] else: return 0.0
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: return self._compound_mfrs[ self.material.get_compound_index(compound)] else: return 0.0
[ "Determine", "the", "mass", "flow", "rate", "of", "the", "specified", "compound", "in", "the", "stream", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1627-L1640
[ "def", "get_compound_mfr", "(", "self", ",", "compound", ")", ":", "if", "compound", "in", "self", ".", "material", ".", "compounds", ":", "return", "self", ".", "_compound_mfrs", "[", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "]", "else", ":", "return", "0.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_compound_afrs
Determine the amount flow rates of all the compounds. :returns: List of amount flow rates. [kmol/h]
auxi/modelling/process/materials/thermo.py
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(compound) result[index] = stoich.amount(compound, result[index]) return result
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(compound) result[index] = stoich.amount(compound, result[index]) return result
[ "Determine", "the", "amount", "flow", "rates", "of", "all", "the", "compounds", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1642-L1653
[ "def", "get_compound_afrs", "(", "self", ")", ":", "result", "=", "self", ".", "_compound_mfrs", "*", "1.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "result", "[", "index", "]", "=", "stoich", ".", "amount", "(", "compound", ",", "result", "[", "index", "]", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_compound_afr
Determine the amount flow rate of the specified compound. :returns: Amount flow rate. [kmol/h]
auxi/modelling/process/materials/thermo.py
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])
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", "amount", "flow", "rate", "of", "the", "specified", "compound", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1655-L1663
[ "def", "get_compound_afr", "(", "self", ",", "compound", ")", ":", "index", "=", "self", ".", "material", ".", "get_compound_index", "(", "compound", ")", "return", "stoich", ".", "amount", "(", "compound", ",", "self", ".", "_compound_mfrs", "[", "index", "]", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.afr
Determine the sum of amount flow rates of all the compounds. :returns: Amount flow rate. [kmol/h]
auxi/modelling/process/materials/thermo.py
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
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", "sum", "of", "amount", "flow", "rates", "of", "all", "the", "compounds", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1666-L1676
[ "def", "afr", "(", "self", ")", ":", "result", "=", "0.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "result", "+=", "self", ".", "get_compound_afr", "(", "compound", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_element_mfrs
Determine the mass flow rates of elements in the stream. :returns: Array of element mass flow rates. [kg/h]
auxi/modelling/process/materials/thermo.py
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)) for compound in self.material.compounds: result += self.get_compound_mfr(compound) *\ stoich.element_mass_fractions(compound, elements) return result
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)) for compound in self.material.compounds: result += self.get_compound_mfr(compound) *\ stoich.element_mass_fractions(compound, elements) return result
[ "Determine", "the", "mass", "flow", "rates", "of", "elements", "in", "the", "stream", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1678-L1691
[ "def", "get_element_mfrs", "(", "self", ",", "elements", "=", "None", ")", ":", "if", "elements", "is", "None", ":", "elements", "=", "self", ".", "material", ".", "elements", "result", "=", "numpy", ".", "zeros", "(", "len", "(", "elements", ")", ")", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "result", "+=", "self", ".", "get_compound_mfr", "(", "compound", ")", "*", "stoich", ".", "element_mass_fractions", "(", "compound", ",", "elements", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_element_mfr_dictionary
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]
auxi/modelling/process/materials/thermo.py
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_element_mfrs() result = dict() for s, mfr in zip(element_symbols, element_mfrs): result[s] = mfr return result
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_element_mfrs() result = dict() for s, mfr in zip(element_symbols, element_mfrs): result[s] = mfr return result
[ "Determine", "the", "mass", "flow", "rates", "of", "elements", "in", "the", "stream", "and", "return", "as", "a", "dictionary", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1693-L1706
[ "def", "get_element_mfr_dictionary", "(", "self", ")", ":", "element_symbols", "=", "self", ".", "material", ".", "elements", "element_mfrs", "=", "self", ".", "get_element_mfrs", "(", ")", "result", "=", "dict", "(", ")", "for", "s", ",", "mfr", "in", "zip", "(", "element_symbols", ",", "element_mfrs", ")", ":", "result", "[", "s", "]", "=", "mfr", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.get_element_mfr
Determine the mass flow rate of the specified elements in the stream. :returns: Mass flow rates. [kg/h]
auxi/modelling/process/materials/thermo.py
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 += self.get_compound_mfr(compound) *\ stoich.element_mass_fraction(formula, element) return result
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 += self.get_compound_mfr(compound) *\ stoich.element_mass_fraction(formula, element) return result
[ "Determine", "the", "mass", "flow", "rate", "of", "the", "specified", "elements", "in", "the", "stream", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1708-L1720
[ "def", "get_element_mfr", "(", "self", ",", "element", ")", ":", "result", "=", "0.0", "for", "compound", "in", "self", ".", "material", ".", "compounds", ":", "formula", "=", "compound", ".", "split", "(", "'['", ")", "[", "0", "]", "result", "+=", "self", ".", "get_compound_mfr", "(", "compound", ")", "*", "stoich", ".", "element_mass_fraction", "(", "formula", ",", "element", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
MaterialStream.extract
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 by other and the extracted stream is returned as a new stream. * tuple (compound, mass): The other tuple specifies the mass flow rate of a compound to be extracted. It is extracted from self and the extracted mass flow rate is returned as a new stream. * string: The 'other' string specifies the compound to be extracted. All of the mass flow rate of that compound will be removed from self and a new stream created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialStream object.
auxi/modelling/process/materials/thermo.py
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 by other and the extracted stream is returned as a new stream. * tuple (compound, mass): The other tuple specifies the mass flow rate of a compound to be extracted. It is extracted from self and the extracted mass flow rate is returned as a new stream. * string: The 'other' string specifies the compound to be extracted. All of the mass flow rate of that compound will be removed from self and a new stream created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialStream object. """ # Extract the specified mass flow rate. if type(other) is float or \ type(other) is numpy.float64 or \ type(other) is numpy.float32: return self._extract_mfr(other) # Extract the specified mass flow rateof the specified compound. elif self._is_compound_mfr_tuple(other): return self._extract_compound_mfr(other[0], other[1]) # Extract all of the specified compound. elif type(other) is str: return self._extract_compound(other) # TODO: Test # Extract all of the compounds of the specified material. elif type(other) is Material: return self._extract_material(other) # If not one of the above, it must be an invalid argument. else: raise TypeError("Invalid extraction argument.")
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 by other and the extracted stream is returned as a new stream. * tuple (compound, mass): The other tuple specifies the mass flow rate of a compound to be extracted. It is extracted from self and the extracted mass flow rate is returned as a new stream. * string: The 'other' string specifies the compound to be extracted. All of the mass flow rate of that compound will be removed from self and a new stream created with it. * Material: The 'other' material specifies the list of compounds to extract. :returns: New MaterialStream object. """ # Extract the specified mass flow rate. if type(other) is float or \ type(other) is numpy.float64 or \ type(other) is numpy.float32: return self._extract_mfr(other) # Extract the specified mass flow rateof the specified compound. elif self._is_compound_mfr_tuple(other): return self._extract_compound_mfr(other[0], other[1]) # Extract all of the specified compound. elif type(other) is str: return self._extract_compound(other) # TODO: Test # Extract all of the compounds of the specified material. elif type(other) is Material: return self._extract_material(other) # If not one of the above, it must be an invalid argument. else: raise TypeError("Invalid extraction argument.")
[ "Extract", "other", "from", "this", "stream", "modifying", "this", "stream", "and", "returning", "the", "extracted", "material", "as", "a", "new", "stream", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/modelling/process/materials/thermo.py#L1722-L1766
[ "def", "extract", "(", "self", ",", "other", ")", ":", "# Extract the specified mass flow rate.", "if", "type", "(", "other", ")", "is", "float", "or", "type", "(", "other", ")", "is", "numpy", ".", "float64", "or", "type", "(", "other", ")", "is", "numpy", ".", "float32", ":", "return", "self", ".", "_extract_mfr", "(", "other", ")", "# Extract the specified mass flow rateof the specified compound.", "elif", "self", ".", "_is_compound_mfr_tuple", "(", "other", ")", ":", "return", "self", ".", "_extract_compound_mfr", "(", "other", "[", "0", "]", ",", "other", "[", "1", "]", ")", "# Extract all of the specified compound.", "elif", "type", "(", "other", ")", "is", "str", ":", "return", "self", ".", "_extract_compound", "(", "other", ")", "# TODO: Test", "# Extract all of the compounds of the specified material.", "elif", "type", "(", "other", ")", "is", "Material", ":", "return", "self", ".", "_extract_material", "(", "other", ")", "# If not one of the above, it must be an invalid argument.", "else", ":", "raise", "TypeError", "(", "\"Invalid extraction argument.\"", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Gr
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 thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float .. math:: \\mathrm{Gr} = \\frac{g \\beta (Ts - Tinf ) L^3}{\\nu ^2} Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter
auxi/tools/transportphenomena/dimensionlessquantities.py
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 thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float .. math:: \\mathrm{Gr} = \\frac{g \\beta (Ts - Tinf ) L^3}{\\nu ^2} Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter """ return g * beta * (Ts - Tf) * L**3.0 / nu**2.0
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 thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float .. math:: \\mathrm{Gr} = \\frac{g \\beta (Ts - Tinf ) L^3}{\\nu ^2} Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter """ return g * beta * (Ts - Tf) * L**3.0 / nu**2.0
[ "Calculate", "the", "Grashof", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/dimensionlessquantities.py#L29-L50
[ "def", "Gr", "(", "L", ":", "float", ",", "Ts", ":", "float", ",", "Tf", ":", "float", ",", "beta", ":", "float", ",", "nu", ":", "float", ",", "g", ":", "float", ")", ":", "return", "g", "*", "beta", "*", "(", "Ts", "-", "Tf", ")", "*", "L", "**", "3.0", "/", "nu", "**", "2.0" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Re
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
auxi/tools/transportphenomena/dimensionlessquantities.py
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
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", "Reynolds", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/dimensionlessquantities.py#L66-L77
[ "def", "Re", "(", "L", ":", "float", ",", "v", ":", "float", ",", "nu", ":", "float", ")", "->", "float", ":", "return", "v", "*", "L", "/", "nu" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Ra
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/s] fluid thermal diffusivity. :param beta: [1/K] fluid coefficient of thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float Ra = Gr*Pr Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter
auxi/tools/transportphenomena/dimensionlessquantities.py
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/s] fluid thermal diffusivity. :param beta: [1/K] fluid coefficient of thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float Ra = Gr*Pr Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter """ return g * beta * (Ts - Tinf) * L**3.0 / (nu * alpha)
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/s] fluid thermal diffusivity. :param beta: [1/K] fluid coefficient of thermal expansion. :param nu: [m2/s] fluid kinematic viscosity. :returns: float Ra = Gr*Pr Characteristic dimensions: * vertical plate: vertical length * pipe: diameter * bluff body: diameter """ return g * beta * (Ts - Tinf) * L**3.0 / (nu * alpha)
[ "Calculate", "the", "Ralleigh", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/dimensionlessquantities.py#L80-L102
[ "def", "Ra", "(", "L", ":", "float", ",", "Ts", ":", "float", ",", "Tf", ":", "float", ",", "alpha", ":", "float", ",", "beta", ":", "float", ",", "nu", ":", "float", ")", "->", "float", ":", "return", "g", "*", "beta", "*", "(", "Ts", "-", "Tinf", ")", "*", "L", "**", "3.0", "/", "(", "nu", "*", "alpha", ")" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Nu
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
auxi/tools/transportphenomena/dimensionlessquantities.py
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
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", "Nusselt", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/dimensionlessquantities.py#L105-L116
[ "def", "Nu", "(", "L", ":", "float", ",", "h", ":", "float", ",", "k", ":", "float", ")", "->", "float", ":", "return", "h", "*", "L", "/", "k" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
Sh
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
auxi/tools/transportphenomena/dimensionlessquantities.py
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
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
[ "Calculate", "the", "Sherwood", "number", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/transportphenomena/dimensionlessquantities.py#L119-L130
[ "def", "Sh", "(", "L", ":", "float", ",", "h", ":", "float", ",", "D", ":", "float", ")", "->", "float", ":", "return", "h", "*", "L", "/", "D" ]
2dcdae74154f136f8ca58289fe5b20772f215046
valid
PolynomialModelT.create
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' :param degree: the polynomial degree to use :returns: a new PolynomialModelT object
auxi/tools/materialphysicalproperties/polynomial.py
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' :param degree: the polynomial degree to use :returns: a new PolynomialModelT object """ x_vals = dataset.data['T'].tolist() y_vals = dataset.data[symbol].tolist() coeffs = np.polyfit(x_vals, y_vals, degree) result = PolynomialModelT(dataset.material, dataset.names_dict[symbol], symbol, dataset.display_symbols_dict[symbol], dataset.units_dict[symbol], None, [dataset.name], coeffs) result.state_schema['T']['min'] = float(min(x_vals)) result.state_schema['T']['max'] = float(max(x_vals)) return result
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' :param degree: the polynomial degree to use :returns: a new PolynomialModelT object """ x_vals = dataset.data['T'].tolist() y_vals = dataset.data[symbol].tolist() coeffs = np.polyfit(x_vals, y_vals, degree) result = PolynomialModelT(dataset.material, dataset.names_dict[symbol], symbol, dataset.display_symbols_dict[symbol], dataset.units_dict[symbol], None, [dataset.name], coeffs) result.state_schema['T']['min'] = float(min(x_vals)) result.state_schema['T']['max'] = float(max(x_vals)) return result
[ "Create", "a", "model", "object", "from", "the", "data", "set", "for", "the", "property", "specified", "by", "the", "supplied", "symbol", "using", "the", "specified", "polynomial", "degree", "." ]
Ex-Mente/auxi.0
python
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/materialphysicalproperties/polynomial.py#L45-L70
[ "def", "create", "(", "dataset", ",", "symbol", ",", "degree", ")", ":", "x_vals", "=", "dataset", ".", "data", "[", "'T'", "]", ".", "tolist", "(", ")", "y_vals", "=", "dataset", ".", "data", "[", "symbol", "]", ".", "tolist", "(", ")", "coeffs", "=", "np", ".", "polyfit", "(", "x_vals", ",", "y_vals", ",", "degree", ")", "result", "=", "PolynomialModelT", "(", "dataset", ".", "material", ",", "dataset", ".", "names_dict", "[", "symbol", "]", ",", "symbol", ",", "dataset", ".", "display_symbols_dict", "[", "symbol", "]", ",", "dataset", ".", "units_dict", "[", "symbol", "]", ",", "None", ",", "[", "dataset", ".", "name", "]", ",", "coeffs", ")", "result", ".", "state_schema", "[", "'T'", "]", "[", "'min'", "]", "=", "float", "(", "min", "(", "x_vals", ")", ")", "result", ".", "state_schema", "[", "'T'", "]", "[", "'max'", "]", "=", "float", "(", "max", "(", "x_vals", ")", ")", "return", "result" ]
2dcdae74154f136f8ca58289fe5b20772f215046