Giter Club home page Giter Club logo

fplanck's Introduction

PyPi Version Conda Version tests

FPlanck

FPlanck is a Python library for numerically solving the Fokker-Planck partial differential equation (also known as the Smoluchowski equation) in N dimensions using a matrix numerical method:

The method is based on the paper "Physically consistent numerical solver for time-dependent Fokker-Planck equations" by V. Holubec, K. Kroy, and S. Steffenoni, available on arXiv and published in APS.

Features

  • Can specify an external potential (conservative) and force field (non-conservative) in N-dimensions
  • Solve for the steady-state probability distribution and probability currents
  • Propagate any initial probability distribution to the solution at any later time
  • Periodic and reflecting boundary conditions (can be mixed along different dimensions)

Installation

FPlanck can be installed with pip

pip install fplanck

or conda

conda install -c japarker fplanck

Examples

On the left: a single particle in a titled periodic potential with periodic boundary conditions. The animation shows the time evolution of the probability distribution for the particle location. The PDF is driven in the positive direction due to the tilted potential.

On the right: a single particle in a 2D harmonic potential. The particle is initially away from the center of the harmonic well, and over time is restored to the center.

Usage

See the examples folder for how to use FPlanck.

License

FPlanck is licensed under the terms of the MIT license.


References

[1] Wikipedia contributors, "Fokker–Planck equation," Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Fokker%E2%80%93Planck_equation&oldid=906834519

[2] Holubec, V., Kroy, K. and Steffenoni, S., 2019. Physically consistent numerical solver for time-dependent Fokker-Planck equations. Physical Review E, 99(3), p.032117.

fplanck's People

Contributors

johnaparker 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fplanck's Issues

Convert physical potential into software units

Hi,
I am very interested in using this software for a scientific project and I have a question about it. I have a 1D potential expressed in kJ/mol defined along a unit-less variable going from 0 to 1. Concerning the mesh, I am assuming - based on your examples - that I can create a mesh mesh = numpy.linspace(0,1e-9,ngrid_points) with reflective boundary conditions but how about rescaling the potential to the units the software uses? I am not sure how to approach this, because the examples do not seem to cover this point. Any suggestion would be greatly appreciated!

how to run ?

how to run this program and get giff ?
please tell, which command

relative imports?

Hey John,

I'm in an env where I don't have fplanck installed -- i.e, I just cloned the repo, and did not want to run pip install fplank, because I'd like to play with the code.

In this case, do you get relative import path issues when you try to add initial distribution functions to functions.py? When I pip install fplanck in an env, and make changes to the work tree, the examples don't find my changes, because they correctly stop looking after they find the pip installed path.

Cheers!

not loading utilities

Dear John;

Thanks for providing a code to solve FP. I installed fplanck via conda in python 3.5, and now I am trying to re-run one of your examples, namely the ratchet.py:

https://github.com/johnaparker/fplanck/blob/master/examples/ratchet.py

however, I got some errors. The first error appeared after loading fplanck:

from . import utility
raise ValueError(f'input vector ({value}) does not have the correct dimensions (ndim = {ndim})')
SyntaxError: invalid syntax

As a quick solution, I just commented out the lines 12-13 in utility.py; that is:

#        if vec.size != ndim:
#            raise ValueError(f'input vector ({value}) does not have the correct dimensions (ndim = {ndim})')

Then, I got a second error:

class boundary(enum.Enum):
"""enum for the types ofboundary conditions"""
reflecting = enum.auto()

class boundary(enum.Enum):
"""enum for the types ofboundary conditions"""
reflecting = enum.auto()
periodic   = enum.auto()

AttributeError: module 'enum' has no attribute 'auto'

In short, fplanck can not be loaded clean. Am I missing something?, perhaps a mistake from my side?, any suggestion?

Regards;

Eduardo

Examples

Is it possible to provide the equations of "tilted_bigaussian" and "ring"? Thank you!

Factor is exactly singular

Sometimes, when the parameters are just right, the matrix is exactly singular and the steady-state PDF cannot be solved for. Is there a way to ensure the matrix is never singular? In the below case, the error occurs, but if S = 100.0001*nm there is no error.

example case

import numpy as np
from fplanck import fokker_planck, boundary

nm = 1e-9
viscosity = 8e-4
radius = 50*nm
S = 100*nm

def drag(x):
    return 6*np.pi*viscosity*radius*(1 + np.abs(x)/S)

sim = fokker_planck(temperature=300, drag=drag, extent=200*nm,
            resolution=5*nm, boundary=boundary.periodic)

steady = sim.steady_state()

Help

Hello,

Thank you for writing a code to solve FPE. The examples seem to use some physics language, which I find difficult to translate to "standard" math formulation. Can you please let me know how to setup a problem to solve the following problem. Suppose the two state-variables follow

dy_t = x_tdt
dx_t = f(x_t, y_t)dt + bdW_t,
where b is a constant and f(x_t, y_t) is a general function (it ensures that x_t and y_t have stationary dynamics on 0<x<inf, y<0<inf).

I would like to solve for a stationary density g, which amount to solving the following FPE: -xg'_y - (f(x,y)g)'_x +b^2*g''_xx/2 = 0. Does you code allow to solve this problem? And if so, how one can do that?

Many thanks,
Igor

passing parameters, and time dependent forces

Hi, I really like your implementation.

I'm trying to use it to run some nonlinear simulations, and i've managed to adimensionalize the code to use it for 'non-physical' processes.
However i'm not sure how to input a time-dependent force, since non of the examples include this case.
I'm also struggling to pass keyword arguments for the force parameters, if you have any tip on how o do that, i'd really appreciate it.

I'm also modifying the code to use non-symmetrical domains. But hopefully i'll have that done fairly quick.

Cheers,
Alexis

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.