CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Modifying sonicFoam to add EM terms (https://www.cfd-online.com/Forums/openfoam-programming-development/148413-modifying-sonicfoam-add-em-terms.html)

Alexee February 11, 2015 10:55

Modifying sonicFoam to add EM terms
 
Hello, everyone!

I'm trying to include electromagnetic force UxB (where B is constant in time) and Joule heating into sonicFoam, but I'm having troubles modifying the equations.

I added B into createFields.H and terms into right hand sides of UEqn and EEqn, but it doesn't seem to work. (I have very little idea about programming with openFoam)

Here are the codes of equations I modified:

Code:

F = sigma*U^B^B;
fvVectorMatrix UEqn
(
    fvm::ddt(rho, U)
  + fvm::div(phi, U)
  + turbulence->divDevRhoReff(U)
  + F
);
solve(UEqn == -fvc::grad(p));
K = 0.5*magSqr(U);

EEqn
Code:

E = U^B;
J = sigma*E;
Q = J&E;

{
    solve
    (
        fvm::ddt(rho, e) + fvm::div(phi, e)
      + fvc::ddt(rho, K) + fvc::div(phi, K)
      + fvc::div(fvc::absolute(phi/fvc::interpolate(rho), U), p, "div(phiv,p)")
      - fvm::laplacian(turbulence->alphaEff(), e)
      - Q
    );
 

    thermo.correct();
}

Can anyone please tell me, what is wrong with my code?


All times are GMT -4. The time now is 11:32.