Files
CoolProp/wrappers/Fluent/Example_windows_UDF.cpp
Omar Zaki 64f0bbdf52 Add Windows Instructions and example for Fluent Wrapper (#2624)
* Add Windows Instructions and example

I added how to use the wrapper for Windows through the shared library. There might be a better way using the static library, but I believe this method works for 99% of use cases.

* Update Windows setup instructions in Fluent README

Clarified and expanded the step-by-step instructions for setting up CoolProp with Fluent on Windows. Added details about launching Fluent, using absolute paths, and using '//' in paths. Improved clarity and fixed minor typos.

* Update Windows instructions in Fluent wrapper README

Added clarification about limitations of using the shared library method and recommended using a static library for more robust results. Minor formatting and wording improvements were also made to the step-by-step instructions.
2025-10-06 20:34:53 -04:00

51 lines
1.4 KiB
C++

#include "udf.h"
#include "CoolPropLib.h"
#include <string>
#pragma comment(lib, "C:\\XX\\XX\\CoolProp.lib")
// User settings
static const std::string FLUID_NAME = "R134a";
DEFINE_ON_DEMAND(test)
{
double PropResult = PropsSI("T", "P", 101325, "Q", 0, "Water");
Message0("Saturation temperature of Water at 1 atm = %g K\n", PropResult);
}
// Density via CoolProp
DEFINE_PROPERTY(rho_coolprop, cell, thread)
{
real P = C_P(cell, thread);
real H = C_H(cell, thread);
double rho = PropsSI("VISCOSITY",
"P", static_cast<double>(P),
"Hmass",static_cast<double>(H),
FLUID_NAME.c_str());
return static_cast<real>(rho);
}
// Viscosity via CoolProp
DEFINE_PROPERTY(mu_coolprop, cell, thread)
{
real P = C_P(cell, thread);
real H = C_H(cell, thread);
double mu = PropsSI("VISCOSITY",
"P", static_cast<double>(P),
"Hmass",static_cast<double>(H),
FLUID_NAME.c_str());
return static_cast<real>(mu);
}
// Thermal conductivity via CoolProp
DEFINE_PROPERTY(k_coolprop, cell, thread)
{
real P = C_P(cell, thread);
real H = C_H(cell, thread);
double k = PropsSI("CONDUCTIVITY",
"P", static_cast<double>(P),
"Hmass",static_cast<double>(H),
FLUID_NAME.c_str());
return static_cast<real>(k);
}