GithubHelp home page GithubHelp logo

joshkarpel / idesolver Goto Github PK

View Code? Open in Web Editor NEW
31.0 31.0 4.0 4.74 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%
integro-differential-equations mathematics numerical-integration python

idesolver's Introduction

Hello Worlds!

I'm Josh Karpel!

Interests:

  • 🐍 Python
  • πŸ¦€ Rust
  • 🦺 Typescript
  • πŸ§ͺ Testing
  • ⌨️ CLI Tools
  • πŸ•ΈοΈ Distributed Systems

I'm currently a Software Engineer in Machine Learning at Workday. I design and develop systems for serving machine learning models.

Before that, I was a postdoc at the Morgridge Institute for Research / Center for High-Throughput Computing. I facilitated high-throughput computing projects that involved machine learning, image processing, and Python. I also helped maintain the HTCondor Python Bindings and worked on projects like HTMap. Before that, I got a PhD in Physics at the University of Wisconsin-Madison in the Yavuz Group, working on simulating interactions between quantum systems and high-power lasers.

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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

idesolver's Issues

__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.

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

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.

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.

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 ==============================================```

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

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?

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.