Thank you for help. I am still trying.

best,
Zebo

2015-09-09 13:03 GMT-05:00 Guyer, Jonathan E. Dr. <[email protected]>:

> Zebo -
>
> A few points to augment Trevor's (correct) answer:
>
> * I think I know what mean when you distinguish between "discretized
> region" and "continuum region", but be aware that FiPy does not solve
> continuum equations. Any FiPy mesh is a discretization in space to enable
> solution by the finite volume method of discretizing PDEs in space and time.
>
> * We provide convenience properties like mesh.x and mesh.y to give the
> illusion of continuous parameterization in space, but mesh.x and mesh.y are
> just discretized arrays of cell center coordinates. As long as you index a
> CellVariable with a boolean mask that is also a CellVariable (e.g. mesh.x >
> 2.5), then everything works fine, but some arbitrary list of x positions
> will not work because it is not aligned with the mesh of the CellVariable.
>
> * All FiPy CellVariable's are internally stored as an array of shape
> (dimension, number_of_cells). For scalar data, it's just a 1D array.
> interp2d returns an array of values so, as Trevor says, it needs to be
> reshaped. You'll want to do some tests on cases where you know the answer
> to make sure you're unravelling the data in the right way.
>
> - Jon
>
> On Sep 9, 2015, at 10:39 AM, Keller, Trevor <[email protected]>
> wrote:
>
> > Hello Zebo,
> >
> > I believe the problem here is that the setValue method requires a
> boolean mask indicating where to set the values. For example, the typical
> usage in 1D might set the value in every point of half the grid equal to
> one:
> > val.setValue(1, where=x>Npoints/2).
> >
> > So, to fix your bug, please add a second argument specifying in which
> mesh points to apply the interpolated data.
> > I've created a more complete example here:
> https://gist.github.com/tkphd/2f8ac66fe2f883fee352
> >
> > In your case, since the interpolation is in 2D, you might need to
> "shape" the boolean mask to match up to your mesh.
> >
> > Hope that helps,
> > Trevor
> >
> >
> > Trevor Keller, Ph.D.
> > Materials Science and Engineering Division
> > National Institute of Standards and Technology
> > 100 Bureau Dr. MS 8550; Gaithersburg, MD 20899
> > Office: 223/A131 or (301) 975-2889
> >
> >
> >
> > From: [email protected] <[email protected]> on behalf of Zebo
> LI <[email protected]>
> > Sent: Tuesday, September 8, 2015 9:50 PM
> > To: FIPY
> > Subject: How to combine scipy.interpolate.interp2d with fipy variables
> >
> > Hi,
> >
> > I am now working on a 2D problem, in which I need to couple a
> discretized region with a continuum region. The solution of the discretized
> region are values at individual points (Irregularly distributed). Now we
> need to define a fipy variable 'val'(continuous function), which matches
> the discretized solution. For this, I use the interpolation function
> scipy.interpolate.interp2d to generate a function 'f', which is based on
> the linear interpolation of those points. But when I try to use
> 'val.setValue' to set values for val, I got an error of "Invalid input
> data". The following is this piece of code:
> > for i in range(Npoints):
> >         xold[i] = Cl.item((i,0))
> >         yold[i] = Cl.item((i,1))
> >         zold[i] = np.log10(abs(CV.item(i)))                 ##Cl are the
> coordinates, CV are the values, they are initially defined as matrices
> > f = scipy.interpolate.interp2d(xold, yold, zold, kind='linear')
>  ##If I print f(1.5,2,3)[0], it gives me a double data due to interpolation
> > val.setValue(function(X,Y)[0])               ##This one does not work.
> val is the variable defined on certain mesh, X,Y =mesh.cellCenters
> >
> > I wonder that is there anyone meet the same type of problems, and know
> how to solve it?
> >
> > best,
> > Zebo
> > _______________________________________________
> > 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 ]
>
_______________________________________________
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