Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88606635
potential.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Oct 19, 17:30
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Oct 21, 17:30 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21793403
Attached To
R6746 RationalROMPy
potential.py
View Options
# Copyright (C) 2018-2020 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import
numpy
as
np
from
rrompy.utilities.base.types
import
Tuple
,
Np1D
from
rrompy.utilities.exception_manager
import
RROMPyWarning
__all__
=
[
'potential'
]
def
potential
(
x
:
Np1D
,
foci
:
Tuple
[
float
,
float
]
=
[
-
1.
,
1.
])
->
Np1D
:
"""Evaluation of complex potential for ellipses or line segments."""
mu0
=
np
.
mean
(
foci
)
musig
=
foci
[
0
]
-
mu0
xFinite
=
np
.
isinf
(
x
)
==
False
dist
=
np
.
empty
(
len
(
x
))
dist
[
xFinite
==
False
]
=
np
.
inf
xEffR
=
x
[
xFinite
]
-
mu0
if
np
.
isclose
(
musig
,
0.
,
atol
=
1e-15
):
if
foci
[
0
]
!=
foci
[
1
]:
RROMPyWarning
(
"Collapsing different but numerically equal foci."
)
dist
[
xFinite
]
=
np
.
abs
(
xEffR
)
else
:
xEffR
/=
musig
bernEff
=
(
xEffR
**
2.
-
1
)
**
.
5
dist
[
xFinite
]
=
np
.
max
(
np
.
vstack
((
np
.
abs
(
xEffR
+
bernEff
),
np
.
abs
(
xEffR
-
bernEff
))),
axis
=
0
)
return
dist
Event Timeline
Log In to Comment