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
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to