On Sep 14, 2011, at 5:21 AM, Jean-Philippe Thierry wrote:

> I am jumping into fipy and I really find it easy to use for day-to-day 
> simulations (mainly non-linear diffusion for me).

That's good to hear.

> I am trying to go one step further and apply variable boundary conditions. I 
> thought it would have been straightforward looking at the documentation 
> but... I would like to use my own functions and I can't get it to work. Here 
> is what I have in mind:
> 
> time = Variable()
> bc = FixedValue(faces=faces, value=my_super_function(time))

The problem with this is that, even though time is a Variable, 
my_super_function(time) is just a value. In order for the boundary condition to 
update with time, you must pass something that is a Variable dependent on time.

> for it in iterations:
>     time.setValue(time() + dt)
>     eq.solve...
> 
> The idea behind it is to use recorded data (like relative humidity), put a 
> spline on it (scipy.interpolate.interp1d for example) and use this callable. 
> A workaround will be to update the bc value at each timestep but I was 
> wondering wether there is a "nicer" solution.

I'm not sure it's "nicer", but the solution I would recommend was discussed on 
the list several years ago, toward the end of

  http://article.gmane.org/gmane.comp.python.fipy/932


Specifically

  bc = FixedValue(faces=faces, 
value=time._UnaryOperatorVariable(my_super_function))

should do the trick.



Reply via email to