<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function

"""
Example of a 4 dimensional root finidng problem (chemical
acid/base equilbria)
"""

from sympy import pprint

from symneqsys import SimpleNEQSys, Problem
from symneqsys.minpack import MINPACK_Solver

from pycompilation.helpers import term_fmt


class ChemSys(SimpleNEQSys):
    var_tokens = 'NH3 NH4p Hp OHm H2O'
    param_tokens = 'Kw Ka ' + ' '.join(['init_'+x for x \
                                        in var_tokens.split()])
    @property
    def exprs(self):
        NH3, NH4p, Hp, OHm, H2O, Kw, Ka = [
            self[token] for token \
            in ('NH3', 'NH4p', 'Hp', 'OHm', 'H2O', 'Kw', 'Ka')]
        init = {x: self['init_'+x] for x in self.var_tokens.split()}
        return [
            Hp*NH3/NH4p-Ka, # NH4+ acid equil
            Hp*OHm/H2O-Kw, # Water autoprotolysis equilibrium
            NH3+NH4p-init['NH3']-init['NH4p'], # preserv. of N atoms<commit_msg>Change in pycomilation upstream.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function

"""
Example of a 4 dimensional root finidng problem (chemical
acid/base equilbria)
"""

from sympy import pprint

from symneqsys import SimpleNEQSys, Problem
from symneqsys.minpack import MINPACK_Solver

from pycompilation.util import term_fmt


class ChemSys(SimpleNEQSys):
    var_tokens = 'NH3 NH4p Hp OHm H2O'
    param_tokens = 'Kw Ka ' + ' '.join(['init_'+x for x \
                                        in var_tokens.split()])
    @property
    def exprs(self):
        NH3, NH4p, Hp, OHm, H2O, Kw, Ka = [
            self[token] for token \
            in ('NH3', 'NH4p', 'Hp', 'OHm', 'H2O', 'Kw', 'Ka')]
        init = {x: self['init_'+x] for x in self.var_tokens.split()}
        return [
            Hp*NH3/NH4p-Ka, # NH4+ acid equil
            Hp*OHm/H2O-Kw, # Water autoprotolysis equilibrium
            NH3+NH4p-init['NH3']-init['NH4p'], # preserv. of N atoms
{'fraction_non_alphanumeric': 0.13006923837784373, 'fraction_numerical': 0.018793273986152326, 'mean_word_length': 2.5305410122164047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5287413', 'n_tokens_mistral': 761, 'n_tokens_neox': 710, 'n_words': 192}