kill(all)$

Maxima : Example 2:ph for mixing(10 cm^3 0.04M,H2SO4,10 cm^3 0.115M,NaOH)
peter.vlasschaert @gmail.com, 24/01/2019

load packages
============

load(lrats)$

Theory
======

use :  vt  rule :
============
------------------------------------------
definition : v1*t1/ a = v2*t2/b  
------------------------------------------
volume             : v1,v2
concentration : t1,t2    ( units : M )
-----------------------------------------

predicate :
=========

===========================================================
a,b : number(= integer >0) exchange :OH from a base or H from a acid
general :  a ≠ b
===========================================================

simple : system (NaOH,HCl)  = (a=1,b=1)
---------------------------------------------------------------------------------------------------------

t1,t2        : Molarity            : Example      0.04M   H2SO4
t1/a,t2/b :  Normality        : Example      0.02N  (= 0.04M/g1 =0.04M/2 ) H2SO4
--------------------------------------------------------------------------------------------------------------
acid   : H2SO4 ⇒   g1 H(+)  +  SO4(2-)    => integer = g1 = 2
base :  NaOH   ⇒  g2 OH(-) +  Na(+)       => integer = g2  = 1
-------------------------------------------------------------------------------------------------------------

volume              : 1cm^3 = 1ml    {v1,v2}
concentration  :  Molarity or Normality 

definition :  1M,  chemical substance 'NaCl'
----------------------
MW NaCl (g) = Molecular Weigth = Atomic mass Na (g) + Atomic mass Cl (g)
----------------------------------------------------------------------------------------------------------------
g = gram
 =>     1M  =  MW NaCl/l  ( meaning = 1 mol NaCl solved  1 l (aq) )  ' called solution '

result : vt rule
============

symbole :  v*t  = cm^3 *M  = ml*M= mmol

problem : ph for mixing (10 cm^3 0.04M,H2SO4,10 cm^3 0.115M,NaOH)
===========================================================
===========================================================

solution problem :
===============

reaction  :  H2SO4 + 2*Na OH ⇒ Na2SO4 + 2H2O    '1'

1e) H2SO4

volume , concentration
===================

p1:v1= 10;                                    /*cm^3 */
p1a:t1= 0.04;                                  /*M*/
p1b: a=2;                                    /*integer*/
p1c:u1=rhs(p1)*rhs(p1a)           /*mmol*/;
p1d : uu1 = rhs(p1c)/lhs(p1b)               /*N*/;

2e) NaOH

volume , concentration
===================

p2:v2= 10;                               /*cm^3 */
p2a:t2= 0.115;                      /*M*/
p2b: b=1;                              /*integer*/
p2c:u2=rhs(p2)*rhs(p2a)    /*mmol*/;
p2d : uu2= rhs(p2c)/lhs(p2b)        /*N*/;

find ecess product:
================
from reaction  '1' by mixing both products

reaction  :  H2SO4 + 2*Na OH ⇒ Na2SO4 + 2H2O    '1'
------------------------------------------------------------------------------
first :H2SO4 : ref
==============

H2SO4 + 2*Na OH ⇒ Na2SO4 + 2H2O  ,'1a'
0.4mmol   0.8mmol
--------------------------------------------------------------
=>               = 2*0.4mmol

reaction  :  H2SO4 + 2*Na OH ⇒ Na2SO4 + 2H2O    '1'
------------------------------------------------------------------------------
second :NaOH : ref
================

H2SO4 + 2*Na OH ⇒ Na2SO4 + 2H2O ,'1b'
0.575 mmol   1.15 mmol
-------------------------------------------------------------
=>                   = 1.15 mmol

reaction '1b'  => excess of  NaOH
==========
result (NaOH excess)  = NaOH, '1b' - NaOH, '1a'   >  0
                                          = 1.15 mmol -0.8 mmol = 0.35 mmol
--------------------------------------------------------------------------------------
rem : > 0 : otherwise no physical meaning

p3:NaOHexcess  = rhs(p2c) - lhs(p1b)*rhs(p1c);  /*mmol*/

see :  reaction   '1a'
================

p3a:lhs(p3) = subst([p1b],rhs(p3));     /*mmol*/  

What is concentration NaOH excess
===============================

total volume
==========

p4:p1+p2;               /*ml*/

concentration NaOHexcess    ( for pH  calculation)
========================

p5:concNaOHexcess = rhs(p3a)/lhs(p4);

p5a:subst([p4],p5);

'-----------------------------------------------------------------------------------------------------------------'

rem :  mmol/ml  = M    units

'-----------------------------------------------------------------------------------------------------------------'

calculation ph
============

Definitions : log10,ph,pOh
======================

p6:log10(xx) := log(xx)/log(10);

p6a: ph(xx) := -log10(xx);
p6b: pOh(xx):= -log10(xx);

rem : pOH + pH = 14  , from K_w  (aq)

first calculation : pOH
==================

p6c:pOh(rhs(p5a)),float,numer;

second calculation  :  pH
================

p6d:pH = 14 - p6c;

'-------------------------------------------------------------------------------------------------------------------------------------------------'