Thanks a lot for the explanation, it really got  me on track.
To make your example work, I had to add these 2 lines in the time loop:

>>>             for var in y:
                var.stale = 1

other wise it looks like CellVariables do not know they've got some new 
values.
Am I doing someting wrong by using the stale attribute of CellVariables?

Thanks again,
bruno


PS: I attach a file with dummy tests that helped understanding what 
happens.






Jonathan Guyer <[email protected]> 
Envoyé par : <[email protected]>
05/24/2012 03:52 PM
Veuillez répondre à
<[email protected]>


A
FIPY <[email protected]>
cc

Objet
Re: Coupled PDE and Non-Liner Algebraic Equations







On May 23, 2012, at 10:45 PM, I wrote:

> For small values of N\phi and Ny, I think the following would do the 
trick. For larger numbers of variables and equations, I have some ideas, 
but would need to experiment a little.

OK, it looks like you can use memory and store values a bit more 
efficiently by taking advantage of NumPy "views":

----

phi = [CellVariable(mesh=mesh, name=r"$\phi_%d$" % i, hasOld=True) for i 
in range(Nphi)]

y = [CellVariable(mesh=mesh, name=r"$y_%d$" % i, hasOld=True) for i in 
range(Ny)]

ystore = numerix.empty((Ny * Nx,))
for var, arr in zip(y, numerix.split(ystore, Ny)):
    var.value = arr

----

and then in your solve loop, do:

----

        ystore[:] = scipy.optimize.fsolve(func=F, 
                                          x0=ystore, 
                                          args=(phi,))

----

This is for FiPy 2.1. If you are using trunk, then switch to "var._value = 
arr".

You can use views again in your F function like this: 

----


def F(x, *args):
    y = numerix.split(x, Ny)

    ...

----

There are probably ways to vectorize the result of your F function using 
arrays of parameters, as well, but I leave that as an exercise for the 
reader.
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


"This e-mail is confidential and may contain legally privileged information.
If you are not the intended recipient, you should not copy, distribute, 
disclose or use the information it contains.
Please e-mail the sender immediately and delete this message from your system.
E-mails are susceptible to corruption, interception and unauthorised amendment; 
we do not accept liability for any such changes, or for their consequences.
You should be aware, that the company  may monitor your emails and their 
content."

Attachment: test.py
Description: Binary data

_______________________________________________
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