interplane.Get Omega
Read in your language

yang

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

yang / scripts / check_dyadic_grid.sh

46 lines · 1974 bytes Raw Blame History
1#!/bin/sh
2# Runs on Spark after build_and_run_spark.sh has synchronized the checkout.
3set -eu
4root=$1
5omc=$2
6build=$(mktemp -d)
7trap 'rm -rf "$build"' EXIT
8pin=$(sed -n 's/^omc_sha256=//p' "$root/PIN")
9echo "$pin $omc" | sha256sum -c -
10{ echo om2; cat "$root/src/ufbi_math.om" "$root/src/ufbi_ivmath.om" "$root/scripts/dyadic_grid_dump.om"; } > "$build/unit.om"
11"$omc" < "$build/unit.om" > "$build/dump"
12chmod +x "$build/dump"
13"$build/dump" > "$build/omega.tsv"
14{ echo om2; cat "$root/src/ufbi_math.om" "$root/src/ufbi_ivmath.om" "$root/src/ufbi_w2_dyadic.om" "$root/scripts/dyadic_w2_dump.om"; } > "$build/w2.om"
15"$omc" < "$build/w2.om" > "$build/w2"
16chmod +x "$build/w2"
17"$build/w2" > "$build/w2-omega.tsv"
18cd "$HOME/workspace/yang-lean-bridge"
19export PATH="$HOME/.elan/bin:$PATH"
20lake env sh -ec '
21 export LEAN_PATH="$1:$LEAN_PATH"
22 cd "$2"
23 lean -o "$1/DyadicTrig.olean" proofs/DyadicTrig.lean
24 lean -o "$1/DyadicExp.olean" proofs/DyadicExp.lean
25 lean --run scripts/ReplayDyadicTrig.lean > "$1/lean.tsv"
26 lean --run scripts/ReplayDyadicW2.lean > "$1/w2-lean.tsv"
27' sh "$build" "$root"
28cmp "$build/omega.tsv" "$build/lean.tsv"
29test "$(wc -l < "$build/lean.tsv")" = 2048
30sha256sum "$build/lean.tsv"
31echo 'DYADIC_GRID_REPLAY cells=2048 status=PASS'
32cmp "$build/w2-omega.tsv" "$build/w2-lean.tsv"
33test "$(wc -l < "$build/w2-lean.tsv")" = 2048
34sha256sum "$build/w2-lean.tsv"
35# A one-unit change to the computed polar energy must disagree with the reference.
36sed 's/^par = fluxEnergy zLo$/par = add 1 fluxEnergy zLo/' "$build/w2.om" > "$build/w2-mutant.om"
37"$omc" < "$build/w2-mutant.om" > "$build/w2-mutant"
38chmod +x "$build/w2-mutant"
39"$build/w2-mutant" > "$build/mutant.tsv"
40test "$(wc -l < "$build/mutant.tsv")" = 2048
41if cmp -s "$build/mutant.tsv" "$build/w2-lean.tsv"; then
42 echo 'W2_MUTATION undetected' >&2
43 exit 1
44fi
45echo 'W2_MUTATION polar_energy_plus_one detected'
46echo 'DYADIC_W2_REPLAY couplings=16 field_boxes=2048 angle_cells_per_box=2048 status=PASS'