Application Output

Result files

All applications store their output in application specific binary result archives, with extension .res, and name usually the parameters.project_name. These output files are usually stored within the parameters.working_directory under the parameters.target_code sub directory. They are simply serialized forms of the applications core.result.ResultsSummary instance.

The utilities.load_file utility can be used to open and explore these result files, for example:

>>> from core import *
>>> res = utilities.load_file('FULL_PATH_TO_ROOT/WORKING_DIRECTORY/TARGET_CODE/project_name.res')

Since these objects are considered part of the low level interface, they are only fully described in the developers manual, but some online help is available when using

>>> help(res)

where res is the result object loaded earlier. Result tokens, which is described next, provides a cleaner interface to the application’s results archive.

Using output tokens

These are special, application specific objects that:

  1. Customize how results are extracted from the result archive, and provide a more user friendly interface to these results.

  2. Is used as a general placeholder for the results, in that it can be used as a variable (in any expression), even before the result is known.

  3. Set the required input variables and flags required by the application in order for the result to be available.

The last two properties play an important role in applications which dynamically generate sub applications based on output requirements (e.g reload), and the document generation utility docgen.

Using a token to extract results

Each token has a get method, which can be used to retrieve the requested output from the result archive. For example,

import applications.critical_case as app
from core import *

res = utilities.load_file('FULL_PATH_TO_ROOT/WORKING_DIRECTORY/TARGET_CODE/project_name.res')
# Extract k_eff using the multiplication_factor token
k_eff = app.multiplication_factor.get(res)
# Extract power fraction map

Changing the underlying application parameters

For application that dynamically generate sub-applications based on requested output tokens (such as reload), the behavior of the generated application can be customized by passing some additional parameters during the token construction:

  1. The parameters keyword, set to a dict object, mapping standard application parameter names to their requested values. For example,

    import applications.critical_case as app
    
    tkn = app.multiplication_factor(parameters={'target_mode': 'SERPENT', 'particles': 16000})
    

    will set the app_param.target_mode and app_param.particles parameters of the generated critical_case application.

    Parameter names can be nested, so that any sub-parameter can be set as well. For example,

    import applications.critical_case as app
    from core import *
    
    tkn = app.multiplication_factor(parameters={'target_mode': 'SERPENT', 'particles': 16000, 'model.state': state_param.fuel(50 * units.degC)})
    

    will also modify the model.state.

  2. The setup keyword, which can be used to pass a custom function (or function object) to perform more complex modifications of the generated application. The function passed must accept a single argument, which is the parameter set of the target application. For example, the same results as above can be achieved using

    import applications.critical_case as app
    from core import *
    
    def func(param):
    
        param.target_mode = 'SERPENT'
        param.particles = 16000
        param.model.state[state_param.fuel] = 50 * units.degC
    
    tkn = app.multiplication_factor(setup=func)