Skip to content

Instantly share code, notes, and snippets.

@n7275
n7275 / SPSDKAntoineEquation.m
Last active September 22, 2021 02:42
SPSDKAntoineEquation
#Vapor Pressure
clear;
clc;
res = 75;
R_CONST = 8314.4621 ##(L*Pa)/(mol*K)
MMASS = [31.998, 2.01588, 18.01528, 28.0134, 44.01, 33.434432, 92.146, 92.01, 4.00260]; #g/mol
VAPENTH = [213.13, 445.46, 2260.0, 198.83, 347.0, 1769.195, 991.01556, 414.3, 0.0829 ]; #J/g
VAPPRESS = [1314841.0, 4925221.0, 39441.0, 1528361.0, 493284.0, 25639.45, 21722.212986, 206782.99342, 14778377.09 ]; #Pa @ 273.00K
clear;
clc;
res = 300;
H = linspace(0,75,res);
O = linspace(0,75,res);
[HH,OO] = meshgrid(H,O);
import re
import glob
import os
### THIS SCRIPT HAS NO UNDO BUTTON. IT UPDATES ALL. SCENERIOS IN THE CURRENT DIRECTORY ###
### BACK UP YOUR FILES. KNOW WHAT DIRECTORY THIS IS RUNNING IN.
### I WILL DO THE UPDATE FOR YOU, BUT I CAN'T FIX AN INCORRECTLY PERFORMED UPDATE THAT YOU DO
### PM ME ON ORBITER-FORUM.COM (@n72.75)
all_scn_files = glob.glob('./*.scn')
@n7275
n7275 / ThreadPoolTest.cpp
Created February 22, 2022 04:08
EmbarrassinglyBadThreadPool
#include <iostream>
#include <thread>
#include <vector>
#include <mutex>
#include <functional>
#include <cmath>
void JobFunction(double dt) {
double dtTemp = cos(dt);
@n7275
n7275 / ThreadPoolTest.cpp
Last active February 26, 2022 18:38
Better (but still broken) Thread Pool
#include <iostream>
#include <thread>
#include <vector>
#include <mutex>
#include <functional>
#include <cmath>
//simple test function to give the CPU something to do
void JobFunction(double dt) {
double dtTemp = 0;
@n7275
n7275 / AgZnBatteryDischargeVoltage.m
Created January 10, 2023 20:35
AgZn Battery Discharge Voltage
function [V] = BatVoltage(ChargeLevel,MaxChargeVoltage)
## ChargeLevel = 0.0 -- 1.0
## MaxChargeVoltage, voltage when ChargeLevel == 1.0
V = (1.007921192669853 - 0.009537198357788667./(ChargeLevel+0.09727407714017093).^2).*MaxChargeVoltage;
end
@n7275
n7275 / o2h2n2density.m
Last active April 18, 2023 01:43
N2, O2 and H2 density
clear;
clc;
#O2 and H2 density
O2Tcrit = 154.7;
H2Tcrit = 33.2;
N2crit = 126.2;
temp1 = linspace(0,O2Tcrit,75);
temp2 = linspace(O2Tcrit,500,100);
temp3 = linspace(0,H2Tcrit,15);
@n7275
n7275 / VDWDensityCalc.m
Created January 31, 2023 19:22
VanDerWaalDensityCalculator
clear;
clc;
T = linspace(0,500,2000);
V1 = [];
V2 = [];
V3 = [];
R = 8.31446261815324E-2; #L.bar.K^-1.mol^-1
@n7275
n7275 / heater_ramp.m
Last active February 14, 2023 21:32
Heater Ramp Simulation
%Tank Heater
clear;
clc;
nominal_heat = 200; %Watts
ramp_rate = 10.0;
Dt = .1;
heat = 0;
@n7275
n7275 / RK4FlowRates.m
Last active March 1, 2023 21:40
RK4FlowRates
#Flow rate
clear;
clc;
size = 0.00500;
dt = .005;
Volume1 = 120;
Volume2 = 240;
mass = 300;