Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sumpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexandru Fikl
sumpy
Commits
9d620e2f
Commit
9d620e2f
authored
7 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Fiddle with Helmholtz error model in SimpleExpansionOrderFinder
parent
fdeea5c6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sumpy/expansion/level_to_order.py
+13
-6
13 additions, 6 deletions
sumpy/expansion/level_to_order.py
with
13 additions
and
6 deletions
sumpy/expansion/level_to_order.py
+
13
−
6
View file @
9d620e2f
...
...
@@ -102,13 +102,15 @@ class SimpleExpansionOrderFinder(object):
.. math::
C_{\text{helm}} \frac 1{p!} (hk)^{p+1},
C_{\text{helm}} \frac 1{p!}
\left(C_{\text{helm\_scale}} \cdot \frac{hk}{2\pi}\right)^{p+1},
where :math:`d` is the number of dimensions, :math:`p` is the expansion order,
:math:`h` is the box size, and :math:`k` is the wave number.
"""
def
__init__
(
self
,
tol
,
err_const_laplace
=
0.01
,
err_const_helmholtz
=
100
,
scaling_const_helmholtz
=
4
,
extra_order
=
1
):
"""
:arg extra_order: order increase to accommodate, say, the taking of
...
...
@@ -118,6 +120,7 @@ class SimpleExpansionOrderFinder(object):
self
.
err_const_laplace
=
err_const_laplace
self
.
err_const_helmholtz
=
err_const_helmholtz
self
.
scaling_const_helmholtz
=
scaling_const_helmholtz
self
.
extra_order
=
extra_order
...
...
@@ -140,13 +143,17 @@ class SimpleExpansionOrderFinder(object):
tree
.
stick_out_factor
*
tree
.
root_extent
/
(
1
<<
level
))
factor
=
box_lengthscale
*
helmholtz_k
/
(
2
*
float
(
np
.
pi
))
factor
=
(
self
.
scaling_const_helmholtz
*
box_lengthscale
*
helmholtz_k
/
(
2
*
float
(
np
.
pi
)))
from
math
import
factorial
helm_order
=
1
helm_error
=
self
.
err_const_helmholtz
*
factor
helm_
rec_
error
=
self
.
err_const_helmholtz
*
factor
while
True
:
helm_error
=
helm_error
*
factor
/
(
helm_order
+
1
)
helm_
rec_
error
=
helm_
rec_
error
*
factor
/
(
helm_order
+
1
)
if
helm_order
<
4
:
# this may overflow for large orders
...
...
@@ -154,10 +161,10 @@ class SimpleExpansionOrderFinder(object):
1
/
factorial
(
helm_order
+
1
)
*
self
.
err_const_helmholtz
*
factor
**
(
helm_order
+
1
))
assert
(
abs
(
helm_error
-
helm_error_direct
)
assert
(
abs
(
helm_
rec_
error
-
helm_error_direct
)
<
1e-13
*
abs
(
helm_error_direct
))
if
helm_error
<
self
.
tol
:
if
helm_
rec_
error
*
helm_order
**
(
tree
.
dimensions
-
1
)
<
self
.
tol
:
break
helm_order
+=
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