From f5cff7baefeecd259e8d0714382c036443d88cbf Mon Sep 17 00:00:00 2001 From: liangjg Date: Thu, 28 Mar 2019 16:58:46 -0400 Subject: [PATCH] generate heating number --- openmc/data/photon.py | 11 ++++++----- src/tallies/tally_scoring.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 78b48593ee..fd6a8fd177 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -523,8 +523,7 @@ class IncidentPhoton(EqualityMixin): data.reactions[mt] = PhotonReaction.from_ace(ace, mt) # Get heating cross sections [eV*barn] from factors [eV per collision] - # by multiplying with total xs (sum of (502, 504, 515, 517, 522)) - # but currently we cannot do this right as we miss 517) + # by multiplying with total xs (sum of (502, 504, 515, 522)) data.reactions[525].xs.y *= sum([data.reactions[mt].xs.y for mt in (502, 504, 515, 522)]) @@ -658,7 +657,7 @@ class IncidentPhoton(EqualityMixin): data._add_bremsstrahlung() # Add heating cross sections - #data._compute_heating() + data._compute_heating() return data @@ -909,12 +908,14 @@ class IncidentPhoton(EqualityMixin): k = E/MASS_ELECTRON_EV k_p = k/(1.0 + k*(1.0 - mu)) x = E * np.sqrt(0.5*(1.0 - mu)) / PLANCK_C - return np.pi * RE*RE * k_p/k * k_p/k * (k_p + 1.0/k_p + + return np.pi*RE*RE*k_p/k*k_p/k*(k_p + 1.0/k_p + mu*mu - 1.0) * rx.scattering_factor(x) def xs_mu_E(mu, E): E_p = E/(1.0 + E/MASS_ELECTRON_EV*(1-mu)) return xs_mu(mu, E) * E_p - e_new = np.array([quad(xs_mu_E, -1, 1, args=(e,))[0]/quad(xs_mu, -1, 1, args=(e,))[0] for e in energy]) + e_new = np.array([quad(xs_mu_E, -1, 1, args=(e,), epsabs=0.0, + epsrel=1.0e-3)[0] / quad(xs_mu, -1, 1, args=(e,), + epsabs=0.0, epsrel=1.0e-3)[0] for e in energy]) heating_xs += (energy - e_new)*rx.xs(energy) if 515 in self: diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index b0bf8f4483..8fb85db5db 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -1247,8 +1247,8 @@ score_general_ce(Particle* p, int i_tally, int start_index, std::string element = name.substr(0, pos); int i_element = data::element_map[element]; auto& heating {data::elements[i_element].heating_}; - auto i_grid = simulation::micro_photon_xs[i_element].index_grid; - auto f = simulation::micro_photon_xs[i_element].interp_factor; + auto i_grid = p->photon_xs_[i_element].index_grid; + auto f = p->photon_xs_[i_element].interp_factor; score = std::exp(heating(i_grid) + f * (heating(i_grid+1) - heating(i_grid))) * atom_density * flux; } else { @@ -1258,8 +1258,8 @@ score_general_ce(Particle* p, int i_tally, int start_index, auto i_element = material.element_[i]; auto atom_density = material.atom_density_(i); auto& heating {data::elements[i_element].heating_}; - auto i_grid = simulation::micro_photon_xs[i_element].index_grid; - auto f = simulation::micro_photon_xs[i_element].interp_factor; + auto i_grid = p->photon_xs_[i_element].index_grid; + auto f = p->photon_xs_[i_element].interp_factor; score += std::exp(heating(i_grid) + f * (heating(i_grid+1) - heating(i_grid))) * atom_density * flux; }