-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
[WIP] Basic implementation of the formal integral #726
Conversation
Looks like a good starting point! Can you make a list of milestones to define the scope of this PR? |
Something like this? |
Well, if you want to do everything in one go then I'd say yes. |
Not necessarily. We can split the PR in several smaller and more focused ones. Do you have suggestions? |
I'd rather do it in smaller chunks and split it up into sensible sub-projects. E.g.:
|
According to your suggestion part 1 is mostly done? Only function documentation is missing as of right now. Additionally I'm not happy with the implementation as it does not allow for modularity right now. But I have changes in mind that should solve this. |
The refactor changes the way a spectrum is handled. Instead of creating a spectrum and updating it after each montecarlo iteration, we create a new spectrum from the MontecarloRunner whenever it is needed. Benefits: - TARDISSpectrum is now a general purpose spectrum class that is not linked to the Iteration sheme anymore. - It is now possible to save spectra for all iterations without them being updated each iteration. - This class can now also be used for spectra created by the formal integral approach (upcoming PR tardis-sn#726)
The refactor changes the way a spectrum is handled. Instead of creating a spectrum and updating it after each montecarlo iteration, we create a new spectrum from the MontecarloRunner whenever it is needed. Benefits: - TARDISSpectrum is now a general purpose spectrum class that is not linked to the Iteration sheme anymore. - It is now possible to save spectra for all iterations without them being updated each iteration. - This class can now also be used for spectra created by the formal integral approach (upcoming PR tardis-sn#726)
This implementation is siginficantly faster than the python version.
This reduces the time to traverse the line list by a huge amount for a huge number of lines, especially if the start is near the red end of the line list.
Currently the c function expects a storage model, a blackbody temperature, an array of frequencies, the length of said array, the source function and the number of integration points. The function returns a array with the same length as the frequency array. Remember to free the result to prevent memory leaks. The python wrapper expects a simulation object, a np.ndarray of frequencies and the number of integration points. Additionally the identation of the C code was changed
Expand documentation Fix bug in populate_z.
In very rare cases when the outermost p line has an equal distance to the center as the radius of the outer shell, the code could try to access memory out of bounds.
c5be218
to
532d85d
Compare
The class stores a reference to model, plasma and runner to be able to calculate the formal integral. In this implementation it is first instantiated in MontecarloRunner.run() and available thereafter. It returns a TARDISSpectrum of the integrated spectrum.
The FormalIntegrator is responsible for all calculations associated with the formal integration method. It contains methods to calculate the source function and a wrapper to the c implementation.
There is a new option under spectrum which defaults to 'virtual' but can be set to 'real' or 'integrated' as well.
Close in favor of #740. |
This is still WIP and contains a basic implementation of the formal integral approach ported to C.
Milestones: