mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Changes in data/endf.c from PullRequest Inc. review
This commit is contained in:
parent
72f2855553
commit
d56c784806
3 changed files with 20 additions and 1 deletions
|
|
@ -1,14 +1,31 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
//! Convert string representation of a floating point number into a double
|
||||
//
|
||||
//! This function handles converting floating point numbers from an ENDF 11
|
||||
//! character field into a double, covering all the corner cases. Floating point
|
||||
//! numbers are allowed to contain whitespace (which is ignored). Also, in
|
||||
//! exponential notation, it allows the 'e' to be omitted. A field containing
|
||||
//! only whitespace is to be interpreted as a zero.
|
||||
//
|
||||
//! \param buffer character input from an ENDF file
|
||||
//! \param n Length of character input
|
||||
//! \return Floating point number
|
||||
|
||||
double cfloat_endf(const char* buffer, int n)
|
||||
{
|
||||
char arr[12]; // 11 characters plus a null terminator
|
||||
int j = 0; // current position in arr
|
||||
int found_significand = 0;
|
||||
int found_exponent = 0;
|
||||
|
||||
// limit n to 11 characters
|
||||
n = n > 11 ? 11 : n;
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
// Skip whitespace characters
|
||||
char c = buffer[i];
|
||||
|
||||
// Skip whitespace characters
|
||||
if (c == ' ') continue;
|
||||
|
||||
if (found_significand) {
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ class KalbachMann(AngleEnergy):
|
|||
eout_i = Mixture([p_discrete, 1. - p_discrete],
|
||||
[eout_discrete, eout_continuous])
|
||||
|
||||
# Precompound factor and slope are on rows 3 and 4, respectively
|
||||
km_r = Tabulated1D(data[0, j:j+n], data[3, j:j+n])
|
||||
km_a = Tabulated1D(data[0, j:j+n], data[4, j:j+n])
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ def test_float_endf():
|
|||
assert endf.float_endf('1.+2') == approx(100.0)
|
||||
assert endf.float_endf('-1.+2') == approx(-100.0)
|
||||
assert endf.float_endf(' ') == 0.0
|
||||
assert endf.float_endf('9.876540000000000') == approx(9.87654)
|
||||
|
||||
|
||||
def test_int_endf():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue