Skip to content

Instantly share code, notes, and snippets.

View pabloferz's full-sized avatar

Pablo Zubieta pabloferz

View GitHub Profile
@pabloferz
pabloferz / setup.sh
Created July 28, 2022 19:49
Setup PySAGES for OpenMM and HOOMD-blue
cd
rsync -a --exclude=*/__pycache__ /data/scratch/pysages . &> /dev/null
find pysages -type f \( -name "*.py" -name "*.sh" \) -exec sed -i "s|/data/scratch|$HOME|g" {} +
. pysages/modules.sh
python -m pip -q install ParmEd
python -m pip -q install netCDF4
@pabloferz
pabloferz / setup.sh
Created July 28, 2022 13:18
Workshop PySAGES + ASE Installation
cd
rsync -a --exclude=*/__pycache__ /data/scratch/pysages-ase . &> /dev/null
find pysages-ase -type f \( -name *.py -name *.sh \) -exec sed -i "s|/data/scratch|$HOME|g" {} +
module purge
module load cuda
source $HOME/pysages-ase/bin/activate
alias python="python3"
@pabloferz
pabloferz / cuda_zygote.jl
Last active August 9, 2021 00:19
Zygote+CUDA
using LinearAlgebra
using CUDA, StaticArrays, Zygote
dihedral_angle(p₁, p₂, p₃, p₄) = dihedral_angle(p₂ - p₁, p₃ - p₂, p₄ - p₃)
@inline function dihedral_angle(a, b, c)
p = a × b
q = b × c
return atan((p × q) ⋅ b, (p ⋅ q) * norm(b))
end
from jaxlib.xla_extension import DeviceArray as JaxArray
from jax.tree_util import register_pytree_node
from plum import dispatch, parametric
from typing import Tuple
import jax.numpy as jnp
def register_pytree_parametric(cls):
register_pytree_node(
@pabloferz
pabloferz / hw2.jl
Created January 3, 2021 22:46
Avoid vcat
# Esta opción es suficiente para pasar el ejercicio,
# pero abajo hay una opción aún más rápida
function remove_in_each_row_no_vcat(img, column_numbers)
@assert size(img, 1) == length(column_numbers) # same as the number of rows
m, n = size(img)
local img′ = similar(img, m, n-1) # create a similar image with one less column
for (i, j) in enumerate(column_numbers)
# EDIT THE FOLLOWING LINE and split it into two lines
@pabloferz
pabloferz / example.log
Created June 8, 2020 21:04
ADP in water SSAGES - Gromacs example
:-) GROMACS - ssages, VERSION 5.1.3-dev-20160713-01db2c5752-dirty (-:
GROMACS is written by:
Emile Apol Rossen Apostolov Herman J.C. Berendsen Par Bjelkmar
Aldert van Buuren Rudi van Drunen Anton Feenstra Sebastian Fritsch
Gerrit Groenhof Christoph Junghans Anca Hamuraru Vincent Hindriksen
Dimitrios Karkoulis Peter Kasson Jiri Kraus Carsten Kutzner
Per Larsson Justin A. Lemkul Magnus Lundborg Pieter Meulenhoff
Erik Marklund Teemu Murtola Szilard Pall Sander Pronk
Roland Schulz Alexey Shvetsov Michael Shirts Alfons Sijbers
#!/bin/sh
# This configuration file was taken from <https://github.com/JuliaParallel/MPI.jl>
set -e
set -x
MPI_IMPL="$1"
os=`uname`
OMPIVER=4.0.3
MPICHVER=3.3.2
@pabloferz
pabloferz / compress.jl
Created December 4, 2019 20:35
HuffmanCodes
# This example work for strings but can be easily adapted to other streams of data
function compress(str::String, hdict)
nbits = sum(c -> hdict[c][2], str)
bv = falses(nbits)
n = 0
for c in str
code, i = hdict[c] # code and number of bits
d = div(n, 64) + 1 # current storage chunk
r = 64 * d - n # number of bits available in the current chunk
u = (i < r) ? (code << (r - i)) : (code >> (i - r))
function unique_recursive(itr)
T = Base._default_eltype(typeof(itr))
out = Vector{T}()
seen = Set{T}()
i = start(itr)
if done(itr, i)
return out
end
x, i = next(itr, i)
if !isleaftype(T)
@pabloferz
pabloferz / Free Electron.ipynb
Created February 6, 2016 22:24
Free Electron
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.