yardasol / ubuntu-nuclear-software-installer

Scripts I wrote to help automatically install nuclear physics and related software that I use for research
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

Openmc scripts #21

Closed yardasol closed 3 years ago

yardasol commented 3 years ago

This PR adds scripts to install, build, and test OpenMC. The build script in particular assumes that you have HDF5 version 1.10.7. I have also included a script that should install and build HDF5 from source. You can change the version in the file manually.

yardasol commented 3 years ago

Update: 7 tests are failing. 3 value failures and 4 technical failures

All of these tests must pass before I merge this PR

yardasol commented 3 years ago

UPDATE: It's been a few months since I touched this project. I updated my conda installation and made sure my openmc version was the latest stable version and tested the openmc-build and openmc-test scripts again. Only two tests are failing now. Output pasted below"

========================================================== FAILURES ===========================================================
_______________________________________________ test_trigger_statepoint_restart _______________________________________________

model = <openmc.model.model.Model object at 0x7f386e9cbcd0>

    def test_trigger_statepoint_restart(model):
        # Assuming we converge within 1000 batches, the statepoint filename
        # should include the batch number padded by at least one '0'.
        harness = TriggerStatepointRestartTestHarness('statepoint.0*.h5', model)
>       harness.main()

/home/ooblack/projects/openmc/tests/regression_tests/trigger_statepoint_restart/test.py:132: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/ooblack/projects/openmc/tests/testing_harness.py:296: in main
    self.execute_test()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.regression_tests.trigger_statepoint_restart.test.TriggerStatepointRestartTestHarness object at 0x7f386e9cb580>

    def execute_test(self):
        """
        Perform initial and restart runs using the model.run method,
        Check all inputs and outputs which should be the same as those
        generated using the normal PyAPITestHarness update methods.
        """
        try:
            args = {'openmc_exec': config['exe'], 'event_based': config['event']}
            if config['mpi']:
                args['mpi_args'] = [config['mpiexec'], '-n', config['mpi_np']]

            # First non-restart run
            spfile = self._model.run(**args)
            sp_batchno_1 = 0
            print('Last sp file: %s' % spfile)
            assert spfile
            with openmc.StatePoint(spfile) as sp:
                 sp_batchno_1 = sp.current_batch
                 k_combined_1 = sp.k_combined
>           assert sp_batchno_1 > 10
E           assert 10 > 10

/home/ooblack/projects/openmc/tests/regression_tests/trigger_statepoint_restart/test.py:95: AssertionError
---------------------------------------------------- Captured stdout call -----------------------------------------------------
Last sp file: /home/ooblack/projects/openmc/tests/regression_tests/trigger_statepoint_restart/statepoint.0010.h5
_________________________________________________________ test_triso __________________________________________________________

    def test_triso():
        harness = TRISOTestHarness('statepoint.4.h5')
>       harness.main()

/home/ooblack/projects/openmc/tests/regression_tests/triso/test.py:97: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/ooblack/projects/openmc/tests/testing_harness.py:296: in main
    self.execute_test()
/home/ooblack/projects/openmc/tests/testing_harness.py:309: in execute_test
    self._compare_results()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.regression_tests.triso.test.TRISOTestHarness object at 0x7f386e8ee250>

    def _compare_results(self):
        """Make sure the current results agree with the reference."""
        compare = filecmp.cmp('results_test.dat', 'results_true.dat')
        if not compare:
            expected = open('results_true.dat').readlines()
            actual = open('results_test.dat').readlines()
            diff = unified_diff(expected, actual, 'results_true.dat',
                                'results_test.dat')
            print('Result differences:')
            print(''.join(colorize(diff)))
            os.rename('results_test.dat', 'results_error.dat')
>       assert compare, 'Results do not agree'
E       AssertionError: Results do not agree
E       assert False

