Skip to content
TumRegels edited this page Oct 16, 2013 · 12 revisions

To be able to create Parcs compatible XSEC cards you need to run your calculation with isXSEC property set to true:

sim.isXSEC = true

Here I will use fuelpinburn example to explain the work-flow. At this point we assume that simulation results data_for_fuelpinburn.m are ready and saved as allresults.mat file.

To generate XSEC cards you need to run data_analyser.m file inside fuelpinburn folder.

>> pwd
/home/user/stop/examples/fuelpinburn
>> data_analyser

If you get an error, consider adding the stop directory to Matlab path:

>> addpath(genpath('/absolute/path/to/stop/'))
>> data_analyser

So at this point the code will generate one xsecforparcs.txt file and 42 xsecburn_*.txt files (there are 41 burnup-steps + 1 no-burnup specified in fuelpinburn.spi)

The xsecforparcs.txt file is generated due to the following part of code

>> dbtype data_analyser.m 50:75 

50    % generate xsec card for universe 1 and 2, use only last burnup
51    
52    % optimize calculation data for xsec class
53    ref   = xsec.dataOptimizer(fuelpinburn_ref.res(end));
54    fhhi  = xsec.dataOptimizer(fuelpinburn_fhhi.res(end));
55    fthi  = xsec.dataOptimizer(fuelpinburn_fthi.res(end));
56    cdlow = xsec.dataOptimizer(fuelpinburn_cdlow.res(end));
57    
58    xs = xsec();
59    
60    xs.comp_num(1);
61    xs.base_macro(ref,1);
62    xs.dxs_dtf( (fthi-ref)./(log(1800)-log(300)),1);
63    xs.dxs_ddm( (cdlow-ref)./1100,1);
64    xs.dxs_axexp( (fhhi-ref)./2700,1);
65    
66    xs.comp_num(2);
67    xs.base_macro(ref,2);
68    xs.dxs_dtf( (fthi-ref)./(log(1800)-log(300)),2);
69    xs.dxs_ddm( (cdlow-ref)./1100,2);
70    xs.dxs_axexp( (fhhi-ref)./2700,2);
71    
72    xs.display();
73    xs.write();
74    
75    clear xs;

Usage of xsec.dataOptimizer class

The lines between 52:56 of data_analyser.m file use dataOptimizer class to optimize simulation data and outputs special objects.

In this case generated objects are: ref,fhhi,fthi,cdlow.

>> dbtype data_analyser.m 52:56
52    % optimize calculation data for xsec class
53    ref   = xsec.dataOptimizer(fuelpinburn_ref.res(end));
54    fhhi  = xsec.dataOptimizer(fuelpinburn_fhhi.res(end));
55    fthi  = xsec.dataOptimizer(fuelpinburn_fthi.res(end));
56    cdlow = xsec.dataOptimizer(fuelpinburn_cdlow.res(end));

These objects have a special behaviour when it comes to the following operations:

Description Operation Method
Binary addition a + b plus(a,b)
Binary subtraction a - b minus(a,b)
Element-wise multiplication a.*b times(a,b)
Right element-wise division a./b rdivide(a,b)
Element-wise power a.^b power(a,b)

In the table a and b can stand for any of these objects: ref,fhhi,fthi,cdlow.

Warning: Use only operations defined in the table above, when manipulating the objects of dataOptimizer class.

For example you can approximate the dXS/dlnT as:

(fthi-ref)./(log(1800)-log(300))

Nonetheless, if you try without . operator, e.g.

(fthi-ref)/(log(1800)-log(300))

This will produce the error: Undefined function or method 'mrdivide'.

This is because mrdivide(a,b) stands for 'Matrix right division' and is not defined for our objects ref,fhhi,fthi,cdlow.

