Skip to content

Commit

Permalink
Add a better error message if fluid does not have thermal conductivit…
Browse files Browse the repository at this point in the history
…y or viscosity model

See #285

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
  • Loading branch information
ibell committed Dec 5, 2014
1 parent 8ed02ee commit e842743
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/CoolPropFluid.h
Expand Up @@ -293,6 +293,8 @@ class TransportPropertyData
BibTeX_conductivity; ///< The BibTeX key for the conductivity model
bool viscosity_using_ECS; ///< A flag for whether to use extended corresponding states for viscosity. False for no
bool conductivity_using_ECS; ///< A flag for whether to use extended corresponding states for conductivity. False for no
bool conductivity_model_provided; ///< A flag for whether thermal conductivity model is provided. False for no
bool viscosity_model_provided; ///< A flag for whether viscosity model is provided. False for no
long double sigma_eta, ///< The Lennard-Jones 12-6 \f$ \sigma \f$ parameter
epsilon_over_k; ///< The Lennard-Jones 12-6 \f$ \varepsilon/k \f$ parameter
ViscosityHardcodedEnum hardcoded_viscosity; ///< Hardcoded flags for the viscosity
Expand All @@ -301,6 +303,8 @@ class TransportPropertyData
hardcoded_conductivity = CONDUCTIVITY_NOT_HARDCODED;
viscosity_using_ECS = false;
conductivity_using_ECS = false;
viscosity_model_provided = false;
conductivity_model_provided = false;
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/Backends/Helmholtz/Fluids/FluidLibrary.h
Expand Up @@ -856,11 +856,13 @@ class JSONFluidLibrary
// Parse viscosity
if (transport.HasMember("viscosity")){
parse_viscosity(transport["viscosity"],fluid);
fluid.transport.viscosity_model_provided = true;
}

// Parse thermal conductivity
if (transport.HasMember("conductivity")){
parse_thermal_conductivity(transport["conductivity"],fluid);
fluid.transport.conductivity_model_provided = true;
}
};

Expand Down
8 changes: 8 additions & 0 deletions src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp
Expand Up @@ -399,6 +399,10 @@ long double HelmholtzEOSMixtureBackend::calc_viscosity(void)
{
// Get a reference for code cleanness
CoolPropFluid &component = *(components[0]);

if (!component.transport.viscosity_model_provided){
throw ValueError(format("Viscosity model is not available for this fluid"));
}

// Check if using ECS
if (component.transport.viscosity_using_ECS)
Expand Down Expand Up @@ -465,6 +469,10 @@ long double HelmholtzEOSMixtureBackend::calc_conductivity(void)
{
// Get a reference for code cleanness
CoolPropFluid &component = *(components[0]);

if (!component.transport.conductivity_model_provided){
throw ValueError(format("Thermal conductivity model is not available for this fluid"));
}

// Check if using ECS
if (component.transport.conductivity_using_ECS)
Expand Down

0 comments on commit e842743

Please sign in to comment.