mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Make use of make_unique
Also use make_shared more consistently
This commit is contained in:
committed by
Ingmar Schoegl
parent
da264799cb
commit
7a69a67f2c
@@ -37,6 +37,7 @@ namespace Cantera
|
||||
using std::shared_ptr;
|
||||
using std::make_shared;
|
||||
using std::unique_ptr;
|
||||
using std::make_unique;
|
||||
using std::isnan; // workaround for bug in libstdc++ 4.8
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
using ArrheniusBase::ArrheniusBase; // inherit constructors
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<ArrheniusRate, ArrheniusData>);
|
||||
return make_unique<MultiRate<ArrheniusRate, ArrheniusData>>();
|
||||
}
|
||||
|
||||
virtual const std::string type() const override {
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
const UnitStack& rate_units={});
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<BlowersMaselRate, BlowersMaselData>);
|
||||
return make_unique<MultiRate<BlowersMaselRate, BlowersMaselData>>();
|
||||
}
|
||||
|
||||
virtual const std::string type() const override {
|
||||
|
||||
@@ -108,8 +108,7 @@ public:
|
||||
ChebyshevRate(const AnyMap& node, const UnitStack& rate_units={});
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const {
|
||||
return unique_ptr<MultiRateBase>(
|
||||
new MultiRate<ChebyshevRate, ChebyshevData>);
|
||||
return make_unique<MultiRate<ChebyshevRate, ChebyshevData>>();
|
||||
}
|
||||
|
||||
const std::string type() const { return "Chebyshev"; }
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
CustomFunc1Rate(const AnyMap& node, const UnitStack& rate_units);
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<CustomFunc1Rate, ArrheniusData>);
|
||||
return make_unique<MultiRate<CustomFunc1Rate, ArrheniusData>>();
|
||||
}
|
||||
|
||||
const std::string type() const override { return "custom-rate-function"; }
|
||||
|
||||
@@ -286,8 +286,7 @@ public:
|
||||
const vector_fp& c);
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override{
|
||||
return unique_ptr<MultiRateBase>(
|
||||
new MultiRate<LindemannRate, FalloffData>);
|
||||
return make_unique<MultiRate<LindemannRate, FalloffData>>();
|
||||
}
|
||||
|
||||
virtual const std::string subType() const override {
|
||||
@@ -337,7 +336,7 @@ public:
|
||||
const vector_fp& c);
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<TroeRate, FalloffData>);
|
||||
return make_unique<MultiRate<TroeRate, FalloffData>>();
|
||||
}
|
||||
|
||||
//! Set coefficients used by parameterization
|
||||
@@ -436,7 +435,7 @@ public:
|
||||
}
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<SriRate, FalloffData>);
|
||||
return make_unique<MultiRate<SriRate, FalloffData>>();
|
||||
}
|
||||
|
||||
//! Set coefficients used by parameterization
|
||||
@@ -543,7 +542,7 @@ public:
|
||||
}
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<TsangRate, FalloffData>);
|
||||
return make_unique<MultiRate<TsangRate, FalloffData>>();
|
||||
}
|
||||
|
||||
//! Set coefficients used by parameterization
|
||||
|
||||
@@ -372,8 +372,7 @@ public:
|
||||
}
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(
|
||||
new MultiRate<InterfaceRate<RateType, DataType>, DataType>);
|
||||
return make_unique<MultiRate<InterfaceRate<RateType, DataType>, DataType>>();
|
||||
}
|
||||
|
||||
//! Identifier of reaction rate type
|
||||
@@ -461,8 +460,7 @@ public:
|
||||
}
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(
|
||||
new MultiRate<StickingRate<RateType, DataType>, DataType>);
|
||||
return make_unique<MultiRate<StickingRate<RateType, DataType>, DataType>>();
|
||||
}
|
||||
|
||||
//! Identifier of reaction rate type
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
PlogRate(const AnyMap& node, const UnitStack& rate_units={});
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const {
|
||||
return unique_ptr<MultiRateBase>(new MultiRate<PlogRate, PlogData>);
|
||||
return make_unique<MultiRate<PlogRate, PlogData>>();
|
||||
}
|
||||
|
||||
//! Identifier of reaction rate type
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
//!
|
||||
//! ```.cpp
|
||||
//! unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
//! return unique_ptr<MultiRateBase>(new MultiRate<RateType, DataType>);
|
||||
//! return make_unique<MultiRate<RateType, DataType>>();
|
||||
//! ```
|
||||
//!
|
||||
//! where `RateType` is the derived class name and `DataType` is the corresponding
|
||||
|
||||
@@ -78,8 +78,7 @@ public:
|
||||
TwoTempPlasmaRate(const AnyMap& node, const UnitStack& rate_units={});
|
||||
|
||||
unique_ptr<MultiRateBase> newMultiRate() const override {
|
||||
return unique_ptr<MultiRateBase>(
|
||||
new MultiRate<TwoTempPlasmaRate, TwoTempPlasmaData>);
|
||||
return make_unique<MultiRate<TwoTempPlasmaRate, TwoTempPlasmaData>>();
|
||||
}
|
||||
|
||||
virtual const std::string type() const override {
|
||||
|
||||
@@ -607,7 +607,7 @@ AnyValue& AnyValue::operator=(AnyValue const& other) {
|
||||
}
|
||||
AnyBase::operator=(other);
|
||||
m_key = other.m_key;
|
||||
m_value.reset(new boost::any{*other.m_value});
|
||||
m_value = make_unique<boost::any>(*other.m_value);
|
||||
m_equals = other.m_equals;
|
||||
return *this;
|
||||
}
|
||||
@@ -1560,7 +1560,8 @@ AnyMap::OrderedProxy::OrderedProxy(const AnyMap& data)
|
||||
{
|
||||
// Units always come first
|
||||
if (m_data->hasKey("__units__") && m_data->at("__units__").as<AnyMap>().size()) {
|
||||
m_units.reset(new std::pair<const string, AnyValue>{"units", m_data->at("__units__")});
|
||||
m_units = make_unique<pair<const string, AnyValue>>(
|
||||
"units", m_data->at("__units__"));
|
||||
m_units->second.setFlowStyle();
|
||||
m_ordered.emplace_back(std::pair<int, int>{-2, 0}, m_units.get());
|
||||
}
|
||||
@@ -1672,7 +1673,7 @@ void AnyMap::applyUnits(shared_ptr<UnitSystem>& units) {
|
||||
m_data.erase("units");
|
||||
}
|
||||
if (hasKey("__units__")) {
|
||||
m_units.reset(new UnitSystem(*units));
|
||||
m_units = make_shared<UnitSystem>(*units);
|
||||
m_units->setDefaults(m_data["__units__"].asMap<std::string>());
|
||||
} else {
|
||||
m_units = units;
|
||||
@@ -1691,7 +1692,7 @@ void AnyMap::setUnits(const UnitSystem& units)
|
||||
} else {
|
||||
m_data["__units__"] = units.getDelta(*m_units);
|
||||
}
|
||||
m_units.reset(new UnitSystem(units));
|
||||
m_units = make_shared<UnitSystem>(units);
|
||||
}
|
||||
|
||||
void AnyMap::setFlowStyle(bool flow) {
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace Cantera
|
||||
Storage::Storage(std::string fname, bool write) : m_write(write)
|
||||
{
|
||||
if (m_write) {
|
||||
m_file.reset(new h5::File(fname, h5::File::OpenOrCreate));
|
||||
m_file = make_unique<h5::File>(fname, h5::File::OpenOrCreate);
|
||||
} else {
|
||||
m_file.reset(new h5::File(fname, h5::File::ReadOnly));
|
||||
m_file = make_unique<h5::File>(fname, h5::File::ReadOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ Application::Messages::Messages()
|
||||
{
|
||||
// install a default logwriter that writes to standard
|
||||
// output / standard error
|
||||
logwriter.reset(new Logger());
|
||||
logwriter = make_unique<Logger>();
|
||||
}
|
||||
|
||||
void Application::Messages::addError(const std::string& r, const std::string& msg)
|
||||
|
||||
@@ -1657,7 +1657,7 @@ extern "C" {
|
||||
{
|
||||
static unique_ptr<Logger> logwriter;
|
||||
try {
|
||||
logwriter.reset(new ExternalLogger(writer));
|
||||
logwriter = make_unique<ExternalLogger>(writer);
|
||||
setLogger(logwriter.get());
|
||||
return 0;
|
||||
} catch (...) {
|
||||
|
||||
@@ -53,7 +53,7 @@ VCS_SOLVE::VCS_SOLVE(MultiPhase* mphase, int printLvl) :
|
||||
{
|
||||
m_speciesThermoList.resize(m_nsp);
|
||||
for (size_t kspec = 0; kspec < m_nsp; kspec++) {
|
||||
m_speciesThermoList[kspec].reset(new VCS_SPECIES_THERMO());
|
||||
m_speciesThermoList[kspec] = make_unique<VCS_SPECIES_THERMO>();
|
||||
}
|
||||
|
||||
string ser = "VCS_SOLVE: ERROR:\n\t";
|
||||
@@ -123,7 +123,7 @@ VCS_SOLVE::VCS_SOLVE(MultiPhase* mphase, int printLvl) :
|
||||
// Phase Info
|
||||
m_VolPhaseList.resize(m_numPhases);
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
m_VolPhaseList[iph].reset(new vcs_VolPhase(this));
|
||||
m_VolPhaseList[iph] = make_unique<vcs_VolPhase>(this);
|
||||
}
|
||||
|
||||
// For Future expansion
|
||||
|
||||
@@ -189,7 +189,7 @@ void ImplicitSurfChem::solvePseudoSteadyStateProblem(int ifuncOverride,
|
||||
// time scale - time over which to integrate equations
|
||||
doublereal time_scale = timeScaleOverride;
|
||||
if (!m_surfSolver) {
|
||||
m_surfSolver.reset(new solveSP(this, bulkFunc));
|
||||
m_surfSolver = make_unique<solveSP>(this, bulkFunc);
|
||||
// set ifunc, which sets the algorithm.
|
||||
ifunc = SFLUX_INITIALIZE;
|
||||
} else {
|
||||
|
||||
@@ -282,7 +282,7 @@ void Reaction::setRate(shared_ptr<ReactionRate> rate)
|
||||
"Reaction equation for falloff reaction '{}'\n does not "
|
||||
"contain valid pressure-dependent third body", equation());
|
||||
}
|
||||
m_third_body.reset(new ThirdBody("(+M)"));
|
||||
m_third_body = make_shared<ThirdBody>("(+M)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin)
|
||||
"Collision efficiencies need to specify single species", equation);
|
||||
}
|
||||
third_body = effs.begin()->first;
|
||||
m_third_body.reset(new ThirdBody(third_body));
|
||||
m_third_body = make_shared<ThirdBody>(third_body);
|
||||
m_third_body->explicit_3rd = true;
|
||||
} else if (input.hasKey("default-efficiency")) {
|
||||
// insufficient disambiguation of third bodies
|
||||
@@ -462,7 +462,7 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin)
|
||||
}
|
||||
m_third_body->setName(third_body);
|
||||
} else {
|
||||
m_third_body.reset(new ThirdBody(third_body));
|
||||
m_third_body = make_shared<ThirdBody>(third_body);
|
||||
}
|
||||
|
||||
// adjust reactant coefficients
|
||||
@@ -825,7 +825,7 @@ ThreeBodyReaction::ThreeBodyReaction()
|
||||
{
|
||||
warn_deprecated("ThreeBodyReaction",
|
||||
"To be removed after Cantera 3.0. Replaceable with Reaction.");
|
||||
m_third_body.reset(new ThirdBody);
|
||||
m_third_body = make_shared<ThirdBody>();
|
||||
setRate(newReactionRate(type()));
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ FalloffReaction::FalloffReaction()
|
||||
{
|
||||
warn_deprecated("FalloffReaction",
|
||||
"To be removed after Cantera 3.0. Replaceable with Reaction.");
|
||||
m_third_body.reset(new ThirdBody);
|
||||
m_third_body = make_shared<ThirdBody>();
|
||||
setRate(newReactionRate(type()));
|
||||
}
|
||||
|
||||
@@ -880,19 +880,19 @@ FalloffReaction::FalloffReaction(const AnyMap& node, const Kinetics& kin)
|
||||
warn_deprecated("FalloffReaction",
|
||||
"To be removed after Cantera 3.0. Replaceable with Reaction.");
|
||||
if (node.empty()) {
|
||||
m_third_body.reset(new ThirdBody);
|
||||
m_third_body = make_shared<ThirdBody>();
|
||||
setRate(newReactionRate(type()));
|
||||
}
|
||||
}
|
||||
|
||||
unique_ptr<Reaction> newReaction(const std::string& type)
|
||||
{
|
||||
return unique_ptr<Reaction>(new Reaction());
|
||||
return make_unique<Reaction>();
|
||||
}
|
||||
|
||||
unique_ptr<Reaction> newReaction(const AnyMap& rxn_node, const Kinetics& kin)
|
||||
{
|
||||
return unique_ptr<Reaction>(new Reaction(rxn_node, kin));
|
||||
return make_unique<Reaction>(rxn_node, kin);
|
||||
}
|
||||
|
||||
void parseReactionEquation(Reaction& R, const std::string& equation,
|
||||
@@ -970,7 +970,7 @@ std::vector<shared_ptr<Reaction>> getReactions(const AnyValue& items,
|
||||
{
|
||||
std::vector<shared_ptr<Reaction>> all_reactions;
|
||||
for (const auto& node : items.asVector<AnyMap>()) {
|
||||
shared_ptr<Reaction> R(new Reaction(node, kinetics));
|
||||
auto R = make_shared<Reaction>(node, kinetics);
|
||||
R->check();
|
||||
R->validate(kinetics);
|
||||
if (R->valid() && R->checkSpecies(kinetics)) {
|
||||
|
||||
@@ -55,8 +55,8 @@ ReactionRateDelegator::ReactionRateDelegator()
|
||||
|
||||
unique_ptr<MultiRateBase> ReactionRateDelegator::newMultiRate() const
|
||||
{
|
||||
auto multirate = std::make_unique<MultiRate<ReactionRateDelegator,
|
||||
ReactionDataDelegator>>();
|
||||
auto multirate = make_unique<MultiRate<ReactionRateDelegator,
|
||||
ReactionDataDelegator>>();
|
||||
multirate->sharedData().setType(m_rateType);
|
||||
ExtensionManager::wrapReactionData(m_rateType, multirate->sharedData());
|
||||
return multirate;
|
||||
|
||||
@@ -466,7 +466,7 @@ void IDA_Solver::init(doublereal t0)
|
||||
}
|
||||
|
||||
// pass a pointer to func in m_data
|
||||
m_fdata.reset(new ResidData(&m_resid, this, m_resid.nparams()));
|
||||
m_fdata = make_unique<ResidData>(&m_resid, this, m_resid.nparams());
|
||||
flag = IDASetUserData(m_ida_mem, m_fdata.get());
|
||||
if (flag != IDA_SUCCESS) {
|
||||
throw CanteraError("IDA_Solver::init", "IDASetUserData failed.");
|
||||
|
||||
@@ -29,7 +29,7 @@ void Domain1D::resize(size_t nv, size_t np)
|
||||
// new grid refiner is required.
|
||||
if (nv != m_nv || !m_refiner) {
|
||||
m_nv = nv;
|
||||
m_refiner.reset(new Refiner(*this));
|
||||
m_refiner = make_unique<Refiner>(*this);
|
||||
}
|
||||
m_nv = nv;
|
||||
m_name.resize(m_nv,"");
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace Cantera
|
||||
|
||||
OneDim::OneDim()
|
||||
{
|
||||
m_newt.reset(new MultiNewton(1));
|
||||
m_newt = make_unique<MultiNewton>(1);
|
||||
}
|
||||
|
||||
OneDim::OneDim(vector<Domain1D*> domains)
|
||||
{
|
||||
// create a Newton iterator, and add each domain.
|
||||
m_newt.reset(new MultiNewton(1));
|
||||
m_newt = make_unique<MultiNewton>(1);
|
||||
for (size_t i = 0; i < domains.size(); i++) {
|
||||
addDomain(domains[i]);
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void OneDim::resize()
|
||||
m_mask.resize(size());
|
||||
|
||||
// delete the current Jacobian evaluator and create a new one
|
||||
m_jac.reset(new MultiJac(*this));
|
||||
m_jac = make_unique<MultiJac>(*this);
|
||||
m_jac_ok = false;
|
||||
|
||||
for (size_t i = 0; i < nDomains(); i++) {
|
||||
|
||||
@@ -396,7 +396,7 @@ void DebyeHuckel::initThermo()
|
||||
// Initialize the water property calculator. It will share the internal
|
||||
// eos water calculator.
|
||||
if (m_form_A_Debye == A_DEBYE_WATER) {
|
||||
m_waterProps.reset(new WaterProps(m_waterSS));
|
||||
m_waterProps = make_unique<WaterProps>(m_waterSS);
|
||||
}
|
||||
} else if (dynamic_cast<PDSS_ConstVol*>(providePDSS(0)) == 0) {
|
||||
throw CanteraError("DebyeHuckel::initThermo", "Solvent standard state"
|
||||
|
||||
@@ -668,7 +668,7 @@ void HMWSoln::initThermo()
|
||||
|
||||
// Initialize the water property calculator. It will share the internal eos
|
||||
// water calculator.
|
||||
m_waterProps.reset(new WaterProps(dynamic_cast<PDSS_Water*>(m_waterSS)));
|
||||
m_waterProps = make_unique<WaterProps>(dynamic_cast<PDSS_Water*>(m_waterSS));
|
||||
|
||||
// Lastly calculate the charge balance and then add stuff until the charges
|
||||
// compensate
|
||||
|
||||
@@ -271,7 +271,7 @@ void PDSS_HKFT::initThermo()
|
||||
m_Z_pr_tr = -1.0 / relepsilon;
|
||||
doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
|
||||
m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
|
||||
m_waterProps.reset(new WaterProps(m_waterSS));
|
||||
m_waterProps = make_unique<WaterProps>(m_waterSS);
|
||||
m_presR_bar = OneAtm / 1.0E5;
|
||||
m_presR_bar = 1.0;
|
||||
convertDGFormation();
|
||||
|
||||
@@ -104,13 +104,13 @@ AnyMap Species::parameters(const ThermoPhase* phase, bool withInput) const
|
||||
|
||||
unique_ptr<Species> newSpecies(const AnyMap& node)
|
||||
{
|
||||
unique_ptr<Species> s(new Species(node["name"].asString(),
|
||||
node["composition"].asMap<double>()));
|
||||
auto s = make_unique<Species>(node["name"].asString(),
|
||||
node["composition"].asMap<double>());
|
||||
|
||||
if (node.hasKey("thermo")) {
|
||||
s->thermo = newSpeciesThermo(node["thermo"].as<AnyMap>());
|
||||
} else {
|
||||
s->thermo.reset(new SpeciesThermoInterpType());
|
||||
s->thermo = make_shared<SpeciesThermoInterpType>();
|
||||
}
|
||||
|
||||
s->size = node.getDouble("sites", 1.0);
|
||||
|
||||
@@ -187,25 +187,25 @@ unique_ptr<SpeciesThermoInterpType> newSpeciesThermo(const AnyMap& node)
|
||||
{
|
||||
std::string model = node["model"].asString();
|
||||
if (model == "NASA7") {
|
||||
unique_ptr<NasaPoly2> thermo(new NasaPoly2());
|
||||
auto thermo = make_unique<NasaPoly2>();
|
||||
setupNasaPoly(*thermo, node);
|
||||
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
|
||||
return thermo;
|
||||
} else if (model == "Shomate") {
|
||||
unique_ptr<ShomatePoly2> thermo(new ShomatePoly2());
|
||||
auto thermo = make_unique<ShomatePoly2>();
|
||||
setupShomatePoly(*thermo, node);
|
||||
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
|
||||
return thermo;
|
||||
} else if (model == "NASA9") {
|
||||
unique_ptr<Nasa9PolyMultiTempRegion> thermo(new Nasa9PolyMultiTempRegion());
|
||||
auto thermo = make_unique<Nasa9PolyMultiTempRegion>();
|
||||
setupNasa9Poly(*thermo, node);
|
||||
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
|
||||
return thermo;
|
||||
} else if (model == "constant-cp") {
|
||||
unique_ptr<ConstCpPoly> thermo(new ConstCpPoly());
|
||||
auto thermo = make_unique<ConstCpPoly>();
|
||||
setupConstCp(*thermo, node);
|
||||
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
|
||||
return thermo;
|
||||
} else if (model == "piecewise-Gibbs") {
|
||||
unique_ptr<Mu0Poly> thermo(new Mu0Poly());
|
||||
auto thermo = make_unique<Mu0Poly>();
|
||||
setupMu0(*thermo, node);
|
||||
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
|
||||
return thermo;
|
||||
} else {
|
||||
throw CanteraError("newSpeciesThermo",
|
||||
"Unknown thermo model '{}'", model);
|
||||
|
||||
@@ -79,7 +79,7 @@ void WaterSSTP::initThermo()
|
||||
double rho0 = m_sub.density(298.15, OneAtm, WATER_LIQUID);
|
||||
setDensity(rho0);
|
||||
|
||||
m_waterProps.reset(new WaterProps(&m_sub));
|
||||
m_waterProps = make_unique<WaterProps>(&m_sub);
|
||||
|
||||
// Set the flag to say we are ready to calculate stuff
|
||||
m_ready = true;
|
||||
|
||||
@@ -179,12 +179,12 @@ void setupGasTransportData(GasTransportData& tr, const AnyMap& node)
|
||||
unique_ptr<TransportData> newTransportData(const AnyMap& node)
|
||||
{
|
||||
if (node.getString("model", "") == "gas") {
|
||||
unique_ptr<GasTransportData> tr(new GasTransportData());
|
||||
auto tr = make_unique<GasTransportData>();
|
||||
setupGasTransportData(*tr, node);
|
||||
return unique_ptr<TransportData>(move(tr));
|
||||
return tr;
|
||||
} else {
|
||||
// Transport model not handled here
|
||||
unique_ptr<TransportData> tr(new TransportData());
|
||||
auto tr = make_unique<TransportData>();
|
||||
tr->input = node;
|
||||
return tr;
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ public:
|
||||
KineticsAddSpecies()
|
||||
: pp_ref(newThermo("../data/kineticsfromscratch.yaml"))
|
||||
{
|
||||
p.reset(new IdealGasPhase());
|
||||
p = make_shared<IdealGasPhase>();
|
||||
vector<shared_ptr<ThermoPhase>> th;
|
||||
th.push_back(pp_ref);
|
||||
kin_ref = newKinetics(th, "../data/kineticsfromscratch.yaml", "ohmech");
|
||||
|
||||
@@ -904,9 +904,9 @@ TEST_F(ReactionToYaml, unconvertible3)
|
||||
{
|
||||
Reaction R(
|
||||
{{"H2", 1}, {"OH", 1}}, {{"H2O", 1}, {"H", 1}},
|
||||
shared_ptr<ReactionRate>(new TroeRate(
|
||||
make_shared<TroeRate>(
|
||||
ArrheniusRate(1e5, -1.0, 12.5), ArrheniusRate(1e5, -1.0, 12.5),
|
||||
{0.562, 91.0, 5836.0, 8552.0})));
|
||||
vector_fp{0.562, 91.0, 5836.0, 8552.0}));
|
||||
AnyMap params = R.parameters();
|
||||
UnitSystem U{"g", "cm", "mol"};
|
||||
params.setUnits(U);
|
||||
|
||||
@@ -91,11 +91,11 @@ TEST_F(MaskellSolidSolnPhase_Test, standardConcentrations)
|
||||
TEST_F(MaskellSolidSolnPhase_Test, fromScratch) {
|
||||
auto sH = make_shared<Species>("H(s)", parseCompString("H:1 He:2"));
|
||||
double coeffs1[] = {1.0, 0.0, 0.0, 0.0};
|
||||
sH->thermo.reset(new ConstCpPoly(250, 800, 1e5, coeffs1));
|
||||
sH->thermo = make_shared<ConstCpPoly>(250, 800, 1e5, coeffs1);
|
||||
|
||||
auto sHe = make_shared<Species>("He(s)", parseCompString("He:1"));
|
||||
double coeffs2[] = {1.0, 1000.0, 0.0, 0.0};
|
||||
sHe->thermo.reset(new ConstCpPoly(250, 800, 1e5, coeffs2));
|
||||
sHe->thermo = make_shared<ConstCpPoly>(250, 800, 1e5, coeffs2);
|
||||
|
||||
MaskellSolidSolnPhase* p = new MaskellSolidSolnPhase();
|
||||
test_phase.reset(p);
|
||||
@@ -103,11 +103,11 @@ TEST_F(MaskellSolidSolnPhase_Test, fromScratch) {
|
||||
p->addSpecies(sH);
|
||||
p->addSpecies(sHe);
|
||||
|
||||
std::unique_ptr<PDSS_ConstVol> ssH(new PDSS_ConstVol());
|
||||
auto ssH = make_unique<PDSS_ConstVol>();
|
||||
ssH->setMolarVolume(0.005);
|
||||
p->installPDSS(0, std::move(ssH));
|
||||
|
||||
std::unique_ptr<PDSS_ConstVol> ssHe(new PDSS_ConstVol());
|
||||
auto ssHe = make_unique<PDSS_ConstVol>();
|
||||
ssHe->setMolarVolume(0.01);
|
||||
p->installPDSS(1, std::move(ssHe));
|
||||
|
||||
|
||||
@@ -98,24 +98,24 @@ TEST_F(RedlichKister_Test, standardConcentrations)
|
||||
|
||||
TEST_F(RedlichKister_Test, fromScratch)
|
||||
{
|
||||
test_phase.reset(new RedlichKisterVPSSTP());
|
||||
test_phase = make_shared<RedlichKisterVPSSTP>();
|
||||
RedlichKisterVPSSTP& rk = dynamic_cast<RedlichKisterVPSSTP&>(*test_phase);
|
||||
|
||||
auto sLiC6 = make_shared<Species>("Li(C6)", parseCompString("C:6 Li:1"));
|
||||
double coeffs1[] = {298.15, -11.65e6, 0.0, 0.0};
|
||||
sLiC6->thermo.reset(new ConstCpPoly(100, 5000, 101325, coeffs1));
|
||||
sLiC6->thermo = make_shared<ConstCpPoly>(100, 5000, 101325, coeffs1);
|
||||
|
||||
auto sVC6 = make_shared<Species>("V(C6)", parseCompString("C:6"));
|
||||
double coeffs2[] = {298.15, 0.0, 0.0, 0.0};
|
||||
sVC6->thermo.reset(new ConstCpPoly(250, 800, 101325, coeffs2));
|
||||
sVC6->thermo = make_shared<ConstCpPoly>(250, 800, 101325, coeffs2);
|
||||
|
||||
rk.addSpecies(sLiC6);
|
||||
rk.addSpecies(sVC6);
|
||||
|
||||
std::unique_ptr<PDSS> ssLiC6(new PDSS_IdealGas());
|
||||
auto ssLiC6 = make_unique<PDSS_IdealGas>();
|
||||
rk.installPDSS(0, std::move(ssLiC6));
|
||||
|
||||
std::unique_ptr<PDSS> ssVC6(new PDSS_IdealGas());
|
||||
auto ssVC6 = make_unique<PDSS_IdealGas>();
|
||||
rk.installPDSS(1, std::move(ssVC6));
|
||||
|
||||
double hcoeffs[] = {-3.268E6, 3.955E6, -4.573E6, 6.147E6, -3.339E6, 1.117E7,
|
||||
|
||||
@@ -37,7 +37,7 @@ shared_ptr<Species> make_species(const std::string& name,
|
||||
const std::string& composition, const double* nasa_coeffs)
|
||||
{
|
||||
auto species = make_shared<Species>(name, parseCompString(composition));
|
||||
species->thermo.reset(new NasaPoly2(200, 3500, 101325, nasa_coeffs));
|
||||
species->thermo = make_shared<NasaPoly2>(200, 3500, 101325, nasa_coeffs);
|
||||
return species;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ shared_ptr<Species> make_shomate_species(const std::string& name,
|
||||
const std::string& composition, const double* shomate_coeffs)
|
||||
{
|
||||
auto species = make_shared<Species>(name, parseCompString(composition));
|
||||
species->thermo.reset(new ShomatePoly(200, 3500, 101325, shomate_coeffs));
|
||||
species->thermo = make_shared<ShomatePoly>(200, 3500, 101325, shomate_coeffs);
|
||||
return species;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ shared_ptr<Species> make_shomate2_species(const std::string& name,
|
||||
const std::string& composition, const double* shomate_coeffs)
|
||||
{
|
||||
auto species = make_shared<Species>(name, parseCompString(composition));
|
||||
species->thermo.reset(new ShomatePoly2(200, 3500, 101325, shomate_coeffs));
|
||||
species->thermo = make_shared<ShomatePoly2>(200, 3500, 101325, shomate_coeffs);
|
||||
return species;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ shared_ptr<Species> make_species(const std::string& name,
|
||||
{
|
||||
auto species = make_shared<Species>(name, parseCompString(composition));
|
||||
double coeffs[] = {2, h298, T1, mu1*GasConstant*T1, T2, mu2*GasConstant*T2};
|
||||
species->thermo.reset(new Mu0Poly(200, 3500, pref, coeffs));
|
||||
species->thermo = make_shared<Mu0Poly>(200, 3500, pref, coeffs);
|
||||
return species;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ shared_ptr<Species> make_const_cp_species(const std::string& name,
|
||||
{
|
||||
auto species = make_shared<Species>(name, parseCompString(composition));
|
||||
double coeffs[] = {T0, h0, s0, cp};
|
||||
species->thermo.reset(new ConstCpPoly(200, 3500, 101325, coeffs));
|
||||
species->thermo = make_shared<ConstCpPoly>(200, 3500, 101325, coeffs);
|
||||
return species;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ TEST(IonsFromNeutralConstructor, fromScratch)
|
||||
auto neutral = make_shared<MargulesVPSSTP>();
|
||||
auto sKCl = make_shomate_species("KCl(L)", "K:1 Cl:1", kcl_shomate_coeffs);
|
||||
neutral->addSpecies(sKCl);
|
||||
std::unique_ptr<PDSS_ConstVol> ssKCl(new PDSS_ConstVol());
|
||||
auto ssKCl = make_unique<PDSS_ConstVol>();
|
||||
ssKCl->setMolarVolume(0.03757);
|
||||
neutral->installPDSS(0, std::move(ssKCl));
|
||||
neutral->initThermo();
|
||||
@@ -96,8 +96,8 @@ TEST(IonsFromNeutralConstructor, fromScratch)
|
||||
sClm->input["equation-of-state"]["model"] = "ions-from-neutral-molecule";
|
||||
p.addSpecies(sKp);
|
||||
p.addSpecies(sClm);
|
||||
std::unique_ptr<PDSS_IonsFromNeutral> ssKp(new PDSS_IonsFromNeutral());
|
||||
std::unique_ptr<PDSS_IonsFromNeutral> ssClm(new PDSS_IonsFromNeutral());
|
||||
auto ssKp = make_unique<PDSS_IonsFromNeutral>();
|
||||
auto ssClm = make_unique<PDSS_IonsFromNeutral>();
|
||||
ssKp->setNeutralSpeciesMultiplier("KCl(L)", 1.2);
|
||||
ssClm->setNeutralSpeciesMultiplier("KCl(L)", 1.5);
|
||||
ssClm->setSpecialSpecies();
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
, sCO(make_species("CO", "C:1 O:1", o2_nasa_coeffs))
|
||||
, sCO2(new Species("CO2", parseCompString("C:1 O:2")))
|
||||
{
|
||||
sCO2->thermo.reset(new ShomatePoly2(200, 3500, 101325, co2_shomate_coeffs));
|
||||
sCO2->thermo = make_shared<ShomatePoly2>(200, 3500, 101325, co2_shomate_coeffs);
|
||||
}
|
||||
|
||||
shared_ptr<Species> sH2O, sH2, sO2, sOH, sCO, sCO2;
|
||||
@@ -251,7 +251,7 @@ TEST(PureFluidFromScratch, CarbonDioxide)
|
||||
{
|
||||
PureFluidPhase p;
|
||||
auto sCO2 = make_shared<Species>("CO2", parseCompString("C:1 O:2"));
|
||||
sCO2->thermo.reset(new ShomatePoly2(200, 6000, 101325, co2_shomate_coeffs));
|
||||
sCO2->thermo = make_shared<ShomatePoly2>(200, 6000, 101325, co2_shomate_coeffs);
|
||||
p.addSpecies(sCO2);
|
||||
p.setSubstance("carbon-dioxide");
|
||||
p.initThermo();
|
||||
@@ -277,7 +277,7 @@ TEST(IdealMolalSoln, fromScratch)
|
||||
p.addSpecies(make_species("CH4(aq)", "C:1, H:4", h2_nasa_coeffs));
|
||||
size_t k = 0;
|
||||
for (double v : {1.5, 1.3, 0.1, 0.1}) {
|
||||
std::unique_ptr<PDSS_ConstVol> ss(new PDSS_ConstVol());
|
||||
auto ss = make_unique<PDSS_ConstVol>();
|
||||
ss->setMolarVolume(v);
|
||||
p.installPDSS(k++, std::move(ss));
|
||||
}
|
||||
@@ -324,11 +324,11 @@ TEST(DebyeHuckel, fromScratch)
|
||||
for (auto& s : {sH2O, sNa, sCl, sH, sOH, sNaCl}) {
|
||||
p.addSpecies(s);
|
||||
}
|
||||
std::unique_ptr<PDSS_Water> ss(new PDSS_Water());
|
||||
auto ss = make_unique<PDSS_Water>();
|
||||
p.installPDSS(0, std::move(ss));
|
||||
size_t k = 1;
|
||||
for (double v : {1.3, 1.3, 0.0, 1.3, 1.3}) {
|
||||
std::unique_ptr<PDSS_ConstVol> ss(new PDSS_ConstVol());
|
||||
auto ss = make_unique<PDSS_ConstVol>();
|
||||
ss->setMolarVolume(v);
|
||||
p.installPDSS(k++, std::move(ss));
|
||||
}
|
||||
@@ -368,7 +368,7 @@ TEST(MargulesVPSSTP, fromScratch)
|
||||
p.addSpecies(sLiCl);
|
||||
size_t k = 0;
|
||||
for (double v : {0.03757, 0.020304}) {
|
||||
std::unique_ptr<PDSS_ConstVol> ss(new PDSS_ConstVol());
|
||||
auto ss = make_unique<PDSS_ConstVol>();
|
||||
ss->setMolarVolume(v);
|
||||
p.installPDSS(k++, std::move(ss));
|
||||
}
|
||||
@@ -500,11 +500,11 @@ TEST(HMWSoln, fromScratch)
|
||||
for (auto& s : {sH2O, sCl, sH, sNa, sOH}) {
|
||||
p.addSpecies(s);
|
||||
}
|
||||
std::unique_ptr<PDSS_Water> ss(new PDSS_Water());
|
||||
auto ss = make_unique<PDSS_Water>();
|
||||
p.installPDSS(0, std::move(ss));
|
||||
size_t k = 1;
|
||||
for (double v : {1.3, 1.3, 1.3, 1.3}) {
|
||||
std::unique_ptr<PDSS_ConstVol> ss(new PDSS_ConstVol());
|
||||
auto ss = make_unique<PDSS_ConstVol>();
|
||||
ss->setMolarVolume(v);
|
||||
p.installPDSS(k++, std::move(ss));
|
||||
}
|
||||
@@ -567,11 +567,11 @@ TEST(HMWSoln, fromScratch_HKFT)
|
||||
double c[][2] = {{18.18, -29810}, {-4.4, -57140}, {0.0, 0.0}, {4.15, -103460}};
|
||||
double omega[] = {33060, 145600, 0.0, 172460};
|
||||
|
||||
std::unique_ptr<PDSS_Water> ss(new PDSS_Water());
|
||||
auto ss = make_unique<PDSS_Water>();
|
||||
p.installPDSS(0, std::move(ss));
|
||||
UnitSystem units;
|
||||
for (size_t k = 0; k < 4; k++) {
|
||||
std::unique_ptr<PDSS_HKFT> ss(new PDSS_HKFT());
|
||||
auto ss = make_unique<PDSS_HKFT>();
|
||||
if (h0[k] != Undef) {
|
||||
ss->setDeltaH0(units.convertFrom(h0[k], "cal/gmol"));
|
||||
}
|
||||
@@ -625,7 +625,7 @@ TEST(PDSS_SSVol, fromScratch)
|
||||
auto sLi = make_shomate2_species("Li(L)", "Li:1", coeffs);
|
||||
p.addSpecies(sLi);
|
||||
p.setStandardConcentrationModel("unity");
|
||||
std::unique_ptr<PDSS_SSVol> ss(new PDSS_SSVol());
|
||||
auto ss = make_unique<PDSS_SSVol>();
|
||||
double rho_coeffs[] = {536.504, -1.04279e-1, 3.84825e-6, -5.2853e-9};
|
||||
ss->setDensityPolynomial(rho_coeffs);
|
||||
p.installPDSS(0, std::move(ss));
|
||||
|
||||
@@ -39,9 +39,9 @@ TEST_F(SpeciesThermoInterpTypeTest, install_const_cp)
|
||||
auto sO2 = make_shared<Species>("O2", parseCompString("O:2"));
|
||||
auto sH2 = make_shared<Species>("H2", parseCompString("H:2"));
|
||||
auto sH2O = make_shared<Species>("H2O", parseCompString("H:2 O:1"));
|
||||
sO2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_o2));
|
||||
sH2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_h2));
|
||||
sH2O->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_h2o));
|
||||
sO2->thermo = make_shared<ConstCpPoly>(200, 5000, 101325, c_o2);
|
||||
sH2->thermo = make_shared<ConstCpPoly>(200, 5000, 101325, c_h2);
|
||||
sH2O->thermo = make_shared<ConstCpPoly>(200, 5000, 101325, c_h2o);
|
||||
p.addSpecies(sO2);
|
||||
p.addSpecies(sH2);
|
||||
p.addSpecies(sH2O);
|
||||
@@ -60,8 +60,8 @@ TEST_F(SpeciesThermoInterpTypeTest, DISABLED_install_bad_pref)
|
||||
// pressure consistency.
|
||||
auto sO2 = make_shared<Species>("O2", parseCompString("O:2"));
|
||||
auto sH2 = make_shared<Species>("H2", parseCompString("H:2"));
|
||||
sO2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_o2));
|
||||
sH2->thermo.reset(new ConstCpPoly(200, 5000, 100000, c_h2));
|
||||
sO2->thermo = make_shared<ConstCpPoly>(200, 5000, 101325, c_o2);
|
||||
sH2->thermo = make_shared<ConstCpPoly>(200, 5000, 100000, c_h2);
|
||||
p.addSpecies(sO2);
|
||||
// Pref does not match
|
||||
ASSERT_THROW(p.addSpecies(sH2), CanteraError);
|
||||
@@ -74,9 +74,9 @@ TEST_F(SpeciesThermoInterpTypeTest, install_nasa)
|
||||
auto sO2 = make_shared<Species>("O2", parseCompString("O:2"));
|
||||
auto sH2 = make_shared<Species>("H2", parseCompString("H:2"));
|
||||
auto sH2O = make_shared<Species>("H2O", parseCompString("H:2 O:1"));
|
||||
sO2->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs));
|
||||
sH2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs));
|
||||
sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs));
|
||||
sO2->thermo = make_shared<NasaPoly2>(200, 3500, 101325, o2_nasa_coeffs);
|
||||
sH2->thermo = make_shared<NasaPoly2>(200, 3500, 101325, h2_nasa_coeffs);
|
||||
sH2O->thermo = make_shared<NasaPoly2>(200, 3500, 101325, h2o_nasa_coeffs);
|
||||
p.addSpecies(sO2);
|
||||
p.addSpecies(sH2);
|
||||
p.addSpecies(sH2O);
|
||||
@@ -95,8 +95,8 @@ TEST_F(SpeciesThermoInterpTypeTest, install_shomate)
|
||||
IdealGasPhase p2("simplephases.yaml", "shomate1");
|
||||
auto sCO = make_shared<Species>("CO", parseCompString("C:1 O:1"));
|
||||
auto sCO2 = make_shared<Species>("CO2", parseCompString("C:1 O:2"));
|
||||
sCO->thermo.reset(new ShomatePoly2(200, 6000, 101325, co_shomate_coeffs));
|
||||
sCO2->thermo.reset(new ShomatePoly2(200, 6000, 101325, co2_shomate_coeffs));
|
||||
sCO->thermo = make_shared<ShomatePoly2>(200, 6000, 101325, co_shomate_coeffs);
|
||||
sCO2->thermo = make_shared<ShomatePoly2>(200, 6000, 101325, co2_shomate_coeffs);
|
||||
p.addSpecies(sCO);
|
||||
p.addSpecies(sCO2);
|
||||
p.initThermo();
|
||||
|
||||
@@ -26,9 +26,9 @@ public:
|
||||
, tO2(new GasTransportData())
|
||||
, tH2O(new GasTransportData())
|
||||
{
|
||||
sH2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs));
|
||||
sO2->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs));
|
||||
sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs));
|
||||
sH2->thermo = make_shared<NasaPoly2>(200, 3500, 101325, h2_nasa_coeffs);
|
||||
sO2->thermo = make_shared<NasaPoly2>(200, 3500, 101325, o2_nasa_coeffs);
|
||||
sH2O->thermo = make_shared<NasaPoly2>(200, 3500, 101325, h2o_nasa_coeffs);
|
||||
|
||||
tH2->setCustomaryUnits("linear", 2.92, 38.0, 0.0, 0.79, 280.0);
|
||||
tO2->setCustomaryUnits("linear", 3.458, 107.40, 0.0, 1.60, 3.80);
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
"species: [{gri30.yaml/species: [H2, O2, H2O]}]");
|
||||
|
||||
ref = newThermo(phase_def);
|
||||
test.reset(new IdealGasPhase());
|
||||
test = make_shared<IdealGasPhase>();
|
||||
|
||||
test->addElement("O");
|
||||
test->addElement("H");
|
||||
|
||||
@@ -17,8 +17,8 @@ void testProblem(int printLvl)
|
||||
auto LiSi_solid = newThermo("Li7Si3_latsol.yaml", "Li7Si3_and_Interstitials(S)");
|
||||
auto Li_liq = newThermo("Li7Si3_latsol.yaml", "Li(L)");
|
||||
auto LiFixed = newThermo("Li7Si3_latsol.yaml", "LiFixed");
|
||||
shared_ptr<ThermoPhase> salt(new MargulesVPSSTP(
|
||||
"Li7Si3_latsol.yaml", "MoltenSalt_electrolyte"));
|
||||
auto salt = make_unique<MargulesVPSSTP>(
|
||||
"Li7Si3_latsol.yaml", "MoltenSalt_electrolyte");
|
||||
|
||||
// set states
|
||||
vector_fp x(salt->nSpecies(), 0);
|
||||
|
||||
@@ -85,8 +85,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Initialize the individual phases
|
||||
|
||||
shared_ptr<ThermoPhase> hmw(new HMWSoln(
|
||||
inputFile, "NaCl_electrolyte_complex_shomate"));
|
||||
auto hmw = make_shared<HMWSoln>(inputFile, "NaCl_electrolyte_complex_shomate");
|
||||
hmw->setName("NaCl_electrolyte");
|
||||
size_t kk = hmw->nSpecies();
|
||||
vector_fp Xmol(kk, 0.0);
|
||||
@@ -106,7 +105,7 @@ int main(int argc, char** argv)
|
||||
gas->setState_TPX(T, pres, Xmol.data());
|
||||
|
||||
|
||||
shared_ptr<ThermoPhase> ss(new StoichSubstance("NaCl_Solid.yaml"));
|
||||
auto ss = make_unique<StoichSubstance>("NaCl_Solid.yaml");
|
||||
ss->setState_TP(T, pres);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user