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

BCs and correctBoundaryConditions() for an electric field and current solver

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 21, 2014, 07:56
Default BCs and correctBoundaryConditions() for an electric field and current solver
  #1
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
Hello,

I'm working on a solver for calculating electric field and current in an inhomogenous conductivity field.

I'm currently evaluating the validity of the solution and I'm wondering which boundary conditions make most sense, and which fields need to use field.correctBoundaryConditions(). To my understanding correctBoundaryConditions() adjusts the values of the boundary so they match their gradient conditions after the values of the cells were (explicitly) modified.

Here's a simplified excerpt of the solver code:

Code:
forAll(sigma, iter)
{
    sigma[iter] = someValues;
}
sigma.correctBoundaryConditions();
int i = 0;
while(i < 10)
{
  i++;

  //quasistatic electric potential
  fvScalarMatrix phiEqn
  (
    fvm::laplacian(sigma, phiE)
  );
  Foam::solverPerformance phiSolve = phiEqn.solve();

  //electric field
  EField = -fvc::grad(phiE);
  //EField.correctBoundaryConditions();

  //current density
  j = sigma * EField;
  //j.correctBoundaryConditions();

  Info << "phiE: " << min(phiE) << "/" << max(phiE) << endl;

  if(phiSolve.nIterations() == 0 && phiSolve.converged())
  {
    Info << "phi equation converged in " << i << " iterations" << endl;
    break;
  }
}
Now I am examining the current through electrodes, which are modelled as boundary conditions. I can either specify zeroGradient BC, i.e. same conductivity as the neighbouring cell, or specify the conductivity of the metal used in the electrode (which is usually much much higher). The latter method produces no realistic results at all.

Electric field and current both use zeroGradient BC, although I would prefer to use a BC that has zeroGradient in normal direction and fixedValue 0 in tangential direction. Is there such a BC?

For testing, I've used zeroGradient for the conductivity and I'm having some numerical problems. Below you can see the output of the calculated current using different methods, with j being the current density:

Quote:
without correctBoundaryConditions(only sigma), bc for sigma at electrodes: zeroGradient
Sf() & j over electrode1: 0.0555727
Sf() & j over electrode2: -3.00958e-08
Sf() & j over electrode3: -0.0555726
Difference between electrodes:-1.62838e-09(-2.93018e-06%)
Integral(j) over electrode1: (-3.69829e-19 -0.000252525 -0.0555727)
Integral(j) over electrode2: (-5.99056e-23 -5.249e-09 -2.61724e-08)
Integral(j) over electrode3: (5.1536e-17 -0.0555726 -0.00882784)
Difference between electrodes5.11661e-17 -0.0558252 -0.0644005)
Magnitude(Integral(j)) over electrode1: 0.0555732
Magnitude(Integral(j)) over electrode2: 2.66935e-08
Magnitude(Integral(j)) over electrode3: 0.0562694
Difference between electrodes: -0.000696218(-1.25279%)

with correctBoundaryConditions(sigma, EField, j), bc for sigma at electrodes: zeroGradient
Sf() & j over electrode1: 0.0555727
Sf() & j over electrode2: -2.98116e-08
Sf() & j over electrode3: -0.053637
Difference between electrodes:0.00193558(3.48298%)
Integral(j) over electrode1: (-3.69829e-19 -0.000252525 -0.0555727)
Integral(j) over electrode2: (-5.99056e-23 -5.13672e-09 -2.60005e-08)
Integral(j) over electrode3: (5.1536e-17 -0.053637 -0.00882784)
Difference between electrodes5.11661e-17 -0.0538896 -0.0644005)
Magnitude(Integral(j)) over electrode1: 0.0555732
Magnitude(Integral(j)) over electrode2: 2.65031e-08
Magnitude(Integral(j)) over electrode3: 0.0543587
Difference between electrodes: 0.00121455(2.18549%)
I expected to see the same results for "Sf() & j" (inner product with the surface area vector) and Magnitude(Integral(j)), because the current should be orthogonal to the surface, since the electric potential is constant on the surface.
I also expect that the difference between the electrodes should be (close to) zero, meaning that the current is conserved. However, there is a significant error.

