Example #1
0
alpha = 0.015
temperature = 1.

dx = L / nx

from fipy.meshes.grid1D import Grid1D

mesh = Grid1D(dx=dx, nx=nx)

from fipy.variables.cellVariable import CellVariable

phase = CellVariable(name='PhaseField', mesh=mesh, value=1.)

from fipy.variables.modularVariable import ModularVariable

theta = ModularVariable(name='Theta', mesh=mesh, value=1.)
theta.setValue(0., where=mesh.getCellCenters()[..., 0] > L / 2.)

from fipy.terms.implicitSourceTerm import ImplicitSourceTerm

mPhiVar = phase - 0.5 + temperature * phase * (1 - phase)
thetaMag = theta.getOld().getGrad().getMag()
implicitSource = mPhiVar * (phase - (mPhiVar < 0))
implicitSource += (2 * s + epsilon**2 * thetaMag) * thetaMag

from fipy.terms.transientTerm import TransientTerm
from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
phaseEq = TransientTerm(phaseTransientCoeff) == \
          ExplicitDiffusionTerm(alpha**2) \
          - ImplicitSourceTerm(implicitSource) \
          + (mPhiVar > 0) * mPhiVar * phase
Example #2
0
    temperature = 10.

    bench.start()

    from fipy.variables.cellVariable import CellVariable
    phase = CellVariable(
        name = 'PhaseField',
        mesh = mesh,
        value = 0.
        )

    from fipy.variables.modularVariable import ModularVariable
    pi = numerix.pi
    theta = ModularVariable(
        name = 'Theta',
        mesh = mesh,
        value = -pi + 0.0001,
        hasOld = 1
        )

    x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
    for a, b, thetaValue in ((0., 0.,  2. * pi / 3.), 
                             (Lx, 0., -2. * pi / 3.), 
                             (0., Lx, -2. * pi / 3. + 0.3), 
                             (Lx, Lx,  2. * pi / 3.)):
        segment = (x - a)**2 + (y - b)**2 < (Lx / 2.)**2
        phase.setValue(1., where=segment)
        theta.setValue(thetaValue, where=segment)

    bench.stop('variables')

    bench.start()
Example #3
0
    thetaTransientCoeff = 0.01
    gamma = 1e3
    epsilon = 0.008
    s = 0.01
    alpha = 0.015
    temperature = 10.

    bench.start()

    from fipy.variables.cellVariable import CellVariable
    phase = CellVariable(name='PhaseField', mesh=mesh, value=0.)

    from fipy.variables.modularVariable import ModularVariable
    pi = numerix.pi
    theta = ModularVariable(name='Theta',
                            mesh=mesh,
                            value=-pi + 0.0001,
                            hasOld=1)

    x, y = mesh.getCellCenters()[..., 0], mesh.getCellCenters()[..., 1]
    for a, b, thetaValue in ((0., 0., 2. * pi / 3.), (Lx, 0., -2. * pi / 3.),
                             (0., Lx, -2. * pi / 3. + 0.3), (Lx, Lx,
                                                             2. * pi / 3.)):
        segment = (x - a)**2 + (y - b)**2 < (Lx / 2.)**2
        phase.setValue(1., where=segment)
        theta.setValue(thetaValue, where=segment)

    bench.stop('variables')

    bench.start()

    from fipy.terms.transientTerm import TransientTerm
Example #4
0
File: input.py Project: ghorn/Eg
phaseTransientCoeff = 0.1
epsilon = 0.008
s = 0.01
alpha = 0.015
      
dx = L / nx
dy = L / ny

from fipy.meshes.grid2D import Grid2D
mesh = Grid2D(dx, dy, nx, ny)

from fipy.variables.cellVariable import CellVariable
phase = CellVariable(name = 'PhaseField', mesh = mesh, value = 1.)

from fipy.variables.modularVariable import ModularVariable
theta = ModularVariable(name = 'Theta', mesh = mesh, value = 1.)
x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
theta.setValue(0., where=(x - L / 2.)**2 + (y - L / 2.)**2 < (L / 4.)**2)

from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
mPhiVar = phase - 0.5 + temperature * phase * (1 - phase)
thetaMag = theta.getOld().getGrad().getMag()
implicitSource = mPhiVar * (phase - (mPhiVar < 0))
implicitSource += (2 * s + epsilon**2 * thetaMag) * thetaMag

from fipy.terms.transientTerm import TransientTerm
from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
phaseEq = TransientTerm(phaseTransientCoeff) == \
          ExplicitDiffusionTerm(alpha**2) \
          - ImplicitSourceTerm(implicitSource) \
          + (mPhiVar > 0) * mPhiVar * phase
Example #5
0
File: input.py Project: ghorn/Eg
epsilon = 0.008
s = 0.01
alpha = 0.015

dx = L / nx
dy = L / ny

from fipy.meshes.grid2D import Grid2D
mesh = Grid2D(dx, dy, nx, ny)

from fipy.variables.cellVariable import CellVariable
phase = CellVariable(name = 'PhaseField', mesh = mesh, value = 1.)

from fipy.variables.modularVariable import ModularVariable
from fipy.tools import numerix
theta = ModularVariable(name = 'Theta', mesh = mesh, value = 2. * numerix.pi / 3.)
x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
theta.setValue(-2. * numerix.pi / 3., where=(x - L / 2.)**2 + (y - L / 2.)**2 < (L / 4.)**2) 

from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
mPhiVar = phase - 0.5 + temperature * phase * (1 - phase)
thetaMag = theta.getOld().getGrad().getMag()
implicitSource = mPhiVar * (phase - (mPhiVar < 0))
implicitSource += (2 * s + epsilon**2 * thetaMag) * thetaMag

from fipy.terms.transientTerm import TransientTerm
from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
phaseEq = TransientTerm(phaseTransientCoeff) == \
          ExplicitDiffusionTerm(alpha**2) \
          - ImplicitSourceTerm(implicitSource) \
          + (mPhiVar > 0) * mPhiVar * phase
Example #6
0
File: input.py Project: ghorn/Eg
phaseTransientCoeff = 0.1
epsilon = 0.008
s = 0.01
alpha = 0.015
temperature = 1.

dx = L / nx

from fipy.meshes.grid1D import Grid1D
mesh = Grid1D(dx = dx, nx = nx)

from fipy.variables.cellVariable import CellVariable
phase = CellVariable(name = 'PhaseField', mesh = mesh, value = 1.)

from fipy.variables.modularVariable import ModularVariable
theta = ModularVariable(name = 'Theta', mesh = mesh, value = 1.)
theta.setValue(0., where=mesh.getCellCenters()[...,0] > L / 2.)

from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
mPhiVar = phase - 0.5 + temperature * phase * (1 - phase)
thetaMag = theta.getOld().getGrad().getMag()
implicitSource = mPhiVar * (phase - (mPhiVar < 0))
implicitSource += (2 * s + epsilon**2 * thetaMag) * thetaMag

from fipy.terms.transientTerm import TransientTerm
from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
phaseEq = TransientTerm(phaseTransientCoeff) == \
          ExplicitDiffusionTerm(alpha**2) \
          - ImplicitSourceTerm(implicitSource) \
          + (mPhiVar > 0) * mPhiVar * phase