Error function erf in a form
Hello
I want to use the error function erf (http://
praveen
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Martin Sandve Alnæs
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
On 20 October 2011 06:45, Praveen C
<email address hidden> wrote:
> New question #175381 on DOLFIN:
> https:/
>
> Hello
>
> I want to use the error function erf (http://
This function is currently not supported but it shouldn't be too
difficult to implement. I can add the pieces to get this working in
UFL and FFC (apart from handling automatic differentiation).
Should I go ahead Martin?
Kristian
> praveen
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
Revision history for this message
|
#2 |
On 20 October 2011 10:45, Kristian B. Ølgaard
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Status: Open => Answered
>
> Kristian B. Ølgaard proposed the following answer:
> On 20 October 2011 06:45, Praveen C
> <email address hidden> wrote:
>> New question #175381 on DOLFIN:
>> https:/
>>
>> Hello
>>
>> I want to use the error function erf (http://
>
> This function is currently not supported but it shouldn't be too
> difficult to implement. I can add the pieces to get this working in
> UFL and FFC (apart from handling automatic differentiation).
> Should I go ahead Martin?
I don't mind. The derivative of erf is easy to add in pure UFL.
The fast and accurate C++ implementation of the actual
function is the hardest part for this kind of functions.
Search for e.g. "Cos" and "cos" in all UFL files to find
relevant places to change.
Should UFL simply treat this kind of functions as named scalar functions
along the lines of cos, sin, etc.? So far all the special functions are
found in <cmath>, while this one must be implemented by the
form compiler. We may want to add other special functions later,
so we could f.ex. provide reference implementations of them bundled
with UFL.
Martin
Revision history for this message
|
#4 |
You could also take a look at the FEniCS book, there's a chapter there
about some geology application where they use erf, so they must have
solved it some way.
Martin
On 20 October 2011 11:15, Praveen C
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Praveen C posted a new comment:
> That would be great.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
Revision history for this message
|
#5 |
On 20 October 2011 11:10, Martin Sandve Alnæs
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Martin Sandve Alnæs proposed the following answer:
> On 20 October 2011 10:45, Kristian B. Ølgaard
> <email address hidden> wrote:
>> Question #175381 on DOLFIN changed:
>> https:/
>>
>> Status: Open => Answered
>>
>> Kristian B. Ølgaard proposed the following answer:
>> On 20 October 2011 06:45, Praveen C
>> <email address hidden> wrote:
>>> New question #175381 on DOLFIN:
>>> https:/
>>>
>>> Hello
>>>
>>> I want to use the error function erf (http://
>>
>> This function is currently not supported but it shouldn't be too
>> difficult to implement. I can add the pieces to get this working in
>> UFL and FFC (apart from handling automatic differentiation).
>> Should I go ahead Martin?
>
> I don't mind. The derivative of erf is easy to add in pure UFL.
> The fast and accurate C++ implementation of the actual
> function is the hardest part for this kind of functions.
> Search for e.g. "Cos" and "cos" in all UFL files to find
> relevant places to change.
OK.
> Should UFL simply treat this kind of functions as named scalar functions
> along the lines of cos, sin, etc.? So far all the special functions are
> found in <cmath>, while this one must be implemented by the
> form compiler. We may want to add other special functions later,
> so we could f.ex. provide reference implementations of them bundled
> with UFL.
I was thinking of just using the one from <cmath>, a quick test
appears to be working but our test volunteer will soon find out :)
Kristian
> Martin
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
Revision history for this message
|
#6 |
Can I use the snapshot from tomorrow to try the erf function ? Or do I have to build from sources ?
Thanks
praveen
Revision history for this message
|
#7 |
On 10/20/2011 11:25 AM, Martin Sandve Alnæs wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Martin Sandve Alnæs proposed the following answer:
> You could also take a look at the FEniCS book, there's a chapter there
> about some geology application where they use erf, so they must have
> solved it some way.
That chapter uses 'erf' when defining an Expression. If that if what
you want, go ahead and take a look.
--
Marie
> Martin
>
> On 20 October 2011 11:15, Praveen C
> <email address hidden> wrote:
>> Question #175381 on DOLFIN changed:
>> https:/
>>
>> Praveen C posted a new comment:
>> That would be great.
>>
>> --
>> You received this question notification because you are a member of
>> DOLFIN Team, which is an answer contact for DOLFIN.
>>
Revision history for this message
|
#8 |
Marie is right. Expression is not a problem (I think) since I can use erf from python (2.7 has erf but not older versions of python). But I want to do something like erf(u) in a form where u = Function(some function space).
Revision history for this message
|
#9 |
On 20 October 2011 11:25, Kristian B. Ølgaard
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Kristian B. Ølgaard proposed the following answer:
> On 20 October 2011 11:10, Martin Sandve Alnæs
> <email address hidden> wrote:
>> Question #175381 on DOLFIN changed:
>> https:/
>>
>> Martin Sandve Alnæs proposed the following answer:
>> On 20 October 2011 10:45, Kristian B. Ølgaard
>> <email address hidden> wrote:
>>> Question #175381 on DOLFIN changed:
>>> https:/
>>>
>>> Status: Open => Answered
>>>
>>> Kristian B. Ølgaard proposed the following answer:
>>> On 20 October 2011 06:45, Praveen C
>>> <email address hidden> wrote:
>>>> New question #175381 on DOLFIN:
>>>> https:/
>>>>
>>>> Hello
>>>>
>>>> I want to use the error function erf (http://
>>>
>>> This function is currently not supported but it shouldn't be too
>>> difficult to implement. I can add the pieces to get this working in
>>> UFL and FFC (apart from handling automatic differentiation).
>>> Should I go ahead Martin?
>>
>> I don't mind. The derivative of erf is easy to add in pure UFL.
>> The fast and accurate C++ implementation of the actual
>> function is the hardest part for this kind of functions.
>> Search for e.g. "Cos" and "cos" in all UFL files to find
>> relevant places to change.
>
> OK.
>
>> Should UFL simply treat this kind of functions as named scalar functions
>> along the lines of cos, sin, etc.? So far all the special functions are
>> found in <cmath>, while this one must be implemented by the
>> form compiler. We may want to add other special functions later,
>> so we could f.ex. provide reference implementations of them bundled
>> with UFL.
>
> I was thinking of just using the one from <cmath>, a quick test
> appears to be working but our test volunteer will soon find out :)
Ok. But just so you know, that's C++11, so
even quite new compilers may not have it.
Seems that bessel functions are part of TR1,
so we could add those as well quite easily (later).
Martin
Revision history for this message
|
#10 |
On 20 October 2011 11:30, Praveen C
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Praveen C posted a new comment:
> Can I use the snapshot from tomorrow to try the erf function ? Or do I
> have to build from sources ?
It should be available now if you get the development version using Dorsal.
Can you please test it and report back if it behaves as you expect it to?
Kristian
> Thanks
> praveen
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
Revision history for this message
|
#11 |
I have never built with dorsal before. I tried it on many of my computers but all of them failed with different errors.
Will the nightly binary snapshots include the updated code ?
praveen
Revision history for this message
|
#12 |
Yes, the binary snapshots will include this update. What platform are you on?
Revision history for this message
|
#13 |
Snow Leopard with system python (2.6)
Revision history for this message
|
#14 |
Dorsal should work with Snow Leopard, as it is a reasonably well-tested platform. If you're interested in getting it to work, please file a separate bug report indicating what the problem is, and I will help you fix it. That way, you don't need to wait for binary snapshots in order to get new features/bug fixes.
Revision history for this message
|
#15 |
I tried with dorsal-1.0-beta and get problems with petsc/slepc. Should I try dorsal-0.8.2
Basically, I see that PETSC_ARCH=
=======
SLEPc Configuration
=======
SLEPc source directory:
/Users/
SLEPc install directory:
/Users/
PETSc directory:
/Users/
Architecture "installed-petsc" with double precision real numbers
**
** Before running "make" your PETSC_ARCH must be specified with:
** ** setenv PETSC_ARCH installed-petsc (csh/tcsh)
** ** PETSC_ARCH=
**
/Users/
/Users/
make: *** No rule to make target `/Users/
Failure with exit status: 2
Exit message: There was a problem building slepc-3.1-p6.
Revision history for this message
|
#16 |
I got the snapshot few minutes back and tried it. But the erf function is not found.
praveen
PS: Snow leopard
Revision history for this message
|
#17 |
I have rebuilt the binary snapshot for Snow Leopard and it seems that the erf function is in place. At least I can do "pydoc ufl.erf".
Could you download a new copy and try again?
Revision history for this message
|
#18 |
The snow leopard binary is using python2.6 but that version of python does not have math.erf so I get an error
File "/Users/
return _mathfunction(f, Erf, math.erf)
AttributeError: 'module' object has no attribute 'erf'
Revision history for this message
|
#19 |
I've pushed a fix for this.
Praveen, you can do a quick fix manually in your installed UFL source
code in your installation by doing this:
In 'ufl/operators.py', just replace 'math.erf' with None.
In 'ufl/mathfuncti
if isinstance(
This last step may not be necessary, depending on how you use it.
Martin
On 21 October 2011 14:10, Praveen C
<email address hidden> wrote:
> Question #175381 on DOLFIN changed:
> https:/
>
> Praveen C posted a new comment:
> The snow leopard binary is using python2.6 but that version of python
> does not have math.erf so I get an error
>
> File "/Users/
> return _mathfunction(f, Erf, math.erf)
> AttributeError: 'module' object has no attribute 'erf'
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
Revision history for this message
|
#20 |
Thanks Martin, that seems to have worked. I am still resolving other issues in this problem. Once I get the results, I will report back here.
Revision history for this message
|
#21 |
Thanks Martin Sandve Alnæs, that solved my question.