Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
usadelndsoc
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JYU Condensed Matter Theory
usadelndsoc
Commits
5f5dfd3f
Commit
5f5dfd3f
authored
10 months ago
by
patavirt
Browse files
Options
Downloads
Patches
Plain Diff
solver: improve docs for interpolate_J
parent
666c2cf4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
usadelndsoc/solver.py
+26
-8
26 additions, 8 deletions
usadelndsoc/solver.py
with
26 additions
and
8 deletions
usadelndsoc/solver.py
+
26
−
8
View file @
5f5dfd3f
...
...
@@ -1530,12 +1530,6 @@ def interpolate_J(x0, y0, J, x, y, method="bilinear"):
The current values are defined on links between cells, and not at
the cell centers, so special interpolation is necessary.
The interpolant inside each cell is linear :math:`J(x,y) = (J_0x + x J_1,
J_0y + y J_2)`. The component perpendicular to the cell faces is
piecewise linear, but the component parallel to cell faces is
piecewise constant. The interpolant is divergenceless inside
cells, if the matrix current values do not indicate divergence.
Parameters
----------
x0 : array, shape (nx,)
...
...
@@ -1551,12 +1545,34 @@ def interpolate_J(x0, y0, J, x, y, method="bilinear"):
method : {
'
linear
'
,
'
bilinear
'
}
Interpolation method.
- ``linear``: :math:`J_x` is a continuous linear function
along :math:`x` but piecewise constant along `y
'
, and vice versa
for :math:`J_y`.
- ``bilinear``: :math:`J_x` and :math:`J_y` are continuous
piecewise linear functions both along :math:`x` and :math:`y`.
Returns
-------
J_interp : array, shape broadcast_shape(x, y) + (2, ...)
Array containing x and y components of the current,
interpolated at the coordinates (x, y).
Notes
-----
For all of the interpolants, the integral of the interpolated
current across each cell edge equals the corresponding value in
the original *J* array.
Consequently, the average of the divergence of the interpolant
over a cell equals the sum of currents flowing out of the cell in
the original *J* array. Hence, the interpolated currents satisfy
similar conservation laws as the original ones.
Covariant conservation is however not exactly preserved. Current
across an edge between cells is taken as the average of the
current on both sides.
"""
dx
=
x0
[
1
]
-
x0
[
0
]
...
...
@@ -1615,7 +1631,8 @@ def interpolate_J(x0, y0, J, x, y, method="bilinear"):
# Solve corner values Iyc: (Iyc(i,j) + Iyc(i+1,j))/2 == I3(i,j)
r
=
np
.
empty
((
nx
,
ny
+
1
)
+
I0
.
shape
[
2
:],
dtype
=
I0
.
dtype
)
r
[:,
:
ny
]
=
I3
r
[:,
0
]
=
I3
[:,
0
]
r
[:,
1
:
ny
]
=
(
I3
[:,
1
:]
+
I1
[:,
:
-
1
])
/
2
r
[:,
ny
]
=
I1
[:,
-
1
]
rp
=
r
.
reshape
(
nx
,
-
1
)
...
...
@@ -1624,7 +1641,8 @@ def interpolate_J(x0, y0, J, x, y, method="bilinear"):
# Solve corner values Ixc: (Ixc(i,j) + Ixc(i,j+1))/2 == I2(i,j)
r
=
np
.
empty
((
nx
+
1
,
ny
)
+
I0
.
shape
[
2
:],
dtype
=
I0
.
dtype
)
r
[:
nx
,
:]
=
I2
r
[
0
,
:]
=
I2
[
0
,
:]
r
[
1
:
nx
,
:]
=
(
I2
[
1
:]
+
I0
[:
-
1
])
/
2
r
[
nx
,
:]
=
I0
[
-
1
,
:]
rp
=
np
.
moveaxis
(
r
,
1
,
0
).
reshape
(
ny
,
-
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment