On May 22, 2012, at 4:46 AM, <[email protected]> 
<[email protected]> wrote:

> I'm trying to solve the following system of PDE and Non-Liner Algebraic 
> Equations (NLAE): 
> 
> the PDEs read: 
> \frac{\partial{\phi}}{\partial t} = \nabla ( D(y) \nabla y) 
> where both phi and y are arrays of cellVariable and the number of PDE equals 
> the length of the \phi array 
> 
> and the set of NLAE 
> 
> F(\phi, y)= 0 at every node in the domain 
> where y is the local root of F, i.e. \frac{\partial F}{\partial y} is a 
> square full matrix. 
> This local problem is non-linear and I use SciPy.optimize.fsolve as solver. 
> 
> 
> My problem: 
> 
> I don't know an explict way of writing y = G{\phi} (and its derivatives) as 
> suggested for example 
> here:http://www.ctcms.nist.gov/fipy/examples/phase/generated/examples.phase.simple.html?highlight=expansion%20source
>  

The equations you have posed are fully explicit, so I'm not sure any of that is 
germane.

> Do you have any suggestion for improving the performance of this resolution? 
> and avoiding the use of setValue getValue for this kind of coupled problem? 

It's hard to say, as I'm not sure I accurately understand what you are trying 
to do. If I assume that 

D(y) = y^2
F(\phi, y) = \phi + y

is this a fair representation of your code?


import scipy.optimize

from fipy import *

mesh = Grid1D(nx=10, dx=1.)
x, = mesh.getCellCenters()

phi = CellVariable(mesh=mesh, name=r"$\phi$", value=x, hasOld=True)
y = CellVariable(mesh=mesh, name="y", value=1., hasOld=True)

D = y.getFaceValue()**2

eq = TransientTerm() == (D * y.getFaceGrad()).getDivergence()

viewer = Viewer(vars=(phi, y))

def F(x, *args):
    return phi.getValue() + x
    
for step in range(100):
    phi.updateOld()
    y.updateOld()
    res = 1e100
    while res > 1e-3:
        res = eq.sweep(var=phi, dt=1e-4)
        y.setValue(scipy.optimize.fsolve(func=F, x0=y.getValue()))
    viewer.plot()


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to