Thanks Jonathan for your hint, it was very helpfully for me and I don't have
that error message,
But i have some strange plot, the value of phi at left and right are very
huge in contradiction of the initial value of phi. and the plot of p still a
straight line at value 1 and the plot of phi must be between o and 1. but
this is not the case, may you try jonathan to run my code and try to see
what happened.
***********************************************************************************************************************************************************************
from __future__ import division
porisity=1.
rho1=1.
rho2=1.
mu1=1.
mu2=1.
K=1
L=1.
nx=100
dx=L/100
valueLeft=0.
valueRight=1.
timeStepDuration=0.4
from fipy.meshes.grid1D import Grid1D
mesh=Grid1D(dx=dx, nx=nx)
from fipy.variables.cellVariable import CellVariable
phi=CellVariable(name="saturation", mesh=mesh)
p=CellVariable(name="pressure",mesh=mesh)
x=mesh.getCellCenters()[...,0]
phi.setValue(.9, where=x<.5)
phi.setValue(.3, where=x>=.5)
p.setValue(1.)
pcs=0
qin=40*((x>=.1)&(x<=.3))+20*((x>=.7)&(x<=.9))
qout=60*((x>=.4)&(x<=.6))
sin=.8
pin=0
q1s=sin*qin+phi*qout
q2s=(1-sin)*qin+(1-phi)*qout
from fipy.boundaryConditions.fixedValue import FixedValue
BCs=(FixedValue(faces=mesh.getFacesLeft(), value=valueLeft),
     FixedValue(faces=mesh.getFacesRight(), value=valueRight))
if __name__=='__main__':
    import fipy.viewers
    phiviewer=fipy.viewers.make(vars=(phi), limits={'ymin':0.2,
'ymax':1,'datamin':0, 'datamax':1})
    pviewer=fipy.viewers.make(vars=(p), limits={'datamin':0, 'datamax':1})
    phiviewer.plot()
    pviewer.plot()
    raw_input("initial condition. press <return> to proceed...")
from fipy.terms.transientTerm import TransientTerm
from fipy.terms.powerLawConvectionTerm import PowerLawConvectionTerm
from fipy.terms.explicitSourceTerm import _ExplicitSourceTerm
from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
eq1=ImplicitDiffusionTerm(coeff=-1)==_ExplicitSourceTerm(q1s+q2s)
eq2=TransientTerm(coeff=2)==_ExplicitSourceTerm(q1s-q2s)+PowerLawConvectionTerm(coeff=2*p.getFaceGrad())-p.getFaceGrad().getDivergence()
steps=100
for i in range(steps):
    eq1.solve(p, dt=timeStepDuration, boundaryConditions = BCs)
    eq2.solve(phi, dt=timeStepDuration)
    if __name__ =='__main__':
        phiviewer.plot()
        pviewer.plot()
*************************************************************************************************************************************************************************
Regards
2008/8/25 Jonathan Guyer <[EMAIL PROTECTED]>

>
>
> On Aug 25, 2008, at 8:56 AM, franck kalala wrote:
>
>  I beleive that fipy can solve my simple problem. But I spend many time to
>> figure it out , but I can not. I need your suggestions, or maybe can not
>> solve in fipy.
>>
>
>
> Poisson's equation $-\nabla\cdot\nabla p = q1 + q2$ admits an infinite
> number of solutions. You obtain a particular solution by specifying a
> boundary condition. This is not unique to FiPy. If you "ground" p by giving
> it a FixedValue boundary condition, then your code produces stable
> solutions.
>
>
>


-- 
***********************************************
***********************************************
Franck Kalala Mutombo
[EMAIL PROTECTED]
African Institut for Mathematical Sciences, Muizenberg Cape Town, South
Africa
[EMAIL PROTECTED]
************************************************
************************************************

Reply via email to