This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ApplicativeDo #-} | |
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE OverloadedLists #-} | |
{-# LANGUAGE PatternSynonyms #-} | |
-- | | |
-- | |
-- Constructive solid geometry. Not quite FRep or signed distance function. | |
module CSG where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% | |
using BSplineKit, LinearAlgebra, Optimization | |
using Plots | |
using RCall | |
using SplitApplyCombine | |
using Symbolics | |
@rlibrary ggplot2 | |
import OptimizationOptimisers, DataFrames |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S freecad --console | |
import os | |
import sys | |
import textwrap | |
import FreeCAD | |
import PartDesign | |
import tempfile | |
import shutil | |
from typing import TypeVar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TupleSections #-} | |
{-# HLINT ignore "Functor law" #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ViewPatterns #-} | |
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn bmp_tptp( | |
i2c_ref: Arc<Mutex<I2C0>>, | |
sda: AnyIOPin, | |
scl: AnyIOPin, | |
config: Config, | |
) -> anyhow::Result<[f32; 4]> { | |
use bme280::i2c::BME280; | |
let i2c = i2c_ref.lock().unwrap(); | |
let i2c = RefCell::new(I2cDriver::new(i2c, sda, scl, &config)?); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(pacman) | |
p_load(tidyverse, tictoc, glue, e1071, directlabels, cache) | |
split <- function(x) unlist(strsplit(x, "")) | |
sample(c(letters, split("{}[]()")), 10^5, replace = TRUE) %>% as.list() %>% do.call(str_c, .) %>% writeLines("input0.txt") | |
# map_chr(commands, function(command) readLines(paste0(command, ".hs"))) %>% setNames(commands) %>% deparse %>% writeLines | |
mains <- c( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
module VVariable where | |
import Control.Monad | |
import Control.Monad.Trans.Writer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://link.springer.com/article/10.1007/s00170-006-0556-9 | |
library(pacman) | |
p_load(tidyverse, directlabels) | |
delta <- function(dh,alpha,hdt,dt,L,H) { | |
n <- H / dh | |
te <- hdt - dt | |
tibble(n=n, te=te, delta = n^3 * dh / (6*alpha*dt*(n-1)) * (1 - cos(3*alpha*L/(n*dh) * dt * (n-1)/n^2 ))) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Water Heater | |
For backpacking weight is an important constraint. Often boiling water is | |
enough for food and drink -- the food can be precooked and/or dehydrated etc. | |
such that it doesn't need to simmer. Therefore a stove and a pot could be | |
unnecessary, if a tube containing burning fuel is put inside a water bottle. | |
Methanol stoves where the pot has a shield ("caldera cone", jetboil etc.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Success[0.1, 0.1, 0.1, 0.1, 0.1, 0.09999999999999999, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.09999999999999999, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.09999999999999999, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]% | |
# The problem is probably the pressure tank composition equation. | |
# challenge Valliers 2004 sweep gas claim | |
# flanges are a,b,c,d etc. | |
# where "a" is upstream and "b" is downstream | |
# | |
## | |
using ModelingToolkit, Plots, DifferentialEquations |