def _parse_SURFACE_SPECIES(self, lines): """ sample : Hfo_sOH + H+ = Hfo_sOH2+ log_k 7.29 # = pKa1,int relevant info: - name Hfo_sOH2+, first term of right member - log_k 7.29 - equation """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: eq = Equation(line) species[str(eq.getMainTerm())] = entry = {EQUATION: eq} line = self._readNextLine(it) logk = line.split()[1] entry[LOGK] = logk line = self._readNextLine(it) return species return ""
def _parse_SURFACE_SPECIES(self, lines): """ sample : Hfo_sOH + H+ = Hfo_sOH2+ log_k 7.29 # = pKa1,int relevant info: - name Hfo_sOH2+, first term of right member - log_k 7.29 - equation """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: eq = Equation(line) species[str(eq.getMainTerm())] = entry = {EQUATION:eq} line = self._readNextLine(it) logk = line.split()[1] entry[LOGK] = logk line = self._readNextLine(it) return species return ""
def _parse_SOLUTION_SPECIES(self, lines): """ format a bit complex, seems to be several variants : anyways the first line of an entry is an equation followed by several other lines, but the only other line that seems of interest for us is the log_k the equation line has to be parsed : the main name of the element is the first member of the right part Return: a list of [Equation, logk] """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) eq = None # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: if line.find(EQUALS) != -1: # new entry try: eq = Equation(line) except Exception, err: warnings.warn( "got exception parsing SOLUTION_SPECIES equation, line is \n" + line + "\n error is " + str(err)) raise elt = str(eq.getMainTerm()) species[elt] = entry = { ELEMENT: elt, FORMULA: elt, EQUATION: eq } elif line.find('log_k') != -1: logk = line.split()[1] entry[LOGK] = self._makeFloat(logk) line = self._readNextLine(it)
def _parse_SOLUTION_SPECIES(self, lines): """ format a bit complex, seems to be several variants : anyways the first line of an entry is an equation followed by several other lines, but the only other line that seems of interest for us is the log_k the equation line has to be parsed : the main name of the element is the first member of the right part Return: a list of [Equation, logk] """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) eq = None # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: if line.find(EQUALS) != -1: # new entry try: eq = Equation(line) except Exception, err: warnings.warn("got exception parsing SOLUTION_SPECIES equation, line is \n" + line + "\n error is " + str(err)) raise elt = str(eq.getMainTerm()) species[elt] = entry = {ELEMENT: elt, FORMULA: elt, EQUATION:eq} elif line.find('log_k') != -1: logk = line.split()[1] entry[LOGK] = self._makeFloat(logk) line = self._readNextLine(it)
def _parse_EXCHANGE_SPECIES(self, lines): """" excerpt from the phreeqc manual: Example Line 0: EXCHANGE_SPECIES Line 1a: X- = X- Line 2a: log_k 0.0 Line 1b: X- + Na+ = NaX Line 2b: log_k 0.0 Line 1c: 2X- + Ca+2 = CaX2 Line 2c: log_k 0.8 Line 1d: Xa- = Xa- Line 2d: log_k 0.0 Line 1e: X- + Na+ = NaX Line 2e: log_k 0.0 Line 1f: 2Xa- + Ca+2 = CaXa2 Line 2f: log_k 2.0 Explanation Line 0: EXCHANGE_SPECIES Keyword for the data block. No other data are input on the keyword line. Line 1: Association reaction Association reaction for exchange species. The defined species must be the first species to the right of the equal sign. The association reaction must precede any identifiers related to the exchange species. Master species have an identity reaction (lines 1a and 1d). Line 2: log_k log K log_k--Identifier for log K at 25oC. Optionally, -log_k, logk, -l[og_k], or -l[ogk]. log K--Log K at 25oC for the reaction. Default 0.0. Unlike log K for aqueous species, the log K for exchange species is implicitly relative to a single exchange species. In the default database file, sodium (NaX) is used as the reference and the reaction X- + Na+ = NaX is given a log K of 0.0 (line 2b). The log K for the exchange reaction for the reaction given in line 2c is then numerically equal to the log K for the reaction 2NaX + Ca+2 = CaX2 + 2Na+. Master species have log K of 0.0 (lines 2a and 2d); reference species have log K of 0.0 (lines 2b and 2e). """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) eq = None # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: if line.find(EQUALS) != -1: # new entry try: eq = Equation(line) except Exception, err: msg = "error parsing EXCHANGE_SPECIES equation, line %s \n error: %s \n" % ( line, str(err)) warnings.warn(msg) raise elt = str(eq.getMainTerm()) species[elt] = entry = { ELEMENT: elt, FORMULA: elt, EQUATION: eq, LOGK: 0.0, ACTIVITY_LAW: [ACTIVITY_LAW_NONE] } elif line.find('og') != -1: logk = line.split()[1] entry[LOGK] = self._makeFloat(logk) line = self._readNextLine(it)
def _parse_EXCHANGE_SPECIES(self, lines): """" excerpt from the phreeqc manual: Example Line 0: EXCHANGE_SPECIES Line 1a: X- = X- Line 2a: log_k 0.0 Line 1b: X- + Na+ = NaX Line 2b: log_k 0.0 Line 1c: 2X- + Ca+2 = CaX2 Line 2c: log_k 0.8 Line 1d: Xa- = Xa- Line 2d: log_k 0.0 Line 1e: X- + Na+ = NaX Line 2e: log_k 0.0 Line 1f: 2Xa- + Ca+2 = CaXa2 Line 2f: log_k 2.0 Explanation Line 0: EXCHANGE_SPECIES Keyword for the data block. No other data are input on the keyword line. Line 1: Association reaction Association reaction for exchange species. The defined species must be the first species to the right of the equal sign. The association reaction must precede any identifiers related to the exchange species. Master species have an identity reaction (lines 1a and 1d). Line 2: log_k log K log_k--Identifier for log K at 25oC. Optionally, -log_k, logk, -l[og_k], or -l[ogk]. log K--Log K at 25oC for the reaction. Default 0.0. Unlike log K for aqueous species, the log K for exchange species is implicitly relative to a single exchange species. In the default database file, sodium (NaX) is used as the reference and the reaction X- + Na+ = NaX is given a log K of 0.0 (line 2b). The log K for the exchange reaction for the reaction given in line 2c is then numerically equal to the log K for the reaction 2NaX + Ca+2 = CaX2 + 2Na+. Master species have log K of 0.0 (lines 2a and 2d); reference species have log K of 0.0 (lines 2b and 2e). """ species = {} it = iter(lines) line = self._skipEmptyLinesAndComments(it) eq = None # parse format1 entry = None while line is not None: if line and line[0] != COMMENT: if line.find(EQUALS) != -1: # new entry try: eq = Equation(line) except Exception, err: msg = "error parsing EXCHANGE_SPECIES equation, line %s \n error: %s \n" %(line, str(err)) warnings.warn( msg ) raise elt = str(eq.getMainTerm()) species[elt] = entry = {ELEMENT: elt, FORMULA:elt, EQUATION:eq , LOGK:0.0, ACTIVITY_LAW:[ACTIVITY_LAW_NONE] } elif line.find('og') != -1: logk = line.split()[1] entry[LOGK] = self._makeFloat(logk) line = self._readNextLine(it)