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 
127  // Inherited entries
128  ...
129  }
130  \endverbatim
131 
132  where the entries mean:
133  \table
134  Property | Description | Type | Reqd | Deflt
135  type | Type name: electricPotential | word | yes | -
136  libs | Library name: solverFunctionObjects | word | yes | -
137  sigma | Isotropic electrical conductivity of phase | scalar | yes | -
138  epsilonr | Isotropic relative permittivity of phase | scalar | no | -
139  nCorr | Number of corrector iterations | int | no | 1
140  writeDerivedFields | Flag to write extra fields | bool | no | false
141  V | Name of electric potential field | word | no | electricPotential:V
142  electricField | Flag to calculate electric field | bool | no | false
143  E | Name of electric field | word | no | electricPotential:E
144  \endtable
145 
146  The inherited entries are elaborated in:
147  - \link functionObject.H \endlink
148 
149  Fields written out when the \c writeDerivedFields entry is \c true:
150  \table
151  Operand | Type | Location
152  Current density | volVectorField | <time>/electricPotential:J
153  Charge density | volScalarField | <time>/electricPotential:rho
154  \endtable
155 
156 SourceFiles
157  electricPotential.C
158 
159 \*---------------------------------------------------------------------------*/
160 
161 #ifndef functionObjects_electricPotential_H
162 #define functionObjects_electricPotential_H
163 
164 #include "fvMeshFunctionObject.H"
165 #include "volFields.H"
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 namespace Foam
170 {
171 namespace functionObjects
172 {
173 
174 /*---------------------------------------------------------------------------*\
175  Class electricPotential Declaration
176 \*---------------------------------------------------------------------------*/
177 
178 class electricPotential
179 :
180  public fvMeshFunctionObject
181 {
182  // Private Data
183 
184  //- Dictionary of phase data
185  dictionary phasesDict_;
186 
187  //- List of phase names
188  wordList phaseNames_;
189 
190  //- Unallocated list of phase fields
191  UPtrList<volScalarField> phases_;
192 
193  //- List of isotropic electrical conductivity of phases
194  PtrList<dimensionedScalar> sigmas_;
195 
196  //- Isotropic electrical conductivity of a single phase
197  dimensionedScalar sigma_;
198 
199  //- List of isotropic relative permittivity of phases
200  PtrList<dimensionedScalar> epsilonrs_;
201 
202  //- Isotropic relative permittivity of a single phase
203  dimensionedScalar epsilonr_;
204 
205  //- Name of electric potential field
206  word Vname_;
207 
208  //- Name of electric field
209  word Ename_;
210 
211  //- Number of corrector iterations
212  int nCorr_;
213 
214  //- Flag to write derived fields of
215  //- electric field, current density and free-charge density
216  bool writeDerivedFields_;
217 
218  //- Flag to calculate electric field
219  bool electricField_;
220 
221 
222  // Private Member Functions
223 
224  //- Return requested field from the object registry
225  //- or read+register the field to the object registry
226  volScalarField& getOrReadField(const word& fieldName) const;
227 
228 
229  //- Return the isotropic electrical conductivity field of the mixture
230  tmp<volScalarField> sigma() const;
231 
232  //- Return the isotropic permittivity field of the mixture
233  tmp<volScalarField> epsilonm() const;
234 
235 
236  //- No copy construct
237  electricPotential(const electricPotential&) = delete;
238 
239  //- No copy assignment
240  void operator=(const electricPotential&) = delete;
241 
242 
243 public:
244 
245  //- Runtime type information
246  TypeName("electricPotential");
247 
248 
249  // Constructors
250 
251  //- Construct from Time and dictionary
252  electricPotential
253  (
254  const word& name,
255  const Time& runTime,
256  const dictionary& dict
257  );
258 
259 
260  //- Destructor
261  virtual ~electricPotential() = default;
262 
263 
264  // Member Functions
265 
266  //- Read the function object data
267  virtual bool read(const dictionary& dict);
268 
269  //- Calculate the function object
270  virtual bool execute();
271 
272  //- Write the function object output
273  virtual bool write();
274 };
275 
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 } // End namespace functionObjects
280 } // End namespace Foam
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #endif
285 
286 // ************************************************************************* //
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:58
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Namespace for OpenFOAM.