On Tue, Apr 19, 2016 at 4:10 PM, Phil Battle wrote:
> Hi Daniel
> Thank you for following up-
> I did try your suggestion, ( C is my concentration dependent Cell variable)
>
> Dx=Dpe_x*(a_x+((1.-a_x)/(b_x*C+g_x)))
> Dz=Dpe_z*(a_z+((1.-a_z)/(b_z*C+g_z)))
> diff = Dx.dot([[1,0],[0,0]])+Dz.dot([[0,0],[0,1]])
>
> and program runs and "looks correct" so good to go!!
Great news.
> But before your suggestion I was trying to create the suggested rank 2
> diffusion coefficient a different way and I did not get far before hitting a
> road block- If you have time to answer this specific question it may help
> with understanding the structure of variables in this program
>
> I created a 2x2 Cell Variable on a 2x2 2Dim mesh. I can show that code if
> necessary, but the result for the initialized CellVariable is shown below
>
> print(D.value)
>
> [[[ 0. 2. 4. 6.]
> [ 1. 1. 1. 1.]]
>
> [[ 1. 1. 1. 1.]
> [ 1. 1. 1. 1.]]]
>
>
> Now the part that I am having trouble with. How can I change the 6 to a 0.?
I think you just need to do
D[0, 0, 3] = 6.
However, it isn't always a good practice to access the spatial index
since if the grid changes then the index has a different spatial
location
> The closet I can come is changing all the values at that mesh position to 0.
> that is using
>
> D.setValue(0,where=[[0,0,0,1]])
I'm not sure why the [[0, 0, 0, 1]] does what it does. Numpy does the following:
~~~
In [9]: a = np.arange(16).reshape([2, 2, 4])
In [10]: a
Out[10]:
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7]],
[[ 8, 9, 10, 11],
[12, 13, 14, 15]]])
In [12]: a[[[0, 0, 0, 1]]] = -1
In [13]: print a
[[[-1 -1 -1 -1]
[-1 -1 -1 -1]]
[[-1 -1 -1 -1]
[-1 -1 -1 -1]]]
~~~
If you're trying to do fancy indexing with FiPy, you might want check
with Numpy first so that you can trust the FiPy result.
--
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]