Skip to content

Instantly share code, notes, and snippets.

View Luthaf's full-sized avatar
🦆

Guillaume Fraux Luthaf

🦆
View GitHub Profile
@Luthaf
Luthaf / Foo.cpp
Last active September 18, 2023 22:40
Calling C++ from Fortran
#include "Foo.hpp"
#include <iostream>
using namespace std;
Foo::Foo(int _a, int _b): a(_a), b(_b){
cout << "C++ side, constructor" << endl;
}
Foo::~Foo(){
@Luthaf
Luthaf / potential.yml
Last active October 12, 2015 09:22
Input files in YAML
pairs: # Non bonded atoms pairs
- atoms: [*, *] # Default value
type: NullPotential
- atoms: [He, He]
type: LennardJones
sigma: 3.4 A
epsilon: 0.45 kJ/mol
- atoms: [He, Ar]
type: LennardJones
sigma: 2.8 A
@Luthaf
Luthaf / potentials.rs
Created February 5, 2016 21:32
Cloning Boxed trait objects
trait Potential {
fn energy(&self) -> f64;
}
// This is just a marker trait, to know which potentials can be used as pair
// potentials. I also have AnglePotential, GlobalPotential, ...
trait PairPotential: Potential {}
impl Clone for Box<PairPotential> {
fn clone(&self) -> Box<PairPotential> {
@Luthaf
Luthaf / build.jl
Last active January 3, 2023 01:21
Using pip to install python dependencies for Julia.
using PyCall
# Change that to whatever packages you need.
const PACKAGES = ["pyyaml"]
# Import pip
try
@pyimport pip
catch
# If it is not found, install it
@Luthaf
Luthaf / molecules.rs
Created March 2, 2016 16:16
Iterate over particles in a molecule with a pointer
use std::slice;
pub struct Vector3d([f64; 3]);
pub struct Atom {
pub position: Vector3d,
pub velocity: Vector3d,
pub name: String
}
@Luthaf
Luthaf / MolecularDynamics.toml
Created March 25, 2016 23:13
TOML input files
[input]
version = 1.0
[[systems]]
cell = 20 # Cubic cell
positions = "initial.xyz"
velocities = {init = "300 K"}
potentials = "potentials.toml"
[[simulations]]
@Luthaf
Luthaf / valgrind.log
Created September 16, 2016 20:49
Chemfiles Bus Error
==24579== Memcheck, a memory error detector
==24579== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==24579== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==24579== Command: tests/xyz
==24579==
--24579-- run: /usr/bin/dsymutil "tests/xyz"
==24579== Conditional jump or move depends on uninitialised value(s)
==24579== at 0x10000BAB1: boost::filesystem::detail::recur_dir_itr_imp::push_directory(boost::system::error_code&) (operations.hpp:1054)
==24579== by 0x10000B900: boost::filesystem::detail::recur_dir_itr_imp::increment(boost::system::error_code*) (operations.hpp:1085)
==24579== by 0x1000079E0: ____C_A_T_C_H____T_E_S_T____102() (operations.hpp:1278)
@Luthaf
Luthaf / dilated.pdb
Created February 21, 2017 11:06
Initial configurations
CRYST1 100.000 100.000 100.000 90.00 90.00 90.00 P 1 1
HETATM 1 He RES X 1 4.905 84.135 0.777 1.00 0.00 He
HETATM 2 He RES X 2 88.376 32.438 11.077 1.00 0.00 He
HETATM 3 He RES X 3 84.431 8.811 41.520 1.00 0.00 He
HETATM 4 He RES X 4 101.038 20.851 52.080 1.00 0.00 He
HETATM 5 He RES X 5 97.902 6.895 72.124 1.00 0.00 He
HETATM 6 He RES X 6 6.789 11.264 7.060 1.00 0.00 He
HETATM 7 He RES X 7 88.061 9.591 13.068 1.00 0.00 He
HETATM 8 He RES X 8 1.762 9.043 29.016 1.00 0.00 He
HETATM 9 He RES X 9 6.755 39.358 58.695 1.00 0.00 He
$ cargo benchcmp safe.log unsafe.log --threshold=2
name safe.log ns/iter unsafe.log ns/iter diff ns/iter diff %
cache_move_all_rigid_molecules 1,463,817 1,168,495 -295,322 -20.17%
cache_move_all_rigid_molecules_ewald 10,620,984 8,721,128 -1,899,856 -17.89%
cache_move_all_rigid_molecules_wolf 8,386,407 10,278,223 1,891,816 22.56%
cache_move_particle 201,875 244,669 42,794 21.20%
cache_move_particle_ewald 528,745 491,710 -37,035 -7.00%
cache_move_particles 354,655 282,355 -72,300 -20.39%
cache_move_particles_ewald 1,025,460 887,721 -137,739 -13.43%
cache_move_particles_wolf 507,774 553,008 45,234 8.91%
@Luthaf
Luthaf / lazy_benchmarks.patch
Created April 6, 2017 10:25
lazy_static in benchmarks
diff --git a/Cargo.toml b/Cargo.toml
index 68e2fc36..5389a05e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,6 +26,7 @@ clap = "2"
[dev-dependencies]
bencher = "0.1"
+lazy_static = "0.2"
rand = "0.3"