Dear Jonathan and Daniel,

Thank you for the quick responses. I've solved my problem. In my
method definition:

def setInitial(self):

    self.a.setValue(linspace(1,7,self.nx))
    self.b.setValue(1)

It is very important to call *.updateOld() after *.setValue().
Otherwise, the first sweep of the PDE will change the variable
drastically from the initial value.

As an aside, I really like the new toys in FiPy 3. Especially the
vector equation syntax.

Regards,

Lafras

On 4 December 2012 17:25, Jonathan Guyer <[email protected]> wrote:
>
> On Dec 4, 2012, at 10:08 AM, Daniel Wheeler wrote:
>
>> What I mean is: will all
>> variables be updated as they should be after each iteration of sweep &
>> updateOld?
>>
>> All "var.updateOld()" does is update the var's old value. Each CellVariable 
>> (if "var.hasOld = True") has an "old" attribute, which is itself a 
>> CellVariable. If the CellVariable has ("hasOld = False") then "var.old = 
>> var". Now, the TransientTerm simply uses "(var - var.old) / dt". If there 
>> are no sweeps then an old value is not required as "var" is implicit. 
>> However, if your problem does have sweeps then you require an old value 
>> otherwise "var.old" will be the value from the previous sweep rather than 
>> the previous time step. Thus, if you use sweeps, you need to call 
>> updateOld() on all your CellVariable's between each time step.
>
> While that's true, I'm not sure the updateOld() is particularly germane to 
> Lafras' question. There's nothing special about being in __main__. If FiPy 
> doesn't throw an error when you instantiate the variables, then there's no 
> reason that any Variable expressions won't continue to work as you iterate 
> the problem.
>
>
> _______________________________________________
> 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