kill(all)$

Electrochemistry (part 1b : Thermodynamics  dG 'Gibbs free energy')
peter.vlasschaert@gmail.com, 24/02/2019

rem :Electrochemistry (part 1a : Thermodynamics  dG 'Gibbs free energy')

load ' packages'
=============
load(lrats)  : used for simplification.

load(lrats)$

what about :Gibbs free energy ( = non ideal)
===================================

ideal gas ( = perfect gas ).
------------------------------------
see :  part 1a : 'p18b','p18c'

p1a: G=R*log(P)*T+G0;
p1b: Gk=log(P)*T*kb+G0k;

legend:
======
-----------------------------------------------------
R  : gas-constant.
kb : boltzmann constant
T   : absolute temperature
P   : pressure
G  : Gibbs free energy  (G,G0,Gk,G0k)
Na : Avogadro constant 
------------------------------------------------------
relation : 
=>  R = Na*kb ( moles of substance )
------------------------------------------------------

non-ideal 
-------------

p2: G = Gid +Gnid;

legend
======
----------------------------------------------------
Gid   :  Gibbs free energy (i)deal
Gnid :  Gibbs free energ  (n)on (id)eal
----------------------------------------------------
rem 
Gnid  =  real solution or result ionic interaction
Gid    =  'see  : p1a,p1b '

real solution :  P ( = pressure)  =>  c (= concentration)

see from : part1a 
==============

ideal:  Gibbs free energy  ( non interaction)
-----------------------------------
rem : part1a : 'p15c'

p3a:del(G)=V*del(P)-S*del(T);

non ideal : Gibbs free energy  ( interaction )
--------------
interaction : chemical reaction or ionic interaction.

p3b: del(G)=V*del(P)-S*del(T) +sum(μ[i]*del(n[i]),i,1,n);

legend:
======
------------------------------------------------------------
S  : entropy
μ_i   : chemical potential of i
T   : absolute temperature
P   : pressure
G  : Gibbs free energy 
n_i : number of particles of the mass ( = m_i)
V    : volume
--------------------------------------------------------------

How to get definition ( = chemical potential 'μ_i ')
======================================

G  function :  ' G(T,P,n_i) '  =>  G = G(T,P,n_i)

depends(G,[T,P,n[i]]);

1e) step : total differential 'p3b'
--------------------------------------------

;p4:'diff(G) = diff(G);

2e) realation between 'p4' and 'p3b'
--------------------------------------------------

p4a:rhs(p4) = rhs(p3b);

3e) How coef : 'del(n[i]),del(T),del(P)'
-----------------------------------------------------

p5a: coeff(p4a,del(n[i]));
p5b: coeff(p4a,del(T));
p5c: coeff(p4a,del(P));

maxima : coeff  'wrong result ' for  'p5a'
same : result  as part1a 

4e)  How to find coef : 'del(n[i])'
---------------------------------------------

p6:part(lhs(p4a),1) = part(rhs(p4a),3);

p6a:lhs(p6) = part(rhs(p6),1);

Definition : Chemical potentail μ_i
===========================
===========================

p6b1:p6a/del(n[i]);

p6b1:coeff(p6a,del(n[i]));

we have found definition : chemical potential (μ_i)
=======================================
What are constraint  ' use p3b,from above'

1e) constraint (T,P)
---------------------------

Temperature = constant 
Pressure        = constant

p7:[del(T) = 0 , del(P) = 0];

2e) use '1e' on the equation 'p3b'
-----------------------------------------------

p7a:subst(p7,p3b);

when : T,P,n_j  are constant  ( j ≠ i)

ΔG = sum(μ_i*Δn_i,i,1,n)

we want to find something about : del(μ[i])
=================================
rem : general  f1 = n_i ,f2 = μ_i

why this tour around otherwise we must kill dependecies G ?
--------------------------------------------------------------------------------------

p8:[ff=G,f1=n[i],f2=μ[i]];

1e)  only write a product
----------------------------------

p8a: ff =f1*f2;

2e) diff , ff
---------------

p8b1:diff(p8a);

p8b2:subst(p8,p8b1);

from :einstein convention , rhs is  a sum ( = two sums)
T ,P, n_j, must be constant

3e) How to bring sum symbol , ' p8b2 '
-----------------------------------------------------

p8c1:lhs(p8b2) = sum(rhs(p8b2),i,1,n);

two sums :
---------------

p8c2a:sum(part(rhs(p8b2),1),i,1,n);
p8c2b:sum(part(rhs(p8b2),2),i,1,n);;

p8c3:lhs(p8c1) = p8c2a + p8c2b;

what about sumcontract : Maxima
-----------------------------------------------

p8c4:sumcontract(p8c3);

rem : see also
see website :Sum (appendix 1,2),version 1.0

How to find :  Gibbs - Duhem equation.
==============================
use : 'p7a' and 'p8c3'

p9:rhs(p7a) = rhs(p8c3);

Definition : Gibbs - Duhem equation
============================
============================

p9a:p9 - rhs(p7a);

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