For more details check [Implementing Operators for Your Class] (http://www.mathworks.se/help/matlab/matlab_oop/implementing-operators-for-your-class.html)

Generation of XSEC cards

At this point we have created objects ref,fhhi,fthi,cdlow which obey to the specific rules of xsec class.

To generate xsec card for universe 1 of fuelpinburn.spi we need the following code:

>> dbtype data_analyser.m 58:64

58    xs = xsec(); % create instance of xsec class
59    
60    xs.comp_num(1); % generate comp_num of xsec card
61    xs.base_macro(ref,1); % generate base_macro card using ref object for uni 1
62    xs.dxs_dtf( (fthi-ref)/(log(1800)-log(300)),1); % generate dxs_dtf card for uni 1
63    xs.dxs_ddm( (cdlow-ref)./1100,1);
64    xs.dxs_axexp( (fhhi-ref)./2700,1);

This will generate the following string (we use 4 energy groups in fuelpinburn.spi).

!====================
 comp_num    1    !UNIVERSE 1
!====================
 base_macro      1.428350E-01    7.292110E-03    1.961350E-02    2.163144E-13
                 2.714020E-01    5.621010E-03    6.842740E-03    7.831517E-14
                 4.929060E-01    2.623120E-02    2.158140E-02    2.496620E-13
                 8.163120E+00    4.897870E-01    1.391790E+01    1.494473E-10
    3.291520E-02
    2.360680E-05    1.217530E-03
    0.000000E+00    0.000000E+00    0.000000E+00
 fiss_spec       7.631370E-01    2.367060E-01    1.574800E-04    0.000000E+00
!====================
 dxs_dtf        -1.467831E-04   -2.205095E-05   -7.858198E-05   -6.127267E-16
                 1.144685E-03    4.847749E-05    5.162523E-05    5.919411E-16
                 7.244276E-04    6.003596E-04   -6.563381E-05   -5.377076E-16
                -4.555924E+00   -2.733553E-01   -7.767728E+00   -8.340812E-11
   -4.581530E-04
   -2.771019E-07    4.888491E-05
    0.000000E+00    0.000000E+00    0.000000E+00
!====================
 dxs_ddm        -4.080000E-06    4.700909E-08    5.900000E-08    3.106153E-19
                -5.204545E-06    3.412727E-08    2.199091E-08    2.245318E-19
                -2.079818E-05    5.954545E-08    6.800000E-07    7.968980E-18
                -2.121891E-03   -3.392782E-04   -1.265264E-02   -4.072270E-14
   -1.055636E-06
   -2.146073E-08   -1.948182E-08
    0.000000E+00    0.000000E+00    0.000000E+00
!====================
 dxs_axexp      -1.898519E-06   -5.209259E-08   -2.034444E-07   -2.049268E-18
                -1.471852E-06   -3.914444E-08   -5.842593E-08   -6.803200E-19
                -5.100741E-06   -3.733333E-07   -3.491852E-07   -4.041495E-18
                -2.384519E-03   -1.365863E-04   -5.154778E-03   -5.028600E-14
   -8.582963E-07
   -5.124204E-09    3.590370E-08
    0.000000E+00    0.000000E+00    0.000000E+00
!====================

Warning: These numbers where generated during a test run with very small neutron population and therefore are wrong.

To generate XSEC card for universe 2 we use similar code:

>> dbtype data_analyser.m 66:70 

66    xs.comp_num(2);
67    xs.base_macro(ref,2);
68    xs.dxs_dtf( (fthi-ref)./(log(1800)-log(300)),2);
69    xs.dxs_ddm( (cdlow-ref)./1100,2);
70    xs.dxs_axexp( (fhhi-ref)./2700,2);

Finally, we write this data to file with this code:

>> dbtype data_analyser.m 72:75

72    xs.display(); % diplay generated xsec card
73    xs.write();   % write to `xsecforparcs.txt` file by default
74    
75    clear xs;     % delete xs object

You can specify the name of the file as xs.write('myxseccard.txt'). This will save the xsec cards under myxseccard.txt under pwd.

To generate xsec card for each burnup-step we use for loop as follows:

>> dbtype data_analyser.m 77:100

77    % generate xsec cards for all burnups for universe 1.
78    
79    for i = 1:length(fuelpinburn_ref.res)
80        
81        ref   = xsec.dataOptimizer(fuelpinburn_ref.res(i));
82        fhhi  = xsec.dataOptimizer(fuelpinburn_fhhi.res(i));
83        fthi  = xsec.dataOptimizer(fuelpinburn_fthi.res(i));
84        cdlow = xsec.dataOptimizer(fuelpinburn_cdlow.res(i));
85        
86        xs = xsec();
87        
88        xs.comp_num(1);
89        xs.base_macro(ref,1);
90        xs.dxs_dtf( (fthi-ref)./(log(1800)-log(300)),1);
91        xs.dxs_ddm( (cdlow-ref)./1100,1);
92        xs.dxs_axexp( (fhhi-ref)./2700,1);
93        
94        
95        xs.display();
96        xs.write(['xsecburn_' num2str(i) '.txt']);% save with unique name
97        
98        clear xs; % delete xs instance of xsec class.
99        
100   end

This code will generate 42 xsecburn_*.txt files for each burnup step:

>> ls xsecburn_*
xsecburn_10.txt  xsecburn_20.txt  xsecburn_30.txt  xsecburn_40.txt
xsecburn_11.txt  xsecburn_21.txt  xsecburn_31.txt  xsecburn_41.txt
xsecburn_12.txt  xsecburn_22.txt  xsecburn_32.txt  xsecburn_42.txt
xsecburn_13.txt  xsecburn_23.txt  xsecburn_33.txt  xsecburn_4.txt
xsecburn_14.txt  xsecburn_24.txt  xsecburn_34.txt  xsecburn_5.txt
xsecburn_15.txt  xsecburn_25.txt  xsecburn_35.txt  xsecburn_6.txt
xsecburn_16.txt  xsecburn_26.txt  xsecburn_36.txt  xsecburn_7.txt
xsecburn_17.txt  xsecburn_27.txt  xsecburn_37.txt  xsecburn_8.txt
xsecburn_18.txt  xsecburn_28.txt  xsecburn_38.txt  xsecburn_9.txt
xsecburn_19.txt  xsecburn_29.txt  xsecburn_39.txt
xsecburn_1.txt	 xsecburn_2.txt   xsecburn_3.txt
Clone this wiki locally