The derivation below is based on this resource from the people who created the CocoSimulator and this older paper from the same authors.
To write the derivative of the activity coefficient w.r.t to mole fraction, we’ll work from the Gibbs excess energy to find an expression for the activity coefficient in terms of derivatives of Gibbs excess energy.
Q=RTgE=i=1∑nxilnγi
Therefore, the activity coefficient is:
lnγi=∂ni∂(ntQ)∣T,P,nk=i
where nk=i indicates the unconstrained derivative where all components are fixed except i
Using chain rule to expand:
lnγi=Q+nt∂ni∂Q∣T,P,nk=i
We can expand the second term again using chain rule
Cancel out nt and expand the Kronecker delta out of the sum to get our desired expression for the activity coefficient:
lnγi=Q+Qi+k=1∑nxkQk
Now we can easily find the derivative of the activity coefficient w.r.t the mole fraction - this is the version that only constrains one mole fraction but doesn’t enforce them all summing to one:
To get the constrained version, we can observe that an increase in the mole fraction of one component will result in an equal and opposite decrease in the mole fraction of another (given all other mole fractions are fixed except one). This then implies the following equations, starting from the total derivative of the activity coefficient:
d(lnγi(x1,…,xN))=k=1∑N∂xk∂lnγi∣xj=kdxk
Only two mole fractions are actually varying so when we take the partial derivative:
From what I understand you can arbitrarily choose m. This is the component which will be determined by all the others. In the paper, they choose the nth component. From the third page in the PDF: