CEMeNT-PSAAP / MCDC

MC/DC: Monte Carlo Dynamic Code
https://mcdc.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
20 stars 20 forks source link

iQMC Refactor #204

Closed spasmann closed 2 months ago

spasmann commented 2 months ago

This PR includes two significant changes: 1) All of the iQMC functions in both loop.py and kernel.py have been moved into iqmc_loop.py and iqmc_kernel.py inside of an iqmc/ subfolder. Additionally, iQMC now calls it's own loop_source, loop_partcile, and step_particle functions. These changes are intended to reduce the complexity in the primary MCDC loop and kernel functions - most embedded iQMC conditional statements and loops have been removed (except for copying the P["iqmc"]["w"] because there is still only one particle type). This should also increase readability for both Monte Carlo and iQMC functions.

2) The Scipy low-discrepency sequences have been removed and custom Halton sequences were added. halton() is the standard Halton sequence that is currently used for all iQMC simulations. rhalton() is the randomized-Halton sequence which will be used in a forth-coming batching method PR. This removes the dependence for scipy.

EDIT: I thought removing the halton sequence removed our dependence for scipy. However, we still use it in input_.py to integrate

            # Make cdf
            card["energy"][1, :] = sp.integrate.cumulative_trapezoid(
                card["energy"][1], x=card["energy"][0], initial=0.0
            )
jpmorgan98 commented 2 months ago

Really cool changes! IF/when we want to port iqmc to GPUs will this make that more difficult as we have more independent source files?

I will run the GPU tests to ensure they still compile with all these changes and then merge

jpmorgan98 commented 2 months ago

Also just so I understand it every iQMC function now uses the Halton sequence, right? Therefore it's no longer a togglable option with no need for input_.py documentation?

ilhamv commented 2 months ago

Thanks, @spasmann . Does the refactor solve the issue in the CSG PR #198 ?

jpmorgan98 commented 2 months ago

Passed GPU tests