Package Exports
- brownian
- brownian/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (brownian) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
brownian - Brownian Motion Simulator in Node.js - A Simple Library for Learning and Prototyping
Overview
Brownian motion is the random movement of particles suspended in a fluid resulting from the impact of the fluid molecules on the particles. Brownian motion is a physical phenomenon that can be observed in dust particles suspended in a liquid, or in smoke particles in a gas.
For more information, please refer to the Wikipedia.
This library provides a simple and easy-to-use implementation of Brownian motion in Node.js, allowing you to simulate and visualize this phenomenon intuitively. It is ideal for those who are starting to study statistical physics, computational simulation or simply want to better understand how this type of random motion works.
My goal is to learn as well! So if you find any bugs or have any suggestions for improvements, feel free to open an issue or submit a pull request. Feedback is always welcome! Also, I have some ideas for improvements and new features that I would like to implement š
Installation
You can install the library via npm:
npm i brownian
usage
The library provides a simple and intuitive API for simulating Brownian motion. Here is a basic usage example:
import { brownian } from 'brownian';
// Initial position of the particle on the x-axis
const starting_x = 0;
// Initial position of the particle on the y-axis
const starting_y = 0;
// Number of steps to simulate
const n_steps = 1000;
// Simulate the Brownian motion of a particle starting at the position (0, 0) for 1000 steps on a cartesian plane
const path = brownian(starting_x, starting_y, n_steps);
console.log(path); // Shows the path of the particle on the cartesian plane
// Something like [ [0, 0], [1.2547..., 0.8648...], ... ]
Limitations
- The library does not yet support simulations in 3 dimensions or more.
- The library does not yet support graphical visualization of the results.
- The current implementation is still quite simple and may not be the ideal tool for more complex simulations.
- The current implementation may have performance issues in simulations with a large number of steps.
- Numerical inconsistencies may occur due to the limited precision of floating-point numbers. Do not treat the results as an absolute truth! (at least for now š )
It is worth mentioning that the Javascript/NodeJs ecosystem is not the most suitable for extensive mathematical calculations, nor for processing/generating a large amount of data, but it is a great tool for rapid prototyping and simple testing. This is exactly why I suggest that you use this library for educational purposes and small tests, and not for complex and extensive simulations. If you want more robustness, I suggest that you use other languages āāthat are more suitable for this, such as Python for example.
If it change in the future, I will update this README accordingly (and also be very happy).
Contributing
If you would like to contribute to the library, please follow the instructions below:
- Fork the repository
- Create a branch for your feature
- Commit your changes
- Push to the branch
- Create a new Pull Request
Roadmap (in no particular order)
- Implementar suporte para simulaƧƵes em 3D
- Implementar suporte para visualização grÔfica dos resultados
- Melhorar a precisão numérica da simulação
- Melhorar o desempenho da simulação
- Possibilitar simulaƧƵes mais complexas, como partĆculas interagindo entre si, forƧas externas, etc.
- Implementar um exemplo de aplicação prÔtica da biblioteca
Goals
- Leverage Javascript/Node.js for educational purposes on statistical physics and computational simulation
- Provide a set of tools for prototyping and testing simple simulations using Brownian motion
- Learn more about Brownian motion and its applications
License
This project is licensed under the MIT license - see the LICENSE file for more details.