Skip to content

Instantly share code, notes, and snippets.

View mducle's full-sized avatar

Duc Le mducle

View GitHub Profile
diff --git a/+sw_tests/+unit_tests/unittest_ndbase_optimisers.m b/+sw_tests/+unit_tests/unittest_ndbase_optimisers.m
index 5f6d9f5..9ec3ffe 100644
--- a/+sw_tests/+unit_tests/unittest_ndbase_optimisers.m
+++ b/+sw_tests/+unit_tests/unittest_ndbase_optimisers.m
@@ -59,25 +59,25 @@ classdef unittest_ndbase_optimisers < sw_tests.unit_tests.unittest_super
function test_optimise_rosen_upper_bound_minimum_not_accessible(testCase, optimiser)
[pars_fit, cost_val, ~] = optimiser([], testCase.rosenbrock, [-1,-1], 'ub', [0, inf]);
testCase.verify_val(pars_fit, [0, 0], 'abs_tol', 1e-3);
- testCase.verify_val(cost_val, 1, 'abs_tol', 2e-3);
+ testCase.verify_val(cost_val, 1, 'abs_tol', 1e-4);
@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}