Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour for sandy.sampling.run() for libraries without covaraince data #291

Open
jbae11 opened this issue Dec 6, 2023 · 1 comment
Open

Comments

@jbae11
Copy link

jbae11 commented Dec 6, 2023

Please note that I'm not too knowledgeable with the code, so feel free to comment angry messages and close the issue if this is in error :)

For example, for ENDF-B-VII.1-neutrons n-008-O_017.endf,

sandy.sampling.run() errors because the get_perturbations() will return an empty dictionary (i.e., smps={}). This will cause the apply_perturbations() function to error with the following error message:

Traceback (most recent call last):
  File "go.py", line 10, in <module>
    obj.run()
  File "/home/4ib/anaconda3/envs/env_neutronics/lib/python3.7/site-packages/fermi-0.1-py3.7.egg/fermi/neutronics/nuclear_data_perturbation/openmc_data_pert.py", line 40, in run
    self.generate_perturbed_data()
  File "/home/4ib/anaconda3/envs/env_neutronics/lib/python3.7/site-packages/fermi-0.1-py3.7.egg/fermi/neutronics/nuclear_data_perturbation/openmc_data_pert.py", line 95, in generate_perturbed_data
    sandy.sampling.run(' '.join(cli))
  File "/home/4ib/anaconda3/envs/env_neutronics/lib/python3.7/site-packages/sandy-1.0.37-py3.7.egg/sandy/sampling.py", line 185, in inner
    foo(iargs)
  File "/home/4ib/anaconda3/envs/env_neutronics/lib/python3.7/site-packages/sandy-1.0.37-py3.7.egg/sandy/sampling.py", line 305, in run
    verbose=iargs.debug,
  File "/home/4ib/anaconda3/envs/env_neutronics/lib/python3.7/site-packages/sandy-1.0.37-py3.7.egg/sandy/core/endf6.py", line 2204, in apply_perturbations
    if not item:
UnboundLocalError: local variable 'item' referenced before assignment

Is there a way to add an argument so that if the file does not have any covariance data it will just output something helpful? Thanks!

@jbae11
Copy link
Author

jbae11 commented Dec 6, 2023

This is what I used, but I feel like it's not the most appropriate:


    if not smps: # covariance data does not exist
        print('Covariance data does not exist!')
        pendf = endf6.get_pendf(**pendf_kws)
        ace = endf6.get_ace(pendf=pendf, **ace_kws)
        suffix = ace_kws.get("suffix", "." + sandy.njoy.get_temperature_suffix(temperature))
        file_name = iargs.outname + suffix + 'c'
        for i in range(iargs.samples):
            fn = file_name.replace('{SMP}', str(i))
            with open(fn, 'w') as f:
                f.write(ace['ace'])
            fn += '.xsd'
            with open(fn, 'w') as f:
                f.write(ace['xsdir'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant