Giter Site home page Giter Site logo

joshkarpel / idesolver Goto Github PK

View Code? Open in Web Editor NEW
30.0 6.0 4.0 4.75 MB

A general-purpose numerical integro-differential equation solver

Home Page: https://idesolver.readthedocs.io

License: GNU General Public License v3.0

Python 98.01% TeX 1.99%
mathematics python numerical-integration integro-differential-equations

idesolver's Introduction

idesolver

image

image

PyPI

image

pre-commit.ci status

A general purpose numeric integro-differential equation (IDE) solver, based on an iterative scheme devised by Gelmi and Jorquera. IDEs appear in many contexts, particularly when trying to describe a system whose current behavior depends on its own history. IDESolver provides a simple interface for solving these kinds of equations in Python.

Stable releases are available on PyPI: pip install idesolver. IDESolver requires Python 3.6+, numpy, and scipy. We recommend installing into a virtual environment.

Full documentation can be found here. If you use idesolver in your research, please consider citing the associated paper.

Details about running the test suite are at the end of the manual. Problems with IDESolver should be reported via GitHub issues. We are open to improvements: see the Code of Conduct and the Contribution Guidelines for details.

idesolver's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar joshkarpel avatar nbrucy avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

idesolver's Issues

Relicense to BSD (adding IDEsolver to SciPy)

I know that the original author published his code with a GPL3 license.

But, have you tried to contact him? Maybe he has no problem changing the license to BSD-3 so you can add this superb code into SciPy.

Need root for `pip install idesolver`

I would be nice to mention in readme that the given pip command requires root and/or also provide a version for local installation: pip install --user idesolver

Generalize to coupled IDEs

Thanks very much for this amazing IDE solver. In physics applications, often coupled IDEs appear, i.e. y is a vector and c(y), F(y) couple the different components of y. Is it possible to generalize this solver to this case?

__init__() got an unexpected keyword argument 'y_initial'

Don't know whether this is a documentation or code issue but trying out the quickstart:

import numpy as np
from idesolver import IDESolver
solver = IDESolver(
    x = np.linspace(0, 1, 100),
    y_initial = 0,
    c = lambda x, y: y - (.5 * x) + (1 / (1 + x)) - np.log(1 + x),
    d = lambda x: 1 / (np.log(2)) ** 2,
    k = lambda x, s: x / (1 + s),
    f = lambda y: y,
    lower_bound = lambda x: 0,
    upper_bound = lambda x: 1,
)

I get:

Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
TypeError: __init__() got an unexpected keyword argument 'y_initial'

y instead of y_initial doesn't work either.

Invalid syntax in idesolver.py

After doing a pip3 install --user idesolver and trying to import idesolver in python3 I get:

Python 3.5.4 (default, Oct  9 2017, 12:07:29) 
[GCC 6.4.1 20170727 (Red Hat 6.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from idesolver import IDESolver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../.local/lib/python3.5/site-packages/idesolver/__init__.py", line 1, in <module>
    from .idesolver import *
  File ".../.local/lib/python3.5/site-packages/idesolver/idesolver.py", line 257
    logger.debug(f'Advanced to iteration {self.iteration}. Current error: {error_current}.')
                                                                                          ^
SyntaxError: invalid syntax

while in python2 I get (installed with pip instead of pip3):

Python 2.7.13 (default, Dec  1 2017, 09:21:53) 
[GCC 6.4.1 20170727 (Red Hat 6.4.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from idesolver import IDESolver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../.local/lib/python2.7/site-packages/idesolver/__init__.py", line 1, in <module>
    from .idesolver import *
  File ".../.local/lib/python2.7/site-packages/idesolver/idesolver.py", line 40
    def complex_quad(integrand: Callable, lower_bound: float, upper_bound: float, **kwargs) -> (complex, float, float, tuple, tuple):
                              ^
SyntaxError: invalid syntax

Allow constants as lower and upper bounds

It's annoying that you need to pass functions in even when the bounds are constant, which is fairly often. This is easy enough to do, because we can just check whether the things passed in are callables or not.

Test failures

Running pytest gives me:

================================================================= ERRORS ==================================================================
____________________________________ ERROR at setup of test_callback_is_called_correct_number_of_times ____________________________________
file .../idesolver/tests/test_misc.py, line 73
  def test_callback_is_called_correct_number_of_times(mocker):
E       fixture 'mocker' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, default_solver, doctest_namespace, dummy_args, monkeypatch, pytestconfig, record_xml_property, recwarn, tmpdir, tmpdir_factory                                                                   
>       use 'pytest --fixtures [testpath]' for help on them.

.../idesolver/tests/test_misc.py:73
================================================================ FAILURES =================================================================
______________________________________________ test_raise_exception_if_unexpectedly_complex _______________________________________________
tests/test_complex_valued.py:21: in test_raise_exception_if_unexpectedly_complex
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
__________________________________________________ test_no_exception_if_expected_complex __________________________________________________
tests/test_complex_valued.py:36: in test_no_exception_if_expected_complex
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________________ test_warning_when_not_enough_iterations _________________________________________________
tests/test_misc.py:26: in test_warning_when_not_enough_iterations
    good_solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
________________________________ test_number_of_intermediate_solutions_is_same_as_iteration_count_plus_one ________________________________
tests/test_misc.py:67: in test_number_of_intermediate_solutions_is_same_as_iteration_count_plus_one
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver0-exact0] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver1-exact1] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver2-exact2] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver3-exact3] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver4-exact4] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver5-exact5] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
_________________________________________ test_real_ide_against_analytic_solution[solver6-exact6] _________________________________________
tests/test_solver_against_analytic_solutions.py:114: in test_real_ide_against_analytic_solution
    solver.solve()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:249: in solve
    y_current = self._initial_y()
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:296: in _initial_y
    return self._solve_ode(self.c)
../../.local/lib/python3.6/site-packages/idesolver/idesolver.py:363: in _solve_ode
    sol = integ.solve_ivp(
E   AttributeError: module 'scipy.integrate' has no attribute 'solve_ivp'
============================================== 11 failed, 64 passed, 1 error in 2.18 seconds ==============================================```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.