kill(all)$

maxima :partial molar properties (= Mbar(M,x[i])),version 1.0
peter.vlasschaert@gmail.com,13/09/2020

load packages , option.
==================

load(lrats)$ ratprint:falss$

see : website
maxima :partial molar properties,version 1.0 (r10)

find : Mbar[i] = f(M),see :r10
=====================

nc:4$   /* number of components */

r1a:Mbar[i]='diff((M*n),n[i]);/*P,T ,constant */

r1aa:expand(diff(M*n)/del(n[i]));

n =sum(n[i],i,1,nc)

r1aaa:[del(n)/del(n[i])=1,del(M)/del(n[i])='diff(M,n[i])];
r1a4:lratsubst(r1aaa,r1aa);

r1b:lhs(r1a)=r1a4;

a) M=M(x[1],x[2],x[3],x[4])
====================

r2:[x[1],x[2],x[3],x[4]];

depends(M,r2);

r2a:del(M)=diff(M);

r2b:del(M)='sum('diff(M,x[i]),i,1,nc);

b) mole fraction:x[k]
===============

r3:n = sum(n[i],i,1,nc);

def: molefraction

r3a: x[k] = n[k]/n;

r3a1:reverse(r3a);

r3b:solve(r3a,n[k])[1];

r3b1:reverse(r3b);

r3a1:del(lhs(r3a))=ev(del(rhs(r3a)),nouns);

c) ('diff(M),n[i])
===========

r4:part(part(rhs(r1b),1),1);

use :chain rule ,for differentation

r4a:'sum('diff(M,x[k])*'diff(x[k],n[i]),k,1,nc);

r4a1:args(r4a);

r4a2:part(r4a1[1],2);

r4b:r4=r4a;

d)  use r4a2 & r3a
--------------------------

r5a:r4a2=lratsubst([r3a],r4a2);

use :r3a1

r5a1:1/del(n[i])*r3a1,expand;

use :r3b

r5a2:subst([r3b],r5a1),factorsum;

m1:use: n =sum(n[i],i,1,nc),rule1

r5a3:del(n)/del(n[i])= 1;

m2:use del(x[k])/del(n[i])

r5a4:del(x[k])/del(n[i])='diff(x[k],n[i]);

m3:use del(n[k])/(n*del(n[i]))

r5a5:del(n[k])/(del(n[i]))='diff(n[k],n[i]);

use : r5a1

r5a6:lratsubst([r5a3,r5a4,r5a5],r5a1),expand;

use :r3a

r5a7:lratsubst([reverse(r3a)],r5a6),expand;

r5a8:subst([r3b1],r5a7),factorsum;

e) insert r5a8 into r4b
------------------------------

r6a1:lratsubst([r5a8],r4b);

declare(sum,linear)$/*divide sum : terms */

r6a2:expand(r6a1);

rule:('diff(n[k],n[i]))  = 1 ( k=i),first term.

r6a2a:part(rhs(r6a2),1);

r6a2a1:args(args(r6a2a)[1])[1]/n;

r6a2a2:subst([k=i],r6a2a1);

no rule :second term

r6b:part(rhs(r6a2),2);

combination
-------------------

r7:lhs(r6a2)=(r6a2a2+r6b);

final :result
========
use:r1b, 4 & k=1 => sum;see 'r7'

r7a:lhs(r1b) =ratexpand(n*rhs(r7))+part(rhs(r1b),2);