Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
solve for (C_co2_o, C_h2s_o, C_h, C_hco3, C_co3, C_h2s_w), m_co2 = V_g * P_co2 + V_o * C_co2_o + V_w * (C_co2_w + C_hco3 + C_co3), m_h2s = V_g * P_h2s + V_o * C_h2s_o + V_w * (C_h2s_w + C_hs), alk_tot = C_hco3 + 2 * C_co3 + C_hs + C_oh - C_h, K1 = C_h * C_hco3 / C_co2_w, K2 = C_h * C_co3 / C_hco3, K_h2s = C_hs * C_h / C_h2s_w
@tadeu
tadeu / pH.py
Last active December 18, 2015 11:39
pH.py
(C_co2_o, m_co2, V_g, P_co2, V_o, V_w, C_co2_w, C_hco3, C_co3, m_h2s, P_h2s, C_h2s_o, C_h2s_w, C_hs, alk_tot, C_oh, C_h, K1, K2, K_h2s) = symbols(
'C_co2_o m_co2 V_g P_co2 V_o V_w C_co2_w C_hco3 C_co3 m_h2s P_h2s C_h2s_o C_h2s_w C_hs alk_tot C_oh C_h K1 K2 K_h2s')
eq_co2_mass = ( m_co2 - V_g * P_co2 + V_o * C_co2_o + V_w * (C_co2_w + C_hco3 + C_co3) )
eq_h2s_mass = ( m_h2s - V_g * P_h2s + V_o * C_h2s_o + V_w * (C_h2s_w + C_hs) )
eq_alk = ( alk_tot - C_hco3 + 2 * C_co3 + C_hs + C_oh - C_h )
eq_h2co3_1st = (K1 - C_h * C_hco3 / C_co2_w)
eq_h2co3_2nd = (K2 - C_h * C_co3 / C_hco3)
eq_h2s_dissoc = (K_h2s - C_hs * C_h / C_h2s_w)
@tadeu
tadeu / download-python-sources.bat
Last active February 22, 2018 07:34
download-python-sources.bat
@echo off
mkdir D:\Workspaces
subst W: D:\Workspaces
cdd W:\
mkdir dist__12.0-win32-builddist
cdd W:\dist__12.0-win32-builddist
:: aa dist.build python --no-build --no-package
def ExecuteCommandReturningStatusStdoutAndStderr(cmd, input=None, cwd=None, env=None):
from subprocess import Popen, PIPE
pipe = Popen(cmd, shell=False, cwd=cwd, env=env, stdout=PIPE, stderr=PIPE)
(output, errout) = pipe.communicate(input=input)
status = pipe.returncode
return (status, output, errout)