# Adding complex source term in momentum equation

 Register Blogs Members List Search Today's Posts Mark Forums Read

August 24, 2019, 22:48
Adding complex source term in momentum equation
#1
Member

Bidesh Sengupta
Join Date: Sep 2018
Posts: 60
Rep Power: 3
Hi Foamers,

I wish to add some complex source term in the momentum equation, which is giving me a bit of trouble. If any one can help me, it shall be great.

I have attached the images of the equations that are used.
I have written the following code.

volScalarField ux = U.component(vector::X);
volScalarField uy = U.component(vector::Y);
volScalarField uz = U.component(vector::Z);
volScalarField u_airx = U_Air.component(vector::X);
volScalarField u_airy = U_Air.component(vector::Y);
volScalarField u_airz = U_Air.component(vector::Z);
volScalarField Re_u = (rho_Air*MVD/mu_Air)*mag(u_airx-ux);
volScalarField Re_v = (rho_Air*MVD/mu_Air)*mag(u_airy-uy);
volScalarField Re_w = (rho_Air*MVD/mu_Air)*mag(u_airz-uz);
volScalarField CD_u = (24/Re_u)*(1+0.0197*pow(Re_u,0.63)+2.6e-4*pow(Re_u,1.38));
volScalarField CD_v = (24/Re_v)*(1+0.0197*pow(Re_v,0.63)+2.6e-4*pow(Re_v,1.38));
volScalarField CD_w = (24/Re_w)*(1+0.0197*pow(Re_w,0.63)+2.6e-4*pow(Re_w,1.38));
volScalarField A_u = 0.75*rho_Air*CD_u*Re_u*mu_Air/(rho*pow(MVD,2));
volScalarField A_v = 0.75*rho_Air*CD_v*Re_v*mu_Air/(rho*pow(MVD,2));
volScalarField A_w = 0.75*rho_Air*CD_w*Re_w*mu_Air/(rho*pow(MVD,2));
volScalarField SD_x = A_u*(u_airx-ux);
volScalarField SD_y = A_v*(u_airy-uy);
volScalarField SD_z = A_w*(u_airz-uz);
volVectorField SD = SD_x*vector(1,0,0)+SD_y*vector(0,1,0)+SD_z*vector( 0,0,1);
volScalarField frac = (1-rho_Air/rho)*g_z;
volVectorField SG = -frac*rho*vector(0,0,1);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
solve
(
1.0/beta[i]*fvm::ddt(rhoU)
+ fvc::div(dbnsFlux.rhoUFlux())
+ fvc::Sp(1, SD)
+ fvc::Sp(1, SG)
);

The compilation was successful but when I am trying to run the simulation it shows segmentation fault, core dumped. To test I ran the simulation putting off the 'SD' term, the simulation went well. I think I am making mistake in evaluating 'SD' term.

Kindly help me to overcome it. Thank you very much for your time.
Attached Images
 GoverningEquation.png (45.2 KB, 8 views) SourceTerms.png (43.8 KB, 8 views) OtherDefinitions.png (72.8 KB, 5 views)

 September 5, 2019, 05:34 #2 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 297 Rep Power: 14 Division by zero because MVD goes to zero? __________________ www.cypriensoulaine.com/openfoam

 September 8, 2019, 02:57 #3 Member   Bidesh Sengupta Join Date: Sep 2018 Posts: 60 Rep Power: 3 Yes, Thank you. You are right. I corrected it and it runs.