Particle Motion UDF
The Particle Motion UDF allows changing the equations for the friction coefficient, Cunningham correction, diffusivity and external forces.
This UDF contains three functions:
The first function contains the definition of the Cunningham correction and returns . The second function returns the diffusivity . The last function returns the external force .
As an example, the file ParticleMotionUDF-Standard.cpp shows the formulas as implemented in GeoDict:
double udf_friction(const InputData_UDF& d) { double lambda = d.meanFreePath; double cunningham = 1.0 + lambda / d.particleRadius * (1.17 + 0.525 * exp(-0.78 * d.particleRadius / lambda) ); double dynViscosity = d.kinematicViscosity * d.fluidDensity; double g = 6.0 * M_PI * dynViscosity * d.particleRadius / cunningham; return g; } |
// returns friction coefficient in [kg/s] |
double udf_diffusivity(const InputData_UDF& d, const int materialID) { double gamma = udf_friction(d); return 1.3806485e-23 * d.temperature / gamma; } |
// returns diffusivity in [m^2/s] |
void udf_force(double* f, const InputData_UDF& d) { f[0] = 0; f[1] = 0; f[2] = 0; } |
// returns external force in [N] |
Another example is the file ParticleMotionUDF-Gravity.cpp, where f is used to model gravity:
void udf_force(double* f, const InputData_UDF& d) { const double g = 9.81; // [m/s^2] f[0] = 0; f[1] = 0; // gravity in z-direction // 4/3 * Pi = 4.18879020479 f[2] = g * d.particleDensity * (4.18879020479 * d.particleRadius * d.particleRadius * d.particleRadius); } |
// returns external force in [N] |
To include, e.g., gravity and buoyancy, the function can be changed to (see the file ParticleMotionUDF-GravityPlusBuoyancy.cpp):
void udf_force(double* f, const InputData_UDF& d) { f[0] = 0; f[1] = 0; double g = 9.81; // [m/s^2] double buoyancy = g * 4.0/3.0 * M_PI * pow(d.particleRadius,3) * d.fluidDensity; double gravity = g * d.particleMass; f[2] = gravity - buoyancy; } |
// returns external force in [N] |
The input data struct InputData_UDF is defined in the ParticleMotionStructs.h header file which can be found in the include folder and contains the following data:
struct InputData_UDF{ |
|
double particleRadius; |
// [m] |
double particleDensity; |
// [kg/m^3] |
double particleMass; |
// [kg] |
double kinematicViscosity; |
// [m^2/s] |
double fluidDensity; |
// [kg/m^3] |
double meanFreePath; |
// [m] |
double temperature; |
// [K] |
// Those parameters are only available in the force() function: |
|
double position[3]; |
// [m] |
double eStatic[3]; |
// [V/m] |
void * userData; |
|
}; |
|
The two parameter vectors position and eStatic may only be used inside of the udf_force() function. The functions udf_friction()and udf_diffusivity() are called by GeoDict only once when the particle is initialized, and not while the particle trajectory is computed. Therefore, when these functions are called, those parameters do not contain any meaningful information.