From 93a0855c7f64a9a366df557947ca7b24f93705da Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 22 Jun 2023 13:26:22 -0500 Subject: [PATCH] Fix test error and deprecation warnings from numpy 1.25 (#2573) --- openmc/cmfd.py | 7 +++---- openmc/model/model.py | 13 +++++++++---- .../ref_depletion_with_feed.h5 | Bin 37328 -> 37328 bytes .../ref_depletion_with_removal.h5 | Bin 37328 -> 37328 bytes .../ref_depletion_with_transfer.h5 | Bin 37328 -> 37328 bytes .../ref_no_depletion_only_feed.h5 | Bin 37328 -> 37328 bytes .../ref_no_depletion_only_removal.h5 | Bin 37328 -> 37328 bytes .../ref_no_depletion_with_transfer.h5 | Bin 37328 -> 37328 bytes .../deplete_with_transfer_rates/test.py | 2 ++ tests/testing_harness.py | 2 +- 10 files changed, 15 insertions(+), 9 deletions(-) diff --git a/openmc/cmfd.py b/openmc/cmfd.py index 85550c4951..d45396f141 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -1074,13 +1074,12 @@ class CMFDRun: # Get acceleration map, otherwise set all regions to be accelerated if self._mesh.map is not None: check_length('CMFD coremap', self._mesh.map, - np.product(self._indices[0:3])) + np.prod(self._indices[:3])) if openmc.lib.master(): self._coremap = np.array(self._mesh.map) else: if openmc.lib.master(): - self._coremap = np.ones((np.product(self._indices[0:3])), - dtype=int) + self._coremap = np.ones(np.prod(self._indices[:3]), dtype=int) # Check CMFD tallies accummulated before feedback turned on if self._feedback and self._solver_begin < self._tally_begin: @@ -1434,7 +1433,7 @@ class CMFDRun: # nfissxs # Calculate volume - vol = np.product(self._hxyz, axis=3) + vol = np.prod(self._hxyz, axis=3) # Reshape phi by number of groups phi = self._phi.reshape((n, ng)) diff --git a/openmc/model/model.py b/openmc/model/model.py index db0b05e15d..2b5681d811 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -263,10 +263,10 @@ class Model: model.materials = openmc.Materials.from_xml_element(root.find('materials')) model.geometry = openmc.Geometry.from_xml_element(root.find('geometry'), model.materials) - if root.find('tallies'): + if root.find('tallies') is not None: model.tallies = openmc.Tallies.from_xml_element(root.find('tallies'), meshes) - if root.find('plots'): + if root.find('plots') is not None: model.plots = openmc.Plots.from_xml_element(root.find('plots')) return model @@ -575,10 +575,15 @@ class Model: cell_id = int(name.split()[1]) cell = cells[cell_id] if cell.fill_type in ('material', 'distribmat'): - cell.temperature = group['temperature'][()] + temperature = group['temperature'][()] + cell.temperature = temperature if self.is_initialized: lib_cell = openmc.lib.cells[cell_id] - lib_cell.set_temperature(group['temperature'][()]) + if temperature.size > 1: + for i, T in enumerate(temperature): + lib_cell.set_temperature(T, i) + else: + lib_cell.set_temperature(temperature[0]) # Make sure number of materials matches mats_group = fh['materials'] diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_feed.h5 index ae1c7e42301e81c0fdff0778b280309960aca009..4f270afab00ddb5651aeb22aed0ca9b32c173d06 100644 GIT binary patch delta 702 zcmcbxnCZe|rVR`F>Qg0!BF;|Yw_|{U+EnFTr}AIH`6q%|el6jhU<;FvebMps>I@OM z{70dvjR)hG!uf7Fi}jCmE5Z5d!Y55+y&UZlnj$R3_WiS6`KdX@lUKtoRqM!s!}lHQ z?Pe%9$o5A3vn@F5z|hHc&DO3lPx|`-MYsW5YuGnzYGtv9IpA#dDuIZSg>VO5P6*z6 zrCk%Qe(|<-%lxVi!1--Iznq!8+7Qm4?c-lI|BNq`ufxFbSRiTJ1}iJLf+c@eeaI6s zf%Chqcihnr`Dj0%WAdqfCD(?sIrbOV=O268Zs5GnS}!r!!@&82e_~5Am%p=rV4R|; zrml1JeluP7{8LWy25&$8QoG}H=$x2ov-(A6Ui+@pP2X)@cqbc92&m5~+HA8B5%O;9 zQavHy;$*?rj%x^ewmN4xqNGudR<2Qk>y3++v~ciMOFBF;|Yw_|{U52?z#PUXLX^DhUp{93|0!4@X(_@d+K)fpmi z`31sJ8xO`Wh4a;N7V97BR)X{Y3!OBP^>Va())-+Sw(pZ zZ+A$!LAE#IpY4XT4h)@K*KE%>U*}WTjp1F0M1|a^UImZs}13N3m^Zo`Dc8gd>sac3j#^oHdtA~70CWu^&wBl z1kUfb-f>4idB}2m0Vq77TTX%pMUIWyMgl(YrVu^4+G~f{)sKgT>j4LfpLnW zn!3)l`^|LS^G`Xs8NB`UOYM%+;d5f9&FUAOdF;DVH+{Et5twW^A)tQ2x5El+5FyXM z=I=j8-uG~Ok23XK+Sol2?on@@J?u5cl5qLg>0dgFPp*LTD<5)B4~tTT^UwOKYW{d) zYxgmbQD|NDKif31yQf6YsM&3dOIVQj$Nbt z4RBsp_$lxiJ3QoNCVk8e$Xfz;&;kxo!4D;fnDX2G{MKZTBXIpMCLKP1qu3bEH}+*J znl~v3#y4Pi^T20j27?7mfZ^f?6(6_h2p@=TZp^Jd{L#L5UGdxQ_WH@|C(5#bf*$~| C+t1Sg diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_removal.h5 index 8b60044ad4970e7308d0c470c53382b9786ba745..5ee1d696d3ea0313cecd6169f335bf1b680e2041 100644 GIT binary patch delta 678 zcmcbxnCZe|rVR`F>JLi^MVy_)Z^r-yx@pS0PUXLX^IrtB{93|0!4@VT|DxmR)fpmi z`Psrz8xO`Wh4ZK8EY?5Ltpw-C37<5P^>Vb6Y>u!H+xO3w_j7ZKC$ENGkk*j{hwnSq z+uc@fknN55XM69g14Ad*HQTVpJn8QT6yXNg*RpTe)XHKHbAUVPGNC@70 zrCk%Q-h11+Wqwr$;C$_0U(QTkZ3yQt_3pMI&` zaXNHP%(PkkqBF03SL&wkwl2Jr4JY{5yIxISsmvw-H@{jaXSRgK2RMJLql=o;6GRC2 zUxWlwb1-Jo6UAEl4lYe+!4(MZ k_h>e4*MjqBY&-s9(ezLDYv(RBdcVA5^7@IgETHfQ0NjtqbN~PV delta 678 zcmcbxnCZe|rVR`F>gPxbMVy_)Z^r-y%Tkqhoyva&=NAUE{93|0!4@X}{&~mKt20F4 z^1{MV8xO`Wh4WQ%7V97BR)X_ogio5tdO6ztYmBfE+xO3Q+Nb6ePhJhXM6DwS4&QgI zw~J72knN55XWMz!fuWP@n(di}Jn8QT6yXL$)v|Bc)XHKHb3j-1DuIZSg>VNwPYB+7 zrCk%Q{^_=L%lxVi!1*VBemOIFwIQ6J@8e%K|BNq`FU-K8E0DBpgOwFrLHy*6{noBG zW-qqCus;9T({=-A%_)~Ap9xWQ_C8SDs3>9OZ1pVln3c7vbMAgKUHAM`PPztfKmAg> z<8=6(m}#^6MQ0xSuGCH6ZCwN=8&2@A-~HcObGfnr-2BOxYU8;~KEV0U5BkVo`iuzS zO-~{KT^-#;z7EYttk&ik?Qvs{?E zoxcE|QkRrdz1=FoTFWyF{@Ajuary6l`HHO#f8V#PNeXZS*cjZ(kKbj6hj92#x8PIU z3*aH_Xl4_vpCk)cZ~smEzm~y%IRC-bg!AXGAVN4-DQ1ho<1nbaAp^tWle|U8o6X=F la`+sbTjjOje51*`+u6>2vd>H37`3Q8Wb*onvMiwR2LPh1$VUJG diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_depletion_with_transfer.h5 index 11092aca6e1068573910661177b9f1aedd6aaf25..791447253c5a3d6626037f202ab67dab218303a7 100644 GIT binary patch delta 696 zcmcbxnCZe|rVR`F>K{uAMVy_)Z^r-yQ&N?8oyva&=Wh>Y`L%?1f-Ouw?M27at20F4 z@>#-B8xO`Wh4YJY7V97BR)X_&gio5tdO6x9H$_;8?fYjd^|?94lUKtoUhBw#!}lHQ z?M^5+$o5A3vz>X?fuWP@nypJ?p7i$vif{ui*RXHc)XHKHbHJzSRRR$u3*ippP7L0A zrCk%Q{`9tW%lxVi!1;Q=zMPr7+7Qk^1J!N5qy7rGfgoOW#fT-V&GY4MJU25`ReohL$DL|yH! zq<;C~wePR3`R_#Q(>3aLtkWKc9N=@Rw_ExrUf6xvKif>kfCd%OtF~t9?_xigBf>pq z&cZL-7+B%qu3)%jPHpJ|c(^-$n|QP0o-Eu#v-)VipK=G`{8uvfB!1p7g7cR=Y&vp4 xD;&z#Wneg=p{96sx;b3I9>2$J{%`f*e7l;P@$deBv=9D1ee&vwiY%ZQ003l3&+z~N delta 696 zcmcbxnCZe|rVR`F>UT;CMVy_)Z^r-y^HP;}oyva&=dTK8`L%?1f-Ouw;6=yNt20F4 z@~*;B8xO`Wh4UqI7V97BR)X`jgio5tdO6xfH$_;8?fYl@mk_-7 zO1mapeb=^i%lxVi!1*VCemOIFwIQ5u}k7!v)+_Tlh1^xI{O_cZd8=8a<+Sxdd$jN)j4dxnXY^O zDJLm|x1WBg-ElfRS#g5AplT%J3*C$#PA4~iu50epah^6gaDsk4|1v}V@8|j8w!A$q zQs~k74$j}AxI}bC4kFyA-FZ9B{f;nPepAbjT>b?s;QVtNuPoj%(E!d@Qg|V>Mby>q zx!lhmUi<#qswgL0pRQ52yZrxA$N@g5db^Fnal-D){@M2U1UIONUbUUO`giOHb40k$ z>)Z8Z8v`pm+(Vx4n^Rl503Pmv3pd=XxF-v@u;Nvn-%q)NaK6l^ClWtz7{U2+Z`+O> y&?f3)ve@_zE_iHa)`fAi;e^?YEI<|Z E06AC|82|tP delta 48 zcmcbxnCZe|rVVfUnKvw$IXTf)e&PioLB+KdE7z%CblzZ+VrTx>)`exW;e^?YEI<|Z E04A&zF#rGn diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_only_removal.h5 index 535f5d14387d0231f68133c19a6488c287d084ac..7a3b95c812c47c5bdf5f485f679015ea38c691e3 100644 GIT binary patch delta 48 zcmcbxnCZe|rVVfUnKxw2oSf(?Kk%zF%aKdax7N81y E03Fs8zW@LL delta 48 zcmcbxnCZe|rVVfUnI~A!nw;n=Kk%y|xaKdax7N81y E01?U*DF6Tf diff --git a/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 b/tests/regression_tests/deplete_with_transfer_rates/ref_no_depletion_with_transfer.h5 index 73f290aab629676059dc610bd7fa0045932cf656..7d68d1d5f8576fde9a5e227efe3d18136a6c629e 100644 GIT binary patch delta 48 zcmcbxnCZe|rVVfUnGd|kot)?@Kk%zF%aKdax7N81y E04?qnhX4Qo delta 48 zcmcbxnCZe|rVVfUnHlC}Oipx_pLjt?P;qU=%5~}&oi~`I*qQ&ebz#|TIAJy;3s8kU E00HI`X8-^I diff --git a/tests/regression_tests/deplete_with_transfer_rates/test.py b/tests/regression_tests/deplete_with_transfer_rates/test.py index 99f35a95bd..d6d58bbc03 100644 --- a/tests/regression_tests/deplete_with_transfer_rates/test.py +++ b/tests/regression_tests/deplete_with_transfer_rates/test.py @@ -2,6 +2,7 @@ from pathlib import Path import shutil +import sys import numpy as np import pytest @@ -45,6 +46,7 @@ def model(): return openmc.Model(geometry, materials, settings) +@pytest.mark.skipif(sys.version_info < (3, 9), reason="Requires Python 3.9+") @pytest.mark.parametrize("rate, dest_mat, power, ref_result", [ (1e-5, None, 0.0, 'no_depletion_only_removal'), (-1e-5, None, 0.0, 'no_depletion_only_feed'), diff --git a/tests/testing_harness.py b/tests/testing_harness.py index f0edf4ea44..40c9d37d80 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -181,7 +181,7 @@ class CMFDTestHarness(TestHarness): outstr += '\ncmfd openmc source comparison\n' outstr += '\n'.join(['{:.6E}'.format(x) for x in cmfd_run.src_cmp]) outstr += '\ncmfd source\n' - cmfdsrc = np.reshape(cmfd_run.cmfd_src, np.product(cmfd_run.indices), + cmfdsrc = np.reshape(cmfd_run.cmfd_src, np.prod(cmfd_run.indices), order='F') outstr += '\n'.join(['{:.6E}'.format(x) for x in cmfdsrc]) outstr += '\n'