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

Latin Hypercube Neutronic Sampling #10

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5352233
lhs for parameter space, adjust burnup parameters to shorten calculation
aaswenson Mar 19, 2018
b1f3e4e
generate inputs, tar them
aaswenson Mar 19, 2018
5fb7b85
some htc utiltiles, testing with 40 samples
aaswenson Mar 19, 2018
f995797
--ignore
aaswenson Mar 20, 2018
a9ca809
A module to parse MCNP depletion outputs
aaswenson Mar 20, 2018
f6797df
storing results
aaswenson Mar 20, 2018
71d51d4
test data
aaswenson Mar 20, 2018
30bba7e
plotting and fitting data
aaswenson Mar 21, 2018
d89deca
adding core_power
aaswenson Mar 21, 2018
b0e8814
don't store strings in memory
aaswenson Apr 2, 2018
786c062
initial attempt at multiple regression
aaswenson Apr 3, 2018
50be3ad
adding mass
aaswenson Apr 4, 2018
a44887c
calculate mass
aaswenson Apr 4, 2018
abe77b5
fix ordering of header parameters
aaswenson Apr 11, 2018
ebb7296
added ability to include constant parameters
aaswenson Apr 12, 2018
2e17eb6
data
aaswenson Apr 12, 2018
677fa4e
ND interpolation of the data
aaswenson Apr 16, 2018
2f53046
debuggin NN
aaswenson Apr 17, 2018
667a118
linear fit on the log data, code (rough) processes error
aaswenson Apr 19, 2018
1a5e34a
plot axis labels
aaswenson Apr 23, 2018
39216a6
linear regression use sklearn
aaswenson Apr 26, 2018
d0101a6
convienience featurees in skit_fit.py
aaswenson Apr 30, 2018
162d809
lots of plotting capability, huge commit, kept forgetting to commit...
aaswenson May 2, 2018
47cfb2a
trying different regression models
aaswenson May 2, 2018
88839e8
lots of plotting changes
aaswenson May 7, 2018
e2d25cb
added titles to plotting
aaswenson May 9, 2018
a860836
depletion parser
aaswenson May 14, 2018
2f3ac24
cleaned up neutronic_sweeps.py nad parse_outputs.py
aaswenson May 14, 2018
0d1e51e
more docstrings, comments, and clarifying code changes
aaswenson May 15, 2018
c3f6ffc
remove depletion results csv
aaswenson May 15, 2018
22d0077
docstrings and clarifying comments in parse_outputs.py
aaswenson May 15, 2018
4e511cd
more clarifying comments in neutronics_sweeps.py
aaswenson May 16, 2018
4681c38
set seed for lhs as default optional variable in 'gen_hypercube' func…
aaswenson May 16, 2018
202f162
convert float dimensions to tuples, keep consistency in calculation f…
aaswenson May 21, 2018
73d4418
simplify the parameter range calculation using numpy arrays
aaswenson May 21, 2018
7cd54b2
add reference csv to test output parser, fix energy average
aaswenson May 22, 2018
390aec9
conversion factors, clarifying comments, removal of magic numbers
aaswenson May 22, 2018
49a450e
add pyDOE install to yaml
aaswenson May 22, 2018
c73d6c7
cd into proper directories for testing
aaswenson May 22, 2018
af30af4
fix variable name
aaswenson May 22, 2018
f0c4c66
pep8 spacing, remove dated docstring from get_sampling_params()
aaswenson May 22, 2018
82d4db7
remove incorrect energy tally parser, simplify the keff parser, renam…
aaswenson Jun 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some htc utiltiles, testing with 40 samples
aaswenson committed May 15, 2018
commit 5fb7b857abed91ad58b85ec87763e586a7478da9
20 changes: 18 additions & 2 deletions neutronics/neutronic_sweeps.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
"""
from pyDOE import lhs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8: missing blank line

import os
import glob
import numpy as np
import tarfile

@@ -26,7 +27,7 @@
}

dim = len(parameters.keys())
samples = 2
samples = 40

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 lines there

def gen_hypercube(samples, N):
"""Generate N-dimensional latin hypercube to sample dimensional reactor
@@ -66,6 +67,10 @@ def fill_data_array(samples, parameters, cube):
# save to ndarray
test_cases[sample_idx][dim] = b + cube[sample_idx][dim_idx] * a

# write the data to a csv file
np.savetxt("data.csv", test_cases, delimiter=',',
header=','.join(test_cases.dtype.names))

return test_cases

def write_inputs(sampling_data):
@@ -90,11 +95,22 @@ def write_inputs(sampling_data):
filename = input.write_input(num, header_str)
tarputs.add(filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleanest to delete the file as soon as possible after you add it to the tarfile.


# write HTC input list
htc_inputs = open('input_files.txt', 'w')
htc_inputs.write('\n'.join(glob.glob("*.i")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the list of files you've just created, can't you generate it without a glob. Isn't it safer?

'\n'.join(["{0}.i".format(num) for num in range(len(sample_data))])

htc_inputs.close()

tarputs.add('input_list.txt')
tarputs.add('data.csv')
tarputs.close()

def write_input_list():
"""Write input list for HTC
"""

if __name__=='__main__':
cube = gen_hypercube(samples, dim)
data = fill_data_array(samples, parameters, cube)
write_inputs(data)
os.system('rm *.i')
# cleanup
os.system('rm *.i input_list.txt data.csv')