electricPotential.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionObjects::electricPotential
28 
29 Group
30  grpSolversFunctionObjects
31 
32 Description
33  Computes the steady-state equation of charge conservation to obtain
34  the electric potential by strictly assuming a quasi-static electrostatic
35  field for single-phase and multiphase applications.
36 
37  The steady-state equation of the charge conservation:
38 
39  \f[
40  \nabla \cdot \left( \sigma \nabla V \right) = 0
41  \f]
42 
43  where
44  \vartable
45  V | Electric potential [volt = kg m^2/(A s^3)]
46  \sigma | Isotropic conductivity of mixture [S/m = A^2 s^3/(kg m^3)]
47  \endvartable
48 
49  Optionally, electric field, current density and free-charge
50  density fields can be written out by using the following equations:
51 
52  \f[
53  \vec{E} = - \nabla V
54  \f]
55 
56  \f[
57  \vec{J} = \sigma \vec{E} = - \sigma \nabla V
58  \f]
59 
60  \f[
61  \rho_E = \nabla \cdot \left(\epsilon_m \vec{E} \right)
62  = \nabla \cdot \left(\epsilon_0 \epsilon_r \vec{E} \right)
63  \f]
64 
65  where
66  \vartable
67  \vec{E} | Electric field [m kg/(s^3 A)]
68  \vec{J} | Current density [A/m^2]
69  \rho_E | Volume charge density [C/m^3 = A s/m^3]
70  \epsilon_m | Isotropic permittivity of mixture [F/m = A^2 s^4/(kg m^3)]
71  \epsilon_0 | Isotropic vacuum permittivity [F/m = A^2 s^4/(kg m^3)]
72  \epsilon_r | Isotropic relative permittivity of mixture [-]
73  \endvartable
74 
75  For multiphase applications, \c sigma and \c epsilonr are blended
76  (to consider their interface values) by using the simple weighted
77  arithmetic mean interpolation, for example:
78 
79  \f[
80  \sigma = \alpha_1 \sigma_1 + \alpha_2 \sigma_2
81  = \alpha_1 \sigma_1 + (1 - \alpha_1) \sigma_2
82  \f]
83 
84 Usage
85  Minimal example by using \c system/controlDict.functions:
86  \verbatim
87  electricPotential1
88  {
89  // Mandatory entries
90  type electricPotential;
91  libs (solverFunctionObjects);
92 
93  // Conditional entries
94 
95  // Option-1: single-phase
96  sigma <scalar>;
97  epsilonr <scalar>;
98 
99  // Option-2: multiphase
100  phases
101  {
102  alpha.air
103  {
104  sigma <scalar>;
105  epsilonr <scalar>;
106  }
107  alpha.water
108  {
109  sigma <scalar>;
110  epsilonr <scalar>;
111  }
112  alpha.mercury
113  {
114  sigma <scalar>;
115  epsilonr <scalar>;
116  }
117  ...
118  }
119 
120  // Optional entries
121  nCorr <int>;
122  writeDerivedFields <bool>;
123  V <word>;
124  electricField <bool>;
125  E <word>;
126  fvOptions <dict>;
127 
128  // Inherited entries
129  ...
130  }
131  \endverbatim
132 
133  where the entries mean:
134  \table
135  Property | Description | Type | Reqd | Deflt
136  type | Type name: electricPotential | word | yes | -
137  libs | Library name: solverFunctionObjects | word | yes | -
138  sigma | Isotropic electrical conductivity of phase | scalar | yes | -
139  epsilonr | Isotropic relative permittivity of phase | scalar | no | -
140  nCorr | Number of corrector iterations | int | no | 1
141  writeDerivedFields | Flag to write extra fields | bool | no | false
142  V | Name of electric potential field | word | no | electricPotential:V
143  electricField | Flag to calculate electric field | bool | no | false
144  E | Name of electric field | word | no | electricPotential:E
145  fvOptions | List of finite-volume options | dict | no | -
146  \endtable
147 
148  The inherited entries are elaborated in:
149  - \link functionObject.H \endlink
150  - \link fvOption.H \endlink
151 
152  Fields written out when the \c writeDerivedFields entry is \c true:
153  \table
154  Operand | Type | Location
155  Current density | volVectorField | <time>/electricPotential:J
156  Charge density | volScalarField | <time>/electricPotential:rho
157  \endtable
158 
159 Note
160  - Only constraint-type finite-volume options can be used.
161 
162 SourceFiles
163  electricPotential.C
164 
165 \*---------------------------------------------------------------------------*/
166 
167 #ifndef functionObjects_electricPotential_H
168 #define functionObjects_electricPotential_H
169 
170 #include "fvMeshFunctionObject.H"
171 #include "volFields.H"
172 #include "fvOptionList.H"
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 namespace Foam
177 {
178 namespace functionObjects
179 {
180 
181 /*---------------------------------------------------------------------------*\
182  Class electricPotential Declaration
183 \*---------------------------------------------------------------------------*/
184 
185 class electricPotential
186 :
187  public fvMeshFunctionObject
188 {
189  // Private Data
190 
191  //- Dictionary of phase data
192  dictionary phasesDict_;
193 
194  //- List of phase names
195  wordList phaseNames_;
196 
197  //- Unallocated list of phase fields
198  UPtrList<volScalarField> phases_;
199 
200  //- List of isotropic electrical conductivity of phases
201  PtrList<dimensionedScalar> sigmas_;
202 
203  //- Isotropic electrical conductivity of a single phase
204  dimensionedScalar sigma_;
205 
206  //- List of isotropic relative permittivity of phases
207  PtrList<dimensionedScalar> epsilonrs_;
208 
209  //- Isotropic relative permittivity of a single phase
210  dimensionedScalar epsilonr_;
211 
212  //- Name of electric potential field
213  word Vname_;
214 
215  //- Name of electric field
216  word Ename_;
217 
218  //- Run-time selectable finite volume options
219  fv::optionList fvOptions_;
220 
221  //- Number of corrector iterations
222  int nCorr_;
223 
224  //- Flag to write derived fields of
225  //- electric field, current density and free-charge density
226  bool writeDerivedFields_;
227 
228  //- Flag to calculate electric field
229  bool electricField_;
230 
231 
232  // Private Member Functions
233 
234  //- Return requested field from the object registry
235  //- or read+register the field to the object registry
236  volScalarField& getOrReadField(const word& fieldName) const;
237 
238 
239  //- Return the isotropic electrical conductivity field of the mixture
240  tmp<volScalarField> sigma() const;
241 
242  //- Return the isotropic permittivity field of the mixture
243  tmp<volScalarField> epsilonm() const;
244 
245 
246  //- No copy construct
247  electricPotential(const electricPotential&) = delete;
248 
249  //- No copy assignment
250  void operator=(const electricPotential&) = delete;
251 
252 
253 public:
254 
255  //- Runtime type information
256  TypeName("electricPotential");
257 
258 
259  // Constructors
260 
261  //- Construct from Time and dictionary
262  electricPotential
263  (
264  const word& name,
265  const Time& runTime,
266  const dictionary& dict
267  );
268 
269 
270  //- Destructor
271  virtual ~electricPotential() = default;
272 
273 
274  // Member Functions
275 
276  //- Read the function object data
277  virtual bool read(const dictionary& dict);
278 
279  //- Calculate the function object
280  virtual bool execute();
281 
282  //- Write the function object output
283  virtual bool write();
284 };
285 
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 } // End namespace functionObjects
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #endif
295 
296 // ************************************************************************* //
virtual bool write()
Write the function object output.
dictionary dict
engineTime & runTime
TypeName("electricPotential")
Runtime type information.
const word & name() const noexcept
Return the name of this functionObject.
virtual bool read(const dictionary &dict)
Read the function object data.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
virtual ~electricPotential()=default
Destructor.
virtual bool execute()
Calculate the function object.
List< word > wordList
List of word.
Definition: fileName.H:59
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Namespace for OpenFOAM.