Skip to content

Commit

Permalink
[Thermo] Combine file-based and default constructors
Browse files Browse the repository at this point in the history
For classes derived from ThermoPhase, instead of having separate
constructors for the default constructor and the constructor which
takes an input file and phase id, we can use the case where both
arguments are the default (empty string) to construct a phase without
using an input file. This eliminates the need to repeat any
initialization that takes place in the constructor.
  • Loading branch information
speth committed Feb 18, 2021
1 parent 690aa7b commit 8edb731
Show file tree
Hide file tree
Showing 30 changed files with 64 additions and 224 deletions.
7 changes: 2 additions & 5 deletions include/cantera/thermo/BinarySolutionTabulatedThermo.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,17 @@ namespace Cantera
class BinarySolutionTabulatedThermo : public IdealSolidSolnPhase
{
public:
//! Default constructor for BinarySolutionTabulatedThermo
BinarySolutionTabulatedThermo();

//! Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object
//! directly from an input file
/*!
* This constructor will also fully initialize the object.
*
* @param infile File name for the input file containing information
* for this phase
* for this phase. If not specified, and empty phase will be created.
* @param id The name of this phase. This is used to look up
* the phase in the input file.
*/
BinarySolutionTabulatedThermo(const std::string& infile, const std::string& id="");
explicit BinarySolutionTabulatedThermo(const std::string& infile="", const std::string& id="");

//! Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object
//! directly from an XML database
Expand Down
9 changes: 4 additions & 5 deletions include/cantera/thermo/DebyeHuckel.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,16 @@ class PDSS_Water;
class DebyeHuckel : public MolalityVPSSTP
{
public:
//! Default Constructor
DebyeHuckel();

virtual ~DebyeHuckel();

//! Full constructor for creating the phase.
/*!
* @param inputFile File name containing the definition of the phase
* @param inputFile File name containing the definition of the phase.
* If blank, an empty phase will be created.
* @param id id attribute containing the name of the phase.
*/
DebyeHuckel(const std::string& inputFile, const std::string& id = "");
explicit DebyeHuckel(const std::string& inputFile="",
const std::string& id="");

//! Full constructor for creating the phase.
/*!
Expand Down
7 changes: 3 additions & 4 deletions include/cantera/thermo/HMWSoln.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,6 @@ class WaterProps;
class HMWSoln : public MolalityVPSSTP
{
public:
//! Default Constructor
HMWSoln();
~HMWSoln();

//! Construct and initialize an HMWSoln ThermoPhase object
Expand All @@ -1049,11 +1047,12 @@ class HMWSoln : public MolalityVPSSTP
* a reference to the parsed input file to get the info for the phase.
*
* @param inputFile Name of the input file containing the phase definition
* to set up the object
* to set up the object. If blank, an empty phase will be
* created.
* @param id ID of the phase in the input file. Defaults to the
* empty string.
*/
HMWSoln(const std::string& inputFile, const std::string& id = "");
explicit HMWSoln(const std::string& inputFile="", const std::string& id="");

//! Construct and initialize an HMWSoln ThermoPhase object
//! directly from an XML database
Expand Down
9 changes: 4 additions & 5 deletions include/cantera/thermo/IdealGasPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,17 @@ namespace Cantera
class IdealGasPhase: public ThermoPhase
{
public:
//! Default empty Constructor
IdealGasPhase();

//! Construct and initialize an IdealGasPhase ThermoPhase object
//! directly from an ASCII input file
/*!
* @param inputFile Name of the input file containing the phase definition
* to set up the object
* to set up the object. If blank, an empty phase will be
* created.
* @param id ID of the phase in the input file. Defaults to the
* empty string.
*/
IdealGasPhase(const std::string& inputFile, const std::string& id = "");
explicit IdealGasPhase(const std::string& inputFile="",
const std::string& id="");

//! Construct and initialize an IdealGasPhase ThermoPhase object
//! directly from an XML database
Expand Down
8 changes: 3 additions & 5 deletions include/cantera/thermo/IdealMolalSoln.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,17 @@ namespace Cantera
class IdealMolalSoln : public MolalityVPSSTP
{
public:
/// Constructor
IdealMolalSoln();

//! Constructor for phase initialization
/*!
* This constructor will initialize a phase, by reading the required
* information from an input file.
*
* @param inputFile Name of the Input file that contains information
* about the phase
* about the phase. If blank, an empty phase will be created.
* @param id id of the phase within the input file
*/
IdealMolalSoln(const std::string& inputFile, const std::string& id = "");
explicit IdealMolalSoln(const std::string& inputFile="",
const std::string& id="");

//! Constructor for phase initialization
/*!
Expand Down
6 changes: 4 additions & 2 deletions include/cantera/thermo/IdealSolidSolnPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ class IdealSolidSolnPhase : public ThermoPhase
* is supplied in the constructor or read from the input file.
*
* @param infile File name for the input file containing information
* for this phase
* for this phase. If blank, an empty phase will be
* created.
* @param id The name of this phase. This is used to look up
* the phase in the input file.
* @param formCG This parameter initializes the #m_formGC variable.
* @deprecated the formGC argument is deprecated and will be removed after
* Cantera 2.6. Use the setStandardConcentrationModel method instead.
*/
IdealSolidSolnPhase(const std::string& infile, const std::string& id="", int formCG=-1);
explicit IdealSolidSolnPhase(const std::string& infile,
const std::string& id="", int formCG=-1);

//! Construct and initialize an IdealSolidSolnPhase ThermoPhase object
//! directly from an XML database
Expand Down
9 changes: 1 addition & 8 deletions include/cantera/thermo/IdealSolnGasVPSS.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ namespace Cantera
class IdealSolnGasVPSS : public VPStandardStateTP
{
public:
/*!
* @name Constructors and Duplicators for IdealSolnGasVPSS
*/
//! @{

IdealSolnGasVPSS();

/// Create an object from an input file
IdealSolnGasVPSS(const std::string& infile, std::string id="");
explicit IdealSolnGasVPSS(const std::string& infile="", std::string id="");

//@}
//! @name Utilities (IdealSolnGasVPSS)
Expand Down
12 changes: 4 additions & 8 deletions include/cantera/thermo/IonsFromNeutralVPSSTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,15 @@ class IonsFromNeutralVPSSTP : public GibbsExcessVPSSTP
//! @name Constructors
//! @{

/*!
* Default constructor
*/
IonsFromNeutralVPSSTP();

//! Construct an IonsFromNeutralVPSSTP object from an input file
/*!
* @param inputFile Name of the input file containing the phase definition
* @param inputFile Name of the input file containing the phase definition.
* If blank, an empty phase will be created.
* @param id name (ID) of the phase in the input file. If empty, the
* first phase definition in the input file will be used.
*/
IonsFromNeutralVPSSTP(const std::string& inputFile,
const std::string& id = "");
explicit IonsFromNeutralVPSSTP(const std::string& inputFile="",
const std::string& id="");

//! Construct and initialize an IonsFromNeutralVPSSTP object
//! directly from an XML database
Expand Down
9 changes: 4 additions & 5 deletions include/cantera/thermo/LatticePhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,14 @@ namespace Cantera
class LatticePhase : public ThermoPhase
{
public:
//! Base Empty constructor
LatticePhase();

//! Full constructor for a lattice phase
/*!
* @param inputFile String name of the input file
* @param inputFile String name of the input file. If blank,
* an empty phase will be created.
* @param id string id of the phase name
*/
LatticePhase(const std::string& inputFile, const std::string& id = "");
explicit LatticePhase(const std::string& inputFile="",
const std::string& id="");

//! Full constructor for a water phase
/*!
Expand Down
8 changes: 4 additions & 4 deletions include/cantera/thermo/MargulesVPSSTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ namespace Cantera
class MargulesVPSSTP : public GibbsExcessVPSSTP
{
public:
MargulesVPSSTP();

//! Construct a MargulesVPSSTP object from an input file
/*!
* @param inputFile Name of the input file containing the phase definition
* @param inputFile Name of the input file containing the phase definition.
* If blank, an empty phase will be created.
* @param id name (ID) of the phase in the input file. If empty, the
* first phase definition in the input file will be used.
*/
MargulesVPSSTP(const std::string& inputFile, const std::string& id = "");
explicit MargulesVPSSTP(const std::string& inputFile="",
const std::string& id="");

//! Construct and initialize a MargulesVPSSTP ThermoPhase object directly
//! from an XML database
Expand Down
12 changes: 4 additions & 8 deletions include/cantera/thermo/RedlichKisterVPSSTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,15 @@ namespace Cantera
class RedlichKisterVPSSTP : public GibbsExcessVPSSTP
{
public:
//! Constructor
/*!
* This doesn't do much more than initialize constants with default values.
*/
RedlichKisterVPSSTP();

//! Construct a RedlichKisterVPSSTP object from an input file
/*!
* @param inputFile Name of the input file containing the phase definition
* @param inputFile Name of the input file containing the phase definition.
* If blank, an empty phase will be created.
* @param id name (ID) of the phase in the input file. If empty, the
* first phase definition in the input file will be used.
*/
RedlichKisterVPSSTP(const std::string& inputFile, const std::string& id = "");
explicit RedlichKisterVPSSTP(const std::string& inputFile="",
const std::string& id="");

//! Construct and initialize a RedlichKisterVPSSTP ThermoPhase object
//! directly from an XML database
Expand Down
12 changes: 4 additions & 8 deletions include/cantera/thermo/RedlichKwongMFTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ namespace Cantera
class RedlichKwongMFTP : public MixtureFugacityTP
{
public:
//! @name Constructors and Duplicators
//! @{

//! Base constructor.
RedlichKwongMFTP();

//! Construct a RedlichKwongMFTP object from an input file
/*!
* @param inputFile Name of the input file containing the phase definition
* @param inputFile Name of the input file containing the phase definition.
* If blank, an empty phase will be created.
* @param id name (ID) of the phase in the input file. If empty, the
* first phase definition in the input file will be used.
*/
RedlichKwongMFTP(const std::string& infile, const std::string& id="");
explicit RedlichKwongMFTP(const std::string& infile="",
const std::string& id="");

//! Construct and initialize a RedlichKwongMFTP object directly from an
//! XML database
Expand Down
9 changes: 4 additions & 5 deletions include/cantera/thermo/StoichSubstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,16 @@ namespace Cantera
class StoichSubstance : public SingleSpeciesTP
{
public:
//! Default constructor for the StoichSubstance class
StoichSubstance() {}

//! Construct and initialize a StoichSubstance ThermoPhase object directly
//! from an ASCII input file
/*!
* @param infile name of the input file
* @param infile name of the input file. If blank, an empty phase will be
* created.
* @param id name of the phase id in the file.
* If this is blank, the first phase in the file is used.
*/
StoichSubstance(const std::string& infile, const std::string& id = "");
explicit StoichSubstance(const std::string& infile="",
const std::string& id="");

//! Construct and initialize a StoichSubstance ThermoPhase object directly
//! from an XML database
Expand Down
3 changes: 2 additions & 1 deletion include/cantera/thermo/ThermoPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,8 @@ class ThermoPhase : public Phase
* Used to implement constructors for derived classes which take a
* file name and phase name as arguments.
*
* @param inputFile Input file containing the description of the phase
* @param inputFile Input file containing the description of the phase. If blank,
* no setup will be performed.
* @param id Optional parameter identifying the name of the phase. If
* blank, the first phase definition encountered will be used.
*/
Expand Down
6 changes: 2 additions & 4 deletions include/cantera/thermo/WaterSSTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,13 @@ class WaterProps;
class WaterSSTP : public SingleSpeciesTP
{
public:
//! Base constructor
WaterSSTP();

//! Full constructor for a water phase
/*!
* @param inputFile String name of the input file
* @param id string id of the phase name
*/
explicit WaterSSTP(const std::string& inputFile, const std::string& id = "");
explicit WaterSSTP(const std::string& inputFile="",
const std::string& id="");

//! Full constructor for a water phase
/*!
Expand Down
6 changes: 0 additions & 6 deletions src/thermo/BinarySolutionTabulatedThermo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
namespace Cantera
{

BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo()
: m_kk_tab(npos)
, m_xlast(-1)
{
}

BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo(const std::string& inputFile,
const std::string& id_)
: m_kk_tab(npos)
Expand Down
14 changes: 0 additions & 14 deletions src/thermo/DebyeHuckel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ using namespace std;
namespace Cantera
{

DebyeHuckel::DebyeHuckel() :
m_formDH(DHFORM_DILUTE_LIMIT),
m_IionicMolality(0.0),
m_maxIionicStrength(30.0),
m_useHelgesonFixedForm(false),
m_IionicMolalityStoich(0.0),
m_form_A_Debye(A_DEBYE_CONST),
m_A_Debye(1.172576), // units = sqrt(kg/gmol)
m_B_Debye(3.28640E9), // units = sqrt(kg/gmol) / m
m_waterSS(0),
m_densWaterSS(1000.)
{
}

DebyeHuckel::DebyeHuckel(const std::string& inputFile,
const std::string& id_) :
m_formDH(DHFORM_DILUTE_LIMIT),
Expand Down
34 changes: 0 additions & 34 deletions src/thermo/HMWSoln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,6 @@ using namespace std;
namespace Cantera
{

HMWSoln::HMWSoln() :
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
m_IionicMolality(0.0),
m_maxIionicStrength(100.0),
m_TempPitzerRef(298.15),
m_form_A_Debye(A_DEBYE_CONST),
m_A_Debye(1.172576), // units = sqrt(kg/gmol)
m_waterSS(0),
m_molalitiesAreCropped(false),
IMS_X_o_cutoff_(0.2),
IMS_cCut_(0.05),
IMS_slopegCut_(0.0),
IMS_dfCut_(0.0),
IMS_efCut_(0.0),
IMS_afCut_(0.0),
IMS_bfCut_(0.0),
IMS_dgCut_(0.0),
IMS_egCut_(0.0),
IMS_agCut_(0.0),
IMS_bgCut_(0.0),
MC_X_o_cutoff_(0.0),
MC_dpCut_(0.0),
MC_epCut_(0.0),
MC_apCut_(0.0),
MC_bpCut_(0.0),
MC_cpCut_(0.0),
CROP_ln_gamma_o_min(-6.0),
CROP_ln_gamma_o_max(3.0),
CROP_ln_gamma_k_min(-5.0),
CROP_ln_gamma_k_max(15.0),
m_last_is(-1.0)
{
}

HMWSoln::~HMWSoln()
{
}
Expand Down
5 changes: 0 additions & 5 deletions src/thermo/IdealGasPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ using namespace std;
namespace Cantera
{

IdealGasPhase::IdealGasPhase() :
m_p0(-1.0)
{
}

IdealGasPhase::IdealGasPhase(const std::string& inputFile, const std::string& id_) :
m_p0(-1.0)
{
Expand Down
Loading

0 comments on commit 8edb731

Please sign in to comment.