On May 2, 2013, at 12:19 PM, Edwin Sze Lun Khoo <[email protected]> wrote:
> The original PDE is dC/dt + alpha*d/dx(1/C) = d^2C/dx^2 where C is the
> dependent variable and alpha is a constant. You suggested that:
>
>
>> You can try running the chain rule on it:
>>
>> \alpha\frac{\partial}{\partial x}\frac{1}{C}
>> = -\frac{\alpha}{C^2}\frac{\
>> partial C}{\partial x}
>>
>> so you get a "normal" convection term with a velocity of -alpha/C**2.
> Assigning the coefficient of the convection term as -alpha/C**2 seems
> incorrect because the coefficient of the convection term should be that of
> whatever multiplies the dependent variable inside the divergence operator;
> -alpha/C**2 here, however, is outside and not inside the d/dx operator.
You're right, of course. I don't see a way to make this term implicit. Wheeler
might know a way.
> Also, I am not very clear on how the rank of a Variable (cellVariable or
> faceVariable) relates to the number of paired square brackets. Could you
> please provide some examples that may elucidate how to properly use the
> square brackets that denote the appropriate rank (including rank 2, since I
> suppose a lot of people may need to use diffusivity tensors)?
It depends whether you are passing a single value, or a different value for
each cell or face.
For single values:
2 is a scalar (rank-0)
[[2]] is a 1D vector (rank-1)
[[2], [3]] is a 2D vector (rank-1)
[[2], [3], [4]] is a 3D vector (rank-1)
[[[2]]] is a 1D tensor (rank-2)
[[[2], [3]],
[[4], [5]]] is a 2D tensor (rank-2)
[[[2], [3], [4]],
[[5], [6], [7]],
[[8], [9], [10]]] is a 3D tensor (rank-2)
For fields of values:
[1, 2, 3, ..., 9999] is a list of scalars (rank-0)
[[1, 2, 3, ..., 9999],
[87, 22, 15, ..., 16]] is a list of 2D vectors (rank-1)
[[[1, 2, 3, ..., 9999],
[87, 22, 15, ..., 16]],
[[2, 4, 6, ..., 3333],
[4532, 13432, 332, ..., 1]]] is a list of 2D tensors (rank-2)
> Lastly, I also provide the actual PDEs
> (https://dl.dropboxusercontent.com/u/972246/FiPy%20PDE.pdf) and Python code
> (http://pastebin.com/JUJzaPtN) that I am using to provide some context to the
> questions I asked. As before, I would love to get some ideas on how to
> express the convection term correctly and run the code faster (the current
> time step is pretty small).
Just a couple of things I see:
The residual is not scaled, so I'm not sure why you reduce your time step just
because res > 1.0. The issue is not the value of the residual, but whether it
is converging.
You provide no mechanism for increasing the timestep. If small steps are
required, they may only be needed in the early stages.
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]