summaryrefslogtreecommitdiff
path: root/python-radioactivedecay.spec
blob: d1a8aa1cdff325d9350f7ff6d41d9996d71e6c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
%global _empty_manifest_terminate_build 0
Name:		python-radioactivedecay
Version:	0.4.17
Release:	1
Summary:	A Python package for radioactive decay modelling that supports 1252 radionuclides, decay chains, branching, and metastable states.
License:	MIT, ICRP-07, AMDC
URL:		https://github.com/radioactivedecay/radioactivedecay
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/ab/7c/23154bc6417f4e41167729055362bbe31bfddf0dfc395b91880fc88b4398/radioactivedecay-0.4.17.tar.gz
BuildArch:	noarch

Requires:	python3-matplotlib
Requires:	python3-networkx
Requires:	python3-numpy
Requires:	python3-scipy
Requires:	python3-setuptools
Requires:	python3-sympy
Requires:	python3-importlib-resources

%description
<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/radioactivedecay.png" alt="radioactivedecay logo" width="500"/>

***

[![PyPI](https://img.shields.io/pypi/v/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Conda](https://img.shields.io/conda/v/conda-forge/radioactivedecay)](https://anaconda.org/conda-forge/radioactivedecay)
[![Python Version](https://img.shields.io/pypi/pyversions/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Latest Documentation](https://img.shields.io/badge/docs-latest-brightgreen)](https://radioactivedecay.github.io/)
[![Tests](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml/badge.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml)
[![Tests Coverage](https://codecov.io/gh/radioactivedecay/radioactivedecay/branch/master/graph/badge.svg?token=RX5HSELRYH)](https://codecov.io/gh/radioactivedecay/radioactivedecay)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/3_code_formatting.yml)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.03318/status.svg)](https://doi.org/10.21105/joss.03318)
[![Downloads](https://pepy.tech/badge/radioactivedecay)](https://pepy.tech/project/radioactivedecay)

``radioactivedecay`` is a Python package for radioactive decay calculations.
It supports decay chains of radionuclides, metastable states and branching
decays. By default it uses the decay data from ICRP Publication 107, which
contains 1252 radionuclides of 97 elements, and atomic mass data from the
Atomic Mass Data Center.

The code solves the radioactive decay differential equations analytically using
NumPy and SciPy linear algebra routines. There is also a high numerical
precision calculation mode employing SymPy routines. This gives more accurate
results for decay chains containing radionuclides with orders of magnitude
differences between the half-lives.

This is free-to-use open source software. It was created for engineers,
technicians and researchers who work with radioactivity, and for
educational use.

- **Full Documentation**: 
[https://radioactivedecay.github.io/](https://radioactivedecay.github.io/)


## Installation

``radioactivedecay`` requires Python 3.6+. Install ``radioactivedecay`` from
the [Python Package Index](https://pypi.org/project/radioactivedecay/) using
``pip``:

```console
$ pip install radioactivedecay
```

or from [conda-forge](https://anaconda.org/conda-forge/radioactivedecay):

```console
$ conda install -c conda-forge radioactivedecay
```

Either command will attempt to install the dependencies (Matplotlib, NetworkX,
NumPy, SciPy, Setuptools & SymPy) if they are not already present in the
environment.


## Usage

### Decay calculations

Create an ``Inventory`` of radionuclides and decay it as follows:

```pycon
>>> import radioactivedecay as rd
>>> Mo99_t0 = rd.Inventory({'Mo-99': 2.0}, 'Bq')
>>> Mo99_t1 = Mo99_t0.decay(20.0, 'h')
>>> Mo99_t1.activities('Bq')
{'Mo-99': 1.6207863893776937, 'Ru-99': 0.0,
 'Tc-99': 9.05304236308454e-09, 'Tc-99m': 1.3719829376710406}
```

An ``Inventory`` of 2.0 Bq of Mo-99 was decayed for 20 hours, producing the
radioactive progeny Tc-99m and Tc-99, and the stable nuclide Ru-99.

We supplied ``'h'`` as an argument to ``decay()`` to specify the decay time
period had units of hours. Supported time units include ``'μs'``, ``'ms'``,
``'s'``, ``'m'``, ``'h'``, ``'d'``, ``'y'`` etc. Note seconds (``'s'``) is the
default if no unit is supplied to ``decay()``.

Use `cumulative_decays()` to calculate the total number of atoms of each
radionuclide that decay over the decay time period:

```pycon
>>> Mo99_t0.cumulative_decays(20.0, 'h')
{'Mo-99': 129870.3165339939, 'Tc-99m': 71074.31925850797,
'Tc-99': 0.0002724635511147602}
```

Radionuclides can be specified in four equivalent ways in ``radioactivedecay``:
three variations of nuclide strings or by
[canonical ids](https://pyne.io/usersguide/nucname.html). For example, the
following are equivalent ways of specifying <sup>222</sup>Rn and
<sup>192n</sup>Ir:

* ``'Rn-222'``, ``'Rn222'``, ``'222Rn'``, ``862220000``,
* ``'Ir-192n'``, ``'Ir192n'``, ``'192nIr'``, ``771920002``.

Inventories can be created by supplying activity (``'Bq'``, ``'Ci'``,
``'dpm'``...), mass (``'g'``, ``'kg'``...), mole (``'mol'``, ``'kmol'``...)
units, or numbers of nuclei (``'num'``) to the ``Inventory()`` constructor. Use
the methods ``activities()``, ``masses()``, ``moles()``, ``numbers()``,
``activity_fractions()``, ``mass_fractions()`` and ``mole_fractions()`` to
obtain the contents of the inventory in different formats:

```pycon
>>> H3_t0 = rd.Inventory({'H-3': 3.0}, 'g')
>>> H3_t1 = H3_t0.decay(12.32, 'y')
>>> H3_t1.masses('g')
{'H-3': 1.5, 'He-3': 1.4999900734297729}
>>> H3_t1.mass_fractions()
{'H-3': 0.5000016544338455, 'He-3': 0.4999983455661545}

>>> C14_t0 = rd.Inventory({'C-14': 3.2E24}, 'num')
>>> C14_t1 = C14_t0.decay(3000, 'y')
>>> C14_t1.moles('mol')
{'C-14': 3.6894551567795797, 'N-14': 1.6242698581767292}
>>> C14_t1.mole_fractions()
{'C-14': 0.6943255713073281, 'N-14': 0.3056744286926719}
```


### Plotting decay graphs

Use the ``plot()`` method to graph of the decay of an inventory over time:

```pycon
>>> Mo99_t0.plot(20, 'd', yunits='Bq')
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_decay.png" alt="Mo-99 decay graph" width="450"/>

The graph shows the decay of Mo-99 over 20 days, leading to the ingrowth of
Tc-99m and a trace quantity of Tc-99. The activity of Ru-99 is strictly zero as
it is the stable nuclide at the end of the decay chain. Graphs are drawn using
Matplotlib.


### Fetching decay data

The ``Nuclide`` class can be used to fetch decay information for
individual radionuclides, e.g. for Rn-222:

```pycon
>>> nuc = rd.Nuclide('Rn-222')
>>> nuc.half_life('s')
330350.4
>>> nuc.half_life('readable')
'3.8235 d'
>>> nuc.progeny()
['Po-218']
>>> nuc.branching_fractions()
[1.0]
>>> nuc.decay_modes()
['α']
>>> nuc.Z  # proton number
86
>>> nuc.A  # nucleon number
222
>>> nuc.atomic_mass  # atomic mass in g/mol
222.01757601699998
```

There are similar inventory methods for fetching decay data:

```pycon
>>> Mo99_t1.half_lives('readable')
{'Mo-99': '65.94 h', 'Ru-99': 'stable', 'Tc-99': '0.2111 My', 'Tc-99m': '6.015 h'}
>>> Mo99_t1.progeny()
{'Mo-99': ['Tc-99m', 'Tc-99'], 'Ru-99': [], 'Tc-99': ['Ru-99'], 'Tc-99m': ['Tc-99', 'Ru-99']}
>>> Mo99_t1.branching_fractions()
{'Mo-99': [0.8773, 0.1227], 'Ru-99': [], 'Tc-99': [1.0], 'Tc-99m': [0.99996, 3.7e-05]}
>>> Mo99_t1.decay_modes()
{'Mo-99': ['β-', 'β-'], 'Ru-99': [], 'Tc-99': ['β-'], 'Tc-99m': ['IT', 'β-']}
```


### Decay chain diagrams

The ``Nuclide`` class includes a `plot()` method for drawing decay chain
diagrams:

```pycon
>>> nuc = rd.Nuclide('Mo-99')
>>> nuc.plot()
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_chain.png" alt="Mo-99 decay chain" width="300"/>

These diagrams are drawn using NetworkX and Matplotlib.


### High numerical precision decay calculations

``radioactivedecay`` includes an ``InventoryHP`` class for high numerical
precision calculations. This class can give more reliable decay calculation
results for chains containing long- and short-lived radionuclides:

```pycon
>>> U238_t0 = rd.InventoryHP({'U-238': 1.0})
>>> U238_t1 = U238_t0.decay(10.0, 'd')
>>> U238_t1.activities()
{'At-218': 1.4511675857141352e-25,
 'Bi-210': 1.8093327888942224e-26,
 'Bi-214': 7.09819414496093e-22,
 'Hg-206': 1.9873081129046843e-33,
 'Pa-234': 0.00038581180879502017,
 'Pa-234m': 0.24992285949158477,
 'Pb-206': 0.0,
 'Pb-210': 1.0508864357335218e-25,
 'Pb-214': 7.163682655782086e-22,
 'Po-210': 1.171277829871092e-28,
 'Po-214': 7.096704966148592e-22,
 'Po-218': 7.255923469955255e-22,
 'Ra-226': 2.6127168262000313e-21,
 'Rn-218': 1.4511671865210924e-28,
 'Rn-222': 7.266530698712501e-22,
 'Th-230': 8.690585458641225e-16,
 'Th-234': 0.2499481473619856,
 'Tl-206': 2.579902288672889e-32,
 'Tl-210': 1.4897029111914831e-25,
 'U-234': 1.0119788393651999e-08,
 'U-238': 0.9999999999957525}
```


## How radioactivedecay works

``radioactivedecay`` calculates an analytical solution to the radioactive decay
differential equations using linear algebra operations. It implements the
method described in this paper:
[M Amaku, PR Pascholati & VR Vanin, Comp. Phys. Comm. 181, 21-23
(2010)](https://doi.org/10.1016/j.cpc.2009.08.011). See the
[theory docpage](https://radioactivedecay.github.io/theory.html) for more
details.

It uses NumPy and SciPy routines for standard decay calculations
(double-precision floating-point operations), and SymPy for arbitrary numerical
precision calculations.

By default ``radioactivedecay`` uses decay data from
[ICRP Publication 107
(2008)](https://journals.sagepub.com/doi/pdf/10.1177/ANIB_38_3) and atomic mass
data from the [Atomic Mass Data Center](https://www-nds.iaea.org/amdc/)
(AMDC - AME2020 and Nubase2020 evaluations).

The [datasets repo](https://github.com/radioactivedecay/datasets) contains
Jupyter Notebooks for creating decay datasets that can be used by
``radioactivedecay``, e.g. [ICRP
107](https://github.com/radioactivedecay/datasets/blob/main/icrp107_ame2020_nubase2020/icrp107_dataset.ipynb).

The [comparisons repo](https://github.com/radioactivedecay/comparisons)
contains some checks of ``radioactivedecay`` against
[PyNE](https://github.com/radioactivedecay/comparisons/blob/main/pyne/rd_pyne_truncated_compare.ipynb)
and [Radiological
Toolbox](https://github.com/radioactivedecay/comparisons/blob/main/radiological_toolbox/radiological_toolbox_compare.ipynb).


## Tests

From the base directory run:

```console
$ python -m unittest discover
```


## License

``radioactivedecay`` is open source software released under the MIT License.
See [LICENSE](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE)
file for details.

The default decay data used by ``radioactivedecay`` (ICRP-107) is copyright
2008 A. Endo and K.F. Eckerman and distributed under a separate
[license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.ICRP-07).
The default atomic mass data is from AMDC
([license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.AMDC)).


## Citation

If you find this package useful for your research, please consider citing the
paper on ``radioactivedecay`` published in the
[Journal of Open Source Software](https://doi.org/10.21105/joss.03318):

> Alex Malins & Thom Lemoine, *radioactivedecay: A Python package for radioactive decay
calculations*. Journal of Open Source Software, **7** (71), 3318 (2022). DOI:
[10.21105/joss.03318](https://doi.org/10.21105/joss.03318).


## Contributing

Contributors are welcome to fix bugs, add new features or make feature
requests. Please open an Issue, Pull Request or new Discussions thread at
[GitHub repository](https://github.com/radioactivedecay/radioactivedecay).

Please read the
[contribution guidelines](https://github.com/radioactivedecay/radioactivedecay/blob/main/CONTRIBUTING.md).





%package -n python3-radioactivedecay
Summary:	A Python package for radioactive decay modelling that supports 1252 radionuclides, decay chains, branching, and metastable states.
Provides:	python-radioactivedecay
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-radioactivedecay
<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/radioactivedecay.png" alt="radioactivedecay logo" width="500"/>

***

[![PyPI](https://img.shields.io/pypi/v/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Conda](https://img.shields.io/conda/v/conda-forge/radioactivedecay)](https://anaconda.org/conda-forge/radioactivedecay)
[![Python Version](https://img.shields.io/pypi/pyversions/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Latest Documentation](https://img.shields.io/badge/docs-latest-brightgreen)](https://radioactivedecay.github.io/)
[![Tests](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml/badge.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml)
[![Tests Coverage](https://codecov.io/gh/radioactivedecay/radioactivedecay/branch/master/graph/badge.svg?token=RX5HSELRYH)](https://codecov.io/gh/radioactivedecay/radioactivedecay)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/3_code_formatting.yml)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.03318/status.svg)](https://doi.org/10.21105/joss.03318)
[![Downloads](https://pepy.tech/badge/radioactivedecay)](https://pepy.tech/project/radioactivedecay)

``radioactivedecay`` is a Python package for radioactive decay calculations.
It supports decay chains of radionuclides, metastable states and branching
decays. By default it uses the decay data from ICRP Publication 107, which
contains 1252 radionuclides of 97 elements, and atomic mass data from the
Atomic Mass Data Center.

The code solves the radioactive decay differential equations analytically using
NumPy and SciPy linear algebra routines. There is also a high numerical
precision calculation mode employing SymPy routines. This gives more accurate
results for decay chains containing radionuclides with orders of magnitude
differences between the half-lives.

This is free-to-use open source software. It was created for engineers,
technicians and researchers who work with radioactivity, and for
educational use.

- **Full Documentation**: 
[https://radioactivedecay.github.io/](https://radioactivedecay.github.io/)


## Installation

``radioactivedecay`` requires Python 3.6+. Install ``radioactivedecay`` from
the [Python Package Index](https://pypi.org/project/radioactivedecay/) using
``pip``:

```console
$ pip install radioactivedecay
```

or from [conda-forge](https://anaconda.org/conda-forge/radioactivedecay):

```console
$ conda install -c conda-forge radioactivedecay
```

Either command will attempt to install the dependencies (Matplotlib, NetworkX,
NumPy, SciPy, Setuptools & SymPy) if they are not already present in the
environment.


## Usage

### Decay calculations

Create an ``Inventory`` of radionuclides and decay it as follows:

```pycon
>>> import radioactivedecay as rd
>>> Mo99_t0 = rd.Inventory({'Mo-99': 2.0}, 'Bq')
>>> Mo99_t1 = Mo99_t0.decay(20.0, 'h')
>>> Mo99_t1.activities('Bq')
{'Mo-99': 1.6207863893776937, 'Ru-99': 0.0,
 'Tc-99': 9.05304236308454e-09, 'Tc-99m': 1.3719829376710406}
```

An ``Inventory`` of 2.0 Bq of Mo-99 was decayed for 20 hours, producing the
radioactive progeny Tc-99m and Tc-99, and the stable nuclide Ru-99.

We supplied ``'h'`` as an argument to ``decay()`` to specify the decay time
period had units of hours. Supported time units include ``'μs'``, ``'ms'``,
``'s'``, ``'m'``, ``'h'``, ``'d'``, ``'y'`` etc. Note seconds (``'s'``) is the
default if no unit is supplied to ``decay()``.

Use `cumulative_decays()` to calculate the total number of atoms of each
radionuclide that decay over the decay time period:

```pycon
>>> Mo99_t0.cumulative_decays(20.0, 'h')
{'Mo-99': 129870.3165339939, 'Tc-99m': 71074.31925850797,
'Tc-99': 0.0002724635511147602}
```

Radionuclides can be specified in four equivalent ways in ``radioactivedecay``:
three variations of nuclide strings or by
[canonical ids](https://pyne.io/usersguide/nucname.html). For example, the
following are equivalent ways of specifying <sup>222</sup>Rn and
<sup>192n</sup>Ir:

* ``'Rn-222'``, ``'Rn222'``, ``'222Rn'``, ``862220000``,
* ``'Ir-192n'``, ``'Ir192n'``, ``'192nIr'``, ``771920002``.

Inventories can be created by supplying activity (``'Bq'``, ``'Ci'``,
``'dpm'``...), mass (``'g'``, ``'kg'``...), mole (``'mol'``, ``'kmol'``...)
units, or numbers of nuclei (``'num'``) to the ``Inventory()`` constructor. Use
the methods ``activities()``, ``masses()``, ``moles()``, ``numbers()``,
``activity_fractions()``, ``mass_fractions()`` and ``mole_fractions()`` to
obtain the contents of the inventory in different formats:

```pycon
>>> H3_t0 = rd.Inventory({'H-3': 3.0}, 'g')
>>> H3_t1 = H3_t0.decay(12.32, 'y')
>>> H3_t1.masses('g')
{'H-3': 1.5, 'He-3': 1.4999900734297729}
>>> H3_t1.mass_fractions()
{'H-3': 0.5000016544338455, 'He-3': 0.4999983455661545}

>>> C14_t0 = rd.Inventory({'C-14': 3.2E24}, 'num')
>>> C14_t1 = C14_t0.decay(3000, 'y')
>>> C14_t1.moles('mol')
{'C-14': 3.6894551567795797, 'N-14': 1.6242698581767292}
>>> C14_t1.mole_fractions()
{'C-14': 0.6943255713073281, 'N-14': 0.3056744286926719}
```


### Plotting decay graphs

Use the ``plot()`` method to graph of the decay of an inventory over time:

```pycon
>>> Mo99_t0.plot(20, 'd', yunits='Bq')
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_decay.png" alt="Mo-99 decay graph" width="450"/>

The graph shows the decay of Mo-99 over 20 days, leading to the ingrowth of
Tc-99m and a trace quantity of Tc-99. The activity of Ru-99 is strictly zero as
it is the stable nuclide at the end of the decay chain. Graphs are drawn using
Matplotlib.


### Fetching decay data

The ``Nuclide`` class can be used to fetch decay information for
individual radionuclides, e.g. for Rn-222:

```pycon
>>> nuc = rd.Nuclide('Rn-222')
>>> nuc.half_life('s')
330350.4
>>> nuc.half_life('readable')
'3.8235 d'
>>> nuc.progeny()
['Po-218']
>>> nuc.branching_fractions()
[1.0]
>>> nuc.decay_modes()
['α']
>>> nuc.Z  # proton number
86
>>> nuc.A  # nucleon number
222
>>> nuc.atomic_mass  # atomic mass in g/mol
222.01757601699998
```

There are similar inventory methods for fetching decay data:

```pycon
>>> Mo99_t1.half_lives('readable')
{'Mo-99': '65.94 h', 'Ru-99': 'stable', 'Tc-99': '0.2111 My', 'Tc-99m': '6.015 h'}
>>> Mo99_t1.progeny()
{'Mo-99': ['Tc-99m', 'Tc-99'], 'Ru-99': [], 'Tc-99': ['Ru-99'], 'Tc-99m': ['Tc-99', 'Ru-99']}
>>> Mo99_t1.branching_fractions()
{'Mo-99': [0.8773, 0.1227], 'Ru-99': [], 'Tc-99': [1.0], 'Tc-99m': [0.99996, 3.7e-05]}
>>> Mo99_t1.decay_modes()
{'Mo-99': ['β-', 'β-'], 'Ru-99': [], 'Tc-99': ['β-'], 'Tc-99m': ['IT', 'β-']}
```


### Decay chain diagrams

The ``Nuclide`` class includes a `plot()` method for drawing decay chain
diagrams:

```pycon
>>> nuc = rd.Nuclide('Mo-99')
>>> nuc.plot()
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_chain.png" alt="Mo-99 decay chain" width="300"/>

These diagrams are drawn using NetworkX and Matplotlib.


### High numerical precision decay calculations

``radioactivedecay`` includes an ``InventoryHP`` class for high numerical
precision calculations. This class can give more reliable decay calculation
results for chains containing long- and short-lived radionuclides:

```pycon
>>> U238_t0 = rd.InventoryHP({'U-238': 1.0})
>>> U238_t1 = U238_t0.decay(10.0, 'd')
>>> U238_t1.activities()
{'At-218': 1.4511675857141352e-25,
 'Bi-210': 1.8093327888942224e-26,
 'Bi-214': 7.09819414496093e-22,
 'Hg-206': 1.9873081129046843e-33,
 'Pa-234': 0.00038581180879502017,
 'Pa-234m': 0.24992285949158477,
 'Pb-206': 0.0,
 'Pb-210': 1.0508864357335218e-25,
 'Pb-214': 7.163682655782086e-22,
 'Po-210': 1.171277829871092e-28,
 'Po-214': 7.096704966148592e-22,
 'Po-218': 7.255923469955255e-22,
 'Ra-226': 2.6127168262000313e-21,
 'Rn-218': 1.4511671865210924e-28,
 'Rn-222': 7.266530698712501e-22,
 'Th-230': 8.690585458641225e-16,
 'Th-234': 0.2499481473619856,
 'Tl-206': 2.579902288672889e-32,
 'Tl-210': 1.4897029111914831e-25,
 'U-234': 1.0119788393651999e-08,
 'U-238': 0.9999999999957525}
```


## How radioactivedecay works

``radioactivedecay`` calculates an analytical solution to the radioactive decay
differential equations using linear algebra operations. It implements the
method described in this paper:
[M Amaku, PR Pascholati & VR Vanin, Comp. Phys. Comm. 181, 21-23
(2010)](https://doi.org/10.1016/j.cpc.2009.08.011). See the
[theory docpage](https://radioactivedecay.github.io/theory.html) for more
details.

It uses NumPy and SciPy routines for standard decay calculations
(double-precision floating-point operations), and SymPy for arbitrary numerical
precision calculations.

By default ``radioactivedecay`` uses decay data from
[ICRP Publication 107
(2008)](https://journals.sagepub.com/doi/pdf/10.1177/ANIB_38_3) and atomic mass
data from the [Atomic Mass Data Center](https://www-nds.iaea.org/amdc/)
(AMDC - AME2020 and Nubase2020 evaluations).

The [datasets repo](https://github.com/radioactivedecay/datasets) contains
Jupyter Notebooks for creating decay datasets that can be used by
``radioactivedecay``, e.g. [ICRP
107](https://github.com/radioactivedecay/datasets/blob/main/icrp107_ame2020_nubase2020/icrp107_dataset.ipynb).

The [comparisons repo](https://github.com/radioactivedecay/comparisons)
contains some checks of ``radioactivedecay`` against
[PyNE](https://github.com/radioactivedecay/comparisons/blob/main/pyne/rd_pyne_truncated_compare.ipynb)
and [Radiological
Toolbox](https://github.com/radioactivedecay/comparisons/blob/main/radiological_toolbox/radiological_toolbox_compare.ipynb).


## Tests

From the base directory run:

```console
$ python -m unittest discover
```


## License

``radioactivedecay`` is open source software released under the MIT License.
See [LICENSE](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE)
file for details.

The default decay data used by ``radioactivedecay`` (ICRP-107) is copyright
2008 A. Endo and K.F. Eckerman and distributed under a separate
[license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.ICRP-07).
The default atomic mass data is from AMDC
([license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.AMDC)).


## Citation

If you find this package useful for your research, please consider citing the
paper on ``radioactivedecay`` published in the
[Journal of Open Source Software](https://doi.org/10.21105/joss.03318):

> Alex Malins & Thom Lemoine, *radioactivedecay: A Python package for radioactive decay
calculations*. Journal of Open Source Software, **7** (71), 3318 (2022). DOI:
[10.21105/joss.03318](https://doi.org/10.21105/joss.03318).


## Contributing

Contributors are welcome to fix bugs, add new features or make feature
requests. Please open an Issue, Pull Request or new Discussions thread at
[GitHub repository](https://github.com/radioactivedecay/radioactivedecay).

Please read the
[contribution guidelines](https://github.com/radioactivedecay/radioactivedecay/blob/main/CONTRIBUTING.md).





%package help
Summary:	Development documents and examples for radioactivedecay
Provides:	python3-radioactivedecay-doc
%description help
<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/radioactivedecay.png" alt="radioactivedecay logo" width="500"/>

***

[![PyPI](https://img.shields.io/pypi/v/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Conda](https://img.shields.io/conda/v/conda-forge/radioactivedecay)](https://anaconda.org/conda-forge/radioactivedecay)
[![Python Version](https://img.shields.io/pypi/pyversions/radioactivedecay)](https://pypi.org/project/radioactivedecay/)
[![Latest Documentation](https://img.shields.io/badge/docs-latest-brightgreen)](https://radioactivedecay.github.io/)
[![Tests](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml/badge.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/1_tests.yml)
[![Tests Coverage](https://codecov.io/gh/radioactivedecay/radioactivedecay/branch/master/graph/badge.svg?token=RX5HSELRYH)](https://codecov.io/gh/radioactivedecay/radioactivedecay)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/radioactivedecay/radioactivedecay/actions/workflows/3_code_formatting.yml)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.03318/status.svg)](https://doi.org/10.21105/joss.03318)
[![Downloads](https://pepy.tech/badge/radioactivedecay)](https://pepy.tech/project/radioactivedecay)

``radioactivedecay`` is a Python package for radioactive decay calculations.
It supports decay chains of radionuclides, metastable states and branching
decays. By default it uses the decay data from ICRP Publication 107, which
contains 1252 radionuclides of 97 elements, and atomic mass data from the
Atomic Mass Data Center.

The code solves the radioactive decay differential equations analytically using
NumPy and SciPy linear algebra routines. There is also a high numerical
precision calculation mode employing SymPy routines. This gives more accurate
results for decay chains containing radionuclides with orders of magnitude
differences between the half-lives.

This is free-to-use open source software. It was created for engineers,
technicians and researchers who work with radioactivity, and for
educational use.

- **Full Documentation**: 
[https://radioactivedecay.github.io/](https://radioactivedecay.github.io/)


## Installation

``radioactivedecay`` requires Python 3.6+. Install ``radioactivedecay`` from
the [Python Package Index](https://pypi.org/project/radioactivedecay/) using
``pip``:

```console
$ pip install radioactivedecay
```

or from [conda-forge](https://anaconda.org/conda-forge/radioactivedecay):

```console
$ conda install -c conda-forge radioactivedecay
```

Either command will attempt to install the dependencies (Matplotlib, NetworkX,
NumPy, SciPy, Setuptools & SymPy) if they are not already present in the
environment.


## Usage

### Decay calculations

Create an ``Inventory`` of radionuclides and decay it as follows:

```pycon
>>> import radioactivedecay as rd
>>> Mo99_t0 = rd.Inventory({'Mo-99': 2.0}, 'Bq')
>>> Mo99_t1 = Mo99_t0.decay(20.0, 'h')
>>> Mo99_t1.activities('Bq')
{'Mo-99': 1.6207863893776937, 'Ru-99': 0.0,
 'Tc-99': 9.05304236308454e-09, 'Tc-99m': 1.3719829376710406}
```

An ``Inventory`` of 2.0 Bq of Mo-99 was decayed for 20 hours, producing the
radioactive progeny Tc-99m and Tc-99, and the stable nuclide Ru-99.

We supplied ``'h'`` as an argument to ``decay()`` to specify the decay time
period had units of hours. Supported time units include ``'μs'``, ``'ms'``,
``'s'``, ``'m'``, ``'h'``, ``'d'``, ``'y'`` etc. Note seconds (``'s'``) is the
default if no unit is supplied to ``decay()``.

Use `cumulative_decays()` to calculate the total number of atoms of each
radionuclide that decay over the decay time period:

```pycon
>>> Mo99_t0.cumulative_decays(20.0, 'h')
{'Mo-99': 129870.3165339939, 'Tc-99m': 71074.31925850797,
'Tc-99': 0.0002724635511147602}
```

Radionuclides can be specified in four equivalent ways in ``radioactivedecay``:
three variations of nuclide strings or by
[canonical ids](https://pyne.io/usersguide/nucname.html). For example, the
following are equivalent ways of specifying <sup>222</sup>Rn and
<sup>192n</sup>Ir:

* ``'Rn-222'``, ``'Rn222'``, ``'222Rn'``, ``862220000``,
* ``'Ir-192n'``, ``'Ir192n'``, ``'192nIr'``, ``771920002``.

Inventories can be created by supplying activity (``'Bq'``, ``'Ci'``,
``'dpm'``...), mass (``'g'``, ``'kg'``...), mole (``'mol'``, ``'kmol'``...)
units, or numbers of nuclei (``'num'``) to the ``Inventory()`` constructor. Use
the methods ``activities()``, ``masses()``, ``moles()``, ``numbers()``,
``activity_fractions()``, ``mass_fractions()`` and ``mole_fractions()`` to
obtain the contents of the inventory in different formats:

```pycon
>>> H3_t0 = rd.Inventory({'H-3': 3.0}, 'g')
>>> H3_t1 = H3_t0.decay(12.32, 'y')
>>> H3_t1.masses('g')
{'H-3': 1.5, 'He-3': 1.4999900734297729}
>>> H3_t1.mass_fractions()
{'H-3': 0.5000016544338455, 'He-3': 0.4999983455661545}

>>> C14_t0 = rd.Inventory({'C-14': 3.2E24}, 'num')
>>> C14_t1 = C14_t0.decay(3000, 'y')
>>> C14_t1.moles('mol')
{'C-14': 3.6894551567795797, 'N-14': 1.6242698581767292}
>>> C14_t1.mole_fractions()
{'C-14': 0.6943255713073281, 'N-14': 0.3056744286926719}
```


### Plotting decay graphs

Use the ``plot()`` method to graph of the decay of an inventory over time:

```pycon
>>> Mo99_t0.plot(20, 'd', yunits='Bq')
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_decay.png" alt="Mo-99 decay graph" width="450"/>

The graph shows the decay of Mo-99 over 20 days, leading to the ingrowth of
Tc-99m and a trace quantity of Tc-99. The activity of Ru-99 is strictly zero as
it is the stable nuclide at the end of the decay chain. Graphs are drawn using
Matplotlib.


### Fetching decay data

The ``Nuclide`` class can be used to fetch decay information for
individual radionuclides, e.g. for Rn-222:

```pycon
>>> nuc = rd.Nuclide('Rn-222')
>>> nuc.half_life('s')
330350.4
>>> nuc.half_life('readable')
'3.8235 d'
>>> nuc.progeny()
['Po-218']
>>> nuc.branching_fractions()
[1.0]
>>> nuc.decay_modes()
['α']
>>> nuc.Z  # proton number
86
>>> nuc.A  # nucleon number
222
>>> nuc.atomic_mass  # atomic mass in g/mol
222.01757601699998
```

There are similar inventory methods for fetching decay data:

```pycon
>>> Mo99_t1.half_lives('readable')
{'Mo-99': '65.94 h', 'Ru-99': 'stable', 'Tc-99': '0.2111 My', 'Tc-99m': '6.015 h'}
>>> Mo99_t1.progeny()
{'Mo-99': ['Tc-99m', 'Tc-99'], 'Ru-99': [], 'Tc-99': ['Ru-99'], 'Tc-99m': ['Tc-99', 'Ru-99']}
>>> Mo99_t1.branching_fractions()
{'Mo-99': [0.8773, 0.1227], 'Ru-99': [], 'Tc-99': [1.0], 'Tc-99m': [0.99996, 3.7e-05]}
>>> Mo99_t1.decay_modes()
{'Mo-99': ['β-', 'β-'], 'Ru-99': [], 'Tc-99': ['β-'], 'Tc-99m': ['IT', 'β-']}
```


### Decay chain diagrams

The ``Nuclide`` class includes a `plot()` method for drawing decay chain
diagrams:

```pycon
>>> nuc = rd.Nuclide('Mo-99')
>>> nuc.plot()
```

<img src="https://raw.githubusercontent.com/radioactivedecay/radioactivedecay/main/docs/source/images/Mo-99_chain.png" alt="Mo-99 decay chain" width="300"/>

These diagrams are drawn using NetworkX and Matplotlib.


### High numerical precision decay calculations

``radioactivedecay`` includes an ``InventoryHP`` class for high numerical
precision calculations. This class can give more reliable decay calculation
results for chains containing long- and short-lived radionuclides:

```pycon
>>> U238_t0 = rd.InventoryHP({'U-238': 1.0})
>>> U238_t1 = U238_t0.decay(10.0, 'd')
>>> U238_t1.activities()
{'At-218': 1.4511675857141352e-25,
 'Bi-210': 1.8093327888942224e-26,
 'Bi-214': 7.09819414496093e-22,
 'Hg-206': 1.9873081129046843e-33,
 'Pa-234': 0.00038581180879502017,
 'Pa-234m': 0.24992285949158477,
 'Pb-206': 0.0,
 'Pb-210': 1.0508864357335218e-25,
 'Pb-214': 7.163682655782086e-22,
 'Po-210': 1.171277829871092e-28,
 'Po-214': 7.096704966148592e-22,
 'Po-218': 7.255923469955255e-22,
 'Ra-226': 2.6127168262000313e-21,
 'Rn-218': 1.4511671865210924e-28,
 'Rn-222': 7.266530698712501e-22,
 'Th-230': 8.690585458641225e-16,
 'Th-234': 0.2499481473619856,
 'Tl-206': 2.579902288672889e-32,
 'Tl-210': 1.4897029111914831e-25,
 'U-234': 1.0119788393651999e-08,
 'U-238': 0.9999999999957525}
```


## How radioactivedecay works

``radioactivedecay`` calculates an analytical solution to the radioactive decay
differential equations using linear algebra operations. It implements the
method described in this paper:
[M Amaku, PR Pascholati & VR Vanin, Comp. Phys. Comm. 181, 21-23
(2010)](https://doi.org/10.1016/j.cpc.2009.08.011). See the
[theory docpage](https://radioactivedecay.github.io/theory.html) for more
details.

It uses NumPy and SciPy routines for standard decay calculations
(double-precision floating-point operations), and SymPy for arbitrary numerical
precision calculations.

By default ``radioactivedecay`` uses decay data from
[ICRP Publication 107
(2008)](https://journals.sagepub.com/doi/pdf/10.1177/ANIB_38_3) and atomic mass
data from the [Atomic Mass Data Center](https://www-nds.iaea.org/amdc/)
(AMDC - AME2020 and Nubase2020 evaluations).

The [datasets repo](https://github.com/radioactivedecay/datasets) contains
Jupyter Notebooks for creating decay datasets that can be used by
``radioactivedecay``, e.g. [ICRP
107](https://github.com/radioactivedecay/datasets/blob/main/icrp107_ame2020_nubase2020/icrp107_dataset.ipynb).

The [comparisons repo](https://github.com/radioactivedecay/comparisons)
contains some checks of ``radioactivedecay`` against
[PyNE](https://github.com/radioactivedecay/comparisons/blob/main/pyne/rd_pyne_truncated_compare.ipynb)
and [Radiological
Toolbox](https://github.com/radioactivedecay/comparisons/blob/main/radiological_toolbox/radiological_toolbox_compare.ipynb).


## Tests

From the base directory run:

```console
$ python -m unittest discover
```


## License

``radioactivedecay`` is open source software released under the MIT License.
See [LICENSE](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE)
file for details.

The default decay data used by ``radioactivedecay`` (ICRP-107) is copyright
2008 A. Endo and K.F. Eckerman and distributed under a separate
[license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.ICRP-07).
The default atomic mass data is from AMDC
([license](https://github.com/radioactivedecay/radioactivedecay/blob/main/LICENSE.AMDC)).


## Citation

If you find this package useful for your research, please consider citing the
paper on ``radioactivedecay`` published in the
[Journal of Open Source Software](https://doi.org/10.21105/joss.03318):

> Alex Malins & Thom Lemoine, *radioactivedecay: A Python package for radioactive decay
calculations*. Journal of Open Source Software, **7** (71), 3318 (2022). DOI:
[10.21105/joss.03318](https://doi.org/10.21105/joss.03318).


## Contributing

Contributors are welcome to fix bugs, add new features or make feature
requests. Please open an Issue, Pull Request or new Discussions thread at
[GitHub repository](https://github.com/radioactivedecay/radioactivedecay).

Please read the
[contribution guidelines](https://github.com/radioactivedecay/radioactivedecay/blob/main/CONTRIBUTING.md).





%prep
%autosetup -n radioactivedecay-0.4.17

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-radioactivedecay -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.17-1
- Package Spec generated