Cahn-Hilliard variational formulation where mobility is a function of the unknown field

Hello,

I am trying to implement the Cahn-Hilliard equation using a mixed finite element method based on the demo code provided here: https://fenicsproject.org/olddocs/dolfin/latest/python/demos/cahn-hilliard/demo_cahn-hilliard.py.html. However, my scalar parameter M (mobility) is a function of the unknown field c. Will this change the variational formulation of the equation?

∂c/∂t − ∇⋅M(∇(df/dc−λ∇2c)) = 0 in Ω,
M(∇(df/dc−λ∇2c))⋅n = flux on ∂Ω,
Mλ∇c⋅n = 0 on ∂Ω,
M = M(c) = constant * c * (1-c).

The variational formulation I am using right now is as follows:

# c_max, kB, T, omega, lmbda, D and flux are constants
c = variable(c) # unknown field
f = c_max*kB*T*(c*ln(c)+(1-c)*ln(1-c) + omega*c*(1-c)) 
dfdc = diff(f, c)

theta = 0.5 # Crank-Nicolson scheme
mu_mid = (1.0-theta)*mu0 + theta*mu 
M_mid = (D/(c_max*kB*T))*((1.0-theta)*c0*(1-c0)+theta*c*(1-c))

L0 = c*q*dx - c0*q*dx - dt*dot(grad(M_mid),grad(mu_mid))*q*dx + dt*M_mid*dot(grad(mu_mid), grad(q))*dx + dt*flux*q*ds(1)
L1 = mu*v*dx - dfdc*v*dx - lmbda*dot(grad(c), grad(v))*dx 
L = L0 + L1

Please let me know if this is correct. If not, I would appreciate any help in determining the modified variational formulation.
Thank you.

Please provide a reproducible example.
I would say this should be similar to the non-linear poisson equation: Implementation — FEniCSx tutorial