-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathreactor_simulation.cpp
1092 lines (1005 loc) · 24.3 KB
/
reactor_simulation.cpp
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
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <cmath>
# include <ctime>
using namespace std;
int main ( );
int absorb ( int &seed );
double cross ( double e );
double dist2c ( double e, int &seed );
double energy ( int &seed );
void output ( int na, double ea, double sa, int nr, double er, double sr,
int nt, double et, double st, int ntot );
double r8_abs ( double x );
double r8_max ( double x, double y );
double r8_uniform_01 ( int &seed );
void scatter ( int &seed, double &e, double &mu, double &azm );
void source ( int &seed, double &e, double &mu, double &azm, double &x,
double &y, double &z );
void timestamp ( );
void update ( double mu, double azm, double d, double &x, double &y, double &z );
//****************************************************************************80
int main ( )
//****************************************************************************80
//
// Purpose:
//
// MAIN is the main program for the reactor shielding simulation.
//
// Discussion:
//
// This is a Monte Carlo simulation, using
// uniform random numbers, which investigates the
// effectiveness of a shield intended to absorb the
// neutrons emitted from a nuclear reactor.
//
// The reactor is modeled as a point source,
// located at (0,0,0).
//
// A particle emitted from the reactor has a random
// initial direction, and an energy selected from
// [Emin,Emax] with a 1/Sqrt(E) distribution.
//
// The shield is modeled as a wall of thickness THICK,
// extending from 0 to THICK in the X direction, and
// extending forever in the Y and Z directions.
//
// Based on the particle energy, a distance D is computed
// which measures how far the particle could travel through
// the shield before colliding.
//
// Based on the particle direction, the position is updated
// by D units.
//
// If the particle is now to the left of the shield, it is
// counted as being REFLECTED.
//
// If the particle is to the right of the shield, it is
// counted as being ABSORBED.
//
// If the particle is inside the shield, it has COLLIDED.
// A particle that collides is either absorbed (end of story)
// or SCATTERED with a new random direction and a new (lower)
// energy.
//
// Every particle is followed from origin to its final fate,
// which is reflection, transmission, or absorption.
// At the end, a summary is printed, giving the number of
// particles with each fate, and the average energy of each
// group of particles.
//
// Increasing NTOT, the number of particles used, will improve the
// expected reliability of the results.
//
// Increasing THICK, the thickness of the shield, should
// result in more absorptions and reflections.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Local Parameters:
//
// Local, double AZM, the azimuthal angle of the particle's
// direction.
//
// Local, double D, the distance that the particle can
// travel through the slab, given its current energy.
//
// Local, double E, the energy of the particle.
//
// Local, double EA, energy absorbed by the slab.
//
// Local, double ER, energy reflected by the slab.
//
// Local, double ET, energy transmitted through the slab.
//
// Local, double MU, the cosine of the angle between the
// particle's direction and the X axis.
//
// Local, int NA, number of particles absorbed by the slab.
//
// Local, int NPART, the index of the current particle.
//
// Local, int NR, number of particles reflected by the slab.
//
// Local, int NT, number of particles transmitted by the slab.
//
// Local, int NTOT, the total number of particles to be
// emitted from the neutron source.
//
// Local, double SA, standard deviation of absorbed energy.
//
// Local, double SR, standard deviation of reflected energy.
//
// Local, double ST, standard deviation of transmitted energy.
//
// Local, double THICK, the thickness of the slab that is
// intended to absorb most of the particles.
//
// Local, double X, Y, Z, the current position of the particle.
//
{
double azm;
double d;
double e;
double ea;
double er;
double et;
int i;
double mu;
int na;
int npart;
int nr;
int nt;
int ntot = 100000;
int part;
double sa;
int seed;
double sr;
double st;
int test;
int test_num = 5;
double thick = 2.0;
double x;
double y;
double z;
timestamp ( );
cout << "\n";
cout << "REACTOR_SIMULATION\n";
cout << " C++ version\n";
cout << " The reactor shielding simulation.\n";
cout << "\n";
cout << " Shield thickness is THICK = " << thick << "\n";
cout << " Number of simulated particles is NTOT = " << ntot << "\n";
cout << " Number of tests TEST_NUM = " << test_num << "\n";
seed = 123456789;
for ( test = 1; test <= test_num; test++ )
{
cout << "\n";
cout << " Test # " << test << "\n";
cout << " SEED = " << seed << "\n";
//
// Initialize.
//
ea = 0.0;
er = 0.0;
et = 0.0;
na = 0;
nr = 0;
nt = 0;
sa = 0.0;
sr = 0.0;
st = 0.0;
//
// Loop over the particles.
//
for ( part = 1; part <= ntot; part++ )
{
//
// Generate a new particle.
//
source ( seed, e, mu, azm, x, y, z );
while ( 1 )
{
//
// Compute the distance that the particle can travel through the slab,
// based on its current energy.
//
d = dist2c ( e, seed );
//
// Update the particle's position by D units.
//
update ( mu, azm, d, x, y, z );
//
// The particle was reflected by the shield, and this path is complete.
//
if ( x < 0.0 )
{
nr = nr + 1;
er = er + e;
sr = sr + e * e;
break;
}
//
// The particle was transmitted through the shield, and this path is complete.
//
else if ( thick < x )
{
nt = nt + 1;
et = et + e;
st = st + e * e;
break;
}
//
// The particle collided with the shield, and was absorbed. This path is done.
//
else if ( absorb ( seed ) )
{
na = na + 1;
ea = ea + e;
sa = sa + e * e;
break;
}
//
// The particle collided with the shield and was scattered.
// Find the scattering angle and energy, and continue along the new path.
//
else
{
scatter ( seed, e, mu, azm );
}
}
}
//
// Print the results of the simulation.
//
output ( na, ea, sa, nr, er, sr, nt, et, st, ntot );
}
//
// Terminate.
//
cout << "\n";
cout << "REACTOR_SIMULATION:\n";
cout << " Normal end of execution.\n";
cout << "\n";
timestamp ( );
return 0;
}
//****************************************************************************80
int absorb ( int &seed )
//****************************************************************************80
//
// Purpose:
//
// ABSORB determines if a colliding particle is absorbed.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input/output, int &SEED, a seed for the random
// number generator.
//
// Output, logical ABSORB, is TRUE if the particle is absorbed.
//
// Local parameters:
//
// Local, double PA, the probability of absorption.
//
{
double pa = 0.1;
double u;
int value;
u = r8_uniform_01 ( seed );
if ( u <= pa )
{
value = 1;
}
else
{
value = 0;
}
return value;
}
//****************************************************************************80
double cross ( double e )
//****************************************************************************80
//
// Purpose:
//
// CROSS returns the "cross section" of a particle based on its energy.
//
// Discussion:
//
// The particle's cross section is a measure of its likelihood to collide
// with the material of the slab. This quantity typically depends on both
// the particle's energy and the kind of medium through which it is traveling.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input, double E, the energy of the particle.
//
// Output, double CROSS, the cross section.
//
{
double s;
double value;
double y;
s = r8_abs ( sin ( 100.0 * ( exp ( e ) - 1.0 ) )
+ sin ( 18.81 * ( exp ( e ) - 1.0 ) ) );
y = r8_max ( 0.02, s );
value = 10.0 * exp ( -0.1 / y );
return value;
}
//****************************************************************************80
double dist2c ( double e, int &seed )
//****************************************************************************80
//
// Purpose:
//
// DIST2C returns the distance to collision.
//
// Discussion:
//
// Assuming the particle has a given energy, and assuming it is currently
// somewhere inside the shield, it is possible to determine a typical distance
// which the particle can travel before it collides with the material of
// the shield.
//
// The computation of the collision distance is made by estimating a
// "cross section" (as though having more energy made the particle "bigger"
// and hence more likely to collide) and then randomly selecting a distance
// that is logarithmically distributed.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input, double E, the energy of the particle.
//
// Input/output, int &SEED, a seed for the random
// number generator.
//
// Output, double DIST2C, the distance the particle can travel
// through the slab before colliding.
//
{
double u;
double value;
u = r8_uniform_01 ( seed );
value = - log ( u ) / cross ( e );
return value;
}
//****************************************************************************80
double energy ( int &seed )
//****************************************************************************80
//
// Purpose:
//
// ENERGY assigns an energy to an emitted particle.
//
// Discussion:
//
// The energy E is in the range [EMIN,EMAX], with distribution
// const/sqrt(energy).
//
// An inverse function approach is used to compute this.
//
// The energies are measured in MeV.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input/output, int &SEED, a seed for the random
// number generator.
//
// Output, double ENERGY, a randomly chosen energy that is
// distributed as described above.
//
// Local parameters:
//
// Local, double EMIN, EMAX, the minimum and maximum
// energies.
//
{
double c;
double emax = 2.5;
double emin = 1.0E-03;
double u;
double value;
u = r8_uniform_01 ( seed );
c = 1.0 / ( 2.0 * ( sqrt ( emax ) - sqrt ( emin ) ) );
value = ( u / ( 2.0 * c ) + sqrt ( emin ) );
value = value * value;
return value;
}
//****************************************************************************80
void output ( int na, double ea, double sa, int nr, double er, double sr,
int nt, double et, double st, int ntot )
//****************************************************************************80
//
// Purpose:
//
// OUTPUT prints the results of the reactor shielding simulation.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input, int NA, number of particles absorbed by the slab.
//
// Input, double EA, energy absorbed by the slab.
//
// Input, double SA, the sum of the squares of the
// absorbed energies.
//
// Input, int NR, number of particles reflected by the slab.
//
// Input, double ER, energy reflected by the slab.
//
// Input, double SR, the sum of the squares of the
// reflected energies.
//
// Input, int NT, number of particles transmitted by the slab.
//
// Input, double ET, energy transmitted through the slab.
//
// Input, double ST, the sum of the squares of the
// transmitted energies.
//
// Input, int NTOT, the total number of particles.
//
{
double ea_ave;
double er_ave;
double et_ave;
double etot;
double pa;
double pr;
double pt;
double ptot;
cout << "\n";
cout << " The Reactor Shielding Problem:\n";
cout << "\n";
cout << " Total Average\n";
cout << " # Energy ";
cout << "Percent Energy StDev\n";
cout << "\n";
etot = ea + er + et;
if ( 0 < na )
{
ea_ave = ea / ( double ) ( na );
sa = sqrt ( sa / ( double ) ( na ) - ea_ave * ea_ave );
}
else
{
ea_ave = 0.0;
}
pa = ( double ) ( na * 100 ) / ( double ) ( ntot );
cout << "Absorbed "
<< " " << setw(8) << na
<< " " << setw(14) << ea
<< " " << setw(6) << pa
<< " " << setw(14) << ea_ave
<< " " << setw(14) << sa << "\n";
if ( 0 < nr )
{
er_ave = er / ( double ) ( nr );
sr = sqrt ( sr / ( double ) ( nr ) - er_ave * er_ave );
}
else
{
er_ave = 0.0;
}
pr = ( double ) ( nr * 100 ) / ( double ) ( ntot );
cout << "Reflected "
<< " " << setw(8) << nr
<< " " << setw(14) << er
<< " " << setw(6) << pr
<< " " << setw(14) << er_ave
<< " " << setw(14) << sr << "\n";
if ( 0 < nt )
{
et_ave = et / ( double ) ( nt );
st = sqrt ( st / ( double ) ( nt ) - et_ave * et_ave );
}
else
{
et_ave = 0.0;
}
pt = ( double ) ( nt * 100 ) / ( double ) ( ntot );
cout << "Transmitted "
<< " " << setw(8) << nt
<< " " << setw(14) << et
<< " " << setw(6) << pt
<< " " << setw(14) << et_ave
<< " " << setw(14) << st << "\n";
ptot = 100.0;
cout << "\n";
cout << "Total "
<< " " << setw(8) << ntot
<< " " << setw(14) << etot
<< " " << setw(6) << ptot << "\n";
return;
}
//****************************************************************************80
double r8_abs ( double x )
//****************************************************************************80
//
// Purpose:
//
// R8_ABS returns the absolute value of an R8.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 14 November 2006
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, double X, the quantity whose absolute value is desired.
//
// Output, double R8_ABS, the absolute value of X.
//
{
double value;
if ( 0.0 <= x )
{
value = + x;
}
else
{
value = - x;
}
return value;
}
//****************************************************************************80
double r8_max ( double x, double y )
//****************************************************************************80
//
// Purpose:
//
// R8_MAX returns the maximum of two R8's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 18 August 2004
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, double X, Y, the quantities to compare.
//
// Output, double R8_MAX, the maximum of X and Y.
//
{
double value;
if ( y < x )
{
value = x;
}
else
{
value = y;
}
return value;
}
//****************************************************************************80
double r8_uniform_01 ( int &seed )
//****************************************************************************80
//
// Purpose:
//
// R8_UNIFORM_01 returns a unit pseudorandom R8.
//
// Discussion:
//
// This routine implements the recursion
//
// seed = ( 16807 * seed ) mod ( 2^31 - 1 )
// u = seed / ( 2^31 - 1 )
//
// The integer arithmetic never requires more than 32 bits,
// including a sign bit.
//
// If the initial seed is 12345, then the first three computations are
//
// Input Output R8_UNIFORM_01
// SEED SEED
//
// 12345 207482415 0.096616
// 207482415 1790989824 0.833995
// 1790989824 2035175616 0.947702
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 09 April 2012
//
// Author:
//
// John Burkardt
//
// Reference:
//
// Paul Bratley, Bennett Fox, Linus Schrage,
// A Guide to Simulation,
// Second Edition,
// Springer, 1987,
// ISBN: 0387964673,
// LC: QA76.9.C65.B73.
//
// Bennett Fox,
// Algorithm 647:
// Implementation and Relative Efficiency of Quasirandom
// Sequence Generators,
// ACM Transactions on Mathematical Software,
// Volume 12, Number 4, December 1986, pages 362-376.
//
// Pierre L'Ecuyer,
// Random Number Generation,
// in Handbook of Simulation,
// edited by Jerry Banks,
// Wiley, 1998,
// ISBN: 0471134031,
// LC: T57.62.H37.
//
// Peter Lewis, Allen Goodman, James Miller,
// A Pseudo-Random Number Generator for the System/360,
// IBM Systems Journal,
// Volume 8, Number 2, 1969, pages 136-143.
//
// Parameters:
//
// Input/output, int &SEED, the "seed" value. Normally, this
// value should not be 0. On output, SEED has been updated.
//
// Output, double R8_UNIFORM_01, a new pseudorandom variate,
// strictly between 0 and 1.
//
{
int i4_huge = 2147483647;
int k;
double r;
if ( seed == 0 )
{
cerr << "\n";
cerr << "R8_UNIFORM_01 - Fatal error!\n";
cerr << " Input value of SEED = 0.\n";
exit ( 1 );
}
k = seed / 127773;
seed = 16807 * ( seed - k * 127773 ) - k * 2836;
if ( seed < 0 )
{
seed = seed + i4_huge;
}
r = ( double ) ( seed ) * 4.656612875E-10;
return r;
}
//****************************************************************************80
void scatter ( int &seed, double &e, double &mu, double &azm )
//****************************************************************************80
//
// Purpose:
//
// SCATTER returns the new direction and energy of a particle that is scattered.
//
// Discussion:
//
// The scattering direction is chosen uniformly on the sphere.
//
// The energy of the scattered particle is chosen uniformly in
// [ 0.3*E, E ].
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input/output, int &SEED, a seed for the random
// number generator.
//
// Input/output, double &E. On input, the particle energy
// before collision. On output, the particle energy after collision
// and scattering.
//
// Output, double &MU, the cosine of the angle between the
// particle's direction and the X axis.
//
// Output, double &AZM, the azimuthal angle of the particle's
// direction.
//
{
double pi = 3.141592653589793;
double u;
u = r8_uniform_01 ( seed );
mu = - 1.0 + 2.0 * u;
u = r8_uniform_01 ( seed );
azm = u * 2.0 * pi;
u = r8_uniform_01 ( seed );
e = ( u * 0.7 + 0.3 ) * e;
return;
}
//****************************************************************************80
void source ( int &seed, double &e, double &mu, double &azm, double &x,
double &y, double &z )
//****************************************************************************80
//
// Purpose:
//
// SOURCE generates a new particle from the neutron source.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 September 2012
//
// Author:
//
// Original FORTRAN77 version by Kahaner, Moler, Nash.
// C++ version by John Burkardt.
//
// Reference:
//
// David Kahaner, Cleve Moler, Steven Nash,
// Numerical Methods and Software,
// Prentice Hall, 1989,
// ISBN: 0-13-627258-4,
// LC: TA345.K34.
//
// Parameters:
//
// Input/output, int &SEED, a seed for the random
// number generator.
//
// Output, double &E, the initial energy of the particle.
//
// Output, double &MU, the cosine of the angle between the
// particle's direction and the X axis.
//
// Output, double &AZM, the azimuthal angle of the particle's
// direction.
//
// Output, double &X, &Y, &Z, the initial coordinates of the particle.
//
{
double pi = 3.141592653589793;
double u;
u = r8_uniform_01 ( seed );
mu = u;
u = r8_uniform_01 ( seed );
azm = u * 2.0 * pi;
x = 0.0;
y = 0.0;
z = 0.0;
e = energy ( seed );
return;
}
//****************************************************************************80
void timestamp ( )
//****************************************************************************80
//
// Purpose:
//
// TIMESTAMP prints the current YMDHMS date as a time stamp.
//
// Example:
//