Page MenuHomec4science

potential.py
No OneTemporary

File Metadata

Created
Thu, Sep 5, 21:22

potential.py

# 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