Begin forwarded message:

I am currently working on a problem of "Diffusion under thermal gradient" in a two phase material. I used fipy to solve the PDEs for a single phase alloy in 1D. Now I am trying to extend it to two-phase alloy and 2D. I want to introduce random circular nuclei of the second phase with a Gaussian radius distribution. My system is a square domain in 2D and I need to account for the volume/ area fraction of the nuclei introduced. I would appreciate if you could suggest a way to do this in fipy.


The NumPy library provides a bunch of random number generators. With FiPy, we recommend that you get at it with

   >>> from fipy.tools.numerix import random

(in sufficiently recent versions of FiPy, you can just do 'from fipy import *' if you prefer).

You can then do

   >>> help(random)

to get documentation on the different distributions available. I would use 'normal' for your Gaussian radius distribution and 'uniform' to pick the positions.

Just set the seeds the way we do for the initial conditions, e.g.

   >>> phase.setValue(1, where=(x-x0)**2 + (y-y0)**2 < r**2)

To get the volume (or area) fraction, you can then just say

   >>> phase.getCellVolumeAverage()


If you want to prohibit overlapping nuclei, then that's just a question of bookkeeping. Store your particle centers and radii and check each new set to be sure that it's not too close to the previous ones. There's nothing unique to FiPy or Python in that, though.


Reply via email to