GithubHelp home page GithubHelp logo

hwayguo / oscode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fruzsinaagocs/oscode

0.0 0.0 0.0 30.93 MB

Code for efficient solution of oscillatory ordinary differential equations

License: BSD 3-Clause "New" or "Revised" License

C++ 98.50% Makefile 0.01% Python 0.41% Dockerfile 0.02% TeX 0.13% C 0.93%

oscode's Introduction

oscode: Oscillatory ordinary differential equation solver

codecov status Travis CI build status Documentation Status Chat on gitter BSD 3-clause license PyPI downloads JOSS status Zenodo doi



Oscode is a C++ tool with a Python interface that solves oscillatory ordinary differential equations efficiently. It is designed to deal with equations of the form

https://github.com/fruzsinaagocs/oscode/raw/master/pyoscode/images/oscillator.png

where gamma (friction term) and omega (frequency) can be given as arrays.

Oscode makes use of an analytic approximation of x(t) embedded in a stepping procedure to skip over long regions of oscillations, giving a reduction in computing time. The approximation is valid when the frequency changes slowly relative to the timescales of integration, it is therefore worth applying when this condition holds for at least some part of the integration range.

For the details of the numerical method used by oscode, see Citation.

Basic requirements for using the C++ interface:

  • C++11 or later
  • Eigen (a header-only library included in this source)

The strictly necessary Python dependencies are automatically installed when you use pip or the setup.py. They are:

The optional dependencies are:

pyoscode can be installed via pip

pip install pyoscode

or via the setup.py

git clone https://github.com/fruzsinaagocs/oscode
cd oscode
python setup.py install --user

or

git clone https://github.com/fruzsinaagocs/oscode
cd oscode
pip install .

You can then import pyoscode from anywhere. Omit the --user option if you wish to install globally or in a virtual environment. If you have any difficulties, check out the FAQs - Installation section below.

You can check that things are working by running tests/ (also ran by Travis continuous integration):

pytest tests/

oscode is a header-only C++ package, it requires no installation.

git clone https://github.com/fruzsinaagocs/oscode

and then include the relevant header files in your C++ code:

#include "solver.hpp"
#include "system.hpp"

Try the following quick examples. They are available in the examples.

Introduction to pyoscode:intro_binder
Cosmology examples:cosmology_binder
Scipy 2020 lecture notebook:scipy_binder

https://github.com/fruzsinaagocs/oscode/raw/master/pyoscode/images/spectra.gif

Introduction to oscode:examples/burst.cpp
To plot results from burst.cpp:examples/plot_burst.py

To compile and run:

g++ -g -Wall -std=c++11 -c -o burst.o burst.cpp
g++ -g -Wall -std=c++11 -o burst burst.o
./burst

Documentation is hosted at readthedocs.

To build your own local copy of the documentation you can run:

cd pyoscode/docs
make html

If you use oscode to solve equations for a publication, please cite:

Any comments and improvements to this project are welcome. You can contribute by:

  • Opening and issue to report bugs and propose new features.
  • Making a pull request.

You can get help by submitting an issue or posting a message on Gitter.

  1. Eigen import errors:
    pyoscode/_pyoscode.hpp:6:10: fatal error: Eigen/Dense: No such file or directory
     #include <Eigen/Dense>
               ^~~~~~~~~~~~~

    Try explicitly including the location of your Eigen library via the CPLUS_INCLUDE_PATH environment variable, for example:

    CPLUS_INCLUDE_PATH=/usr/include/eigen3 python setup.py install --user
    # or
    CPLUS_INCLUDE_PATH=/usr/include/eigen3 pip install pyoscode

    where /usr/include/eigen3 should be replaced with your system-specific eigen location.

Many thanks to Will Handley, Lukas Hergt, Anthony Lasenby, and Mike Hobson for their support and advice regarding the algorithm behind oscode. There are many packages without which some part of oscode (e.g. testing and examples) wouldn't run as nicely and smoothly, thank you all developers for making and maintaining these open-source projects. A special thanks goes to the devs of exhale for making the beautiful C++ documentation possible.

  • 1.0.3:
    • paper accepted to JOSS
  • 1.0.2:
    • Fixed getting correct numpy include directories
  • 1.0.1:
    • Added pyproject.toml to handle build dependencies (numpy)
  • 1.0.0:
    • Dense output
    • Arrays for frequency and damping term need not be evenly spaced
    • Automatic C++ documentation on readthedocs
    • Eigen included in source for pip installability
    • First pip release :)
  • 0.1.2:
    • Bug that occurred when beginning and end of integration coincided corrected
  • 0.1.1:
    • Automatic detection of direction of integration
  • 0.1.0:
    • Memory leaks at python interface fixed
    • C++ documentation added

oscode's People

Contributors

fruzsinaagocs avatar kthyng avatar williamjameshandley avatar

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.