def __init__(self, coeff):
     """
     .. attention:: This class is deprecated. Use `ExplicitDiffusionTerm` instead.
     """
     import warnings
     warnings.warn("ExplicitDiffusionTerm should be used instead of ExplicitNthOrderDiffusionTerm", DeprecationWarning, stacklevel=2)
     ExplicitDiffusionTerm.__init__(self, coeff = coeff)
Exemple #2
0
    def buildPhaseEquation(phase, theta):

        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

        return TransientTerm(phaseTransientCoeff) == \
                  ExplicitDiffusionTerm(alpha**2) \
                  - ImplicitSourceTerm(implicitSource) \
                  + (mPhiVar > 0) * mPhiVar * phase
Exemple #3
0
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

if __name__ == '__main__':

    import fipy.viewers
    phaseViewer = fipy.viewers.make(vars=phase)
    phaseViewer.plot()
    for step in range(steps):
        phaseEq.solve(phase, dt=timeStepDuration)
        phaseViewer.plot()
    raw_input('finished')
Exemple #4
0
#Laplacian=0

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

from fipy.variables.cellVariable import CellVariable
phi = CellVariable(name="solution variable", mesh=mesh, value=0)

z = CellVariable(name="dummy", mesh=mesh, value=0)

valueLeft = 1
valueRight = 0

from fipy.boundaryConditions.fixedValue import FixedValue
BCs = (FixedValue(faces=mesh.getFacesRight(), value=valueRight),
       FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))

from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm

eqX = ExplicitDiffusionTerm(coeff=1)

from fipy import viewers
viewer = viewers.make(vars=(phi), limits={'datamin': 0., 'datamax': 1.})
viewer.plot()
eqX.solve(var=phi, boundaryConditions=BCs)
viewer.plot()
Exemple #5
0
phi = CellVariable(name="solution variable",
                    mesh=mesh,
                    value=0)

z = CellVariable(name="dummy",
                    mesh=mesh,
                    value=0)

valueLeft = 1
valueRight = 0

from fipy.boundaryConditions.fixedValue import FixedValue
BCs = (FixedValue(faces=mesh.getFacesRight(), value=valueRight),
        FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))


from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm

eqX = ExplicitDiffusionTerm(coeff=1) 


from fipy import viewers
viewer = viewers.make(vars=(phi),
                      limits={'datamin': 0., 'datamax': 1.})
viewer.plot()
eqX.solve(var=phi,
        	boundaryConditions=BCs)
viewer.plot()


Exemple #6
0
mesh = Grid1D(nx=nx, dx=dx)

from fipy.variables.cellVariable import CellVariable
phi = CellVariable(name="solution variable", mesh=mesh, value=0)
D = 1

valueLeft = 1
valueRight = 0

from fipy.boundaryConditions.fixedValue import FixedValue
BCs = (FixedValue(faces=mesh.getFacesRight(), value=valueRight),
       FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))

from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
from fipy.terms.transientTerm import TransientTerm
eqX = TransientTerm() == ExplicitDiffusionTerm(coeff=D)

timeStepDuration = 0.9 * dx**2 / (2 * D)
steps = 100

from fipy import viewers
viewer = viewers.make(vars=(phi), limits={'datamin': 0., 'datamax': 1.})


def hit_continue(Prompt='Hit any key to continue'):
    raw_input(Prompt)


for step in range(steps):
    eqX.solve(var=phi, boundaryConditions=BCs, dt=timeStepDuration)
    viewer.plot()
Exemple #7
0
    phaseY = phase.getFaceGrad().dot((0, 1))
    phaseX = phase.getFaceGrad().dot((1, 0))
    psi = theta + numerix.arctan2(phaseY, phaseX)
    Phi = numerix.tan(N * psi / 2)
    PhiSq = Phi**2
    beta = (1. - PhiSq) / (1. + PhiSq)
    betaPsi = -N * 2 * Phi / (1 + PhiSq)
    A = alpha**2 * c * (1. + c * beta) * betaPsi
    D = alpha**2 * (1. + c * beta)**2
    dxi = phase.getFaceGrad()._take((1, 0), axis=1) * (-1, 1)
    anisotropySource = (A * dxi).getDivergence()
    from fipy.terms.transientTerm import TransientTerm
    from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
    from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
    phaseEq = TransientTerm(tau) == ExplicitDiffusionTerm(D) + \
        ImplicitSourceTerm(mVar * ((mVar < 0) - phase)) + \
        ((mVar > 0.) * mVar * phase + anisotropySource)

    from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
    temperatureEq = TransientTerm() == \
                    ImplicitDiffusionTerm(tempDiffusionCoeff) + \
                    (phase - phase.getOld()) / timeStepDuration

    bench.stop('terms')

    phase.updateOld()
    temperature.updateOld()
    phaseEq.solve(phase, dt=timeStepDuration)
    temperatureEq.solve(temperature, dt=timeStepDuration)
Exemple #8
0
    else:
        return 0


def allOthers(face):

    if ((leftSide(face) or inMiddle(face) or rightSide(face))
            or not (face.getID() in bigMesh.getExteriorFaces())):
        return 0
    else:
        return 1


var = CellVariable(name="concentration", mesh=bigMesh, value=valueLeft)

eqn = TransientTerm() == ExplicitDiffusionTerm()

exteriorFaces = bigMesh.getExteriorFaces()
xFace = exteriorFaces.getCenters()[..., 0]

boundaryConditions = (
    FixedValue(exteriorFaces.where(xFace**2 < 0.000000000000001), valueLeft),
    FixedValue(exteriorFaces.where((xFace - (dx * nx))**2 < 0.000000000000001),
               (valueLeft + valueRight) * 0.5),
    FixedValue(
        exteriorFaces.where((xFace - (2 * dx * nx))**2 < 0.000000000000001),
        valueRight))

answer = numerix.array([
    0.00000000e+00, 8.78906250e-23, 1.54057617e-19, 1.19644866e-16,
    5.39556276e-14, 1.55308505e-11, 2.94461712e-09, 3.63798469e-07,