@@ -122,8 +122,17 @@ void ThermoFactory::deleteFactory()
122122 s_factory = 0 ;
123123}
124124
125+ ThermoPhase* ThermoFactory::newThermoPhase (const std::string& model)
126+ {
127+ warn_deprecated (" newThermoPhase" ,
128+ " To be removed after Cantera 3.0; superseded by newThermo." );
129+ return create (model);
130+ }
131+
125132ThermoPhase* newThermoPhase (const string& model)
126133{
134+ warn_deprecated (" newThermoPhase" ,
135+ " To be removed after Cantera 3.0; superseded by newThermo." );
127136 return ThermoFactory::factory ()->create (model);
128137}
129138
@@ -133,13 +142,23 @@ shared_ptr<ThermoPhase> newThermo(const string& model)
133142 return tptr;
134143}
135144
136- ThermoPhase* ThermoFactory:: newThermoPhase (const std::string& model )
145+ shared_ptr< ThermoPhase> newThermoPhase (const AnyMap& phaseNode, const AnyMap& rootNode )
137146{
138- return create (model);
147+ if (!phaseNode.hasKey (" kinetics" ) && phaseNode.hasKey (" reactions" )) {
148+ throw InputFileError (" newPhase" , phaseNode[" reactions" ],
149+ " Phase entry includes a 'reactions' field but does not "
150+ " specify a kinetics model." );
151+ }
152+ shared_ptr<ThermoPhase> t = newThermo (phaseNode[" thermo" ].asString ());
153+ setupPhase (*t, phaseNode, rootNode);
154+ return t;
139155}
140156
141157unique_ptr<ThermoPhase> newPhase (const AnyMap& phaseNode, const AnyMap& rootNode)
142158{
159+ warn_deprecated (" newPhase" ,
160+ " To be removed after Cantera 3.0; superseded by\n "
161+ " newThermoPhase(const AnyMap&, const AnyMap&)." );
143162 if (!phaseNode.hasKey (" kinetics" ) && phaseNode.hasKey (" reactions" )) {
144163 throw InputFileError (" newPhase" , phaseNode[" reactions" ],
145164 " Phase entry includes a 'reactions' field but does not "
@@ -150,24 +169,33 @@ unique_ptr<ThermoPhase> newPhase(const AnyMap& phaseNode, const AnyMap& rootNode
150169 return t;
151170}
152171
153- ThermoPhase* newPhase (const std:: string& infile, std:: string id)
172+ shared_ptr< ThermoPhase> newThermoPhase (const string& infile, const string& id)
154173{
155174 size_t dot = infile.find_last_of (" ." );
156175 string extension;
157176 if (dot != npos) {
158177 extension = toLowerCopy (infile.substr (dot+1 ));
159178 }
179+ string id_ = id;
160180 if (id == " -" ) {
161- id = " " ;
181+ id_ = " " ;
162182 }
163183 if (extension == " cti" || extension == " xml" ) {
164- throw CanteraError (" newPhase " ,
184+ throw CanteraError (" newThermo " ,
165185 " The CTI and XML formats are no longer supported." );
166186 }
167187
168188 AnyMap root = AnyMap::fromYamlFile (infile);
169- AnyMap& phase = root[" phases" ].getMapWhere (" name" , id);
170- return newPhase (phase, root).release ();
189+ AnyMap& phase = root[" phases" ].getMapWhere (" name" , id_);
190+ return newThermoPhase (phase, root);
191+ }
192+
193+ ThermoPhase* newPhase (const std::string& infile, std::string id)
194+ {
195+ warn_deprecated (" newPhase" ,
196+ " To be removed after Cantera 3.0; superseded by\n "
197+ " newThermoPhase(const std::string&, const std::string&)." );
198+ return newThermoPhase (infile, id).get ();
171199}
172200
173201void addDefaultElements (ThermoPhase& thermo, const vector<string>& element_names) {
0 commit comments