/home/ooblack/projects/openmc/tests/testing_harness.py:138: AssertionError
---------------------------------------------------- Captured stdout call -----------------------------------------------------
                                %%%%%%%%%%%%%%%
                           %%%%%%%%%%%%%%%%%%%%%%%%
                        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                                    %%%%%%%%%%%%%%%%%%%%%%%%
                                     %%%%%%%%%%%%%%%%%%%%%%%%
                 ###############      %%%%%%%%%%%%%%%%%%%%%%%%
                ##################     %%%%%%%%%%%%%%%%%%%%%%%
                ###################     %%%%%%%%%%%%%%%%%%%%%%%
                ####################     %%%%%%%%%%%%%%%%%%%%%%
                #####################     %%%%%%%%%%%%%%%%%%%%%
                ######################     %%%%%%%%%%%%%%%%%%%%
                #######################     %%%%%%%%%%%%%%%%%%
                 #######################     %%%%%%%%%%%%%%%%%
                 ######################     %%%%%%%%%%%%%%%%%
                  ####################     %%%%%%%%%%%%%%%%%
                    #################     %%%%%%%%%%%%%%%%%
                     ###############     %%%%%%%%%%%%%%%%
                       ############     %%%%%%%%%%%%%%%
                          ########     %%%%%%%%%%%%%%
                                      %%%%%%%%%%%

                   | The OpenMC Monte Carlo Code
         Copyright | 2011-2021 MIT and OpenMC contributors
           License | https://docs.openmc.org/en/latest/license.html
           Version | 0.12.1
          Git SHA1 | 36913589c4f43b7f843332181645241f0f10ae9e
         Date/Time | 2021-06-09 14:37:11
    OpenMP Threads | 4

 Reading settings XML file...
 Reading cross sections XML file...
 Reading materials XML file...
 Reading geometry XML file...
 Reading U235 from /home/ooblack/nndc_hdf5/U235.h5
 Reading U238 from /home/ooblack/nndc_hdf5/U238.h5
 Reading C0 from /home/ooblack/nndc_hdf5/C0.h5
 Reading O16 from /home/ooblack/nndc_hdf5/O16.h5
 Reading Si28 from /home/ooblack/nndc_hdf5/Si28.h5
 Reading Si29 from /home/ooblack/nndc_hdf5/Si29.h5
 Reading Si30 from /home/ooblack/nndc_hdf5/Si30.h5
 Reading c_Graphite from /home/ooblack/nndc_hdf5/c_Graphite.h5
 Minimum neutron data temperature: 294.0 K
 Maximum neutron data temperature: 294.0 K
 Preparing distributed cell instances...
 Writing summary.h5 file...
 Maximum neutron transport energy: 20000000.0 eV for U235
 Initializing source particles...

 ====================>     K EIGENVALUE SIMULATION     <====================

  Bat./Gen.      k            Average k
  =========   ========   ====================
        1/1    1.60211
        2/1    1.87669    1.73940 +/- 0.13729
        3/1    1.81707    1.76529 +/- 0.08338
        4/1    1.57543    1.71783 +/- 0.07569
 Creating state point statepoint.4.h5...

 =======================>     TIMING STATISTICS     <=======================

 Total time for initialization     = 4.5400e-01 seconds
   Reading cross sections          = 3.8041e-01 seconds
 Total time in simulation          = 3.7665e-01 seconds
   Time in transport only          = 3.7439e-01 seconds
   Time in inactive batches        = 0.0000e+00 seconds
   Time in active batches          = 3.7665e-01 seconds
   Time synchronizing fission bank = 2.3521e-05 seconds
     Sampling source sites         = 2.0027e-05 seconds
     SEND/RECV source sites        = 1.4550e-06 seconds
   Time accumulating tallies       = 2.7540e-06 seconds
   Time writing statepoints        = 1.7710e-03 seconds
 Total time for finalization       = 1.5170e-06 seconds
 Total time elapsed                = 8.3457e-01 seconds
 Calculation Rate (active)         = 1061.99 particles/second

 ============================>     RESULTS     <============================

 k-effective (Collision)     = 1.69390 +/- 0.04704
 k-effective (Track-length)  = 1.71783 +/- 0.07569
 k-effective (Absorption)    = 1.69874 +/- 0.03550
 Combined k-effective        = 1.70141 +/- 0.03181
 Leakage Fraction            = 0.00000 +/- 0.00000

Result differences:
--- results_true.dat
+++ results_test.dat
@@ -1,2 +1,2 @@
 k-combined:
-1.701412E+00 3.180881E-02
+1.701412E+00 3.180877E-02
yardasol commented 3 years ago

Update. Only one test isn't passing now. I didn't save the output unfortunateley but it was one of the early ones, had 'feed' in the name. Gonna merge now cause the script is working very well right now.