-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNuclideClassesMin.pas
4817 lines (4578 loc) · 147 KB
/
NuclideClassesMin.pas
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
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit NuclideClassesMin;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
{$IFnDEF FPC}
Windows,
{$ELSE}
LCLIntf, LCLType, // LMessages,
{$ENDIF}
Classes, Graphics, Forms, ComCtrls, EuLibMin;
type
// TChainOption = DWORD;
// TNuclideType = (ntStable, ntWithMetastableState, ntPrimordial, ntUnstable, ntUnknown);
TNuclideGraphicType = (ngtMeta, ngtBitmap);
TDecayType = (dtNone, dtA, dtBM, dtEC, dtIT, dtN, dtP, dtSF, dtQ);
TNuclideTransition = (ntCapture, ntFission, ntDecay, ntThreshold);
TNuclideTransitions = set of TNuclideTransition;
const
AllNuclideTransitions: TNuclideTransitions = [ntCapture, ntDecay, ntFission, ntThreshold];
intMaxNuclideN = 177;
intMaxNuclideZ = 119;
type
TDecayTypes = set of TDecayType;
TDecay = record
DecayType: TDecayType;
Branching: double;
end;
PDecay = ^TDecay;
TSubBranching = record
DecayType: TDecayType;
BranchingToG: double;
BranchingToM1: double;
BranchingToM2: double;
end;
PSubBranching = ^TSubBranching;
// add
TSubBranchingList = class;
TSubBranchingRecordList = class;
TSubBranchingRecord = record
ThZpA_s: integer;
DecayType: TDecayType;
BranchingToG: double;
BranchingToM1: double;
BranchingToM2: double;
end;
PSubBranchingRecord = ^TSubBranchingRecord; // ????? ?? ?????? ? ???? ?? ????????
{ TSubBranchingRecordList }
TSubBranchingRecordList = class(TList)
protected
function GetSubBranchingRecord(Index: integer): TSubBranchingRecord;
procedure SetSubBranchingRecord(Index: integer; aSubBranchingRecord: TSubBranchingRecord);
public
function LoadFromDB(DataModule: TObject; ProgressBar: TProgressBar = nil): boolean;
function ReadSubBranchingList(const ThZpA_s: integer; var aSubBranchingList: TSubBranchingList): boolean;
procedure Add(aSubBranchingRecord: TSubBranchingRecord);
destructor Destroy; override;
constructor Create;
property SubBranchingRecords[Index: integer]: TSubBranchingRecord read GetSubBranchingRecord write SetSubBranchingRecord; default;
end;
// add end
TGamma = record
MeV: double;
Probability: double;
end;
PGamma = ^TGamma;
TAlpha = record
MeV: double;
Probability: double;
end;
PAlpha = ^TAlpha;
TBeta = record
MeV: double;
MaxMeV: double;
Probability: double;
end;
PBeta = ^TBeta;
TPositron = record
MeV: double;
MaxMeV: double;
Probability: double;
end;
PPositron = ^TPositron;
TElectron = record
MeV: double;
Probability: double;
end;
PElectron = ^TElectron;
TCapture = record
ToState: integer; // 9 - to unknown state
Sigma: double; // barns
end;
PCapture = ^TCapture;
TRI = record
ToState: integer; // 9 - to unknown state
Value: double; // barns
end;
PRI = ^TRI;
TYield = record
ParentThZpA: integer;
CumYieldT: double;
IndYieldT: double;
CumYieldF: double;
IndYieldF: double;
end;
PYield = ^TYield;
TNuclideState = class;
TKarteInfo = class;
{ TDecayList }
TDecayList = class(TList)
protected
State: TNuclideState;
function GetDecay(Index: integer): TDecay;
procedure SetDecay(Index: integer; aDecay: TDecay);
public
procedure Add(aDecay: TDecay);
destructor Destroy; override;
procedure Normalize;
constructor Create(aState: TNuclideState);
property Decays[Index: integer]: TDecay read GetDecay write SetDecay; default;
end;
TFindChain = function(const TheDataModule: TObject; const ThZpA_sStart, ThZpA_sFinish: integer; var MaxStepNo: longint;
Transitions: TNuclideTransitions; Answer: TLongIntList; ChainFinderMaxTime: DWORD = 30000; const ThermalMult: double = 1E-20;
const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20; FirstStep: boolean = True): boolean of object;
{ TSubBranchingList }
TSubBranchingList = class(TList)
protected
State: TNuclideState;
function GetSubBranching(Index: integer): TSubBranching;
procedure SetSubBranching(Index: integer; aSubBranching: TSubBranching);
public
procedure Add(aSubBranching: TSubBranching);
destructor Destroy; override;
procedure Normalize;
constructor Create(aState: TNuclideState);
property SubBranchings[Index: integer]: TSubBranching read GetSubBranching write SetSubBranching; default;
end;
{ TGammaList }
TGammaList = class(TList)
protected
State: TNuclideState;
function GetGamma(Index: integer): TGamma;
function GetKgamma: double;
procedure SetGamma(Index: integer; aGamma: TGamma);
procedure Insert(Index: integer; aGamma: TGamma);
public
procedure Add(aGamma: TGamma);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Kgamma: double read GetKgamma;
property Gammas[Index: integer]: TGamma read GetGamma write SetGamma; default;
end;
{ TElectronList }
TElectronList = class(TList)
protected
State: TNuclideState;
function GetElectron(Index: integer): TElectron;
procedure SetElectron(Index: integer; aElectron: TElectron);
procedure Insert(Index: integer; aElectron: TElectron);
public
procedure Add(aElectron: TElectron);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Electrons[Index: integer]: TElectron read GetElectron write SetElectron; default;
end;
{ TAlphaList }
TAlphaList = class(TList)
protected
State: TNuclideState;
function GetAlpha(Index: integer): TAlpha;
procedure SetAlpha(Index: integer; aAlpha: TAlpha);
procedure Insert(Index: integer; aAlpha: TAlpha);
public
procedure Add(aAlpha: TAlpha);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Alphas[Index: integer]: TAlpha read GetAlpha write SetAlpha; default;
end;
{ TBetaList }
TBetaList = class(TList)
protected
State: TNuclideState;
function GetBeta(Index: integer): TBeta;
procedure SetBeta(Index: integer; aBeta: TBeta);
procedure Insert(Index: integer; aBeta: TBeta);
public
procedure Add(aBeta: TBeta);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Betas[Index: integer]: TBeta read GetBeta write SetBeta; default;
end;
{ TPositronList }
TPositronList = class(TList)
protected
State: TNuclideState;
function GetPositron(Index: integer): TPositron;
procedure SetPositron(Index: integer; aPositron: TPositron);
procedure Insert(Index: integer; aPositron: TPositron);
public
procedure Add(aPositron: TPositron);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Positrons[Index: integer]: TPositron read GetPositron write SetPositron; default;
end;
{ TYieldList }
TYieldList = class(TList)
protected
State: TNuclideState;
function GetYield(Index: integer): TYield;
procedure SetYield(Index: integer; aYield: TYield);
procedure Insert(Index: integer; aYield: TYield);
public
procedure Add(aYield: TYield);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Yields[Index: integer]: TYield read GetYield write SetYield; default;
end;
{ TCaptureList }
TCaptureList = class(TList)
protected
State: TNuclideState;
function GetCapture(Index: integer): TCapture;
procedure SetCapture(Index: integer; aCapture: TCapture);
public
G_factor: double;
procedure Insert(Index: integer; aCapture: TCapture);
procedure SetCaptureToState(ToAstate: integer; aCapture: TCapture);
function GetCaptureToState(ToAstate: integer): double;
procedure Add(aCapture: TCapture);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property Captures[Index: integer]: TCapture read GetCapture write SetCapture; default;
end;
{ TRIList }
TRIList = class(TList)
protected
State: TNuclideState;
function GetRI(Index: integer): TRI;
procedure SetRI(Index: integer; aRI: TRI);
public
procedure Add(aRI: TRI);
procedure Insert(Index: integer; aRI: TRI);
destructor Destroy; override;
constructor Create(aState: TNuclideState);
property RIs[Index: integer]: TRI read GetRI write SetRI; default;
end;
{ TStateList }
TNuclide = class;
TStateList = class(TList)
protected
Nuclide: TNuclide;
function GetNuclideState(Index: integer): TNuclideState;
procedure SetNuclideState(Index: integer; aNuclideState: TNuclideState);
public
procedure Add(aNuclideState: TNuclideState);
destructor Destroy; override;
constructor Create(aNuclide: TNuclide);
property NuclideStates[Index: integer]: TNuclideState read GetNuclideState write SetNuclideState; default;
end;
{ TElement }
TElement = class
Symbol: string[2];
AmassMean: double;
AmassMin: integer;
SigmaA: double;
Ro: double; // Ro_g/cm^3
ksi: double;
SigmaS: double;
RI: double;
Znum: integer;
constructor Create;
destructor Destroy; override;
function FillElementBitmap(var inBitmap: TBitmap; KarteInfo: TKarteInfo): boolean;
end;
{ TElementList }
TElementList = class(TList)
function GetElement(Index: integer): TElement;
procedure SetElement(Index: integer; aElement: TElement);
procedure Add(aElement: TElement);
destructor Destroy; override;
constructor Create;
function LoadFromDB(const DataModule: TObject; ProgressBar: TProgressBar = nil): boolean;
function FindInList(const Znum: integer): integer;
property Elements[Index: integer]: TElement read GetElement write SetElement; default;
end;
{ TNuclide }
TNuclide = class
protected
fNuclideTag: DWORD;
function GetModified: boolean;
procedure SetModified(aModified: boolean);
function GetNuclideType: integer;
public
Amass: integer;
Znum: integer;
Symbol: string[2];
Abundance: double;
StateList: TStateList;
constructor Create(ThZpA: integer);
destructor Destroy; override;
function FillNuclideBitmap(var inBitmap: TBitmap; KarteInfo: TKarteInfo; const ShowText: boolean = True): boolean;
procedure Assign(Source: TNuclide);
procedure AssignStates(Source: TNuclide);
procedure OrderStates;
function LoadFromDB(DataModule: TObject; const Options: DWORD = 1): boolean;
function SaveToDB(DataModule: TObject; Options: DWORD = 3; ProgressBar: TProgressBar = nil; IsDebug: boolean = False): boolean;
function GetCaptureProductStateInfo(DataModule: TObject; var Count, Max, Min: integer): boolean;
property Modified: boolean read GetModified write SetModified;
property NuclideType: integer read GetNuclideType;
property NuclideTag: DWORD read fNuclideTag write fNuclideTag;
end;
{ TNuclideState }
TNuclideState = class
protected
function GetLambda: double;
function GetTotalSigmaC: double;
function GetTotalRI: double;
function GetTotalSigmaFast: double;
function GetThZpA_s: integer;
public
Nuclide: TNuclide;
State: integer;
T1_2: double;
SigmaF: double;
SigmaNP: double;
SigmaNA: double; // (n,alpha)
SigmaN2N: double;
SigmaNN: double; // (n,n')
SigmaNG: double; // (n,gamma)-fast
// g_factor: double;
RIf: double;
Captures: TCaptureList;
RIs: TRIList;
Decays: TDecayList;
Alphas: TAlphaList;
Betas: TBetaList;
Gammas: TGammaList;
Positrons: TPositronList;
Yields: TYieldList;
Electrons: TElectronList;
function GetStateName: string; virtual;
procedure OrderDecays;
procedure OrderAlphas;
procedure OrderBetas;
procedure OrderGammas;
procedure OrderElectrons;
procedure OrderPositrons;
procedure OrderYields;
procedure OrderCaptures;
procedure OrderRIs;
function IsStable: boolean;
procedure Assign(Source: TNuclideState);
constructor Create(aNuclide: TNuclide);
destructor Destroy; override;
property Name: string read GetStateName;
property TotalSigmaC: double read GetTotalSigmaC;
property TotalRI: double read GetTotalRI;
property TotalSigmaFast: double read GetTotalSigmaFast;
property Lambda: double read GetLambda;
property ThZpA_s: integer read GetThZpA_s;
end;
{ TNuclideList }
TNuclideList = class(TList)
private
fAbortChainFinder: boolean;
fChainFinderTimeAborted: boolean;
FFindChain: array [0 .. 1] of TFindChain;
function GetFindChain(Index: integer): TFindChain;
function FindChain1(const TheDataModule: TObject; const ThZpA_sStart, ThZpA_sFinish: integer; var MaxStepNo: longint;
Transitions: TNuclideTransitions; Answer: TLongIntList; ChainFinderMaxTime: DWORD = 30000; const ThermalMult: double = 1E-20;
const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20; FirstStep: boolean = True): boolean;
function FindChain2(const TheDataModule: TObject; const ThZpA_sStart, ThZpA_sFinish: integer; var MaxStepNo: longint;
Transitions: TNuclideTransitions; Answer: TLongIntList; ChainFinderMaxTime: DWORD = 30000; const ThermalMult: double = 1E-20;
const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20; FirstStep: boolean = True): boolean;
protected
function GetNuclide(Index: integer): TNuclide;
procedure SetNuclide(Index: integer; aNuclide: TNuclide);
public
// I_Debug: integer;
function FindChainTest(const TheDataModule: TDataModule; const ThZpA_sStart, ThZpA_sFinish: integer;
var MaxStepNo: longint; Transitions: TNuclideTransitions; Answer: TLongIntList; ChainFinderMaxTime: DWORD = 30000;
const ThermalMult: double = 1E-20; const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20; FirstStep: boolean = True): boolean;
procedure Add(aNuclide: TNuclide);
destructor Destroy; override;
constructor Create;
function LoadFromDB(DataModule: TObject; ProgressBar: TProgressBar = nil): boolean;
function FindInList(const Znum, Amass: integer): integer;
function FindThZpA_s(const ThZpA_s: integer; var NuclideNo, StateNo: integer): boolean;
function FindChilds(const TheDataModule: TObject; const ThZpA_s: integer; Transitions: TNuclideTransitions;
ChildList: TLongIntList; VelocityList: TFloatList = nil; const ThermalMult: double = 1E-20;
const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20): boolean;
function GetLink(const ThZpA_sStart, ThZpA_sFinish: integer; var Answers: TStringList;
Transitions: TNuclideTransitions = [ntCapture, ntFission, ntDecay, ntThreshold]; aDataModule: TObject = nil;
LoadWithCumYield: boolean = True): DWORD; // DataModuleOOB - for SubBranchings
property Nuclides[Index: integer]: TNuclide read GetNuclide write SetNuclide; default;
property FindChain[Index: integer]: TFindChain read GetFindChain;
property AbortChainFinder: boolean read fAbortChainFinder write fAbortChainFinder;
property ChainFinderTimeAborted: boolean read fChainFinderTimeAborted;
function FindThZpA_sState(const ThZpA_s: integer): TNuclideState;
function FindChildsViaSubBranchingRecordList(SubBranchingRecordList: TSubBranchingRecordList; const ThZpA_s: integer;
const Transitions: TNuclideTransitions; ChildList: TLongIntList; VelocityList: TFloatList = nil;
const ThermalMult: double = 1E-20; const ResonanceMult: double = 1E-20; const FastMult: double = 1E-20): boolean;
(* function RemoveNullsFromBrunchings: Boolean; *)
end;
// Classes To draw NUKLIDKARTE
{ TKarteinfo }
TKarteInfo = class
// kiRect: TRect;
SpecialFont: boolean;
FontSymbol, FontT1_2, FontLast: TFont;
StableColor, ITcolor, ECcolor, BMcolor, Acolor, SFcolor, Pcolor, NColor: TColor;
QColor: TColor; // Question color
procedure SetDefaultColor;
constructor Create;
destructor Destroy; override;
procedure Assign(Source: TKarteInfo);
end;
// LIB
function StrToDecayType(const DecayMode: shortstring): TDecayType;
function CanvasRectToBitMap(SourceCanvasHDC: HDC; SourceRect: TRect; BitMap: TBitmap): boolean;
function IsStableT1_2(T1_2: double): boolean;
function DecaySymbol(DecayType: TDecayType): string;
function DecaySpecialSymbol(DecayType: TDecayType): string;
function RussionDecaySymbol(DecayType: TDecayType): string;
function DecayStr(DecayType: TDecayType): string;
function LambdaToStr(const Lambda: double; Width: integer = 3): string;
function T1_2ToStr(T1_2: double; Width: integer = 3): string;
function T1_2ToStrSpecialFont(T1_2: double; Width: integer = 3): string;
function TextT1_2ToNum(const Text: string; var aFloat: double): boolean;
function Color4DecayType(DecayType: TDecayType; KarteInfo: TKarteInfo): TColor;
function FontColor(BrushColor: TColor): TColor;
function IntStateToStr(State: integer): string;
function ValT1_2(FloatText, UnitsText: string; var aFloat: double): boolean;
function ZnumToSymbol(const Znum: integer; var Symbol: string): boolean;
function SymbolToZnum(const Symbol: string; var Znum: integer): boolean;
function ThZpAtoNuclideName(const aThZpA: integer): string;
function NKstr(const InStr: string; const IsSpecialFont: boolean = False; const Font: TFont = nil; StrWidth: integer = 0): string;
function NKstrSymbol(const SymbolStr, AmassStr: string): string;
function DecayProductThZpA(const ParentThZpA: integer; const DecayType: TDecayType): integer;
function ThresholdProductThZpA(const ParentThZpA: integer; const ReactionName: string): integer;
function Bateman(const N0s, Lambdas, ts: array of double; var Ni_t: array of double): boolean;
function StrToThZpA_s(const Str: string): integer;
function ThZpA_sToStr(const ThZpA_s: integer): string;
function AmassFromStateName(const Str: string): integer;
function ElementNameFromStateName(const Str: string): string;
procedure StrToStateNamesList(const InputStr: string; var Lines: TStringList); // it undestands phrases like Co-58..62
function IsStableState(aState: TNuclideState): boolean;
function GetAllDPR(const MamaThZpA_s: integer; // fromMagnolia UnitCalc
const NuclideList: TNuclideList; const SubBranchingRecordList: TSubBranchingRecordList; var Childs: TLongIntList): integer;
type
TypeGasFuelProductZnum = set of 1 .. 100;
const
// Symbols
N_Av = 6.02E23;
BqPerCi = 3.7E10;
MaxSymbolNo = 123;
ConstSymbols: array [1 .. MaxSymbolNo] of string[2] =
('H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca',
'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y',
'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce',
'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm',
'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Ha', 'Sg', 'Ns', 'Hs', 'Mt', '10', '11', '12', '13', '14', '15',
'16', '17', '18', '19', '20', '21', '22', '23');
// ConstGasFuelProductZnum: TypeGasFuelProductZnum = [1,2,6,7,8,9,10];
ConstGasFuelProductZnum: TypeGasFuelProductZnum = [1 .. 110];
MinFissionableZnum = 90;
// TimeInterval
ti_ps: double = 1.0E-12;
ti_ns: double = 1.0E-9;
ti_mks: double = 1.0E-6;
ti_ms: double = 1.0E-3;
ti_sec: double = 1.0;
ti_min: double = 60.0;
ti_hou: double = 3600.0;
ti_day: double = 24 * 3600.0;
// ti_yea: double=365.25*24*3600.0;
ti_yea: double = 31556925.2; // sidereal year
ZiroCaptureToG: TCapture = (ToState: 0; Sigma: 0);
ZiroCaptureToM1: TCapture = (ToState: 1; Sigma: 0);
ZiroCaptureToM2: TCapture = (ToState: 2; Sigma: 0);
ZiroRIToG: TRI = (ToState: 0; Value: 0);
ZiroRIToM1: TRI = (ToState: 1; Value: 0);
ZiroRIToM2: TRI = (ToState: 2; Value: 0);
// Nuclide Load Options
nloBasic: DWORD = $0001;
nloRI: DWORD = $0002;
nloGamma: DWORD = $0004;
nloAlpha: DWORD = $0008;
nloBeta: DWORD = $0010;
nloFission: DWORD = $0020;
nloSigmaThreshold: DWORD = $0040;
nloYield: DWORD = $0080;
nloElectron: DWORD = $01000;
nloPositron: DWORD = $0200;
// NuclideTagBits
ntbModified: DWORD = $0100;
// State Link Types
sltNone: DWORD = $0001;
sltDecay: DWORD = $0002;
sltThermal: DWORD = $0004;
sltResonance: DWORD = $0008;
sltFast: DWORD = $0010;
var
WasProductThZpA: integer;
Symbols: array [1 .. MaxSymbolNo] of string[2];
// Vars for ChainFinder
ChainFinderInitTime: DWORD;
ChainFinderConsided: TLongIntList;
ChainFinderHavePath: TLongIntList;
implementation
uses
Math, SysUtils, Dialogs, UnitDM_OOB;//, Messages;
const
// Mu - for air Mashkovich p.167
MuAirNo = 33;
MuAirE0: array [1 .. MuAirNo] of double = (0.0, 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.08, 0.1, 0.145, 0.15,
0.2, 0.279, 0.3, 0.4, 0.412, 0.5, 0.6, 0.662, 0.8, 1, 1.25, 1.5, 2, 2.75, 3, 4, 5, 6, 8, 10, 1E30);
MuAirMu: array [1 .. MuAirNo] of double = (0.0, 4.65, 1.3, 0.527, 0.15, 0.0671, 0.0404, 0.0301, 0.0239, 0.0232,
0.0247, 0.0249, 0.0267, 0.0284, 0.0287, 0.0295, 0.0295, 0.0297, 0.0295, 0.0294, 0.0288, 0.0279, 0.0266, 0.0254,
0.0234, 0.0212, 0.0206, 0.0187, 0.0174, 0.0165, 0.0152, 0.0144, 0.0);
var
IIIIII: integer;
function InternalTextFormat(const aFloat: double): string;
begin
// Result:= Trim(Format('%-17.15g', [aFloat]));
Result := Trim(Format('%-7.5g', [aFloat]));
end;
{ TSubBranchingRecordList }
constructor TSubBranchingRecordList.Create;
begin
inherited Create;
end;
function TSubBranchingRecordList.GetSubBranchingRecord(Index: integer): TSubBranchingRecord;
begin
Result := TSubBranchingRecord(Items[Index]^);
end;
procedure TSubBranchingRecordList.SetSubBranchingRecord(Index: integer; aSubBranchingRecord: TSubBranchingRecord);
begin
TSubBranchingRecord(Items[Index]^).ThZpA_s := aSubBranchingRecord.ThZpA_s;
TSubBranchingRecord(Items[Index]^).DecayType := aSubBranchingRecord.DecayType;
TSubBranchingRecord(Items[Index]^).BranchingToG := aSubBranchingRecord.BranchingToG;
TSubBranchingRecord(Items[Index]^).BranchingToM1 := aSubBranchingRecord.BranchingToM1;
TSubBranchingRecord(Items[Index]^).BranchingToM2 := aSubBranchingRecord.BranchingToM2;
end;
procedure TSubBranchingRecordList.Add(aSubBranchingRecord: TSubBranchingRecord);
var
NewSubBranchingRecord: PSubBranchingRecord;
begin
New(NewSubBranchingRecord);
with NewSubBranchingRecord^ do
begin
ThZpA_s := aSubBranchingRecord.ThZpA_s;
DecayType := aSubBranchingRecord.DecayType;
BranchingToG := aSubBranchingRecord.BranchingToG;
BranchingToM1 := aSubBranchingRecord.BranchingToM1;
BranchingToM2 := aSubBranchingRecord.BranchingToM2;
end;
inherited Add(NewSubBranchingRecord);
end;
destructor TSubBranchingRecordList.Destroy;
var
I: integer;
begin
for I := 0 to Count - 1 do
if (Items[I] <> nil) then
Dispose(PSubBranchingRecord(Items[I]));
inherited Destroy;
end;
function TSubBranchingRecordList.ReadSubBranchingList(const ThZpA_s: integer; var aSubBranchingList: TSubBranchingList): boolean;
var
I: integer;
aSubBranching: TSubBranching;
begin
try
aSubBranchingList.Clear;
for I := 0 to Self.Count - 1 do
if (Self[I].ThZpA_s = ThZpA_s) then
begin
aSubBranching.DecayType := Self[I].DecayType;
aSubBranching.BranchingToG := Self[I].BranchingToG;
aSubBranching.BranchingToM1 := Self[I].BranchingToM1;
aSubBranching.BranchingToM2 := Self[I].BranchingToM2;
aSubBranchingList.Add(aSubBranching);
end;
Result := True;
except
Result := False;
end;
end;
function TSubBranchingRecordList.LoadFromDB(DataModule: TObject; ProgressBar: TProgressBar): boolean;
begin
ShowMessage('TODO TSubBranchingRecordList.LoadFromDB(DataModule: TObject;');
// if (DataModule is TDataModuleMagnoliaEu) then
// if (DataModule is T_DataModuleOOB) then
// Result:= T_DataModuleOOB(DataModule).ReadSubBranchingRecordList(Self)
// else
// Result:= False;
end;
{ TElement }
constructor TElement.Create;
begin
inherited Create;
Symbol := '';
Ro := 0;
AmassMean := 0;
AmassMin := 0;
SigmaA := 0;
Ro := 0;
ksi := 0;
SigmaS := 0;
RI := 0;
end;
destructor TElement.Destroy;
begin
inherited Destroy;
end;
function TElement.FillElementBitmap(var inBitmap: TBitmap; KarteInfo: TKarteInfo): boolean;
var
ElementCanvas: TCanvas; // before Linux was ElementCanvas: TMetafileCanvas;
TmpBitmap: TBitmap;
aRect: TRect;
begin
TmpBitmap := inBitmap; // 48x48 DefaultRowHeight x DefaultColWidth
aRect.Left := 0;
aRect.Right := inBitmap.Width;
aRect.Top := 0;
aRect.Bottom := inBitmap.Height;
ElementCanvas := TmpBitmap.Canvas; // before Linux was TMetafileCanvas.Create(TmpBitmap, 0);
try
try
with ElementCanvas, KarteInfo do
begin
Brush.Color := clWhite;
FillRect(aRect);
Pen.Width := 2;
Rectangle(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom);
with Font do
begin
Assign(FontSymbol);
Color := clBlack;
Size := 2 * FontSymbol.Size * inBitmap.Width div 48;
end;
TextOut(aRect.Left + 13, aRect.Top + 3, Symbol);
if AmassMean > 0 then
begin
with Font do
begin
Assign(FontT1_2);
Size := 2 * FontT1_2.Size * inBitmap.Width div 48;
Color := clBlack;
end;
TextOut(aRect.Left + 4, aRect.Top + 19 * inBitmap.Width div 48, Trim(Format('%-7.5g', [AmassMean])));
end;
if (SigmaA > 0) then
begin
with Font do
begin
Assign(FontLast);
Color := clBlack;
Size := 2 * FontLast.Size * inBitmap.Width div 48;
end;
if SpecialFont then
TextOut(aRect.Left + 3, aRect.Bottom - 16, #93 + ' ' + Format('%-7.5g', [SigmaA]))
else
TextOut(aRect.Left + 3, aRect.Bottom - 16 * inBitmap.Width div 48, 's ' + Format('%-7.5g', [SigmaA]));
end;
end;
Result := True;
finally
// if (Self.Znum = 1) then
// TmpBitmap.SaveToFile('tstHelement.bmp');
end; // try .. finally
except
Result := False;
end; // try..except
end; { TElement.GetElementBitmap }
{ TNuclide }
function TNuclide.GetModified: boolean;
begin
Result := ((NuclideTag and ntbModified) > 0);
end;
procedure TNuclide.SetModified(aModified: boolean);
begin
if aModified then
NuclideTag := NuclideTag or ntbModified
else
NuclideTag := NuclideTag and not (ntbModified);
end;
function TNuclide.GetCaptureProductStateInfo(DataModule: TObject; var Count, Max, Min: integer): boolean;
begin
if (DataModule is T_DataModuleOOB) then
begin
try
// function ReadCaptureProductStateInfo(const Nuclide: TNuclide; var CountFounded, Max, Min: integer): Boolean;
Result := T_DataModuleOOB(DataModule).ReadCaptureProductStateInfo(Self, Count, Max, Min);
except
Result := False;
end;
end
else if (DataModule is T_DataModuleOOB) then
begin
try
Result := T_DataModuleOOB(DataModule).ReadCaptureProductStateInfo(Self, Count, Max, Min);
except
Result := False;
end;
end
else
Result := False;
end;
function TNuclide.LoadFromDB(DataModule: TObject; const Options: DWORD = 1): boolean;
begin
if (DataModule is T_DataModuleOOB) then
begin
try
Result := T_DataModuleOOB(DataModule).ReadNuclide(Self, Options);
except
Result := False;
end;
end
else if (DataModule is T_DataModuleOOB) then
begin
try
Result := T_DataModuleOOB(DataModule).ReadNuclide(Self, Options);
except
Result := False;
end;
end
else
Result := False;
end;
function TNuclide.SaveToDB(DataModule: TObject; Options: DWORD = 3; ProgressBar: TProgressBar = nil; IsDebug: boolean = False): boolean;
begin
if (DataModule is T_DataModuleOOB) then
begin
try
Result := T_DataModuleOOB(DataModule).WriteNuclide(Self, Options, ProgressBar, IsDebug);
except
Result := False;
end;
end
else if (DataModule is T_DataModuleOOB) then
begin
try
Result := T_DataModuleOOB(DataModule).WriteNuclide(Self, Options, ProgressBar, IsDebug);
except
Result := False;
end;
end
else
Result := False;
end;
procedure TNuclide.AssignStates(Source: TNuclide);
var
I: integer;
State: TNuclideState;
begin
if (Self = Source) then
Exit;
StateList.Clear;
for I := 0 to (Source.StateList.Count - 1) do
begin
State := TNuclideState.Create(Self);
State.Assign(Source.StateList[I]);
State.Nuclide := Self;
StateList.Add(State);
end;
end;
procedure TNuclide.Assign(Source: TNuclide);
begin
if (Self = Source) then
Exit;
AssignStates(Source);
Amass := Source.Amass;
Znum := Source.Znum;
Symbol := Source.Symbol;
NuclideTag := Source.NuclideTag;
Abundance := Source.Abundance;
Modified := Source.Modified;
AssignStates(Source);
end;
constructor TNuclide.Create(ThZpA: integer);
begin
inherited Create;
Amass := ThZpA mod 1000;
Znum := ThZpA div 1000;
StateList := TStateList.Create(Self);
Modified := False;
end;
destructor TNuclide.Destroy;
begin
// StateList.Destroy;
StateList.Free;
inherited Destroy;
end;
procedure TNuclide.OrderStates;
var
I, J: integer;
aState: TNuclideState;
begin
for I := 0 to (StateList.Count - 1) do
begin
StateList[I].OrderDecays;
StateList[I].OrderCaptures;
StateList[I].OrderRIs;
StateList[I].OrderAlphas;
StateList[I].OrderBetas;
StateList[I].OrderGammas;
StateList[I].OrderElectrons;
StateList[I].OrderPositrons;
end;
if (StateList.Count > 1) then
begin
// Order
for J := 1 to (StateList.Count - 1) do
begin
I := J;
while (StateList[I].State < StateList[I - 1].State) do
begin
StateList.Exchange(I, I - 1);
if I = 1 then
break;
Dec(I);
end;
end;
for J := 0 to (StateList.Count - 1) do
if ((StateList[J].State > 2) or (StateList[J].State < 0)) then
begin
MessageDlg('Unknown nuclide state was found' + Symbol + '-' + IntToStr(Amass) + ' not (G,M1,M2)' + #13 +
#10 + 'Call the author.', mtWarning, [mbOK], 0);
Exit;
end;
// InsertMissing
if StateList.Count > 0 then
begin
while (StateList.Count - 1) < StateList[StateList.Count - 1].State do
begin
if (StateList[0].State <> 0) then
begin
aState := TNuclideState.Create(Self);
aState.State := 0;
StateList.Insert(0, aState);
end;
if (StateList[1].State <> 1) then
begin
aState := TNuclideState.Create(Self);
aState.State := 1;
StateList.Insert(1, aState);
end;
end;
end;
end;
end;
function TNuclide.GetNuclideType: integer;
var
HasStable, HasUnStable: boolean;
// HasDecays: Boolean;
I: integer;
begin
// Result := 0; //UnKnown
if StateList.Count < 1 then
begin
Result := 0;
Exit;
end;
HasStable := False;
HasUnStable := False;
// HasDecays := False;
for I := 0 to (StateList.Count - 1) do
begin
// if StateList[I].Decays.Count > 0
// then HasDecays := True;
// if (IsStable(StateList[I].T1_2)) then HasStable := True
if StateList[I].IsStable then
HasStable := True
else
HasUnStable := True;
end;
if ((StateList.Count = 1) and (HasStable)) then
begin
Result := 1; // Stable
end
else if ((HasStable) and (HasUnStable)) then
begin
Result := 2; // StableWithMetastableState
end
else if (not (HasStable) and (Abundance > 0)) then
begin
Result := 3; // Primordial
end
else if (not (HasStable)) then
begin
Result := 4; // UnStable
end
else
Result := 0;
end;
function TNuclide.FillNuclideBitmap(var inBitmap: TBitmap; KarteInfo: TKarteInfo; const ShowText: boolean = True): boolean;
procedure OutSigmas(Canvas: TCanvas; inosRect: TRect; NuclideState: TNuclideState);
var
I: integer;
TheSigma2GPresent, TheSigma2M1Present, TheSigma2M2Present: boolean;
TheSigma, TheSigma2G, TheSigma2M1, TheSigma2M2: double;
FirstChar: string[2];
begin
Result:= False;
if ((NuclideState = nil) or (Canvas = nil) or (inosRect.Bottom - inosRect.Top = 0) or (inosRect.Right - inosRect.Left = 0)) then
Exit;
if (NuclideState.Captures.Count < 1) then
Exit;
with Canvas do
begin
if (NuclideState.Captures.Count = 1) then
begin