Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add predict_time(), make broadening_method = "voigt" as default , add default truncation of 50 cm-1 #343

Merged
merged 33 commits into from Aug 23, 2021

Conversation

anandxkumar
Copy link
Collaborator

@anandxkumar anandxkumar commented Aug 12, 2021

Description

This pull request adds the predict_time() method in SpectrumFactory to precompute the estimated time taken by Legacy>Voigt, LDM>Voigt, and LDM>FFT methods.

Splits broadening_max_width into 2 parameters - neighbour_lines and truncation.

Sets DIT>Voigt as default method with a truncation=300 cm-1 and neighbour_lines = 0.
For LBL>Voigt, truncation=Spectral_range with neighbour_lines = None

Fixes #340

todo :

  • user error message if broadening_max_width used; suggestion with correct truncation value

@anandxkumar anandxkumar added this to In progress in GSOC21 : Automatic Lineshape Engine via automation Aug 12, 2021
@anandxkumar anandxkumar added interface not related to the physics of the code performance labels Aug 12, 2021
Comment on lines 426 to 430
broadening_max_width = 300
if (wavenum_max - wavenum_min) < 300:
broadening_method = "fft"
else:
broadening_method = "voigt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, as discussed in #340 ; we'll just use voigt all the time.
Can you

  • change broadening_max_width to truncation=Default("300") ; neighbour_lines=0
  • keep broadening_method everywhere, it's a good addition and can be used to easily switch/commpare

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwanp in case if the user gives all values that are broadening_max_width and truncation should we use the truncation value and neighbour_lines?
Also what will be the value of neighbour_lines based on different spectral range, optimization and broadening_method or we keep it manual and set it to 0 as default for every case?

radis/lbl/factory.py Outdated Show resolved Hide resolved
radis/lbl/factory.py Show resolved Hide resolved
radis/test/test_examples.py Show resolved Hide resolved
radis/lbl/factory.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2021

Codecov Report

Merging #343 (de1f5e5) into develop (71a7478) will increase coverage by 0.50%.
The diff coverage is 86.69%.

@@             Coverage Diff             @@
##           develop     #343      +/-   ##
===========================================
+ Coverage    75.50%   76.01%   +0.50%     
===========================================
  Files          152      152              
  Lines        16769    16954     +185     
===========================================
+ Hits         12662    12888     +226     
+ Misses        4107     4066      -41     

@anandxkumar anandxkumar changed the title Add predict_time() and optimization='auto' in calc_spectrum Add predict_time() and make broadening_method = "voigt" as default Aug 14, 2021
@anandxkumar anandxkumar marked this pull request as ready for review August 16, 2021 19:43
@erwanp
Copy link
Member

erwanp commented Aug 16, 2021

Is the calculation mode set to DIT/Voigt by default?

@anandxkumar
Copy link
Collaborator Author

Yes with a broadening_max_width =300 and a broadening_max_width = 10 for LBL.

@@ -19,6 +19,7 @@
Tgas=1000, # K
mole_fraction=0.1,
path_length=1, # cm
broadening_method="fft", # @ dev: Doesn't work with 'voigt'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what fails?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttributeError: 'DataFrame' object has no attribute 'selbrd'
Basically voigt uses df.selbrd to calculate the voigt_broadening_HWHM. Seems like the exomol data doesn't have this particular column.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minouHub you'll be interested

Normally, the other broadening (i.e. airbrd in HITRAN, may be different in ExoMol) is used when selbrd is missing.

if optimization is None:
if self.verbose >= 3:
printg(
"LDM algorithm not used. Defaulting truncation from {0} to 10".format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can actually keep 0 in any case.
Well add an a posteriori Accuracy warning if needed

@@ -529,38 +530,29 @@ def __init__(
if optimization is None:
if self.verbose >= 3:
printg(
"LDM algorithm not used. Defaulting truncation from {0} to 10".format(
"LDM algorithm not used. Defaulting truncation from {0} to 0".format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an error here. Default truncation should be 300 cm-1. And default neighbor likes should be 0. Algorithm shouldn't matter (DIT /Voigt and LBL/Voigt have same truncation, only DIT/FFT should raise an error if truncation as its not implemented yet)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIT/Voigt with 300 cm-1 truncation will be feasible, but I'm not sure about LBL/Voigt. As seen from the benchmarks before, LBL is independent of spectral range i.e. neighbour_lines, but is dependent on the truncation. And for a truncation=300cm-1, the calculation time and memory will be very expensive. So a default 300 cm-1 may not be feasible.

Copy link
Member

@erwanp erwanp Aug 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point for the performance drop. But at least the physics remain the same, so it's a good reason to have 300 cm-1 always (similar to the remark of @dcmvdbekerom in #340 : we don't want to change the physical output without the user knowing / deciding)

Given DIT/Voigt is the default, it should be fine in most cases.

And anyway, if the predict_time() is given before the broadening step, the user will know.
We can add an extra PerformanceWarning (with suggestion to switch to DIT/Voigt) if predicted calculation time exceeds a few minutes.

@erwanp erwanp added this to the 0.9.30 milestone Aug 21, 2021
@erwanp erwanp changed the title Add predict_time() and make broadening_method = "voigt" as default Add predict_time(), make broadening_method = "voigt" as default , add default truncation of 300 cm-1 Aug 21, 2021
also minor refactor of register() function in HITEMPDatabaseMAnaager
add note that all registred files will only be downloaded when required (as pointed out in radis#306)
works if truncation=None
fix truncation being half-with and not lineshape full width (in docstrings and code)
with new offset, no need to distinguish between lines in the range and lines outside the range whose half-lineshape only needs to be summed.
(performance ~ same on CO 2100-2200 cm-1 )
fix a bug when database contained 1 isotope in the spectral range but 2+ isotopes were asked
…ing_max_width (full width)

fix truncation not appearing in Spectrum conditions if None
@lgtm-com
Copy link

lgtm-com bot commented Aug 22, 2021

This pull request introduces 1 alert when merging de1f5e5 into 1241f08 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@anandxkumar anandxkumar changed the title Add predict_time(), make broadening_method = "voigt" as default , add default truncation of 300 cm-1 Add predict_time(), make broadening_method = "voigt" as default , add default truncation of 50 cm-1 Aug 23, 2021
@lgtm-com
Copy link

lgtm-com bot commented Aug 23, 2021

This pull request introduces 1 alert when merging 00720e0 into 1241f08 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@anandxkumar anandxkumar merged commit 710cd38 into radis:develop Aug 23, 2021
GSOC21 : Automatic Lineshape Engine automation moved this from In progress to Done Aug 23, 2021
@erwanp erwanp mentioned this pull request Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface not related to the physics of the code performance
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Add a 50cm-1 lineshape truncation by default
3 participants