29
29
_SECONDS_PER_DAY , _SECONDS_PER_JULIAN_YEAR
30
30
from .pool import deplete
31
31
from .reaction_rates import ReactionRates
32
- from .transfer_rates import TransferRates
32
+ from .transfer_rates import TransferRates , ExternalSourceRates
33
33
34
34
35
35
__all__ = [
@@ -607,9 +607,14 @@ class Integrator(ABC):
607
607
next time step. Expected to be of the same shape as ``n0``
608
608
609
609
transfer_rates : openmc.deplete.TransferRates
610
- Instance of TransferRates class to perform continuous transfer during depletion
610
+ Transfer rates for the depletion system used to model continuous
611
+ removal/feed between materials.
611
612
612
613
.. versionadded:: 0.14.0
614
+ external_source_rates : openmc.deplete.ExternalSourceRates
615
+ External source rates for the depletion system.
616
+
617
+ .. versionadded:: 0.15.3
613
618
614
619
"""
615
620
@@ -686,6 +691,7 @@ def __init__(
686
691
self .source_rates = np .asarray (source_rates )
687
692
688
693
self .transfer_rates = None
694
+ self .external_source_rates = None
689
695
690
696
if isinstance (solver , str ):
691
697
# Delay importing of cram module, which requires this file
@@ -731,11 +737,11 @@ def solver(self, func):
731
737
732
738
self ._solver = func
733
739
734
- def _timed_deplete (self , n , rates , dt , matrix_func = None ):
740
+ def _timed_deplete (self , n , rates , dt , i = None , matrix_func = None ):
735
741
start = time .time ()
736
742
results = deplete (
737
- self ._solver , self .chain , n , rates , dt , matrix_func ,
738
- self .transfer_rates )
743
+ self ._solver , self .chain , n , rates , dt , i , matrix_func ,
744
+ self .transfer_rates , self . external_source_rates )
739
745
return time .time () - start , results
740
746
741
747
@abstractmethod
@@ -885,13 +891,14 @@ def integrate(
885
891
self .operator .finalize ()
886
892
887
893
def add_transfer_rate (
888
- self ,
889
- material : Union [str , int , Material ],
890
- components : Sequence [str ],
891
- transfer_rate : float ,
892
- transfer_rate_units : str = '1/s' ,
893
- destination_material : Optional [Union [str , int , Material ]] = None
894
- ):
894
+ self ,
895
+ material : str | int | Material ,
896
+ components : Sequence [str ],
897
+ transfer_rate : float ,
898
+ transfer_rate_units : str = '1/s' ,
899
+ timesteps : Sequence [int ] | None = None ,
900
+ destination_material : str | int | Material | None = None
901
+ ):
895
902
"""Add transfer rates to depletable material.
896
903
897
904
Parameters
@@ -905,18 +912,79 @@ def add_transfer_rate(
905
912
transfer_rate : float
906
913
Rate at which elements are transferred. A positive or negative values
907
914
set removal of feed rates, respectively.
908
- destination_material : openmc.Material or str or int, Optional
909
- Destination material to where nuclides get fed.
910
915
transfer_rate_units : {'1/s', '1/min', '1/h', '1/d', '1/a'}
911
916
Units for values specified in the transfer_rate argument. 's' means
912
917
seconds, 'min' means minutes, 'h' means hours, 'a' means Julian years.
918
+ timesteps : list of int, optional
919
+ List of timestep indices where to set external source rates.
920
+ Defaults to None, which means the external source rate is set for
921
+ all timesteps.
922
+ destination_material : openmc.Material or str or int, Optional
923
+ Destination material to where nuclides get fed.
913
924
914
925
"""
915
926
if self .transfer_rates is None :
916
- self .transfer_rates = TransferRates (self .operator , self .operator .model )
927
+ if hasattr (self .operator , 'model' ):
928
+ materials = self .operator .model .materials
929
+ elif hasattr (self .operator , 'materials' ):
930
+ materials = self .operator .materials
931
+ self .transfer_rates = TransferRates (
932
+ self .operator , materials , len (self .timesteps ))
933
+
934
+ if self .external_source_rates is not None and destination_material :
935
+ raise ValueError ('Currently is not possible to set a transfer rate '
936
+ 'with destination matrial in combination with '
937
+ 'external source rates.' )
938
+
939
+ self .transfer_rates .set_transfer_rate (
940
+ material , components , transfer_rate , transfer_rate_units ,
941
+ timesteps , destination_material )
942
+
943
+ def add_external_source_rate (
944
+ self ,
945
+ material : str | int | Material ,
946
+ composition : dict [str , float ],
947
+ rate : float ,
948
+ rate_units : str = 'g/s' ,
949
+ timesteps : Sequence [int ] | None = None
950
+ ):
951
+ """Add external source rates to depletable material.
952
+
953
+ Parameters
954
+ ----------
955
+ material : openmc.Material or str or int
956
+ Depletable material
957
+ composition : dict of str to float
958
+ External source rate composition vector, where key can be an element
959
+ or a nuclide and value the corresponding weight percent.
960
+ rate : float
961
+ External source rate in units of mass per time. A positive or
962
+ negative value corresponds to a feed or removal rate, respectively.
963
+ units : {'g/s', 'g/min', 'g/h', 'g/d', 'g/a'}
964
+ Units for values specified in the `rate` argument. 's' for seconds,
965
+ 'min' for minutes, 'h' for hours, 'a' for Julian years.
966
+ timesteps : list of int, optional
967
+ List of timestep indices where to set external source rates.
968
+ Defaults to None, which means the external source rate is set for
969
+ all timesteps.
970
+
971
+ """
972
+ if self .external_source_rates is None :
973
+ if hasattr (self .operator , 'model' ):
974
+ materials = self .operator .model .materials
975
+ elif hasattr (self .operator , 'materials' ):
976
+ materials = self .operator .materials
977
+ self .external_source_rates = ExternalSourceRates (
978
+ self .operator , materials , len (self .timesteps ))
979
+
980
+ if self .transfer_rates is not None and self .transfer_rates .index_transfer :
981
+ raise ValueError ('Currently is not possible to set an external '
982
+ 'source rate in combination with transfer rates '
983
+ 'with destination matrial.' )
984
+
985
+ self .external_source_rates .set_external_source_rate (
986
+ material , composition , rate , rate_units , timesteps )
917
987
918
- self .transfer_rates .set_transfer_rate (material , components , transfer_rate ,
919
- transfer_rate_units , destination_material )
920
988
921
989
@add_params
922
990
class SIIntegrator (Integrator ):
@@ -1047,10 +1115,10 @@ def _get_bos_data_from_operator(self, step_index, step_power, n_bos):
1047
1115
return inherited
1048
1116
1049
1117
def integrate (
1050
- self ,
1051
- output : bool = True ,
1052
- path : PathLike = "depletion_results.h5"
1053
- ):
1118
+ self ,
1119
+ output : bool = True ,
1120
+ path : PathLike = "depletion_results.h5"
1121
+ ):
1054
1122
"""Perform the entire depletion process across all steps
1055
1123
1056
1124
Parameters
0 commit comments