Re: Dynamic under-relaxation factors for FiPy sweep
There isn't enough here to tell what's going on. Can you show us the code? > On Sep 19, 2016, at 6:53 PM, Gopalakrishnan, Krishnakumar > wrote: > > Hi Dan, > > Thanks for your suggestion to use the ResidualTerm as per your gist posting > https://gist.github.com/guyer/f29c759fd7f0f01363b8483c7bc644cb of the > Newton's method. > > When I try to implement the Newton's method into my code, python interpreter > gives the following error message > > TypeError: __init__() got an unexpected keyword argument 'var' > File " \fipy-3.1-py2.7.egg\fipy\terms\term.py", line 428, in __eq__ >return self - other > File "\fipy-3.1-py2.7.egg\fipy\terms\term.py", line 422, in __sub__ >return self + (-other) > File "\fipy-3.1-py2.7.egg\fipy\terms\abstractBinaryTerm.py", line 88, in > __neg__ >return (-self.term) + (-self.other) > File "\fipy-3.1-py2.7.egg\fipy\terms\nonDiffusionTerm.py", line 56, in > __neg__ >return self.__class__(coeff=-self.coeff, var=self.var) > TypeError: __init__() got an unexpected keyword argument 'var' > > I am following exactly the same steps given in the original gist posting. Any > idea what might be wrong here ? > > > Krishna > > > > -Original Message- > From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of > Daniel Wheeler > Sent: Tuesday, September 6, 2016 1:46 PM > To: Multiple recipients of list > Subject: Re: Dynamic under-relaxation factors for FiPy sweep > > On Tue, Sep 6, 2016 at 6:58 AM, Krishna wrote: >> >> Since python to be a very distributed ecosystem, this question for >> some kind of a starter code, may not fit well in a >> general/computational math stackexchange post , nor in this mailing >> list. fipy's details are certainly required to implement an Aitken >> type dynamic under relaxation. , I.e. one needs access to the internal >> and residual matrices, in order to apply text book formulae, and then >> split the relaxation vectors into individual scalars for use in the >> 'underrelaxation' parameter for each sweep method. The first two >> sweeps must be static/initial 'underrelaxation' so that we can apply the >> formula. > > I see. Here is an example of doing Newton iterations in FiPy > >https://gist.github.com/guyer/f29c759fd7f0f01363b8483c7bc644cb > > It uses the ResidualTerm. If you look at that code, it uses the > justResidualVector, which gives the residual vector. You can also get access > to the matrix and b vector separately. For the under relaxation, I don't > think it's possible to apply it as a vector that's different for each > equation. There is probably some way to do it akin to what's happening in the > ResidualTerm. > > > > -- > Daniel Wheeler > ___ > 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: Dynamic under-relaxation factors for FiPy sweep
Hi Dan, Thanks for your suggestion to use the ResidualTerm as per your gist posting https://gist.github.com/guyer/f29c759fd7f0f01363b8483c7bc644cb of the Newton's method. When I try to implement the Newton's method into my code, python interpreter gives the following error message TypeError: __init__() got an unexpected keyword argument 'var' File " \fipy-3.1-py2.7.egg\fipy\terms\term.py", line 428, in __eq__ return self - other File "\fipy-3.1-py2.7.egg\fipy\terms\term.py", line 422, in __sub__ return self + (-other) File "\fipy-3.1-py2.7.egg\fipy\terms\abstractBinaryTerm.py", line 88, in __neg__ return (-self.term) + (-self.other) File "\fipy-3.1-py2.7.egg\fipy\terms\nonDiffusionTerm.py", line 56, in __neg__ return self.__class__(coeff=-self.coeff, var=self.var) TypeError: __init__() got an unexpected keyword argument 'var' I am following exactly the same steps given in the original gist posting. Any idea what might be wrong here ? Krishna -Original Message- From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Daniel Wheeler Sent: Tuesday, September 6, 2016 1:46 PM To: Multiple recipients of list Subject: Re: Dynamic under-relaxation factors for FiPy sweep On Tue, Sep 6, 2016 at 6:58 AM, Krishna wrote: > > Since python to be a very distributed ecosystem, this question for > some kind of a starter code, may not fit well in a > general/computational math stackexchange post , nor in this mailing > list. fipy's details are certainly required to implement an Aitken > type dynamic under relaxation. , I.e. one needs access to the internal > and residual matrices, in order to apply text book formulae, and then > split the relaxation vectors into individual scalars for use in the > 'underrelaxation' parameter for each sweep method. The first two > sweeps must be static/initial 'underrelaxation' so that we can apply the > formula. I see. Here is an example of doing Newton iterations in FiPy https://gist.github.com/guyer/f29c759fd7f0f01363b8483c7bc644cb It uses the ResidualTerm. If you look at that code, it uses the justResidualVector, which gives the residual vector. You can also get access to the matrix and b vector separately. For the under relaxation, I don't think it's possible to apply it as a vector that's different for each equation. There is probably some way to do it akin to what's happening in the ResidualTerm. -- Daniel Wheeler ___ 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: Dynamic under-relaxation factors for FiPy sweep
On Tue, Sep 6, 2016 at 6:58 AM, Krishna wrote: > > Since python to be a very distributed ecosystem, this question for some kind > of a starter code, may not fit well in a general/computational math > stackexchange post , nor in this mailing list. fipy's details are certainly > required to implement an Aitken type dynamic under relaxation. , I.e. one > needs access to the internal and residual matrices, in order to apply text > book formulae, and then split the relaxation vectors into individual scalars > for use in the 'underrelaxation' parameter for each sweep method. The first > two sweeps must be static/initial 'underrelaxation' so that we can apply the > formula. I see. Here is an example of doing Newton iterations in FiPy https://gist.github.com/guyer/f29c759fd7f0f01363b8483c7bc644cb It uses the ResidualTerm. If you look at that code, it uses the justResidualVector, which gives the residual vector. You can also get access to the matrix and b vector separately. For the under relaxation, I don't think it's possible to apply it as a vector that's different for each equation. There is probably some way to do it akin to what's happening in the ResidualTerm. -- Daniel Wheeler ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Dynamic under-relaxation factors for FiPy sweep
Hi Dan, This is tired, albeit very loosely with the user's choice of PDE solution library/tool. I come from a MATLAB background, and solving a complicated system of non-linear PDEs is my first ever python project-motivated because of FiPys excellent and easy interface to high quality solvers, it's reputation and no analogous FV toolbox exists for Matlab (atleast to our knowledge). I am learning python concurrently while implementing our problem-specific concepts in FiPy. When I am tackling a new technical concept to implement, such as Aitken under relaxation, I look at MATLAB central, which hosts user-submissions of nifty functions, handy scripts etc.. Usually I find something which helps to get started, and I can edit their code to adapt to my problem in typically a few hours, rather than coding the equations from scratch. Since python to be a very distributed ecosystem, this question for some kind of a starter code, may not fit well in a general/computational math stackexchange post , nor in this mailing list. fipy's details are certainly required to implement an Aitken type dynamic under relaxation. , I.e. one needs access to the internal and residual matrices, in order to apply text book formulae, and then split the relaxation vectors into individual scalars for use in the 'underrelaxation' parameter for each sweep method. The first two sweeps must be static/initial 'underrelaxation' so that we can apply the formula. The details of how to implement such a scheme in FiPy are quite hazy to me. I suspect that for a least squares dynamic under relaxation, one works similarly require access to such internal matrices. I was wondering if something like this has been attempted before in the knowledge of the general FiPy community. Best Regards, Krishna Original Message From: Daniel Wheeler Sent: Tuesday, September 6, 2016 11:01 AM To: Multiple recipients of list Subject: Re: Dynamic under-relaxation factors for FiPy sweep >On Mon, Aug 29, 2016 at 2:40 PM, Gopalakrishnan, Krishnakumar > wrote: >> >> I am trying to sweep for 8 field variables in FiPy, until all their residues >> die down to appreciably small values. >> >> >> >> Currently, the convergence of this iterative loop is very slow. I have fixed >> under-relaxation implemented right now, but looking for implementing a >> dynamic under-relaxation factor for each of these 8 variables – something >> like an Aitken’s or least-squares method should be helpful. >> >> >> >> Is there any helpful resource that the users of FiPy may be able to point me >> to ? > >I don't think there are any FiPy specific resources on that. Your >issue is with the algorithm or theory rather than how to implement it >in Python / FiPy, right? > >-- >Daniel Wheeler > >___ >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: Dynamic under-relaxation factors for FiPy sweep
On Mon, Aug 29, 2016 at 2:40 PM, Gopalakrishnan, Krishnakumar wrote: > > I am trying to sweep for 8 field variables in FiPy, until all their residues > die down to appreciably small values. > > > > Currently, the convergence of this iterative loop is very slow. I have fixed > under-relaxation implemented right now, but looking for implementing a > dynamic under-relaxation factor for each of these 8 variables – something > like an Aitken’s or least-squares method should be helpful. > > > > Is there any helpful resource that the users of FiPy may be able to point me > to ? I don't think there are any FiPy specific resources on that. Your issue is with the algorithm or theory rather than how to implement it in Python / FiPy, right? -- Daniel Wheeler ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Dynamic under-relaxation factors for FiPy sweep
I am trying to sweep for 8 field variables in FiPy, until all their residues die down to appreciably small values. Currently, the convergence of this iterative loop is very slow. I have fixed under-relaxation implemented right now, but looking for implementing a dynamic under-relaxation factor for each of these 8 variables - something like an Aitken's or least-squares method should be helpful. Is there any helpful resource that the users of FiPy may be able to point me to ? Best Regards Krishna ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]