-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcutoff_ace_pyfrensie.py
More file actions
81 lines (64 loc) · 2.7 KB
/
cutoff_ace_pyfrensie.py
File metadata and controls
81 lines (64 loc) · 2.7 KB
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
#! /usr/bin/env python
import PyFrensie.Data.ACE as ACE
import PyFrensie.Utility as Utility
import PyFrensie.Utility.Prng as Prng
import PyFrensie.Utility.Interpolation as Interpolation
import PyFrensie.MonteCarlo.Collision as Collision
import PyTrilinos.Teuchos as Teuchos
import numpy
import matplotlib.pyplot as plt
Utility.initFrensiePrng()
#datadir = '/home/software/mcnpdata/'
datadir = '/home/lkersting/frensie/src/packages/test_files/'
source = Teuchos.FileInputSource( datadir + '/cross_sections.xml' )
xml_obj = source.getObject()
cs_list = Teuchos.XMLParameterListReader().toParameterList( xml_obj )
data_list = cs_list.get( 'H-Native' )
### -------------------------------------------------------------------------- ##
### Forward Elastic Unit Test Check
### -------------------------------------------------------------------------- ##
file_names = [ '/home/lkersting/frensie/src/packages/test_files/ace/test_h_epr14_ace_file.txt']
table_names = ['1000.14p']
for j in range(0,len(table_names) ):
print "\n----------------------------"
print "-----", table_names[j], "Tests -----"
print "----------------------------"
ace_file = ACE.ACEFileHandler( file_names[j], table_names[j], 1 )
ace_data = ACE.XSSEPRDataExtractor( ace_file.getTableNXSArray(), ace_file.getTableJXSArray(), ace_file.getTableXSSArray() )
cutoff_dist = Collision.createCutoffElasticDistribution( ace_data )
###
### Cutoff Distribution PyFrensie Unit Test Check
###
energies = [1e5, 1e-3, 4e-4]
angles = [0.0, 0.9]
print "\n\tEvaluate"
for energy in energies:
print "Energy = ",energy
for angle in angles:
pdf = cutoff_dist.evaluate( energy, angle )
print '\teval[',angle,'] = ','%.16e' % pdf
print "\n\tEvaluate PDF"
for energy in energies:
print "Energy = ",energy
for angle in angles:
pdf = cutoff_dist.evaluatePDF( energy, angle )
print '\tPDF[',angle,'] = ','%.16e' % pdf
print "\n\tEvaluate CDF"
for energy in energies:
print "Energy = ",energy
for angle in angles:
cdf = cutoff_dist.evaluateCDF( energy, angle )
print '\tCDF[',angle,'] = ','%.16e' % cdf
energy = 1e-3
random_numbers = [ 0.5 ]
Prng.RandomNumberGenerator.setFakeStream(random_numbers)
print "\n\t--- Sample ---"
print "Energy = ",energy
energy,angle = cutoff_dist.sample( energy )
print 'angle[0.5] = ','%.16e' % angle
energy = 1e5
random_numbers = [ 0.5]
Prng.RandomNumberGenerator.setFakeStream(random_numbers)
print "Energy = ",energy
energy,angle = cutoff_dist.sample( energy )
print 'angle[0.5] = ','%.16e' % angle