Comments (2)
Have you tried just using a customer shift
function?
from jax-md.
Hey @Noahyt,
Sorry about the delay in response, we were busy getting ready for ICML. As @cpgoodri, it should be possible to do this without really modifying jax md. The basic premise is that we should use a new shift
function that only moves a subset of the particles. By passing an explicit mask to the particles, it should be possible to adjust the frozen particles dynamically. One caveat is that this won't work with simulation environments that need to use the number of degrees of freedom as a parameter (for example, NVT simulations); if this use-case is important for you please let me know and I'll see what I can do!
In any case, here is schematically how I would write such a shift function,
displacement, shift = space.periodic(box_size)
def masked_shift(R, dR, is_mobile=None):
if is_mobile is None:
return shift(R, dR)
return np.where(is_mobile[:, None], shift(R, dR), R)
Then this masked_shift
function can be passed to minimizers. The is_mobile
array can be passed as a keyword argument to the minimizer and it should just work.
fire_init, fire_apply = minimize.fire_descent(energy_fn, masked_shift)
fire_apply = jit(fire_apply)
fire_state = fire_init(R)
# Freeze all but the first 10 particles.
is_mobile = np.arange(N) > 10
for i in range(steps):
fire_state = fire_apply(fire_state, is_mobile=is_mobile)
Here is an example colab notebook that puts all of this together. Please let me know if this isn't what you had in mind or if you get stuck!
from jax-md.
Related Issues (20)
- Brownian simulations break when dt <= ~3e-8
- Better documentation needed for quantity.pair_correlation and quantity.pair_correlation_neighbor_list HOT 1
- Potential implementation for space.periodic_general HOT 4
- neighborlist in non-orthorhombic systems HOT 3
- `jax_md` installation fails from pip install with python 3.11 HOT 1
- Feature Request: Improved execution time for bonds. HOT 2
- Is there a bug in the equivariant neural network notebook? HOT 1
- FireDescent is not implemented correctly
- Is the any way could translate the Sparse neighbor list to OrderedSparse neighbor list?
- Code snippets in README.md give NaNs
- Issues with NPT + Lennard Jones using jax-md-0.2.5 HOT 2
- jax-md renderer not working HOT 1
- Readers of the paper may unintentionally access old code in the `master` branch
- NaNs for Lennard Jones potential gradients. HOT 1
- Error importing jax_md
- documentation not compiling HOT 1
- GPU memory leak when using soft_sphere_neighbor_list with epsilon species tensor
- FireDescent should use velocity and not momentum when calculating P
- Proposal: Extending Jax MD with Monte Carlo Capabilities and Bonded Potentials HOT 7
- nequip uses legacy e3nn-jax modules HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jax-md.