tstTransitionMatrixUpdater.f90

./Manager/libld/f/tests/tstTransitionMatrixUpdater.f90

2 
3 #include "ScaleSTL/FortranTestMacros.h"
4 
8 use scalestl_vec_flt_m, vec_flt=>scalestl_vec_flt
9 use scalestl_vec_int_m, vec_int=>scalestl_vec_int
11 use stringlist_m
12 use datacontainer_m
13 use dbcf_m
14 use origen_testpaths_m
15 use iso_fortran_env, only: error_unit, output_unit
17 
18 !
19 use nemesis_comm, only: build_types, initialize, finalize, node
20 
21 implicit none
22 
24 type(origen_transitionmatrixp) :: trx,tm_base
25 type(origen_libraryheader) :: lh
26 type(origen_nuclideset) :: nucset
27 type(origen_fakefactory) :: ff
28 type(vec_flt) :: mg_flux, bounds_56g
29 type(vec_int) :: nuclide_list,num_mts,mt_list
30 type(vec_flt) :: xs
31 type(integerlist) :: ilist
32 real :: t1,t2,dt
33 integer :: nind,nind2
34 integer :: mt
35 integer(C_SIZE_T) :: g
36 real :: xs_check
37 logical(C_BOOL) :: stat
38 integer,parameter :: l=c_size_t
39 
40 call initialize
41 call build_types
42 if(node() /= 0 ) call finalize
43 
44 !===============================================================
45 ! 0. get base xs library
46 call cpu_time(t1)
47 call load_transition_matrix(tm_base,pwrlib_filepath)
48 call cpu_time(t2)
49 
50 ! check that it is what we expect
51 nind = tm_base % find_nuclide(2,922350)
52 call tm_base % get_nucl(ilist)
53 expect_eq(922350,ilist%at(nind+1)) !found U-235
54 xs_check = tm_base % get_xs(nind+1,18)
55 expect_near(31.2501450,xs_check,1.e-3)
56 write(error_unit,'(a50,f8.1,"ms")')'tst.load_transition_matrix',1000*(t2-t1)
57 
58 call bounds_56g % initialize()
59 stat = ff % getBounds_scale6p2_56g(bounds_56g)
60 expect_true(stat)
61 expect_eq(57_l,bounds_56g%size())
62 
63 !===============================================================
64 ! 1. load data
65 call cpu_time(t1)
66 !---------------------------------------------------------------
67 call tmu % initialize_storage(bounds_56g)
68 call tmu % load(pwrlib_filepath,jeff252_filepath,yields_filepath)
69 if( .not. tmu%initialized() )then
70  write(*,*)'cannot proceed if data sources did not load.'
71  stop 0
72 end if
73 !---------------------------------------------------------------
74 call cpu_time(t2)
75 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.load',1000*(t2-t1)
76 
77 !get header
78 call tmu % library_header(lh)
79 !get nuclide set
80 call nucset % initialize()
81 call lh % get_nuclide_set(nucset);
82 expect_eq(2237, nucset%total_nuclides() )
83 call nucset % destroy()
84 
85 !===============================================================
86 ! 2. update mg flux
87 call cpu_time(t1)
88 call mg_flux % initialize()
89 call ff % getUniformFlux(mg_flux,bounds_56g)
90 expect_eq(56_l,mg_flux%size())
91 call bounds_56g % destroy()
92 !---------------------------------------------------------------
93 call tmu % update_mg_flux(mg_flux)
94 !---------------------------------------------------------------
95 call mg_flux % destroy()
96 call cpu_time(t2)
97 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.update_mg_flux',1000*(t2-t1)
98 
99 
100 !===============================================================
101 ! 3. check xs
102 call cpu_time(t1)
103 call nuclide_list % initialize()
104 call nuclide_list % push_back(92235)
105 
106 call num_mts % initialize()
107 call num_mts % push_back(1)
108 
109 call mt_list % initialize()
110 call mt_list % push_back(18)
111 
112 ! make sure that cross sections have
113 call xs % initialize()
114 !---------------------------------------------------------------
115 call tmu % get_xs("IZZZAAA",nuclide_list,num_mts,mt_list,xs)
116 !---------------------------------------------------------------
117 call cpu_time(t2)
118 expect_eq(1_l, xs%size() )
119 expect_near(1.53126442,xs%at(1_l),1e-5)
120 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.get_xs',1000*(t2-t1)
121 
122 
123 !===============================================================
124 ! 4. get transition matrix
125 call cpu_time(t1)
126 call trx % initialize()
127 !---------------------------------------------------------------
128 call tmu % get_transition_matrix(trx)
129 !---------------------------------------------------------------
130 call cpu_time(t2)
131 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.get_transition_matrix',1000*(t2-t1)
132 
133 call cpu_time(t1)
134 nind2 = trx % find_nuclide(2,922350)
135 expect_eq(nind,nind2)
136 xs_check = trx % get_xs(nind2+1,18)
137 
138 call cpu_time(t2)
139 expect_near(1.53126442,xs_check,1e-5)
140 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixP.get_xs',1000*(t2-t1)
141 
142 
143 !===============================================================
144 ! 5. update user xs
145 call cpu_time(t1)
146 call xs % set(1_l,35.0)
147 !---------------------------------------------------------------
148 call tmu % update_user_xs("IZZZAAA",nuclide_list,num_mts,mt_list,xs)
149 !---------------------------------------------------------------
150 call cpu_time(t2)
151 expect_eq(1_l,xs%size())
152 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.update_user_xs',1000*(t2-t1)
153 
154 
155 !===============================================================
156 ! 6. more checking
157 call cpu_time(t1)
158 call tmu % get_transition_matrix(trx)
159 call cpu_time(t2)
160 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixUpdater.get_transition_matrix',1000*(t2-t1)
161 
162 call cpu_time(t1)
163 xs_check = trx % get_xs(nind+1,18)
164 call cpu_time(t2)
165 write(error_unit,'(a50,f8.1,"ms")')'TransitionMatrixP.get_xs',1000*(t2-t1)
166 
167 call trx % destroy()
168 
169 call tmu % clear()
170 call tmu % destroy()
171 call tm_base % destroy()
172 
173 call finalize
174 
175 contains
176 
177 subroutine load_transition_matrix(trx,path)
178 type(origen_transitionmatrixp),intent(out) :: trx
179 character(*),intent(in) :: path
180 type(origen_library) :: lib
181 type(origen_libraryio) :: lib_io
182 type(datacontainer) :: options
183 logical :: status
184 
185 call lib_io % initialize()
186 call options % initialize()
187 call lib % initialize()
188 status = lib_io % load(lib,path,options)
189 call lib_io % destroy()
190 call lib % newptr_transition_matrix_at(trx,1_c_size_t)
191 call lib%destroy()
192 call lib_io%destroy()
193 call options%destroy()
194 end subroutine
195 
196 end program