" run_01_log.txt " As to internal parameter assigned to be "NaN"

Asked by Han

Dear MadGraph Team,

Hi, I had very lengthy parameter expressions in my "_UFO" file which was generated by FR. Then I generated several event(p p > x x~ say) through MG5, and opened " run_01_log.txt " file to check whether my internal parameters were correctly translated. Then all values were assigned to be (NaN, NaN), please note that these are complex. This was so strange to me, "NaN means None?" asked to myself. Well then I looked at the bottom line frame which read, "length: 22497 lines: 548". This really contradicted to what was given by, "(NaN , NaN)" shortly.

I had already debugged some of suspicious expressions in short pieces, for instance complex(0,1) etc, and found no problem there. So I had a growing anxious to the "length" problem in the parameter expressions.

In summary, I would like to know whether the length of expressions does really matter in running MG5, and the meaning of "(NaN,NaN)".

Thank you for helping me.

Sincerely

Jeong-han Kim

==========================================================================================
Update as to the question: Specifically I found the problematic point

When I wirte input parameter in "parameter.py" file in my UFO file,

AAA = Parameter(name = 'AAA',
                   nature = 'internal',
                   type = 'complex',
                   value = 'cmath.sqrt(-4)',
                   texname = '\\text{AAA}')

MG5 can't read "cmath.sqrt(-4)" when the argument is negative. I changed it into "cmath.sqrt(4)" then it worked!

If one has very lengthy expressions, then sometimes it's possible to have square-root of some negative value. I wonder, in this case, how to avoid this problem. I guess the best way is to go around not to use "cmath.sqrt" function. I would appreciated if you give me any suggestion.

Thanks a lot

Cheers !

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Valentin Hirschi
Solved:
Last query:
Last reply:
Revision history for this message
Valentin Hirschi (valentin-hirschi) said :
#1

Dear Jeong Han Kim,

I don't know the specifics of your model or the process you are attempting to generate. However, concerning your last questions about how to handle customized behavior of a square root functions, I would like to remind you that the UFO format allows you for defining custom functions in the model function_library.py which can be, once defined, used throughout your parameters and couplings definition.

There is a catch however, related to the fact that the definition of the function is in python and there is no way to automatically translate it into a fortran or C++ equivalent function to be used when outputting your process in various languages. There is therefore a bit more work to be done on the MG5 side to implement this new function you will be defining.
This reasonably easy to do and we could even implement that into the next release if this function is general and has potential to be helpful for many models.

If this would be a viable solution for your issue, let me know and I can further help you.

Revision history for this message
Han (jeonghan-kim) said :
#2

Dear Valentin,

Thanks for the reply. I still need your assistance. It's again about "cmath.sqrt" function.

I have the "parameter.py" file (in my UFO file) which reads one of my parameter as:

AAA = Parameter(name = 'AAA',
                   nature = 'internal',
                   type = 'complex',
                   value = 'cmath.sqrt(-4)',
                   texname = '\\text{AAA}')

MG5 can't read 'cmath.sqrt(-4)' for the square-root of negative value( It just returned AAA = (NaN,NaN) ).
I want MG5 to translate it correctly (in this case MG5 should return AAA = (0 , 2.00000) ).

According to your advice, I should go to "function_library.py" to define the function. So I did it as:

square = Function(name = 'square',
  arguments = ('z',),
  expression = 'cmath.sqrt(z)')

And back to my "parameter.py" file to write:

AAA = Parameter(name = 'AAA',
                   nature = 'internal',
                   type = 'complex',
                   value = 'square(-4)',
                   texname = '\\text{AAA}')

But it didn't work.... Is there any mistake here?
Thanks

Cheers !

Jeong-han Kim

Revision history for this message
Valentin Hirschi (valentin-hirschi) said :
#3

Hi Jeong,

Ok, I missunderstood what you wanted to do. I thought that you wanted to be able to have a square root function that dynamically select a given Riemann sheet depending on some other parameters.

So if you simply want a function square root returning the solution with positive imaginary part when called with a negative pure real, then I suggest that you simply always make sure that the argument is a complex parameters. For example, in your case you could write:

AAA = Parameter(name = 'AAA',
                   nature = 'internal',
                   type = 'complex',
                   value = 'cmath.sqrt(complex(-4,0))',
                   texname = '\\text{AAA}')

I would expect this to work.

Revision history for this message
Han (jeonghan-kim) said :
#4

Hi Valentin,

Thanks that works well :D
Let me ask you one more question as an extension to this problem. Suppose now we have an external parameter M = 300 defined. Then, as you said, I wrote such that:

AAA = Parameter(name = 'AAA',
                   nature = 'internal',
                   type = 'complex',
                   value = 'cmath.sqrt(complex(-M,0))',
                   texname = '\\text{AAA}')

It didn't work in MG5. Error message is the following:

ValueError : could not convert string to fload: -M

It's strange that 'cmath.sqrt(complex(-100,0))' works, but 'cmath.sqrt(complex(-M,0))' doesn't work... What should I do?..

Many Many Thanks !

Sincerely

Jeong-han

Revision history for this message
Best Valentin Hirschi (valentin-hirschi) said :
#5

Hi,

In your case, you would then be better of starting from M being a complex parameter to start with. Alternatively, I guess you could also write

cmath.sqrt(complex(1,0)*(-M))

but it it rather inelegant.

Revision history for this message
Han (jeonghan-kim) said :
#6

Hi Valentin !

Wow it worked !! I'm so happy.
Thank you very much

Cheers !

Jeong-han