I am using a simple wedge mesh generated with blockMesh. The electrodes have different angles towards each other, one at the top, one at the bottom, and one at the side of the cylindrical mesh, separated by isolating material with zero conductivity BC. Right now the cells are completely orthogonal.

I believe this could be caused by the somewhat unfitting zeroGradient BC for electric field and current, but I don't know if there is such a condition as described above.

I would be very grateful if someone could give me some hints.
It is important to me to get current conservation (atleast to a certain accuracy).

By the way, can anyone explain to me the meaning of phiSolve.nIterations() and phiSolve.converged() ?
I suspect this is related to the way the solution matrix is approximated, but if it is, why does the loop in the solver above has to run multiple times until the solution converges? I would expect the solver to iterate until conversion is reached. Is there some artificial limit that stops it before convergence?

Last edited by chriss85; January 22, 2014 at 04:55.
chriss85 is offline   Reply With Quote

Old   May 2, 2022, 22:25
Default
  #2
New Member
 
Mostafa
Join Date: Oct 2021
Posts: 22
Rep Power: 5
mostafa kareem is on a distinguished road
hello chriss85,

I know it has been a long time, but I'm also solving electric field after computing electric potential in multiregion solver. i could not get continous electric field across interface. do you have any suggestion how to solve the problem

thanks in advance
mostafa kareem is offline   Reply With Quote

Old   May 3, 2022, 11:32
Default
  #3
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
I don't remember from my head, I think it was about prescribing either current continuity or potential. It might be easier if you have a current source and know what current needs to be pass through the interface in total. In that case you could solve one region first to calculate the potential and then apply that potential to the other region. This will only work if you can assume a vastly different conductivity so that you have an equipotential surface at the interface. Otherwise I think you will need some iterative solution.

Another possibility would be using a third mesh that encompasses both meshes, solve the equation on that mesh and then project the solution on the other two regions.
chriss85 is offline   Reply With Quote

Old   May 3, 2022, 13:08
Default
  #4
New Member
 
Mostafa
Join Date: Oct 2021
Posts: 22
Rep Power: 5
mostafa kareem is on a distinguished road
Thank chriss85 for your reply ,

let me explain my problem well. I successfully solved the electric potential (phi) over fluid and solid mesh and I got continuous electric potential through coupling the two domains using iterative class ( compressible Turbulent Baffle) to set equal fluxes across interface which is used in heat transfer problems.

My question is regarding the Electric field : E = -fvc::grad(phi)

although I had continuous electric potential (phi) across interface, i failed to get a continuous electric field across the interface after taking the gradient of phi

what i did is that

in the fluid domain i solved the electric potential and then took the derivative

solve
(
fvm::laplacian(epsilon,phiS)
);

E = -1*fvc::grad(phiS);

and also i did the same in solid regions


solve
(
fvm::laplacian(epsilon,phiS)
);

E = -1*fvc::grad(phiS);


in electric field file in the zero file , i set all the boundaries to calculated

i'm asking about how the fvc::grad() can compute continous electric field (E) while computing every one on seperate mesh


Thanks in advance
mostafa kareem is offline   Reply With Quote

Old   May 3, 2022, 13:29
Default
  #5
New Member
 
Mostafa
Join Date: Oct 2021
Posts: 22
Rep Power: 5
mostafa kareem is on a distinguished road
Quote:
Originally Posted by chriss85 View Post

Another possibility would be using a third mesh that encompasses both meshes, solve the equation on that mesh and then project the solution on the other two regions.
i tried something like that

i calculated the electric potential over fluid and solid and coupled them using compressibleBaffle class then i mapped the phi on the solid mesh and in the fluid mesh over on mesh contianing both meshes to have one elecctric potential field using MapField , after thaty i took the gradient successfully and got the right Electric field



the problem is mapField took long time about 3 hrs to map field (phi) from solid domain to its projection on the full mesh and other 3 hrs to map field (phi) from fluid domain to it's projection on the full mesh , so i cannot do this all time
mostafa kareem is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 02:56.