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

[WIP] Basic implementation of the formal integral #726

Closed
wants to merge 17 commits into from

Conversation

yeganer
Copy link
Contributor

@yeganer yeganer commented May 19, 2017

This is still WIP and contains a basic implementation of the formal integral approach ported to C.

Milestones:

@unoebauer
Copy link
Contributor

Looks like a good starting point! Can you make a list of milestones to define the scope of this PR?

@yeganer
Copy link
Contributor Author

yeganer commented May 22, 2017

Something like this?

@unoebauer
Copy link
Contributor

Well, if you want to do everything in one go then I'd say yes.

@yeganer
Copy link
Contributor Author

yeganer commented May 22, 2017

Not necessarily. We can split the PR in several smaller and more focused ones. Do you have suggestions?

@unoebauer
Copy link
Contributor

I'd rather do it in smaller chunks and split it up into sensible sub-projects. E.g.:

  • 1: basic C-implementation of FI (without e-scattering, without external configuration)
  • 2: unit testing and configuration
  • 3: including e-scattering
  • 4: generalisation to macro-atom

@yeganer
Copy link
Contributor Author

yeganer commented May 23, 2017

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.

@yeganer yeganer force-pushed the formal_integral branch from 80a38b8 to 84d5e16 Compare June 2, 2017 14:49
yeganer added a commit to yeganer/tardis that referenced this pull request Jun 3, 2017
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)
@yeganer
Copy link
Contributor Author

yeganer commented Jun 6, 2017

fi_spectrum
Plot of the latest version (this PR is behind) of the formal integral.
The difference between MC and Integrator is due to the different initialization of the packets in the montecarlo code.

@yeganer yeganer force-pushed the formal_integral branch from 84d5e16 to d08fe98 Compare June 7, 2017 10:35
yeganer added a commit to yeganer/tardis that referenced this pull request Jun 7, 2017
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)
yeganer added 10 commits June 7, 2017 14:31
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.
@yeganer yeganer force-pushed the formal_integral branch from d08fe98 to c6b5b31 Compare June 7, 2017 12:32
@yeganer yeganer force-pushed the formal_integral branch 2 times, most recently from c5be218 to 532d85d Compare June 8, 2017 14:02
yeganer added 7 commits June 8, 2017 16:19
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.
@yeganer yeganer force-pushed the formal_integral branch from 532d85d to 678186a Compare June 8, 2017 15:35
@yeganer yeganer mentioned this pull request Jun 12, 2017
5 tasks
@yeganer
Copy link
Contributor Author

yeganer commented Jun 12, 2017

Close in favor of #740.

@yeganer yeganer closed this Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants