Skip to content

Commit 0f04cbc

Browse files
committed
refactor documentation
1 parent b079ed5 commit 0f04cbc

15 files changed

+97
-94
lines changed

pypeec/lib_matrix/green_function.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
Analytical solutions and numerical approximations are used.
44
55
The two following integrals are available:
6-
- Integrate all the dimensions (6D integrals).
7-
- Integrate the dimensions except the last one (5D integrals).
6+
- Integrate all the dimensions (for the inductance and potential matrices).
7+
- Integrate the dimensions except the last one (for the coupling matrices).
88
99
Exact Inductance Equations for Rectangular Conductors With Applications to More Complicated Geometries
10-
C. Hoer and C. Love, 1965
10+
C. Hoer and C. Love, Journal of Research of the National Bureau of Standards, 1965
1111
1212
Exact Closed Form Formula for Self Inductance of Conductor of Rectangular Cross Section
13-
Z. Piatek and B. Baron, 2021
13+
Z. Piatek and B. Baron, Progress In Electromagnetics Research, 2012
1414
"""
1515

1616
__author__ = "Thomas Guillod"
@@ -207,7 +207,7 @@ def _get_green_preproc(int_type):
207207
def get_green_ana(d, idx, int_type):
208208
"""
209209
Compute a Green function between two voxels.
210-
An analytical solution is used.
210+
A stable analytical solution is used.
211211
The 5D or 6D integrals can be computed.
212212
"""
213213

@@ -255,7 +255,7 @@ def get_green_num(d, idx, int_type):
255255
"""
256256
Compute a Green function between two voxels.
257257
The 5D or 6D integrals can be computed.
258-
A numerical approximation is used.
258+
A fast numerical approximation is used.
259259
Only valid if the distance between the two voxels is large.
260260
"""
261261

pypeec/lib_matrix/matrix_factorization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- SuperLU is typically slower but is always available (integrated with SciPy).
66
- PARDISO is typically faster than SuperLU (available through Pydiso).
77
- PyAMG is typically slow but uses less memory (risk of convergence issues).
8+
- Diagonal is a dummy factorization (only for debugging).
89
910
This module is only importing the required matrix solver.
1011
This means that the unused matrix solvers are not required.

pypeec/lib_matrix/matrix_multiply.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
66
Three different types of matrices are supported:
77
- Tensor representing a simple potential matrix.
8-
- Size of the last dimension of the input tensor => 1.
9-
- Number of dimensions of the input vector => 1.
10-
- Number of dimensions of the output vector => 1.
8+
- Size of the last dimension of the input tensor: 1.
9+
- Number of dimensions of the input vector: 1.
10+
- Number of dimensions of the output vector: 1.
1111
- Tensor representing a block diagonal inductance matrix.
12-
- Size of the last dimension of the input tensor => 1.
13-
- Number of dimensions of the input vector => 3.
14-
- Number of dimensions of the output vector => 3.
12+
- Size of the last dimension of the input tensor: 1.
13+
- Number of dimensions of the input vector: 3.
14+
- Number of dimensions of the output vector: 3.
1515
- Tensor representing a block off-diagonal coupling matrix.
16-
- Size of the last dimension of the input tensor => 3.
17-
- Number of dimensions of the input vector => 3.
18-
- Number of dimensions of the output vector => 3.
16+
- Size of the last dimension of the input tensor: 3.
17+
- Number of dimensions of the input vector: 3.
18+
- Number of dimensions of the output vector: 3.
1919
20-
A matrix-vector operator is returned for performing the matrix-vector multiplication.
20+
A matrix-vector operator is returned for performing the matrix-vector multiplication:
21+
- For standard multiplication, the full matrix is constructed and stored.
22+
- For FFT multiplication, the full matrix is never constructed nor stored.
2123
"""
2224

2325
__author__ = "Thomas Guillod"

pypeec/lib_matrix/multiply_fft.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,6 @@ def _get_prepare_sub(name, idx_out, idx_in, mat):
358358
return name, n_in, n_out, idx_in_mat, idx_out_mat, mat_fft
359359

360360

361-
def get_prepare(name, idx_out, idx_in, mat):
362-
"""
363-
Construct a circulant tensor from a 4D tensor (log wrapper).
364-
"""
365-
366-
LOGGER.debug("multiplication: %s" % name)
367-
with LOGGER.BlockIndent():
368-
data = _get_prepare_sub(name, idx_out, idx_in, mat)
369-
370-
return data
371-
372-
373361
def set_options(fft_options):
374362
"""
375363
Assign the options and load the right libray.
@@ -399,6 +387,18 @@ def set_options(fft_options):
399387
NPCP = lib_tmp
400388

401389

390+
def get_prepare(name, idx_out, idx_in, mat):
391+
"""
392+
Construct a circulant tensor from a 4D tensor (log wrapper).
393+
"""
394+
395+
LOGGER.debug("multiplication: %s" % name)
396+
with LOGGER.BlockIndent():
397+
data = _get_prepare_sub(name, idx_out, idx_in, mat)
398+
399+
return data
400+
401+
402402
def get_multiply(data, vec_in, flip):
403403
"""
404404
Matrix-vector multiplication with FFT.

pypeec/lib_mesher/mesher_voxel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Module for parsing voxel indices.
2+
Module for creating a voxel structure from given indices.
33
Transform the voxel indices into NumPy arrays.
44
Check the validity of the indices.
55
"""

pypeec/lib_mesher/voxel_conflict.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Different functions for resolving conflict between domains.
3-
Detect and remove shared indices (conflict) between domains.
3+
Check the integrity of the voxel structure after the resolution.
44
"""
55

66
__author__ = "Thomas Guillod"
@@ -14,9 +14,8 @@
1414
def _get_solve_overlap(domain_def, conflict_rules):
1515
"""
1616
Detect and remove shared indices (conflict) between two domains.
17-
The conflict is solved in the following way:
18-
- The reference domain indices remain unchanged.
19-
- The shared indices are removed from the domain to be fixed.
17+
The duplicated indices are removed from the domains to be resolved.
18+
The reference domains indices remain unchanged.
2019
"""
2120

2221
# extract the data

pypeec/lib_plot/manage_pyvista.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,6 @@ def _get_arrow(obj, data_plot):
340340
def _plot_scalar(pl, obj, data_plot, plot_clip, plot_theme):
341341
"""
342342
Plot a scalar variable.
343-
The plot is either made on:
344-
- the unstructured grid describing the non-empty voxels
345-
- the polydata (point cloud) used to evaluate the field
346343
"""
347344

348345
# extract
@@ -387,10 +384,6 @@ def _plot_scalar(pl, obj, data_plot, plot_clip, plot_theme):
387384
def _plot_arrow(pl, grid, obj, data_plot, plot_clip, plot_theme):
388385
"""
389386
Plot a vector variable with an arrow plot (quiver plot).
390-
The plot is either made on:
391-
- the unstructured grid describing the non-empty voxels
392-
- the polydata (point cloud) used to evaluate the field
393-
394387
A scalar variable is used to determine the color of the arrows.
395388
The length of the arrows is constant (and scaled with respect to the voxel size).
396389
"""

pypeec/lib_solver/equation_system.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Different functions for building the equation system.
33
44
Two different equation systems are built:
5-
- A sparse system for the preconditioner.
6-
- A dense system for the iterative solver.
5+
- A sparse system for the preconditioner.
6+
- A dense system for the iterative solver.
77
88
The voxel structure has the following size: (nx, ny, nz).
99
The problem contains n_vc non-empty electric voxels and n_vm non-empty magnetic voxels.
@@ -85,9 +85,9 @@
8585
Only volume charges are used, which is an approximation.
8686
8787
For the preconditioner, the following simplifications are made:
88-
- The dense inductance matrix is diagonalized.
89-
- The dense potential matrix is diagonalized.
90-
- The electric-magnetic coupling matrices are neglected.
88+
- The dense inductance matrix is diagonalized.
89+
- The dense potential matrix is diagonalized.
90+
- The electric-magnetic coupling matrices are neglected.
9191
9292
With these assumptions, a sparse (electric and magnetic) equation system is obtained.
9393
The preconditioner is solved separately for the electric and magnetic equations.
@@ -127,9 +127,8 @@ def _get_system_size(A_net_c, A_net_m, A_src):
127127
"""
128128
Get the size of the equation system.
129129
130-
The equation system has the following size:
131-
- n_fc+n_vc+n_src_c+n_src_v: electric system
132-
- n_fm+n_vm: magnetic system
130+
The electric system has the following size: n_fc+n_vc+n_src_c+n_src_v.
131+
The magnetic system has the following size: n_fm+n_vm.
133132
"""
134133

135134
# get the matrices
@@ -200,9 +199,7 @@ def _get_cond_fact_electric(freq, A_net_c, R_c, L_c, A_src):
200199
Compute the sparse matrices using for the electric preconditioner.
201200
202201
The equation system has the following size: n_fc+n_vc+n_src_c+n_src_v.
203-
The equation system is split in two subsystems:
204-
- n_fc (diagonal block size)
205-
- n_vc+n_src_c+n_src_v (sparse block size)
202+
The first (n_fc, n_fc) block is a diagonal matrix:
206203
"""
207204

208205
# get the matrices
@@ -242,9 +239,7 @@ def _get_cond_fact_magnetic(A_net_m, R_m, P_m):
242239
Compute the sparse matrices using for the magnetic preconditioner.
243240
244241
The equation system has the following size: n_fm+n_vm.
245-
The equation system is split in two subsystems:
246-
- n_fm (diagonal block size)
247-
- n_vm (sparse block size)
242+
The first (n_fm, n_fm) block is a diagonal matrix:
248243
"""
249244

250245
# get the system size
@@ -407,9 +402,9 @@ def get_source_matrix(idx_vc, idx_src_c, idx_src_v, Y_src_c, Z_src_v):
407402
The source matrices connect the sources to the rest of the system.
408403
409404
The source matrices have the following sizes:
410-
- A_vc_src: (n_vc, n_src_c+n_src_v)
411-
- A_src_vc: (n_src_c+n_src_v, n_vc)
412-
- A_src_src: (n_src_c+n_src_v, n_src_c+n_src_v)
405+
- A_vc_src which contains A_vc_src_c and A_vc_src_v: (n_vc, n_src_c+n_src_v).
406+
- A_src_vc which contains A_src_c_vc and A_src_v_vc: (n_src_c+n_src_v, n_vc).
407+
- A_src_src which contains A_src_c_src_c and A_src_v_src_v: (n_src_c+n_src_v, n_src_c+n_src_v).
413408
414409
It should be noted that the matrices connecting the magnetic voxels are all-zeros.
415410
This is explained by the fact that the sources are only connected to electric voxels.

pypeec/lib_solver/extract_convergence.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
2-
Provide a function to extract convergence metrics from the solution vector.
3-
4-
The complex power is extracted at the different terminals.
5-
The total complex power is computed for all the terminals.
6-
The active and reactive power are returned as metrics.
2+
Provide functions to extract convergence metrics from the solution vector:
3+
- The complex power is extracted at the different terminals.
4+
- The total complex power is combined for all the terminals.
5+
- The active and reactive power are returned as metrics.
76
"""
87

98
__author__ = "Thomas Guillod"

pypeec/lib_solver/extract_solution.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""
2-
Different functions for extracting the fields and terminal currents and voltages from the solution vector.
3-
4-
Extract the different fields.
5-
Extract the losses and energy.
6-
Extract the integral quantities.
7-
Extract the source terminal currents and voltages.
8-
Compute the magnetic field for the point cloud.
2+
Different functions for extracting the fields and terminal currents and voltages from the solution vector:
3+
- Extract the different fields.
4+
- Extract the losses and energy.
5+
- Extract the integral quantities.
6+
- Extract the source terminal currents and voltages.
7+
- Compute the magnetic field for the point cloud.
98
109
Warning
1110
-------

0 commit comments

Comments
 (0)