On May 23, 2012, at 9:28 AM, Matej Svejda wrote:

> I want for the H(\alpha, t) function to be automatically updated as
> the Variable t changes. But I have a problem: The value of H is
> defined piecewise, meaning that I have a treshold \epsilon. Depending
> on whether \alpha <= \epsilon or the value of H is calculated
> differently. How do I implement this? I tried something like:
> 
> H[0:10] = h1(\alpha, t)
> H[10:] = h2(\alpha, t)
> 
> But in this case H is not being updated... Any ideas?

H = h1(alpha, t) * (alpha < epsilon) + h2(alpha, t) * (alpha >= epsilon)

> Is it possible that sweeps don't change the value of my variable at
> all?

Sure. Many problems don't require sweeping.

> I have the following code:
> 
> phi = CellVariable(name="Probability for angle", mesh=mesh, rank=0, hasOld=1)
> for step in range(steps):
>       phi.updateOld()
>       for sweep in range(sweeps):
>               eq.sweep(var=phi, boundaryConditions=BCs, dt=timeStepDuration)
>               #normalize
>               sum = (phi.getValue() * dAlpha).sum()
>               phi.setValue(phi.getValue() / sum)
>       ....
> 
> With this I get exactly the same result as when I directly use solve.
> Am I doing something wrong? Is the normalization done in the right
> way?

I would use phi.getCellVolumeAverage() * mesh.getNumberOfCells(), but yes your 
normalization seems OK to me.

I think sweeping doesn't change anything because the equation you have given us 
is conservative, so the normalization doesn't do anything. Further, none of 
your coefficients are a function of phi, so there are no nonlinearities that 
require sweeping.



_______________________________________________
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