`time` is a Variable as FiPy understands it, but stepFunc() simply returns an 
integer, so eqI is defined with a source that is the integer 0.

I'd try

eqI = fipy.TransientTerm(coeff=1.) == ((time < 0.1) * 0. + (time >= 0.1) * 1.)

> On Feb 1, 2019, at 6:05 AM, Bill Greene <[email protected]> wrote:
> 
> I am trying to solve an equation where the source term is
> a discontinuous function of time. I have followed examples
> where the source term is a simple, continuous function of time
> and these appear to work correctly. 
> 
> The key parts of my code are shown below:
> 
> def stepFunc(t):
>   if(t.value<.1):
>     s = 0
>   else:
>     s=1
>   print('t=', t, 's=', s)
>   return s
>       
> time = fipy.Variable(0., cached=1)
> eqI = fipy.TransientTerm(coeff=1.) == stepFunc(time)
> 
> t = 0
> for step in range(steps):
>   time.setValue(t+dt/2.)
>   eqI.solve(var=u, dt=dt)
>   t += dt 
>       
> The function stepFunc appears to be called only once and the solution
> indicates that s=0 for the entire solution time.
> 
> I thought that the cached option on the Variable object might affect this
> behavior but when I set it to zero, I get an error message that I don't 
> understand.
> 
> Any help will be much appreciated.
> 
> Bill Greene
> 
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


_______________________________________________
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