mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-01-30 16:28:06 -05:00
Add function to check if fluid name is valid
Closes https://github.com/CoolProp/CoolProp/issues/204 Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -510,6 +510,22 @@ double Props1SI(std::string FluidName,std::string Output)
|
||||
return PropsSI(Output,"",0,"",0,FluidName);
|
||||
}
|
||||
|
||||
bool is_valid_fluid_string(std::string &input_fluid_string)
|
||||
{
|
||||
try{
|
||||
std::string backend, fluid;
|
||||
std::vector<double> fractions;
|
||||
// First try to extract backend and fractions
|
||||
extract_backend(input_fluid_string, backend, fluid);
|
||||
std::string fluid_string = extract_fractions(fluid, fractions);
|
||||
// We are going to let the factory function load the state
|
||||
shared_ptr<AbstractState> State(AbstractState::factory(backend, fluid_string));
|
||||
return true;
|
||||
}
|
||||
catch (std::exception &e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//EXPORT_CODE double CONVENTION IProps(long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user