I would like to model the Cahn Hilliard equation with a diffusion coefficient 
that depends on the cell variable (concentration X) and time.
The diffusion coefficient (Diff) is proportional to the second derivative of 
the free energy (d2G), for which I have the values in an external file, for a 
range of concentrations.
Initially I interpolated d2G with a polynomial function and could easily 
express Diff as a function of Xf = X.arithmeticFaceValue

However, I realised that this interpolation was not appropriate in my case. The 
only way I found to obtain a correct interpolation of d2G is to use a B-spline 
interpolation, with scipy.interpolate.UnivariateSpline. The piece of code is as 
follows (d2G_fit is the array of values that I imported from an external file):

X = np.arange(0.011,1.0,0.001)

X_var = CellVariable(name=r"$X_{at}$", mesh=mesh, hasOld=True)

noise = GaussianNoiseVariable(mesh=mesh, mean=X_mean, variance=1.0e-7).value
X_var[:] =  noise
Xf = X_var.arithmeticFaceValue

d2G = UnivariateSpline(X, d2G_fit[id_mean_spino], k=3, s=0)
Diff = d2G(Xf)

My problem is that when I start looping with:

while time < duration:
         res0 = eq.sweep(X_var, dt=dt, solver=solver)

I have the error message:

IndexError: diffusion coefficent tensor is not an appropriate shape for this 

I also tried: 

Diff =  Variable(value=d2G(Xf))
Diff =  d2G(Xf)*Variable(list(d2G(Xf)))

but I have the same error.

Could you tell me how I could work this out? Additional comment: Diff evolves 
with time, I update it at selected timestep in the loop.

Any hint would be greatly appreciated!

Thank you in advance!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

fipy mailing list
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to