Skip to content

Instantly share code, notes, and snippets.

View mducle's full-sized avatar

Duc Le mducle

View GitHub Profile
@mducle
mducle / pyspinw_syntax_proposal.py
Last active October 31, 2024 17:23
New spinw syntax proposal
from ase import Atom
from spinw import Lattice, Interaction
import numpy as np
import matplotlib.pyplot as plt
"""
% Matlab code
linipo = spinw;
linipo.genlattice('lat_const', [10.02 5.86 4.68],'sym','P n m a');
linipo.addatom('r',[1/4 1/4 0],'S',1,'label','MNi2','color','b')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
args=()
for var; do
[[ $var != '-batch' ]] && args+=("$var")
done
tmpmfile=mlscript_$(mktemp -u XXXXXXXX)
echo "${args[@]}" > ${tmpmfile}.m
runner_path=/home/runner/work/_actions/matlab-actions/run-command/v2/dist/bin/glnxa64/
@mducle
mducle / sabug_cylaxis.diff
Created December 6, 2023 00:39
Mantid solid angle bug change cylinder axis patch.
diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp
index 286d1d953f8..eda0fa258d5 100644
--- a/Framework/Geometry/src/Objects/CSGObject.cpp
+++ b/Framework/Geometry/src/Objects/CSGObject.cpp
@@ -307,8 +307,9 @@ double cylinderSolidAngle(const V3D &observer, const V3D &centre, const V3D &axi
// axis points up the +Z axis and then rotated into their final position
// Required rotation
- constexpr V3D initial_axis(0., 0., 1.0);
- const Quat transform(initial_axis, axis);
@mducle
mducle / gist:51fa7cc2094f9f0c1cf4b6775d879a09
Last active December 5, 2023 13:20
Advent of code 2023
echo $(sed s/[A-z]//g ~/Downloads/input | sed "s/\([0-9]\)/\1 /g" | awk '{print $1, $NF}'| sed "s/ //" | sed "s/$/+/") | sed "s/+$//"|bc
cp ~/Downloads/input tt && for ii in "one,o1e" "two,t2o" "three,t3e" "four,f4r" "five,f5e" "six,s6x" "seven,s7n" "eight,e8t" "nine,n9e"; do cm=$(echo $ii | awk -F, '{print "sed s/"$1"/"$2"/g tt > t2 && mv t2 tt"}'); echo $cm|bash
@mducle
mducle / cf_multisite_segfault.py
Created July 24, 2023 16:40
Mantid crystalfield multi-site segfault
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
import sys, os
from CrystalField import CrystalField, PointCharge, ResolutionModel, CrystalFieldFit, Background, Function
from pychop.Instruments import Instrument
tb1 = {'B20': -0.2431330412981789, 'B22': -0.17569696468779034, 'IB22': 0.19648505887037993, 'B40': -0.000886093463241086, 'B42': -0.016200141304394847, 'IB42': 0.017849375647540782, 'B44': -0.0011331370797592647, 'IB44': -0.014528896930898594, 'B60': 5.487217052410268e-06, 'B62': 3.0859080066753127e-06, 'IB62': -3.1901616555494786e-06, 'B64': -2.3561324645561506e-06, 'IB64': 1.8508497796793596e-05, 'B66': 2.2094823318064904e-05, 'IB66': 1.273979589242308e-05}
@mducle
mducle / pace_neutrons_installer.exe
Created February 28, 2023 15:27
b85 encoded ctf for testing libpymcr
This file has been truncated, but you can view the full file.
O<Iru0{{R31ONa4|Nj60xBvhE00000KmY&$00000000000000000000000000000000000000002mt^94j;M>0JI6sA-Dld%^_51X>%ZOa&KpHVQnB|VQy}3bRc47AaZqXAZczOL{C#7ZEs{{E)5L|Bme*a00000g91gs$73s#$73s#$73s#s0S#L&0{N*s0S~S)nhA@s0S{Ra$_r#l?y16&SNW+l?yJChGQ#}l?yMD=3^_9s0S*N)?+J^$73p!U}Gzjp$jgO&tof-p$pWL#$zj!p$jRJ#$zj!QfXso$73s#000000000000000000000000000000P(=U$WQGO+06RTP0000000000@BktJ3jz)g0GJB^0A?Ei00000JQD=~01yBG0000$0RR9101yBG00IC21^@s6000001^@s6000000B|P&00aO406RTP0svrv000mG0000001yBG00000000mG0000001yBG00000000005C8xG0000000000)Z`8Tv;Y7A01yxWxG@(10ALRQM63V+000000000008l3Y=n?<`5K0XIQ~&?~000000000000000000000000000000a7qmT0096100000000000I&-Hcm)6e000000000000000000000000000000E_7vhbN~PV5SI%801yBG0GJB^00aO4000000000000000AOHYhE^=gHbYTDhphp7$0I&-H07wG>0GtZ|000000000000000KmY(hE@WYJVE_OCOi%y-000jF04e|g0OSq;000000000000000KmY*1E^uUFbYTDhM63V+0ALRQ0ImQ401giT000000000000000KmY(hE^>2nV*mgExG@(101yxW05TT<0K5+X000000000000000KmY(hE^=jTZ({%e=n?<`08l3Y02BZK0PZFL000000000000000KmY(j0000000000000000000000000000000000000000000000000000000000000000