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

nGray_Analytic_MultigroupOpacity to Compound_Analytic_MultigroupOpacity #619

Merged
merged 2 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//----------------------------------*-C++-*----------------------------------//
/*!
* \file cdi_analytic/nGray_Analytic_MultigroupOpacity.cc
* \author Thomas M. Evans
* \date Tue Nov 13 11:19:59 2001
* \brief nGray_Analytic_MultigroupOpacity class member definitions.
* \file cdi_analytic/Compound_Analytic_MultigroupOpacity.cc
* \brief Compound_Analytic_MultigroupOpacity class member definitions.
* \note Copyright (C) 2016-2019 Triad National Security, LLC.
* All rights reserved. */
//---------------------------------------------------------------------------//

#include "nGray_Analytic_MultigroupOpacity.hh"
#include "Compound_Analytic_MultigroupOpacity.hh"
#include "ds++/Packing_Utils.hh"
#include "ds++/dbc.hh"

Expand All @@ -27,7 +25,7 @@ namespace rtt_cdi_analytic {
* rtt_cdi::Reaction argument.
*
* The group structure (in keV) must be provided by the groups argument. The
* number of Analytic_Opacity_Model objects given in the models argument must
* number of Analytic_Opacity_Model objects given in the models argument must
* be equal to the number of groups.
*
* \param groups vector containing the group boundaries in keV from lowest to
Expand All @@ -37,26 +35,28 @@ namespace rtt_cdi_analytic {
* \param reaction_in rtt_cdi::Reaction type (enumeration)
* \param model_in Enum specifying CDI model.
*/
nGray_Analytic_MultigroupOpacity::nGray_Analytic_MultigroupOpacity(
Compound_Analytic_MultigroupOpacity::Compound_Analytic_MultigroupOpacity(
const sf_double &groups, const sf_Analytic_Model &models,
rtt_cdi::Reaction reaction_in, rtt_cdi::Model model_in)
: Analytic_MultigroupOpacity(groups, reaction_in, model_in),
group_models(models) {
Require(groups.size() - 1 == models.size());
Require(
rtt_dsxx::is_strict_monotonic_increasing(groups.begin(), groups.end()));

Ensure(check_class_invariant());
}

//---------------------------------------------------------------------------//
/*!
* \brief Unpacking constructor.
*
* This constructor rebuilds and nGray_Analytic_MultigroupOpacity from a
* This constructor rebuilds and Compound_Analytic_MultigroupOpacity from a
* vector<char> that was created by a call to pack(). It can only rebuild
* Analytic_Model types that have been registered in the
* rtt_cdi_analytic::Opacity_Models enumeration.
*/
nGray_Analytic_MultigroupOpacity::nGray_Analytic_MultigroupOpacity(
Compound_Analytic_MultigroupOpacity::Compound_Analytic_MultigroupOpacity(
const sf_char &packed)
: Analytic_MultigroupOpacity(packed), group_models() {
// get the number of group boundaries
Expand Down Expand Up @@ -108,7 +108,11 @@ nGray_Analytic_MultigroupOpacity::nGray_Analytic_MultigroupOpacity(
Ensure(group_models[i]);
}

Ensure(num_groups == group_models.size());
Ensure(check_class_invariant());
}
//---------------------------------------------------------------------------//
bool Compound_Analytic_MultigroupOpacity::check_class_invariant() const {
return group_models.size() + 1 == getGroupBoundaries().size();
}

//---------------------------------------------------------------------------//
Expand All @@ -120,28 +124,32 @@ nGray_Analytic_MultigroupOpacity::nGray_Analytic_MultigroupOpacity(
* Given a scalar temperature and density, return the group opacities
* (vector<double>) for the reaction type specified by the constructor. The
* analytic opacity model is specified in the constructor
* (nGray_Analytic_MultigroupOpacity()).
* (Compound_Analytic_MultigroupOpacity()).
*
* \param temperature material temperature in keV
* \param density material density in g/cm^3
* \return group opacities (coefficients) in cm^2/g
*
*/
nGray_Analytic_MultigroupOpacity::sf_double
nGray_Analytic_MultigroupOpacity::getOpacity(double temperature,
double density) const {
Compound_Analytic_MultigroupOpacity::sf_double
Compound_Analytic_MultigroupOpacity::getOpacity(double temperature,
double density) const {
Require(temperature >= 0.0);
Require(density >= 0.0);

// return opacities
sf_double opacities(group_models.size(), 0.0);

// loop through groups and get opacities
auto nu = getGroupBoundaries();
Check(nu.size() == group_models.size() + 1);

for (size_t i = 0; i < opacities.size(); ++i) {
Check(group_models[i]);

// assign the opacity based on the group model
opacities[i] = group_models[i]->calculate_opacity(temperature, density);
opacities[i] = group_models[i]->calculate_opacity(temperature, density,
nu[i], nu[i + 1]);
keadyk marked this conversation as resolved.
Show resolved Hide resolved

Check(opacities[i] >= 0.0);
}
Expand Down Expand Up @@ -170,9 +178,9 @@ nGray_Analytic_MultigroupOpacity::getOpacity(double temperature,
* \return std::vector<std::vector> of multigroup opacities (coefficients) in
* cm^2/g indexed [temperature][group]
*/
nGray_Analytic_MultigroupOpacity::vf_double
nGray_Analytic_MultigroupOpacity::getOpacity(const sf_double &temperature,
double density) const {
Compound_Analytic_MultigroupOpacity::vf_double
Compound_Analytic_MultigroupOpacity::getOpacity(const sf_double &temperature,
double density) const {
Require(density >= 0.0);

// define the return opacity field (same size as temperature field); each
Expand Down Expand Up @@ -219,9 +227,9 @@ nGray_Analytic_MultigroupOpacity::getOpacity(const sf_double &temperature,
* \return std::vector<std::vector> of multigroup opacities (coefficients) in
* cm^2/g indexed [density][group]
*/
nGray_Analytic_MultigroupOpacity::vf_double
nGray_Analytic_MultigroupOpacity::getOpacity(double temperature,
const sf_double &density) const {
Compound_Analytic_MultigroupOpacity::vf_double
Compound_Analytic_MultigroupOpacity::getOpacity(
double temperature, const sf_double &density) const {
Require(temperature >= 0.0);

// define the return opacity field (same size as density field); each
Expand Down Expand Up @@ -256,8 +264,8 @@ nGray_Analytic_MultigroupOpacity::getOpacity(double temperature,
* class must have a pack function; this is enforced by the virtual
* Analytic_Opacity_Model base class.
*/
nGray_Analytic_MultigroupOpacity::sf_char
nGray_Analytic_MultigroupOpacity::pack() const {
Compound_Analytic_MultigroupOpacity::sf_char
Compound_Analytic_MultigroupOpacity::pack() const {
// make a packer
rtt_dsxx::Packer packer;

Expand Down Expand Up @@ -306,5 +314,5 @@ nGray_Analytic_MultigroupOpacity::pack() const {
} // end namespace rtt_cdi_analytic

//---------------------------------------------------------------------------//
// end of nGray_Analytic_MultigroupOpacity.cc
// end of Compound_Analytic_MultigroupOpacity.cc
//---------------------------------------------------------------------------//
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
//----------------------------------*-C++-*----------------------------------//
/*!
* \file cdi_analytic/nGray_Analytic_MultigroupOpacity.hh
* \file cdi_analytic/Compound_Analytic_MultigroupOpacity.hh
* \author Thomas M. Evans
* \date Tue Nov 13 11:19:59 2001
* \brief nGray_Analytic_MultigroupOpacity class definition.
* \brief Compound_Analytic_MultigroupOpacity class definition.
* \note Copyright (C) 2016-2019 Triad National Security, LLC.
* All rights reserved. */
//---------------------------------------------------------------------------//

#ifndef __cdi_analytic_nGray_Analytic_MultigroupOpacity_hh__
#define __cdi_analytic_nGray_Analytic_MultigroupOpacity_hh__
#ifndef __cdi_analytic_Compound_Analytic_MultigroupOpacity_hh__
#define __cdi_analytic_Compound_Analytic_MultigroupOpacity_hh__

#include "Analytic_MultigroupOpacity.hh"

namespace rtt_cdi_analytic {

//===========================================================================//
/*!
* \class nGray_Analytic_MultigroupOpacity
* \class Compound_Analytic_MultigroupOpacity
*
* \brief Derived Analytic_MultigroupOpacity class for analytic opacities.
*
* The nGray_Analytic_MultigroupOpacity class is a derived
* The Compound_Analytic_MultigroupOpacity class is a derived
* Analytic_MultigroupOpacity class. It provides analytic opacity data. The
* specific analytic opacity model is derived from the
* rtt_cdi_analytic::Analytic_Opacity_Model base class. Several pre-built
Expand Down Expand Up @@ -56,14 +56,14 @@ namespace rtt_cdi_analytic {
* Analytic_MultigroupOpacity and can be used with rtt_cdi::CDI to get
* analytic opacities.
*
* \example cdi_analytic/test/tstnGray_Analytic_MultigroupOpacity.cc
* \example cdi_analytic/test/tstCompound_Analytic_MultigroupOpacity.cc
*
* Example usage of nGray_Analytic_MultigroupOpacity, Analytic_Opacity_Model,
* Example usage of Compound_Analytic_MultigroupOpacity, Analytic_Opacity_Model,
* and their incorporation into rtt_cdi::CDI.
*/
//===========================================================================//

class nGray_Analytic_MultigroupOpacity : public Analytic_MultigroupOpacity {
class Compound_Analytic_MultigroupOpacity : public Analytic_MultigroupOpacity {
public:
// Useful typedefs.
typedef std::shared_ptr<Analytic_Opacity_Model> SP_Analytic_Model;
Expand All @@ -80,13 +80,16 @@ private:

public:
// Constructor.
nGray_Analytic_MultigroupOpacity(const sf_double &groups,
const sf_Analytic_Model &models,
rtt_cdi::Reaction reaction_in,
rtt_cdi::Model model_in = rtt_cdi::ANALYTIC);
Compound_Analytic_MultigroupOpacity(
const sf_double &groups, const sf_Analytic_Model &models,
rtt_cdi::Reaction reaction_in,
rtt_cdi::Model model_in = rtt_cdi::ANALYTIC);

// Constructor for packed Analytic_Multigroup_Opacities
explicit nGray_Analytic_MultigroupOpacity(const sf_char &packed);
explicit Compound_Analytic_MultigroupOpacity(const sf_char &packed);

// Check that the class invariant is not violated.
bool check_class_invariant() const;

// >>> ACCESSORS
const_Model get_Analytic_Model(size_t g) const { return group_models[g - 1]; }
Expand All @@ -105,39 +108,39 @@ public:
// Get the data description of the opacity.
inline std_string getDataDescriptor(void) const;

// Pack the nGray_Analytic_MultigroupOpacity into a character string.
// Pack the Compound_Analytic_MultigroupOpacity into a character string.
sf_char pack(void) const;
};

//---------------------------------------------------------------------------//
// INLINE FUNCTIONS
//---------------------------------------------------------------------------//
//! Return a string describing the opacity model.
nGray_Analytic_MultigroupOpacity::std_string
nGray_Analytic_MultigroupOpacity::getDataDescriptor() const {
Compound_Analytic_MultigroupOpacity::std_string
Compound_Analytic_MultigroupOpacity::getDataDescriptor() const {
std_string descriptor;

rtt_cdi::Reaction const rxn = getReactionType();

if (rxn == rtt_cdi::TOTAL)
descriptor = "nGray Multigroup Total";
descriptor = "Compound Multigroup Total";
else if (rxn == rtt_cdi::ABSORPTION)
descriptor = "nGray Multigroup Absorption";
descriptor = "Compound Multigroup Absorption";
else if (rxn == rtt_cdi::SCATTERING)
descriptor = "nGray Multigroup Scattering";
descriptor = "Compound Multigroup Scattering";
else {
Insist(rxn == rtt_cdi::TOTAL || rxn == rtt_cdi::ABSORPTION ||
rxn == rtt_cdi::SCATTERING,
"Invalid nGray multigroup model opacity!");
"Invalid Compound multigroup model opacity!");
}

return descriptor;
}

} // namespace rtt_cdi_analytic

#endif // __cdi_analytic_nGray_Analytic_MultigroupOpacity_hh__
#endif // __cdi_analytic_Compound_Analytic_MultigroupOpacity_hh__

//---------------------------------------------------------------------------//
// end of cdi_analytic/nGray_Analytic_MultigroupOpacity.hh
// end of cdi_analytic/Compound_Analytic_MultigroupOpacity.hh
//---------------------------------------------------------------------------//
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//----------------------------------*-C++-*----------------------------------//
/*!
* \file cdi_analytic/nGray_Analytic_Odfmg_Opacity.cc
* \file cdi_analytic/Compound_Analytic_Odfmg_Opacity.cc
* \author Thomas M. Evans
* \date Tue Nov 13 11:19:59 2001
* \brief nGray_Analytic_Odfmg_Opacity class member definitions.
* \brief Compound_Analytic_Odfmg_Opacity class member definitions.
* \note Copyright (C) 2016-2019 Triad National Security, LLC.
* All rights reserved. */
//---------------------------------------------------------------------------//

#include "nGray_Analytic_Odfmg_Opacity.hh"
#include "nGray_Analytic_MultigroupOpacity.hh"
#include "Compound_Analytic_Odfmg_Opacity.hh"
#include "Compound_Analytic_MultigroupOpacity.hh"
#include "ds++/Packing_Utils.hh"
#include "ds++/dbc.hh"

Expand All @@ -22,13 +22,13 @@ namespace rtt_cdi_analytic {
* \brief Constructor for an analytic multigroup opacity model.
*
* This constructor builds an opacity model defined by the
* rtt_cdi_analytic::nGray_Analytic_Opacity_Model derived class argument.
* rtt_cdi_analytic::Compound_Analytic_Opacity_Model derived class argument.
*
* The reaction type for this instance of the class is determined by the
* rtt_cdi::Reaction argument.
*
* The group structure (in keV) must be provided by the groups argument. The
* number of nGray_Analytic_Opacity_Model objects given in the models argument
* number of Compound_Analytic_Opacity_Model objects given in the models argument
* must be equal to the number of groups.
*
* \param groups vector containing the group boundaries in keV from lowest to
Expand All @@ -40,7 +40,7 @@ namespace rtt_cdi_analytic {
* \param reaction_in rtt_cdi::Reaction type (enumeration)
* \param model_in An enumeration for the model.
*/
nGray_Analytic_Odfmg_Opacity::nGray_Analytic_Odfmg_Opacity(
Compound_Analytic_Odfmg_Opacity::Compound_Analytic_Odfmg_Opacity(
const sf_double &groups, const sf_double &bands,
const sf_Analytic_Model &models, rtt_cdi::Reaction reaction_in,
rtt_cdi::Model model_in)
Expand All @@ -56,12 +56,12 @@ nGray_Analytic_Odfmg_Opacity::nGray_Analytic_Odfmg_Opacity(
/*!
* \brief Unpacking constructor.
*
* This constructor rebuilds and nGray_Analytic_Odfmg_Opacity from a
* This constructor rebuilds and Compound_Analytic_Odfmg_Opacity from a
* vector<char> that was created by a call to pack(). It can only rebuild
* Analytic_Model types that have been registered in the
* rtt_cdi_analytic::Opacity_Models enumeration.
*/
nGray_Analytic_Odfmg_Opacity::nGray_Analytic_Odfmg_Opacity(
Compound_Analytic_Odfmg_Opacity::Compound_Analytic_Odfmg_Opacity(
const sf_char &packed)
: Analytic_Odfmg_Opacity(packed), group_models() {
// the packed size must be at least 5 integers (number of groups, number of
Expand Down Expand Up @@ -131,15 +131,15 @@ nGray_Analytic_Odfmg_Opacity::nGray_Analytic_Odfmg_Opacity(
* Given a scalar temperature and density, return the group opacities
* (vector<double>) for the reaction type specified by the constructor. The
* analytic opacity model is specified in the constructor
* (nGray_Analytic_Odfmg_Opacity()).
* (Compound_Analytic_Odfmg_Opacity()).
*
* \param targetTemperature material temperature in keV
* \param targetDensity material density in g/cm^3
* \return group opacities (coefficients) in cm^2/g
*/
std::vector<std::vector<double>>
nGray_Analytic_Odfmg_Opacity::getOpacity(double targetTemperature,
double targetDensity) const {
Compound_Analytic_Odfmg_Opacity::getOpacity(double targetTemperature,
double targetDensity) const {
Require(targetTemperature >= 0.0);
Require(targetDensity >= 0.0);

Expand Down Expand Up @@ -180,7 +180,7 @@ nGray_Analytic_Odfmg_Opacity::getOpacity(double targetTemperature,
* single density value.
*/
std::vector<std::vector<std::vector<double>>>
nGray_Analytic_Odfmg_Opacity::getOpacity(
Compound_Analytic_Odfmg_Opacity::getOpacity(
const std::vector<double> &targetTemperature, double targetDensity) const {
std::vector<std::vector<std::vector<double>>> opacity(
targetTemperature.size());
Expand All @@ -198,7 +198,7 @@ nGray_Analytic_Odfmg_Opacity::getOpacity(
* density values.
*/
std::vector<std::vector<std::vector<double>>>
nGray_Analytic_Odfmg_Opacity::getOpacity(
Compound_Analytic_Odfmg_Opacity::getOpacity(
double targetTemperature, const std::vector<double> &targetDensity) const {
std::vector<std::vector<std::vector<double>>> opacity(targetDensity.size());

Expand All @@ -214,12 +214,12 @@ nGray_Analytic_Odfmg_Opacity::getOpacity(
* \brief Pack an analytic odfmg opacity.
*
* This function will pack up the Analytic_Mulitgroup_Opacity into a char array
* (represented by a vector<char>). The nGray_Analytic_Opacity_Model derived
* (represented by a vector<char>). The Compound_Analytic_Opacity_Model derived
* class must have a pack function; this is enforced by the virtual
* nGray_Analytic_Opacity_Model base class.
* Compound_Analytic_Opacity_Model base class.
*/
nGray_Analytic_Odfmg_Opacity::sf_char
nGray_Analytic_Odfmg_Opacity::pack() const {
Compound_Analytic_Odfmg_Opacity::sf_char
Compound_Analytic_Odfmg_Opacity::pack() const {
// make a packer
rtt_dsxx::Packer packer;

Expand Down Expand Up @@ -268,5 +268,5 @@ nGray_Analytic_Odfmg_Opacity::pack() const {
} // end namespace rtt_cdi_analytic

//---------------------------------------------------------------------------//
// end of nGray_Analytic_Odfmg_Opacity.cc
// end of Compound_Analytic_Odfmg_Opacity.cc
//---------------------------------------------------------------------------//
Loading