CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

How to Specify a Fixed Volume Charge Density?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 25, 2015, 19:43
Default How to Specify a Fixed Volume Charge Density?
  #1
New Member
 
Cory
Join Date: Jun 2015
Posts: 6
Rep Power: 2
cgerrity is on a distinguished road
Hello,

What is the best way to define a *fixed* space (volume) charge density in OpenFOAM? The electrostaticFoam source code appears to use the continuity equation (in bold), implying rho is not fixed in space:


Code:
Description
    Solver for electrostatics.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "setRootCase.H"

    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting iteration loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Iteration = " << runTime.timeName() << nl << endl;

        solve
        (
            fvm::laplacian(phi) + rho/epsilon0
        );

        rhoFlux = -k*mesh.magSf()*fvc::snGrad(phi);

        solve
        (
            fvm::ddt(rho) + fvm::div(rhoFlux, rho)
        );

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}
cgerrity is offline   Reply With Quote

Old   June 29, 2015, 17:24
Default
  #2
New Member
 
Cory
Join Date: Jun 2015
Posts: 6
Rep Power: 2
cgerrity is on a distinguished road
I was able to do this by copying and modying the electrostatics solver directly. The trick is to specify the charge density for every part of the mesh by looping through it and then running the solver. If you want fixed space charge, make sure your solver doesn't change rho.
cgerrity is offline   Reply With Quote

Reply

Tags
charge density, electrostatic, electrostaticfoam, space charge, volume charge density

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem regarding high density ratio(1:1000) in volume of fluid(VOF) method j.patel Main CFD Forum 0 September 17, 2013 05:25
BlockMesh FOAM warning gaottino OpenFOAM Native Meshers: blockMesh 7 July 19, 2010 14:11
air bubble is disappear increasing time using vof xujjun CFX 9 June 9, 2009 07:59
Error in adjusting mesh volume density in ICEM? Shab CFX 0 October 31, 2007 08:24
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23


All times are GMT -4. The time now is 08:14.