# have trouble to understand cahn-hilliard demo code

There is a demo code under src/demo/

I have gone through the nonlinear and time-dependent prob parts in the tutorial. But I still have trouble to understand the approach the author did. He seems to split the original eqn into 2 eqns. Does anybody know the original eqn and the derivations?

I also have trouble to understand the following code:

dk, dc = split(du)

class CahnHilliardEqu

def __init__(self, a, L):

self.L = L

self.a = a

def F(self, b, x):

def J(self, A, x):

They haven't been covered in the tutorial. Are there any other documents to learn these?

Any help will be appreciated.

## Question information

- Language:
- English Edit question

- Status:
- Solved

- For:
- DOLFIN Edit question

- Assignee:
- No assignee Edit question

- Solved by:
- Andy R Terrel

- Solved:
- 2010-03-30

- Last query:
- 2010-03-30

- Last reply:
- 2010-03-26

Andy R Terrel (andy-terrel) said : | #1 |

I believe this is the paper describing the methods used in the demo.

http://

The split is done to separate the equations based on the Mixed Space.

This comes from the UFL specification so the manual there could give

you more information. It is written this way so that a and L can be

automatically linearized for the Newton-Raphson method.

The CahnHillardEquation class is a NonlinearProblem. This is the

simple way to use Newton-Raphson method that is coded in dolfin. In

this style you need to specify the application of F and its jacobian

J. The easiest way to do that is to define a form and have UFL/FFC

generate the derivatives for you. The newon solver will reconstruct F

and J as it needs to for the Newton-Raphson method.

I hope that helps.

-- Andy

On Tue, Mar 23, 2010 at 10:53 AM, cutejeff

<email address hidden> wrote:

> New question #105304 on DOLFIN:

> https:/

>

> There is a demo code under src/demo/

> I have gone through the nonlinear and time-dependent prob parts in the tutorial. But I still have trouble to understand the approach the author did. He seems to split the original eqn into 2 eqns. Does anybody know the original eqn and the derivations?

>

> I also have trouble to understand the following code:

> dk, dc = split(du)

>

> class CahnHilliardEqu

> def __init__(self, a, L):

> NonlinearProbl

> self.L = L

> self.a = a

> self.reset_

> def F(self, b, x):

> assemble(self.L, tensor=b)

> def J(self, A, x):

> assemble(self.a, tensor=A, reset_sparsity=

> self.reset_

>

> They haven't been covered in the tutorial. Are there any other documents to learn these?

> Any help will be appreciated.

>

> --

> You received this question notification because you are a member of

> DOLFIN Team, which is an answer contact for DOLFIN.

>

> _______

> Mailing list: https:/

> Post to : <email address hidden>

> Unsubscribe : https:/

> More help : https:/

>

cutejeff (illw84u) said : | #2 |

Thanks Andy R Terrel, that solved my question.