Re: Using a different Matplotlib backend on a per-script basis

2019-03-13 Thread Michael J. Waters

Hi Christoph,

Have you tried setting the backend at the start of your FiPy script like 
this?:


importmatplotlib

matplotlib.use('AGG')  

This won't make the changes system wide, only for the script. I think 
this will work since FiPy doesn't appear to deviate from the default 
rcparams setting for the backend. 
(https://github.com/usnistgov/fipy/tree/develop/fipy/viewers/matplotlibViewer)


Best,

-Mike




On 3/13/19 9:43 AM, Christoph Margenfeld wrote:

Hello,

as mentioned in the FiPy FAQ, a different Matplotlib backend has to be
used when exporting images from the MatplotlibViewer class without any
output to the screen.

  From the Matplotlib documentation (at
https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend),
there are three ways to select a backend. The first two would involve
setting it in a .matplotlibrc file or as an environment variable.
However, that would affect all scripts run in that particular
environment, which I do not want to do. The third approach is setting
matplotlib.use('backend').

How can I select a Matplotlib backend for a certain MatplotlibViewer
without affecting any other scripts run from my environment?

Thank you!

Best regards,
Christoph Margenfeld
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Viewer Feature Request / Clarification

2018-03-20 Thread Michael J. Waters

Hi Jonathan,

Sorry to disappoint you.

Kevin,

If you have time, what Jonathon said is /much/ better. Code contribution 
is very important to open source projects!


Best,

-Mike


On 3/20/18 8:21 AM, Guyer, Jonathan E. Dr. (Fed) wrote:

I must confess that this answer makes me sad. FiPy is object oriented precisely 
so that you don't need to do this. The intended design is that you subclass 
Matplotlib1DViewer to override the behavior you want. There are two places you 
can do this:

* In Matplotlib1DViewer.__init__(), around 
https://github.com/usnistgov/fipy/blob/71d82e1cc7b2c4e7c1c996d038fd8542d7e4c5a1/fipy/viewers/matplotlibViewer/matplotlib1DViewer.py#L82
 and following, add a `color=` argument to the creation of the lines.

* In Matplotlib1DViewer._plot(), after 
https://github.com/usnistgov/fipy/blob/71d82e1cc7b2c4e7c1c996d038fd8542d7e4c5a1/fipy/viewers/matplotlibViewer/matplotlib1DViewer.py#L145,
 add a `line[0].set_color()` call.

In addition to subclassing for your own purposes, a pull request that adds this 
capability to Matplotlib1DViewer would be most welcome.

P.S. I think Dan Lewis is thinking of the custom viewers in 
https://www.ctcms.nist.gov/fipy/examples/phase/generated/examples.phase.anisotropy.html
 and 
https://www.ctcms.nist.gov/fipy/examples/phase/generated/examples.phase.polyxtal.html.
 Neither does the specific customization you are looking for, but they 
illustrate how subclassing a Viewer class is intended to work.

- Jon


On Mar 19, 2018, at 12:48 PM, Michael J. Waters <waters.mik...@gmail.com> wrote:

Hi Kevin,

If you are using the Matplotlib Viewers, you could just skip the Viewers and 
use Matplotlib directly.  it's not hard to simply setup subplots using 
Matplotlib and it should be easy to get them to update the figure at each time 
step.
Best,

-Mike


On 3/19/18 11:35 AM, Kevin Blondino wrote:

Hi,

My problem is one-dimensional. When plotting, I wish to have side-by-side plots 
of separate cell variables. The color of the lines default to a color scheme, 
i.e. the first line of each subplot is blue, etc. I wish to have the viewer 
allow me to choose the color of the line. Does this already exist? Or would I 
have to export it as a TSV and plot it under my own accord? I scoured the 
documentation and archive with no avail.

Thanks,
Kevin


___
fipy mailing list

fipy@nist.gov
http://www.ctcms.nist.gov/fipy

   [ NIST internal ONLY:
https://email.nist.gov/mailman/listinfo/fipy
  ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Viewer Feature Request / Clarification

2018-03-19 Thread Michael J. Waters

Hi Kevin,

If you are using the Matplotlib Viewers, you could just skip the Viewers 
and use Matplotlib directly.  it's not hard to simply setup subplots 
using Matplotlib and it should be easy to get them to update the figure 
at each time step.


Best,

-Mike


On 3/19/18 11:35 AM, Kevin Blondino wrote:

Hi,

My problem is one-dimensional. When plotting, I wish to have 
side-by-side plots of separate cell variables. The color of the lines 
default to a color scheme, i.e. the first line of each subplot is 
blue, etc. I wish to have the viewer allow me to choose the color of 
the line. Does this already exist? Or would I have to export it as a 
TSV and plot it under my own accord? I scoured the documentation and 
archive with no avail.


Thanks,
Kevin


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Diffusion coefficient with spline interpolation

2017-08-09 Thread Michael J. Waters

Hi Clara,

Is your spline function returning a numpy array?  I think what is 
happening is that FiPy is seeing it as a tensor diffusion coefficient 
rather than just a list of the values throughout your simulation. I'm a 
little rusty with FiPy these days, but I think you could so something 
like this:


Diff = CellVariable(mesh=mesh)

Diff.setValue(d2G(Xf))

and then update the value in the loop like this:

while time < duration:
 res0 = eq.sweep(X_var, dt=dt, solver=solver)


 Diff.setValue(d2G(Xf))


Maybe 'Diff' should be FaceVariable? whichever way it should be, it 
should be fine in the equation definition then.


Best,
-Mike




On 8/9/17 4:48 PM, Clara Maurel wrote:

Hello,

I would like to model the Cahn Hilliard equation with a diffusion 
coefficient that depends on the cell variable (concentration X) and time.
The diffusion coefficient (Diff) is proportional to the second 
derivative of the free energy (d2G), for which I have the values in an 
external file, for a range of concentrations.
Initially I interpolated d2G with a polynomial function and could 
easily express Diff as a function of Xf = X.arithmeticFaceValue


However, I realised that this interpolation was not appropriate in my 
case. The only way I found to obtain a correct interpolation of d2G is 
to use a B-spline interpolation, with 
scipy.interpolate.UnivariateSpline. The piece of code is as follows 
(d2G_fit is the array of values that I imported from an external file):



X = np.arange(0.011,1.0,0.001)

X_var = CellVariable(name=r"$X_{at}$", mesh=mesh, hasOld=True)

noise = GaussianNoiseVariable(mesh=mesh, mean=X_mean, 
variance=1.0e-7).value

X_var[:] =  noise
X_var.updateOld()
Xf = X_var.arithmeticFaceValue

d2G = UnivariateSpline(X, d2G_fit[id_mean_spino], k=3, s=0)
Diff = d2G(Xf)


My problem is that when I start looping with:

while time < duration:
 res0 = eq.sweep(X_var, dt=dt, solver=solver)

I have the error message:

IndexError: diffusion coefficent tensor is not an appropriate shape 
for this mesh



I also tried:

Diff = Variable(value=d2G(Xf))
and
Diff =  d2G(Xf)*Variable(list(d2G(Xf)))

but I have the same error.

Could you tell me how I could work this out? Additional comment: Diff 
evolves with time, I update it at selected timestep in the loop.



Any hint would be greatly appreciated!

Thank you in advance!
Clara





___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Memory leak using trilinos

2017-06-20 Thread Michael J. Waters

Hi Zhekai Deng,

I had a similar problem. In the end, I just created check point files 
and restarted frequently.


I did find that garbage collecting helped slow the leak and, 
interestingly, also sped up code execution for me.


Best,

-Mike


On 6/20/17 10:39 AM, Zhekai Deng wrote:

HI All,

I think I run into some memory leak issues using trilinos as my solver 
both for serial and parallel case. The total memory goes up from 
initial around 300 MB to the my system memory limit (like 29 GB), and 
program stops. I have attached my example code below.


Somethings I am not sure if I implement it correctly:
1. in the example code, I basically solve multiple equations at the 
same time. I use list, and append my CellVarible together


2. Similar, I use list and append my equation together

3. Create coupled equation by looping through the list element, and 
solve this coupled equation.


4. During the solution step, I loop through the list element, and do 
updateOld()


The results of the numerical calculation looks correct to me, I just 
have this memory issue that prevent me from going longer time steps 
because I run out of  memory.


I wonder is there any workaround/fix to this problem ?

I am using the build from Anaconda repository, default trillions 
solver, and my OS is Ubuntu 16.04.



___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: python 3

2017-06-07 Thread Michael J. Waters
Hi Jonathan,

I am excited for PETSc and wish I could help!

Is there any form adaptive mesh refinement on the horizon?

Best,

-Mike


On 6/7/17 4:03 PM, Guyer, Jonathan E. Dr. (Fed) wrote:
> Yes. More likely to happen is that we'll add support for PETSc, but that's 
> not imminent, either.
>
>> On Jun 7, 2017, at 3:08 PM, Michael J. Waters <waters.mik...@gmail.com> 
>> wrote:
>>
>> Hi Daniel,
>>
>> So FiPy running in Python 3 won't have MPI based parallelism until
>> PyTrilinos supports Python 3?
>>
>> Best,
>>
>> -Mike
>>
>>
>> On 6/7/17 2:01 PM, Daniel Wheeler wrote:
>>> Hi Nils,
>>>
>>> FiPy is not written for Python 3, but it does work after applying
>>> 2to3. However, only the Scipy solvers are then available. See,
>>>
>>> 
>>> https://www.ctcms.nist.gov/fipy/documentation/USAGE.html#running-under-python-3
>>>
>>> To fully make the switch to Python 3, FiPy needs to be natively
>>> updated, which hasn't happened yet. Also, FiPy needs to move away from
>>> using Trilinos as PyTrilinos hasn't been updated to Python 3.
>>> Unfortunately, I can't give a timeline on when those changes will be
>>> made.
>>>
>>> Cheers,
>>>
>>> Daniel
>>>
>>>
>>>
>>>
>>> On Wed, Jun 7, 2017 at 6:16 AM, Nils Becker
>>> <nils.bec...@bioquant.uni-heidelberg.de> wrote:
>>>> hi,
>>>>
>>>> i'm considering updating my scripts from 2.7 to python 3.4 or 3.6.
>>>> should i expect any problems? is fipy tested on py 3?
>>>>
>>>> thanks!
>>>>
>>>> ___
>>>> fipy mailing list
>>>> fipy@nist.gov
>>>> http://www.ctcms.nist.gov/fipy
>>>>[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>>>>
>>>
>> ___
>> fipy mailing list
>> fipy@nist.gov
>> http://www.ctcms.nist.gov/fipy
>>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: python 3

2017-06-07 Thread Michael J. Waters
Hi Daniel,

So FiPy running in Python 3 won't have MPI based parallelism until 
PyTrilinos supports Python 3?

Best,

-Mike


On 6/7/17 2:01 PM, Daniel Wheeler wrote:
> Hi Nils,
>
> FiPy is not written for Python 3, but it does work after applying
> 2to3. However, only the Scipy solvers are then available. See,
>
> 
> https://www.ctcms.nist.gov/fipy/documentation/USAGE.html#running-under-python-3
>
> To fully make the switch to Python 3, FiPy needs to be natively
> updated, which hasn't happened yet. Also, FiPy needs to move away from
> using Trilinos as PyTrilinos hasn't been updated to Python 3.
> Unfortunately, I can't give a timeline on when those changes will be
> made.
>
> Cheers,
>
> Daniel
>
>
>
>
> On Wed, Jun 7, 2017 at 6:16 AM, Nils Becker
>  wrote:
>> hi,
>>
>> i'm considering updating my scripts from 2.7 to python 3.4 or 3.6.
>> should i expect any problems? is fipy tested on py 3?
>>
>> thanks!
>>
>> ___
>> fipy mailing list
>> fipy@nist.gov
>> http://www.ctcms.nist.gov/fipy
>>[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>>
>
>

___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]