Skip to content

Commit

Permalink
Numba formal integral (#1549)
Browse files Browse the repository at this point in the history
* Readded the numba formal integral changes

* Update base.py to match main

* Reverted formal integral instantiation to be more similar to the original C version for consistency

* Moved numba implimentation to the montecarlo_numba folder since this is a numba implementation

* Removed extra ravel

* Added back old formal integral for testing

* Added test for function in the numba formal integral

* Changed the way the shell size is computed, should be correct now

* nevermind

* Moved numba formal integral tests so that paths work out for testing framework

* Moved pointer incrementation to the end of the loop

* Fixed typo

* Switched tests to use numba models

* numba models instantiate with proper data types now

* Fixed numba_formal_integral tests to instantiate numba models with numba compatable types

* Added a couple docstrings with some notes about future improvements

* Streamlined the interface slightly to better catch bugs

* Added some debug statements to watch array sizes in tests

* Changed way size_line and size_shell are created using tau_sobolevs

* Changed the most inner for-loop to be more similar to the C code and updated the njit dict to no longer use fastmath

* Added back in the check for interpolate shells

* Added back in old code for interpolate shells and now computes over the interpolated shells

* Fixed interpolate shells function and made sure dataframes are properly returned when computing the intergral

* Fixed bug in counter for Jred_lu pointer

* More explicit about typing.  the value for SIGMA_THOMSON now comes from the numba config (which is should have in the past).  Should now match C code within test criteria

* Finished tests for the numba formal integral helper functions

* Added some docstrings and removed some commented out code

* Removed old import of C formal integral

* Removed deprecated formal integral import

* Changed test to generate a new numba model as to not interfere with other tests

* removed old C interface

* Updated tests and environment to exclude compilers and Cython

* Reformatted conftest so black doesn't complain

* Removed commented out lines, made cleaner

* Added back montecarlo tests since it apepars some r_packet tests are at least set up here.  Also, readded the setup_package.py file

* Removed commented out packages from the environment file

* Slight optimization and readability improvements

* Further optimization, now pre-computes indices of next resonance point

* Removed old binary search, made formatting fixed

Co-authored-by: Andrew Fullard <andrewgfullard@gmail.com>
Co-authored-by: Wolfgang Kerzendorf <wkerzendorf@gmail.com>
  • Loading branch information
3 people authored Apr 30, 2021
1 parent 64a6369 commit 923e59d
Show file tree
Hide file tree
Showing 33 changed files with 462 additions and 6,537 deletions.
2 changes: 0 additions & 2 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@
PYTEST_HEADER_MODULES["Pandas"] = "pandas"
PYTEST_HEADER_MODULES["Astropy"] = "astropy"
PYTEST_HEADER_MODULES["Yaml"] = "yaml"
PYTEST_HEADER_MODULES["Cython"] = "cython"
PYTEST_HEADER_MODULES["h5py"] = "h5py"
PYTEST_HEADER_MODULES["Matplotlib"] = "matplotlib"
PYTEST_HEADER_MODULES["Ipython"] = "IPython"
# del PYTEST_HEADER_MODULES['h5py']
except (NameError, KeyError): # NameError is needed to support Astropy < 1.0
pass

Expand Down
13 changes: 9 additions & 4 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tardis.util.base import quantity_linspace
from tardis.io.util import HDFWriterMixin
from tardis.montecarlo import packet_source as source
from tardis.montecarlo.formal_integral import FormalIntegrator
from tardis.montecarlo.montecarlo_numba.formal_integral import FormalIntegrator
from tardis.montecarlo import montecarlo_configuration as mc_config_module


Expand Down Expand Up @@ -283,7 +283,6 @@ def run(

set_num_threads(nthreads)

self._integrator = FormalIntegrator(model, plasma, self)
self.time_of_simulation = self.calculate_time_of_simulation(model)
self.volume = model.volume

Expand All @@ -296,6 +295,7 @@ def run(

configuration_initialize(self, no_of_virtual_packets)
montecarlo_radial1d(model, plasma, self)
self._integrator = FormalIntegrator(model, plasma, self)
# montecarlo.montecarlo_radial1d(
# model, plasma, self,
# virtual_packet_flag=no_of_virtual_packets,
Expand Down Expand Up @@ -546,7 +546,9 @@ def calculate_f_lambda(self, wavelength):
pass

@classmethod
def from_config(cls, config, packet_source=None, virtual_packet_logging=False):
def from_config(
cls, config, packet_source=None, virtual_packet_logging=False
):
"""
Create a new MontecarloRunner instance from a Configuration object.
Expand Down Expand Up @@ -597,5 +599,8 @@ def from_config(cls, config, packet_source=None, virtual_packet_logging=False):
debug_packets=config.montecarlo.debug_packets,
logger_buffer=config.montecarlo.logger_buffer,
single_packet_seed=config.montecarlo.single_packet_seed,
virtual_packet_logging=(config.spectrum.virtual.virtual_packet_logging | virtual_packet_logging),
virtual_packet_logging=(
config.spectrum.virtual.virtual_packet_logging
| virtual_packet_logging
),
)
317 changes: 0 additions & 317 deletions tardis/montecarlo/montecarlo.pyx

This file was deleted.

Loading

0 comments on commit 923e59d

Please sign in to comment.