Skip to content

Instantly share code, notes, and snippets.

@aavogt
aavogt / loft.hs
Created October 30, 2025 17:05
right-angle diverging duct as a sequence of lofts
{-# LANGUAGE FlexibleContexts #-}
-- # LANGUAGE NamedFieldPuns #-}
-- # LANGUAGE OverloadedRecordDot #-}
-- import Reinsch
import Control.Lens
import Data.List
import qualified Data.Vector.Storable as V
import Linear
import Waterfall
@aavogt
aavogt / 2025-09-09.tidal.hs
Created September 9, 2025 14:41
-XArrows for tidal join functions almost working
:set -XArrows
:set -i.
:load Arr.hs
:script bin/Tidal.ghci
import Control.Arrow
@aavogt
aavogt / pickup.py
Created September 5, 2025 15:27
garbage pickup bin asymmetry
# diagram or explanation at http://aavogt.github.io/pickup.html
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, CheckButtons
import warnings
warnings.filterwarnings('ignore')
# Vehicle and fuel parameters
truck_mass = 15000 # kg (loaded garbage truck)
drag_coefficient = 0.8 # typical for box truck
@aavogt
aavogt / tape.py
Created August 12, 2025 23:48
offset strip fin using fullcontrol.xyz example for why I started htpl
import fullcontrol as fc
import math
import time
import os
# the main thing is to reduce the temperature
# do I add retraction? Z or E? M207, G10 G11
# do I slow it down?
# do I make them closer together?
# do I add a horizontal line that gets cut off? This way I
@aavogt
aavogt / Learning.hs
Created August 5, 2025 20:03
TMDA handwriting learning
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Binary
import Data.Binary.Get
import qualified Data.ByteString.Lazy as BL
@aavogt
aavogt / InlineOCCT.hs
Last active May 30, 2025 17:44
occt sectionPerimeter
{-# LANGUAGE TemplateHaskell #-}
module InlineOCCT where
import Data.Acquire
import qualified Data.Map as Map
import Foreign hiding (with)
import Language.C.Inline.Context
import Language.C.Inline.Cpp
import Language.C.Inline.HaskellIdentifier
@aavogt
aavogt / main.hs
Created May 28, 2025 02:26
a grid of ellipsoidal bumps on a rectangular baseplate
{-# HLINT ignore "Eta reduce" #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
import Control.Lens
import Linear
import Waterfall
import Waterfall.IO
@aavogt
aavogt / stream.py
Last active April 3, 2025 14:00
paraview.simple purge gas mixing
# install cfdof
# make the geometry where the gases mix such that inlets with z>0 are Ar, z<0 are Air
# adjust rx,ry,rz below
# the normal speed-weighted average composition of a rectangle specified below is calculated
#
# TODO:
# - [ ] diffusion: reconstructPar -latestTime, then use the output velocity field with another openfoam solver for the transport equation
# - [ ] composition from boundary names, instead of the ad-hoc plane split based on the location of the farthest upstream point in the streamline
# - [ ] surrogate model (tgp?) for geometry/flow/model parameter sweeps
from typing import cast
@aavogt
aavogt / pun.R
Created March 13, 2025 01:39
alternative R function argument matching
#' Get the name of a symbol or function call
#'
#' @param expr An expression to extract the name from.
#' @return A character string representing the name of the symbol or function call, or NULL if unsupported.
#' @examples
#' get_pun_name(quote(x)) # returns "x"
#' get_pun_name(quote(f(x))) # returns "f"
get_pun_name <- function(expr) {
if (is.symbol(expr)) {
return(as.character(expr))