elvissoares / PyCahnHilliard

A python script to solve the Cahn-Hilliard equation using an implicit pseudospectral method
GNU General Public License v3.0
35 stars 12 forks source link

Update in time? #1

Closed odannis closed 2 years ago

odannis commented 2 years ago

Hi,

I don't understand the formula that you use to update the concentration field c (https://github.com/elvissoares/PyCahnHilliard/blob/master/cahnhilliard.py#L76) :

c_hat[:] = (c_hat-dt*K2*M*dfdc_hat)/(1+dt*M*kappa*K2**2) # updating in time

In my mind, it should be :

c_hat[:]  = c_hat - dt*K2*dfdc_hat + dfdc_hat*dt*kappa*K2**2

Anyway, thank you for your work :1st_place_medal:

elvissoares commented 2 years ago

Hi, Thanks for your comment.

In fact, your suggestion to time steeping is an explicit Euler time integrator. However, I used an *implicit* Euler time integrator to update the diffusive term in time. An implicit Euler is a more precise time stepper to lead with diffusion equations, even for the spectral method. The time step value in an implicit Euler can be bigger than in the explicit Euler.

Let we start with the Fourier transform of the dynamical equation. This is obtained as

[image: image.png]

to update in time using an implicit Euler, we get

[image: image.png]

and with a little algebra, we get there

[image: image.png]

I hope this discussion will be useful to you.

Best,

Elvis do A. SoaresPos-Doc Researcher ATOMS: Applied Thermodynamics and Molecular SimulationUniversidade Federal do Rio de Janeiro, Rio de Janeiro, RJ - 21941-909 - Brazilhomepage: elvissoares.come-mail: @.***: +55 21 99575-2186

Em qua., 23 de mar. de 2022 às 12:19, Andonis @.***> escreveu:

Hi,

I don't understand the formula that you use to update the concentration field c ( https://github.com/elvissoares/PyCahnHilliard/blob/master/cahnhilliard.py#L76) :

c_hat[:] = (c_hat-dtK2Mdfdc_hat)/(1+dtMkappaK2**2) # updating in time

In my mind, it should be :

c_hat[:] = c_hat - dtK2dfdc_hat + dfdc_hatdtkappa*K2**2

Anyway, thank you for your work 🥇

— Reply to this email directly, view it on GitHub https://github.com/elvissoares/PyCahnHilliard/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI7NRNY22A345WL4L57LSX3VBMZABANCNFSM5ROLIIXA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

odannis commented 2 years ago

Hi,

I noticed that you have updated the README file! Perfect!

Have you any idea why the implicit is more precise than the explicit? A related question will be : Why do you evaluate the Laplacian term at c_k^{n+1} instead of c_k^{n}?

Best, Andonis