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

How to Specify a Fixed Volume Charge Density?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 10
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: 10
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

Old   September 16, 2020, 16:10
Default
  #3
New Member
 
Cody
Join Date: Feb 2020
Location: Montana, USA
Posts: 3
Rep Power: 6
cjessup37 is on a distinguished road
Hi Cory,


I am new to C++ coding and OpenFOAM. What do you mean 'specifying the charge density for every part of the mesh by looping through it'? Could you possibly share your code?



For context, I am trying to use electrostaticFoam as a way to calculate the gravitational field (little g) of a mass(es). I have changed the epsilon constant to what it needs to be for gravity as well as the units of phi and rho. I am having trouble specifying rho. I still need to change the solver to include the little g calculation but that looks straightforward based on what I read in the OpenFoam user guide.


Thanks!
Cody
cjessup37 is offline   Reply With Quote

Reply

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


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 Off
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] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 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 07:24
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23


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