|
[Sponsors] |
How to Specify a Fixed Volume Charge Density? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 25, 2015, 20:43 |
How to Specify a Fixed Volume Charge Density?
|
#1 |
New Member
Cory
Join Date: Jun 2015
Posts: 6
Rep Power: 11 |
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; } |
|
June 29, 2015, 18:24 |
|
#2 |
New Member
Cory
Join Date: Jun 2015
Posts: 6
Rep Power: 11 |
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.
|
|
September 16, 2020, 17:10 |
|
#3 |
New Member
Cody
Join Date: Feb 2020
Location: Montana, USA
Posts: 3
Rep Power: 6 |
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 |
|
Tags |
charge density, electrostatic, electrostaticfoam, space charge, volume charge density |
|
|
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 06:25 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
air bubble is disappear increasing time using vof | xujjun | CFX | 9 | June 9, 2009 08: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 09:23 |