Message Boards Message Boards

Numerical solution of multicomponent difussion in mineral

Attachments:
7 Replies
Posted 4 years ago

Can you add comment lines between each line? Because just like this, it is hard to understand your code

POSTED BY: Alan SAILLET

I tried to clarify my code and I added comments for lines. Thank you for your response.

When I replaced

 eqnFEM = Table[D[Xcomp[t, x][[i]], t] + Inactive[Div][Sum[((-D[[i,j]]*IdentityMatrix[1]).Inactive[Grad][Xcomp[[j]],{x}],{j,1,3}],{x}]==0, {i, 1, 3}];
bound1FEM = 
  Table[DirichletCondition[Xcomp[t, x][[i]] == list[[i]], 
    x == xbegin], {i, 1, 3}];
bound2FEM = 
  Table[DirichletCondition[Xcomp[t, x][[i]] == list[[i + 3]], 
    x == xend], {i, 1, 3}];

by

 eqnFEM = Table[D[Xcomp[t, x][[i]], t] + Sum[D[-D[[i,j]],x]*D[Xcomp[[j]],x],{j,1,3}], {i, 1, 3}]+Sum[-D[[i,j]]*D[Xcomp[[j]],{x,2}],{j,1,3}]=NeumannValue[0,x==xend], {i, 1, 3}];
     bound1FEM = 
       Table[DirichletCondition[Xcomp[t, x][[i]] == list[[i]], 
         x == xbegin], {i, 1, 3}];

I fixed the problem. I happy that it works, but I do not understand yet why it fixed the problem. Guide from Wolfram recommends first form, rather than second.

Posted 4 years ago

My first question (for my personal knowledge): Why do you want to solve it using FEM only?

If you do not specify <<Method -> "FiniteElement">> in NDSolveValue, how can you be sure it is choosing automatically the FEM method? Actually, By specifying <<Method -> "FiniteElement">>, the error is not the same.

As you said, using FEM, you cannot solve 2nd order derivatives. Since <<D[Sum(Dij*D[Xcomp[[j]],x],x]>> is directly a 2nd derivative (you can see that by showing its expression), I think that if you have some results, it has not been obtained using the FEM method

POSTED BY: Alan SAILLET
Posted 4 years ago

Also, in the results you obtain, were can clearly see that there is almost no diffusion over time. Is that what you expected?

POSTED BY: Alan SAILLET

Time for diffusion in example just 300000000 sec or about 10 years. It is extremly small for diffusion in munerals. If you increase time up to 100 000 000 000 sec or 3000 years, you will see the result. In the most geological problem diffusion run during more than 1 million years. In my notebook, I also implemented fitting of initial, boundary parameters and time for getting time of diffusion for my data. It return about 2500 years of diffusion. In more ussual geological problems, I would get millions years of diffusion.

About you first question: I just want to see difference betwen discretization by FEM and TPG. About you second question: If you re-write example as I wrote in previous message and write

z1Function = z1[[2]]
z1Function["ElementMesh"]

you will see that it is not none. There is Mesh, so FEM is used. If you write

{state} = 
 NDSolve`ProcessEquations[{eqnFEM, bound1FEM, bound2FEM, 
   initFEM}, {XMg, XFe, XCa}, {t, 0, 300000000}, {x, xbegin, xend}]

you will see

{NDSolve`StateData["<" 0. ">"]}

so t is considered as temporal variable and, hence, NDSolve automatically choose Method of Lines and FEM as method of discretization. I try to specify NDSolve use purely FEM, but calculation it too long. I think when NDSolve see Dirichlet Condition and initial problem at t=0. It automatically choose Method of Lines and FEM. If you re-write boundary condition without DirchletCondition, you will see that NDSolve automatically choose Method Of Lines and TPG as method of discretization.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract