spex-xray / spex-help

These are the help and manual pages for the SPEX X-ray spectral fitting package.
1 stars 1 forks source link

xabsinput with cloudy #22

Closed drogantini closed 1 year ago

drogantini commented 2 years ago

Hi Jelle,

I have been using xabsinput lately and I got some issues running it using Cloudy. I get only zeros whereas if I use PION with the same input files I get the right output.

-8.5     0.000
-8.4     0.000
-8.3     0.000
 ... 
 6.4     0.000
 6.5     0.000

I get the same issue with both Cloudy13/Cloudy17 and SPEX3.06/SPEX3.05. I attached the SED which consists of a single disc black-body. For the abundances, I used an empty file. What am I doing wrong?

Thank you for your support! ciao Daniele

SED_bb0p18.txt

jdeplaa commented 2 years ago

Hi Daniele,

When I try to reproduce your error, and I do, I get the following error from Cloudy (in run.out):

The energies MUST be in increasing order.  Energy #1321=  2.07e+01 Ryd was greater than or equal to the next one.
Sorry.
 [Stop in ParseInterp at parse_interp.cpp:188, something went wrong]

I have the impression that your SED energy grid has a too high resolution for xabsinput. In the cloudy input file, the energies are converted and only printed with 4 digits accuracy. In some cases, the neighboring energies are the same. An SED with a courser energy grid should work better.

Alternatively, we could see if we can increase the energy resolution of the grid in the cloudy command file that xabsinput creates. I will test this and if it works, we can include this in the next SPEX version

jdeplaa commented 2 years ago

Since you have the source code of SPEX, you can increase the resolution of the input grid for cloudy yourself. In the file code/src/auxx/xabsinput.f90, you can go to line 167-169:

          if (in.eq.1) write (11,'(a12,1(1x,"(",f7.3,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)
          if (in.eq.2) write (11,'(a12,2(1x,"(",f7.3,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)
          if (in.eq.3) write (11,'(a12,3(1x,"(",f7.3,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)

These are the write statements that write the energy grid to the input file of cloudy. If you change the format for the energy from f7.3 to f9.5, then the resolution of the grid is enough to process your particular SED.

          if (in.eq.1) write (11,'(a12,1(1x,"(",f9.5,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)
          if (in.eq.2) write (11,'(a12,2(1x,"(",f9.5,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)
          if (in.eq.3) write (11,'(a12,3(1x,"(",f9.5,1x,f7.3,")"))') word,(e(i),f(i),i=i1,i2)